polotno 4.15.2 → 4.15.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polotno",
3
- "version": "4.15.2",
3
+ "version": "4.15.3",
4
4
  "description": "Design editor SDK: embed a Canva-like editor, generate designs from templates and data, export PNG, PDF, and video in the browser or on a server.",
5
5
  "author": "Anton Lavrenov",
6
6
  "repository": {
@@ -120,7 +120,7 @@
120
120
  "class-variance-authority": "^0.7.1",
121
121
  "clsx": "^2.1.1",
122
122
  "gifuct-js": "^2.1.2",
123
- "konva": "^10.7.0",
123
+ "konva": "^10.7.1",
124
124
  "lodash-es": "^4.18.1",
125
125
  "lucide-react": "^1.52.0",
126
126
  "mediabunny": "^1.61.1",
package/polotno.bundle.js CHANGED
@@ -61,7 +61,7 @@ Error generating stack: `+e.message+`
61
61
  `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=zi,c=!Ia.jitless,l=c&&Bi.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?pc([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function gc(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!oa(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>da(e,r,La())))}),t)}var _c=U(`$ZodUnion`,(e,t)=>{ps.init(e,t),Ea(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),Ea(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Ea(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),Ea(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>wi(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>gc(t,r,e,i)):gc(o,r,e,i)}});function vc(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var yc=U(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,_c.init(e,t);let n=e._zod.parse;Ea(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||Oi(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=ki(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=Si(()=>vc(t));e._zod.parse=(i,a)=>{let o=i.value;if(!zi(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),bc=U(`$ZodIntersection`,(e,t)=>{ps.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Sc(e,t,n)):Sc(e,i,a)}});function xc(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Vi(e)&&Vi(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=xc(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=xc(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Sc(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=xc(t.value,n.value);if(!c.valid){if(oa(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Cc=U(`$ZodRecord`,(e,t)=>{ps.init(e,t);let n=Ia.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Vi(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>da(e,i,La())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...ca(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...ca(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Uo.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>da(e,i,La())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...ca(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...ca(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),wc=U(`$ZodEnum`,(e,t)=>{ps.init(e,t);let n=vi(t.entries),r=new Set(n);e._zod.values=r,Ea(e,`pattern`,e=>{let t=vi(e.def.entries).filter(e=>Ui.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Wi(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Tc=U(`$ZodLiteral`,(e,t)=>{ps.init(e,t);let n=new Set(t.values);e._zod.values=n,Ea(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?Wi(e):e?Wi(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Ec=U(`$ZodTransform`,(e,t)=>{ps.init(e,t),e._zod.optin=`optional`,Ia.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Fa(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Pa;return n.value=i,n}});function Dc(e,t){return e.value=t.issues.length?void 0:t.value,e}var Oc=U(`$ZodOptional`,(e,t)=>{ps.init(e,t),Ea(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,Ea(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),Ea(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${wi(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Dc(e,t)):Dc(e,r)}return t.innerType._zod.run(e,n)}}),kc=U(`$ZodExactOptional`,(e,t)=>{Oc.init(e,t),Ea(e,`values`,e=>e.def.innerType._zod.values),Ea(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ac=U(`$ZodNullable`,(e,t)=>{ps.init(e,t),Ea(e,`optin`,e=>e.def.innerType._zod.optin),Ea(e,`optout`,e=>e.def.innerType._zod.optout),Ea(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${wi(t.source)}|null)$`):void 0}),Ea(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),jc=U(`$ZodDefault`,(e,t)=>{ps.init(e,t),e._zod.optin=`defaulted`,Ea(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Mc(e,t)):Mc(r,t)}});function Mc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Nc=U(`$ZodPrefault`,(e,t)=>{ps.init(e,t),e._zod.optin=`defaulted`,Ea(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Pc=U(`$ZodNonOptional`,(e,t)=>{ps.init(e,t),Ea(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Fc(t,e)):Fc(i,e)}});function Fc(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Ic(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>da(e,r,La()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Lc=U(`$ZodCatch`,(e,t)=>{ps.init(e,t),Ea(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),Ea(e,`optout`,e=>e.def.innerType._zod.optout),Ea(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Ic(e,r,t,n)):Ic(e,r,t,n)}}),Rc=U(`$ZodPipe`,(e,t)=>{ps.init(e,t),Ea(e,`values`,e=>e.def.in._zod.values),Ea(e,`optin`,e=>e.def.in._zod.optin),Ea(e,`optout`,e=>e.def.out._zod.optout),Ea(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>zc(e,t.in,n)):zc(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>zc(e,t.out,n)):zc(r,t.out,n)}});function zc(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Bc=U(`$ZodReadonly`,(e,t)=>{ps.init(e,t),Ea(e,`propValues`,e=>e.def.innerType._zod.propValues),Ea(e,`values`,e=>e.def.innerType._zod.values),Ea(e,`optin`,e=>e.def.innerType?._zod?.optin),Ea(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Vc):Vc(r)}});function Vc(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Hc=U(`$ZodLazy`,(e,t)=>{ps.init(e,t),Di(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),Ea(e,`pattern`,e=>e.innerType?._zod?.pattern),Ea(e,`propValues`,e=>e.innerType?._zod?.propValues),Ea(e,`optin`,e=>e.innerType?._zod?.optin??void 0),Ea(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Uc=U(`$ZodCustom`,(e,t)=>{qo.init(e,t),ps.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Wc(t,n,r,e));Wc(i,n,r,e)}});function Wc(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(ga(e))}}var Gc=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Kc=`~memo`,qc=[];function Jc(e){return typeof e==`object`&&!!e}function Yc(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Xc=new WeakMap,Zc=0,Qc=1,$c=2;function el(e,t,n){let r=Xc.get(e);if(r!==void 0)return r?$c:Zc;if(t.has(e))return $c;t.add(e);let i=Zc,a=e=>{if(i!==$c&&e?._zod){let r=el(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=Zc;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?Qc:o.value?._zod?el(o.value,t,n):Zc;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=ki(c);s(e?o(e,!0):Qc),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?el(r,t,!1):Qc);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),tl(e,i)}function tl(e,t){return t!==Qc&&Xc.set(e,t===$c),t}function nl(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var rl,il=[],al={alloc(e,t,n){let r=rl;if(!r)return n;rl=void 0;let i={value:n,issues:null};return r.set(t.value,i),il.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&sl(n,e.value))throw new Gc;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=el(e,new Set,!1);if(i===Zc)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===$c||r?n=!0:r=!0}let l=s.value;if(!Jc(l))return t(s,c);let u=c[Kc];u||(u={buckets:new WeakMap,backEdges:void 0},c[Kc]=u);let d;i===c?d=a:(d=nl(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Yc(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;rl=d;let p=il.length,m=t(s,c);rl=void 0;let h=il.length>p?il.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Yc(e.issues):qc),e)):(h&&(h.issues=m.issues.length?Yc(m.issues):qc),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function ol(){return al}function sl(e,t){let n=e[Kc]?.backEdges;return n!==void 0&&Jc(t)&&n.has(t)}var cl=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(ha(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${qi(e.values[0])}`:`Invalid option: expected one of ${yi(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${yi(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function ll(){return{localeError:cl()}}var ul,dl=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function fl(){return new dl}(ul=globalThis).__zod_globalRegistry??(ul.__zod_globalRegistry=fl());var pl=globalThis.__zod_globalRegistry;function ml(e){return e.checks&&=[...e.checks],e}function hl(e,t){return new e(ml({type:`string`,...Ki(t)}))}function gl(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Ki(t)})}function _l(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Ki(t)})}function vl(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Ki(t)})}function yl(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Ki(t)})}function bl(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Ki(t)})}function xl(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Ki(t)})}function Sl(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Ki(t)})}function Cl(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Ki(t)})}function wl(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Ki(t)})}function Tl(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Ki(t)})}function El(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Ki(t)})}function Dl(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Ki(t)})}function Ol(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Ki(t)})}function kl(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Ki(t)})}function Al(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Ki(t)})}function jl(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Ki(t)})}function Ml(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Ki(t)})}function Nl(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Ki(t)})}function Pl(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Ki(t)})}function Fl(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Ki(t)})}function Il(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Ki(t)})}function Ll(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Ki(t)})}function Rl(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Ki(t)})}function zl(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Ki(t)})}function Bl(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Ki(t)})}function Vl(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Ki(t)})}function Hl(e,t){return new e(ml({type:`number`,checks:[],...Ki(t)}))}function Ul(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...Ki(t)})}function Wl(e,t){return new e({type:`boolean`,...Ki(t)})}function Gl(e){return new e({type:`unknown`})}function Kl(e,t){return new e({type:`never`,...Ki(t)})}function ql(e,t){return new Xo({check:`less_than`,...Ki(t),value:e,inclusive:!1})}function Jl(e,t){return new Xo({check:`less_than`,...Ki(t),value:e,inclusive:!0})}function Yl(e,t){return new Zo({check:`greater_than`,...Ki(t),value:e,inclusive:!1})}function Xl(e,t){return new Zo({check:`greater_than`,...Ki(t),value:e,inclusive:!0})}function Zl(e,t){return new Qo({check:`multiple_of`,...Ki(t),value:e})}function Ql(e,t){return new es({check:`max_length`,...Ki(t),maximum:e})}function $l(e,t){return new ts({check:`min_length`,...Ki(t),minimum:e})}function eu(e,t){return new ns({check:`length_equals`,...Ki(t),length:e})}function tu(e,t){return new is({check:`string_format`,format:`regex`,...Ki(t),pattern:e})}function nu(e){return new as({check:`string_format`,format:`lowercase`,...Ki(e)})}function ru(e){return new os({check:`string_format`,format:`uppercase`,...Ki(e)})}function iu(e,t){return new ss({check:`string_format`,format:`includes`,...Ki(t),includes:e})}function au(e,t){return new cs({check:`string_format`,format:`starts_with`,...Ki(t),prefix:e})}function ou(e,t){return new ls({check:`string_format`,format:`ends_with`,...Ki(t),suffix:e})}function su(e){return new us({check:`overwrite`,tx:e})}function cu(e){return su(t=>t.normalize(e))}function lu(){return su(e=>e.trim())}function uu(){return su(e=>e.toLowerCase())}function du(){return su(e=>e.toUpperCase())}function fu(){return su(e=>Li(e))}function pu(e,t,n){return new e({type:`array`,element:t,...Ki(n)})}function mu(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Ki(n)})}function hu(e,t){let n=gu(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(ga(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(ga(r))}},e(t.value,t)),t);return n}function gu(e,t){let n=new qo({check:`custom`,...Ki(t)});return n._zod.check=e,n}function _u(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Oi(e,t,n[t]);return e}function vu(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??pl,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function yu(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function bu(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,bu(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&_u(o.schema,c),t.io===`input`&&Au(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function xu(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Su(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${xu(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+xu(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
62
62
 
63
63
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Cu(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Cu(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var wu=new Set([`type`,`properties`,`required`,`additionalProperties`]),Tu=[`oneOf`,`anyOf`];function Eu(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Du(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!wu.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Eu(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Oi(n,r,e.length===1?e[0]:Du(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Eu(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Ou(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of wu)if(t in e)return;let n=t.filter(e=>Tu.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Du(t);else{let e=n[0],i=Tu.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Du([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,_u(e,r))}function ku(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):_u(i,s),_u(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Cu(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Ou(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}_u(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Oi(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Mu(t,`input`,e.processors),output:Mu(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Au(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Au(r.element,n);if(r.type===`set`)return Au(r.valueType,n);if(r.type===`lazy`)return Au(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Au(r.innerType,n);if(r.type===`intersection`)return Au(r.left,n)||Au(r.right,n);if(r.type===`record`||r.type===`map`)return Au(r.keyType,n)||Au(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Au(r.in,n)||Au(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Au(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Au(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Au(e,n))return!0;return!!(r.rest&&Au(r.rest,n))}return!1}var ju=(e,t={})=>n=>{let r=vu({...n,processors:t});return bu(e,r),Su(r,e),ku(r,e)},Mu=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=vu({...i??{},target:a,io:t,processors:n});return bu(e,o),Su(o,e),ku(o,e)},Nu=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Pu=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Fu=(e,t)=>{Nu(e,`minimum`,t),Pu(e,`maximum`,t)},Iu=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Lu=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Ru=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},zu=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Bu=(e,t)=>Nu(e,`minimum`,t.minimum),Vu=(e,t)=>Pu(e,`maximum`,t.maximum),Hu=e=>(t,n)=>{zu(t,n.format);let[r,i]=e[n.format];Nu(t,`minimum`,r),Pu(t,`maximum`,i)},Uu={greater_than:(e,t)=>Nu(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Pu(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Iu(e,t.value),number_format:Hu(Yi),bigint_format:Hu(Xi),min_length:Bu,max_length:Vu,length_equals:(e,t)=>Fu(e,t.length),min_size:Bu,max_size:Vu,size_equals:(e,t)=>Fu(e,t.size),string_format:(e,t)=>{zu(e,t.format),t.pattern&&Lu(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Ru(e,t.mime)};function Wu(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Uu[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Nu(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Nu(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Pu(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Pu(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Iu(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Ru(t,i.mime);for(let e of i.patterns??[])Lu(t,e);return t}var Gu={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ku=new Map([[Ys,jo],[Zs,Mo]]),qu=e=>Ku.get(e)??e,Ju=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Wu(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Gu[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(qu);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Yu=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Wu(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):yu(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Xu=(e,t,n,r)=>{n.type=`boolean`},Zu=(e,t,n,r)=>{n.not={}},Qu=(e,t,n,r)=>{let i=e._zod.def,a=vi(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},$u=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(yu(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(yu(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},ed=(e,t,n,r)=>{yu(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},td=(e,t,n,r)=>{yu(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},nd=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Wu(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=bu(a.element,t,{...r,path:[...r.path,`items`]})};function rd(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?rd(t.out):t.type===`catch`?rd(t.innerType):e._zod.optin}var id=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&yu(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Oi(i.properties,e,bu(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?rd(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=bu(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ad=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>bu(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},od=(e,t,n,r)=>{let i=e._zod.def,a=bu(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=bu(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function sd(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=sd(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>sd(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Uo:Ho).source),p):p}var cd=new WeakMap;function ld(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of cd.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=sd(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var ud=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Wu(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=bu(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Oi(i.patternProperties,qu(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=bu(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=cd.get(t);n||(n=[],cd.set(t,n),t.deferred.push(()=>ld(t))),n.push(e)}i.additionalProperties=bu(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&rd(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},dd=(e,t,n,r)=>{let i=e._zod.def,a=bu(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},fd=(e,t,n,r)=>{let i=e._zod.def;bu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},pd=Symbol();function md(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(yu(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),pd):JSON.parse(o)}var hd=(e,t,n,r)=>{let i=e._zod.def;bu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=md(i.defaultValue,e,t,n,r);o!==pd&&(n.default=o)},gd=(e,t,n,r)=>{let i=e._zod.def;bu(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=md(i.defaultValue,e,t,n,r);o!==pd&&(n._prefault=o)},_d=(e,t,n,r)=>{let i=e._zod.def;bu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{yu(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},vd=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;bu(o,t,r);let s=t.seen.get(e);s.ref=o},yd=(e,t,n,r)=>{let i=e._zod.def;bu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},bd=(e,t,n,r)=>{let i=e._zod.def;bu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xd=(e,t,n,r)=>{let i=e._zod.innerType;bu(i,t,r);let a=t.seen.get(e);a.ref=i},Sd=new WeakSet([Object.prototype,Error.prototype]);function Cd(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var wd=U(`ZodError`,(e,t)=>{Wa.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Sd.has(n)||(Sd.add(n),Cd(n,`format`,e=>t=>qa(e,t)),Cd(n,`flatten`,e=>t=>Ka(e,t)),Cd(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,bi,2)}),Cd(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,bi,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Td=Ya(wd),Ed=Xa(wd),Dd=Za(wd),Od=$a(wd),kd=ao(wd),Ad=oo(wd),jd=so(wd),Md=co(wd),Nd=lo(wd),Pd=uo(wd),Fd=fo(wd),Id=po(wd);function Ld(){Ia.localeError||La(ll())}function Rd(){Ia.memoizer||La({memoizer:ol()})}var zd=U(`ZodType`,(e,t)=>(Ld(),ps.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Fi(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Gi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(up(e,t))},superRefine(e,t){return this.check(dp(e,t))},overwrite(e){return this.check(su(e))},optional(){return Wf(this)},exactOptional(){return Kf(this)},nullable(){return Jf(this)},nullish(){return Wf(Jf(this))},nonoptional(e){return ep(this,e)},array(){return Tf(this)},or(e){return Af([this,e])},and(e){return Pf(this,e)},transform(e){return ip(this,Hf(e))},default(e){return Xf(this,e)},prefault(e){return Qf(this,e)},catch(e){return np(this,e)},pipe(e){return ip(this,e)},readonly(){return op(this)},describe(e){let t=this.clone();return pl.add(t,{description:e}),t},meta(...e){if(e.length===0)return pl.get(this);let t=this.clone();return pl.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return ya(this,`~standard`,{...gs(this),jsonSchema:{input:Mu(this,`input`),output:Mu(this,`output`)}})},set"~standard"(e){va(this,`~standard`,e)},parse:function e(t,n){return Td(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ed(this,t,n,{callee:e})},safeParse(e,t){return Dd(this,e,t)},async safeParseAsync(e,t){return Od(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){va(this,`spa`,e)},validate(e,t){return no(this,e,t)},validateAsync(e,t){return io(this,e,t)},encode:function e(t,n){return kd(this,t,n,{callee:e})},decode:function e(t,n){return Ad(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await jd(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Md(this,t,n,{callee:e})},safeEncode(e,t){return Nd(this,e,t)},safeDecode(e,t){return Pd(this,e,t)},async safeEncodeAsync(e,t){return Fd(this,e,t)},async safeDecodeAsync(e,t){return Id(this,e,t)},toJSONSchema(e){return ju(this,{})(e)},get description(){return pl.get(this)?.description},get _def(){return this._zod.def}}),Bd=U(`_ZodString`,(e,t)=>{_s.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ju(e,t,n,r)},ba({format:e=>Wu(e).format??null,minLength:e=>Wu(e).minimum??null,maxLength:e=>Wu(e).maximum??null},{regex(...e){return this.check(tu(...e))},includes(...e){return this.check(iu(...e))},startsWith(...e){return this.check(au(...e))},endsWith(...e){return this.check(ou(...e))},min(...e){return this.check($l(...e))},max(...e){return this.check(Ql(...e))},length(...e){return this.check(eu(...e))},nonempty(...e){return this.check($l(1,...e))},lowercase(e){return this.check(nu(e))},uppercase(e){return this.check(ru(e))},trim(){return this.check(lu())},normalize(...e){return this.check(cu(...e))},toLowerCase(){return this.check(uu())},toUpperCase(){return this.check(du())},slugify(){return this.check(fu())}})),Vd=U(`ZodString`,(e,t)=>{_s.init(e,t),Bd.init(e,t)},{email(e){return this.check(gl(Jd,e))},url(e){return this.check(Sl(Zd,e))},jwt(e){return this.check(Ll(pf,e))},emoji(e){return this.check(Cl(Qd,e))},guid(e){return this.check(_l(Yd,e))},uuid(e){return this.check(vl(Xd,e))},uuidv4(e){return this.check(yl(Xd,e))},uuidv6(e){return this.check(bl(Xd,e))},uuidv7(e){return this.check(xl(Xd,e))},nanoid(e){return this.check(wl($d,e))},cuid(e){return this.check(Tl(ef,e))},cuid2(e){return this.check(El(tf,e))},ulid(e){return this.check(Dl(nf,e))},base64(e){return this.check(Pl(uf,e))},base64url(e){return this.check(Fl(df,e))},xid(e){return this.check(Ol(rf,e))},ksuid(e){return this.check(kl(af,e))},ipv4(e){return this.check(Al(of,e))},ipv6(e){return this.check(jl(sf,e))},cidrv4(e){return this.check(Ml(cf,e))},cidrv6(e){return this.check(Nl(lf,e))},e164(e){return this.check(Il(ff,e))},datetime(e){return this.check(Rl(Wd,e))},date(e){return this.check(zl(Gd,e))},time(e){return this.check(Bl(Kd,e))},duration(e){return this.check(Vl(qd,e))}});function Hd(e){return hl(Vd,e)}var Ud=U(`ZodStringFormat`,(e,t)=>{vs.init(e,t),Bd.init(e,t)}),Wd=U(`ZodISODateTime`,(e,t)=>{Ls.init(e,t),Ud.init(e,t)}),Gd=U(`ZodISODate`,(e,t)=>{Rs.init(e,t),Ud.init(e,t)}),Kd=U(`ZodISOTime`,(e,t)=>{zs.init(e,t),Ud.init(e,t)}),qd=U(`ZodISODuration`,(e,t)=>{Bs.init(e,t),Ud.init(e,t)}),Jd=U(`ZodEmail`,(e,t)=>{xs.init(e,t),Ud.init(e,t)}),Yd=U(`ZodGUID`,(e,t)=>{ys.init(e,t),Ud.init(e,t)}),Xd=U(`ZodUUID`,(e,t)=>{bs.init(e,t),Ud.init(e,t)}),Zd=U(`ZodURL`,(e,t)=>{ks.init(e,t),Ud.init(e,t)}),Qd=U(`ZodEmoji`,(e,t)=>{As.init(e,t),Ud.init(e,t)}),$d=U(`ZodNanoID`,(e,t)=>{js.init(e,t),Ud.init(e,t)}),ef=U(`ZodCUID`,(e,t)=>{Ms.init(e,t),Ud.init(e,t)}),tf=U(`ZodCUID2`,(e,t)=>{Ns.init(e,t),Ud.init(e,t)}),nf=U(`ZodULID`,(e,t)=>{Ps.init(e,t),Ud.init(e,t)}),rf=U(`ZodXID`,(e,t)=>{Fs.init(e,t),Ud.init(e,t)}),af=U(`ZodKSUID`,(e,t)=>{Is.init(e,t),Ud.init(e,t)}),of=U(`ZodIPv4`,(e,t)=>{Vs.init(e,t),Ud.init(e,t)}),sf=U(`ZodIPv6`,(e,t)=>{Ws.init(e,t),Ud.init(e,t)}),cf=U(`ZodCIDRv4`,(e,t)=>{Gs.init(e,t),Ud.init(e,t)}),lf=U(`ZodCIDRv6`,(e,t)=>{qs.init(e,t),Ud.init(e,t)}),uf=U(`ZodBase64`,(e,t)=>{Xs.init(e,t),Ud.init(e,t)}),df=U(`ZodBase64URL`,(e,t)=>{$s.init(e,t),Ud.init(e,t)}),ff=U(`ZodE164`,(e,t)=>{ec.init(e,t),Ud.init(e,t)}),pf=U(`ZodJWT`,(e,t)=>{nc.init(e,t),Ud.init(e,t)}),mf=U(`ZodNumber`,(e,t)=>{rc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yu(e,t,n,r),e.isFinite=!0},ba({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Wu(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Wu(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Wu(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Wu(e).format??null},{gt(e,t){return this.check(Yl(e,t))},gte(e,t){return this.check(Xl(e,t))},min(e,t){return this.check(Xl(e,t))},lt(e,t){return this.check(ql(e,t))},lte(e,t){return this.check(Jl(e,t))},max(e,t){return this.check(Jl(e,t))},int(e){return this.check(_f(e))},safe(e){return this.check(_f(e))},positive(e){return this.check(Yl(0,e))},nonnegative(e){return this.check(Xl(0,e))},negative(e){return this.check(ql(0,e))},nonpositive(e){return this.check(Jl(0,e))},multipleOf(e,t){return this.check(Zl(e,t))},step(e,t){return this.check(Zl(e,t))},finite(){return this}}));function hf(e){return Hl(mf,e)}var gf=U(`ZodNumberFormat`,(e,t)=>{ic.init(e,t),mf.init(e,t)});function _f(e){return Ul(gf,e)}var vf=U(`ZodBoolean`,(e,t)=>{ac.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xu(e,t,n,r)});function yf(e){return Wl(vf,e)}var bf=U(`ZodUnknown`,(e,t)=>{oc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function xf(){return Gl(bf)}var Sf=U(`ZodNever`,(e,t)=>{sc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zu(e,t,n,r)});function Cf(e){return Kl(Sf,e)}var wf=U(`ZodArray`,(e,t)=>{Rd(),lc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nd(e,t,n,r),e.element=t.element},{min(e,t){return this.check($l(e,t))},nonempty(e){return this.check($l(1,e))},max(e,t){return this.check(Ql(e,t))},length(e,t){return this.check(eu(e,t))},unwrap(){return this.element}});function Tf(e,t){return pu(wf,e,t)}var Ef=U(`ZodObject`,(e,t)=>{Rd(),hc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>id(e,t,n,r),Da(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Rf(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Fi(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Fi(this._zod.def,{catchall:xf()}))},loose(){return this.clone(Fi(this._zod.def,{catchall:xf()}))},strict(){return this.clone(Fi(this._zod.def,{catchall:Cf()}))},strip(){return this.clone(Fi(this._zod.def,{catchall:void 0}))},extend(e){return ea(this,e)},safeExtend(e){return na(this,e)},merge(e){return ra(this,e)},pick(e){return Zi(this,e)},omit(e){return $i(this,e)},partial(...e){return ia(Uf,this,e[0])},exactPartial(...e){return ia(Gf,this,e[0],`exactPartial`)},required(...e){return aa($f,this,e[0])}});function Df(e,t){return new Ef({type:`object`,shape:e??{},...Ki(t)})}function Of(e,t){return new Ef({type:`object`,shape:e,catchall:Cf(),...Ki(t)})}var kf=U(`ZodUnion`,(e,t)=>{_c.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ad(e,t,n,r),e.options=t.options});function Af(e,t){return new kf({type:`union`,options:e,...Ki(t)})}var jf=U(`ZodDiscriminatedUnion`,(e,t)=>{kf.init(e,t),yc.init(e,t)});function Mf(e,t,n){return new jf({type:`union`,options:t,discriminator:e,...Ki(n)})}var Nf=U(`ZodIntersection`,(e,t)=>{bc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>od(e,t,n,r)});function Pf(e,t){return new Nf({type:`intersection`,left:e,right:t})}var Ff=U(`ZodRecord`,(e,t)=>{Rd(),Cc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ud(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function If(e,t,n){return!t||!t._zod?new Ff({type:`record`,keyType:Hd(),valueType:e,...Ki(t)}):new Ff({type:`record`,keyType:e,valueType:t,...Ki(n)})}var Lf=U(`ZodEnum`,(e,t)=>{wc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qu(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Lf({...t,checks:[],...Ki(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Lf({...t,checks:[],...Ki(r),entries:i})}});function Rf(e,t){return new Lf({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Ki(t)})}var zf=U(`ZodLiteral`,(e,t)=>{Tc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$u(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Bf(e,t){return new zf({type:`literal`,values:Array.isArray(e)?e:[e],...Ki(t)})}var Vf=U(`ZodTransform`,(e,t)=>{Rd(),Ec.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>td(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Fa(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(ga(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(ga(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Hf(e){return new Vf({type:`transform`,transform:e})}var Uf=U(`ZodOptional`,(e,t)=>{Oc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wf(e){return new Uf({type:`optional`,innerType:e})}var Gf=U(`ZodExactOptional`,(e,t)=>{kc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Kf(e){return new Gf({type:`optional`,innerType:e})}var qf=U(`ZodNullable`,(e,t)=>{Ac.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jf(e){return new qf({type:`nullable`,innerType:e})}var Yf=U(`ZodDefault`,(e,t)=>{jc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Xf(e,t){return new Yf({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Hi(t)}})}var Zf=U(`ZodPrefault`,(e,t)=>{Nc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qf(e,t){return new Zf({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Hi(t)}})}var $f=U(`ZodNonOptional`,(e,t)=>{Pc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ep(e,t){return new $f({type:`nonoptional`,innerType:e,...Ki(t)})}var tp=U(`ZodCatch`,(e,t)=>{Lc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_d(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function np(e,t){return new tp({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:ka(t)})}var rp=U(`ZodPipe`,(e,t)=>{Rc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vd(e,t,n,r),e.in=t.in,e.out=t.out});function ip(e,t){return new rp({type:`pipe`,in:e,out:t})}var ap=U(`ZodReadonly`,(e,t)=>{Bc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function op(e){return new ap({type:`readonly`,innerType:e})}var sp=U(`ZodLazy`,(e,t)=>{Hc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xd(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function cp(e){return new sp({type:`lazy`,getter:e})}var lp=U(`ZodCustom`,(e,t)=>{Uc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ed(e,t,n,r)});function up(e,t={}){return mu(lp,e,t)}function dp(e,t){return hu(e,t)}function fp(e,t,n,r){let i=Error(t);return i.code=e,n!==void 0&&(i.details=n),r!==void 0&&(i.cause=r),i}var pp=g(),mp=d(v()),hp=[`fontSize`,`fontFamily`,`fontWeight`,`fontStyle`,`textDecoration`,`textTransform`,`fill`,`align`,`verticalAlign`,`lineHeight`,`letterSpacing`,`strokeWidth`,`stroke`,`cellBackground`,`cellPadding`],gp=e=>(e.cells||[]).map(t=>{if(!t)return t;let n={...t};for(let t of hp)n[t]===void 0&&(n[t]=e[t]);return n}),_p=(e,t,n)=>{let r=e.borders?.[n];return{width:r?.width??t.borderWidth,style:r?.style??t.borderStyle,color:r?.color??t.borderColor}},vp=(e,t)=>{let n=e.rowSpan||1,r=e.colSpan||1,i=(n,r)=>{let i=_p(e,t,n);return i.style===`none`||!i.width?0:r?i.width:i.width/2};return{top:i(`top`,e.row===0),bottom:i(`bottom`,e.row+n===t.rows),left:i(`left`,e.col===0),right:i(`right`,e.col+r===t.cols)}},yp={fontSize:14,fontFamily:`Roboto`,fontWeight:`normal`,fontStyle:`normal`,lineHeight:1.2,letterSpacing:0,textTransform:`none`,textDecoration:``,align:`center`,fill:`black`,stroke:`black`,strokeWidth:0,strokeLineJoin:`round`,curveEnabled:!1,curvePower:.5},bp=e=>e!=null&&e<1?1:e,xp=[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],Sp=[`pass-through`,...xp],Cp=[`text`,`image`,`svg`,`line`,`figure`,`gif`,`video`,`table`,`group`];function wp(e){let t=e({delay:hf().default(0).describe(`Delay before the animation starts, in milliseconds.`),duration:hf().default(500).describe(`Animation duration in milliseconds.`),enabled:yf().default(!0).describe(`Whether the animation is enabled.`),type:Rf([`enter`,`exit`,`loop`]).describe(`Animation phase.`),name:Hd().default(`none`).describe(`Animation name identifier.`),data:xf().default({}).describe(`Animation-specific data.`)}),n=If(Hd(),e({intensity:hf().default(1).describe(`Filter intensity (-1 to 1).`)})).describe(`Applied image filters keyed by filter name.`),r=Rf(xp).optional().describe(`How the element composites with the content beneath it. Omitted means normal.`),i={id:Hd().describe(`Unique identifier for the element.`),type:Hd().describe(`Element type identifier.`),name:Hd().default(``).describe(`Display name for the element.`),custom:xf().optional().describe(`Custom data attached to the element.`),x:hf().default(0).describe(`X position in pixels.`),y:hf().default(0).describe(`Y position in pixels.`),width:hf().default(100).describe(`Width in pixels.`),height:hf().default(100).describe(`Height in pixels.`),rotation:hf().default(0).describe(`Rotation angle in degrees.`),opacity:hf().default(1).describe(`Opacity level (0-1).`),blendMode:r,animations:Tf(t).default([]).describe(`Animation configurations.`),blurEnabled:yf().default(!1).describe(`Whether blur effect is enabled.`),blurRadius:hf().default(10).describe(`Blur radius in pixels.`),brightnessEnabled:yf().default(!1).describe(`Whether brightness effect is enabled.`),brightness:hf().default(0).describe(`Brightness level (-1 to 1).`),sepiaEnabled:yf().default(!1).describe(`Whether sepia effect is enabled.`),grayscaleEnabled:yf().default(!1).describe(`Whether grayscale effect is enabled.`),filters:n.default({}),shadowEnabled:yf().default(!1).describe(`Whether shadow is enabled.`),shadowBlur:hf().default(5).describe(`Shadow blur radius in pixels.`),shadowOffsetX:hf().default(0).describe(`Shadow horizontal offset in pixels.`),shadowOffsetY:hf().default(0).describe(`Shadow vertical offset in pixels.`),shadowColor:Hd().default(`black`).describe(`Shadow color.`),shadowOpacity:hf().default(1).describe(`Shadow opacity (0-1).`),visible:yf().default(!0).describe(`Whether the element is visible.`),draggable:yf().default(!0).describe(`Whether the element can be dragged.`),resizable:yf().default(!0).describe(`Whether the element can be resized.`),selectable:yf().default(!0).describe(`Whether the element can be selected.`),removable:yf().default(!0).describe(`Whether the element can be removed.`),contentEditable:yf().default(!0).describe(`Whether the element content can be edited.`),styleEditable:yf().default(!0).describe(`Whether the element style can be edited.`),alwaysOnTop:yf().default(!1).describe(`Whether the element stays on top of others.`),showInExport:yf().default(!0).describe(`Whether the element appears in exports.`)},a={src:Hd().default(``).describe(`URL or data URI of the image file.`),cropX:hf().default(0).describe(`Crop X offset as a fraction (0-1).`),cropY:hf().default(0).describe(`Crop Y offset as a fraction (0-1).`),cropWidth:hf().default(1).describe(`Crop width as a fraction (0-1).`),cropHeight:hf().default(1).describe(`Crop height as a fraction (0-1).`),cornerRadius:hf().default(0).describe(`Corner radius in pixels.`),flipX:yf().default(!1).describe(`Whether the image is flipped horizontally.`),flipY:yf().default(!1).describe(`Whether the image is flipped vertically.`),clipSrc:Hd().default(``).describe(`URL or data URI for a clipping mask.`),borderColor:Hd().default(`black`).describe(`Border color.`),borderSize:hf().default(0).describe(`Border width in pixels.`),keepRatio:yf().default(!1).describe(`Whether to maintain aspect ratio when resizing.`),stretchEnabled:yf().default(!1).describe(`Whether stretch mode is enabled.`)},o={...i,type:Bf(`text`).describe(`Element type identifier.`),text:Hd().default(``).describe(`Visible text shown on canvas.`),placeholder:Hd().default(``).describe(`Placeholder text shown when empty.`),fontSize:hf().overwrite(bp).default(yp.fontSize).describe(`Font size in pixels (minimum 1).`),fontFamily:Hd().default(yp.fontFamily).describe(`Font family name.`),fontStyle:Hd().default(yp.fontStyle).describe(`Font style: 'normal' or 'italic'.`),fontWeight:Hd().default(yp.fontWeight).describe(`Font weight: 'normal', 'bold', or numeric string.`),textDecoration:Hd().default(yp.textDecoration).describe(`Text decoration (e.g. underline, line-through).`),textTransform:Hd().default(yp.textTransform).describe(`Text transform: uppercase, lowercase, capitalize, none.`),fill:Hd().default(yp.fill).describe(`Text color.`),align:Hd().default(yp.align).describe(`Horizontal alignment (commonly left | center | right | justify).`),width:hf().default(100).describe(`Width in pixels.`),height:hf().default(0).describe(`Height in pixels (0 until measured/rendered).`),verticalAlign:Hd().default(`top`).describe(`Vertical alignment: top, middle, bottom.`),strokeWidth:hf().default(yp.strokeWidth).describe(`Stroke width in pixels.`),stroke:Hd().default(yp.stroke).describe(`Stroke color.`),strokeLineJoin:Hd().default(yp.strokeLineJoin).describe(`Stroke corner join: round, miter, bevel.`),lineHeight:Af([hf(),Hd()]).default(yp.lineHeight).describe(`Line height multiplier or 'auto'.`),letterSpacing:hf().default(yp.letterSpacing).describe(`Letter spacing as a fraction of font size.`),backgroundEnabled:yf().default(!1).describe(`Whether the text background is enabled.`),backgroundColor:Hd().default(`#7ED321`).describe(`Text background color.`),backgroundOpacity:hf().default(1).describe(`Text background opacity (0-1).`),backgroundCornerRadius:hf().default(.5).describe(`Text background corner radius.`),backgroundPadding:hf().default(.5).describe(`Text background padding.`),borderColor:Hd().default(`black`).describe(`Text box border color.`),borderSize:hf().default(0).describe(`Text box border width in pixels.`),curveEnabled:yf().default(yp.curveEnabled).describe(`Whether the text curve effect is enabled.`),curvePower:hf().default(yp.curvePower).describe(`Text curve power (-1 to 1, 0 = straight).`),legacyBackground:yf().optional().describe(`Internal compatibility flag stamped by the v2→v3 migration.`)},s={...i,...a,type:Bf(`image`).describe(`Element type identifier.`)},c={...i,type:Bf(`svg`).describe(`Element type identifier.`),src:Hd().default(``).describe(`URL or data URI of the SVG.`),maskSrc:Hd().default(``).describe(`URL or data URI for an SVG mask.`),cropX:a.cropX,cropY:a.cropY,cropWidth:a.cropWidth,cropHeight:a.cropHeight,keepRatio:yf().default(!0).describe(`Whether to maintain aspect ratio when resizing.`),stretchEnabled:yf().default(!0).describe(`Whether stretch mode is enabled.`),flipX:a.flipX,flipY:a.flipY,borderColor:a.borderColor,borderSize:a.borderSize,cornerRadius:a.cornerRadius,colorsReplace:If(Hd(),Hd()).default({}).describe(`Color replacement mappings (original → replacement).`)},l={...i,type:Bf(`line`).describe(`Element type identifier.`),width:hf().default(400).describe(`Width in pixels.`),height:hf().default(10).describe(`Height in pixels.`),color:Hd().default(`black`).describe(`Line color.`),dash:Tf(hf()).default([]).describe(`Dash pattern array.`),startHead:Hd().default(``).describe(`Start arrow head: empty, arrow, circle, square, bar.`),endHead:Hd().default(``).describe(`End arrow head: empty, arrow, circle, square, bar.`)},u={...i,type:Bf(`figure`).describe(`Element type identifier.`),subType:Hd().default(`rect`).describe(`Figure subtype: rect, ellipse, triangle, etc.`),fill:Hd().default(`rgb(0, 161, 255)`).describe(`Fill color.`),dash:Tf(hf()).default([]).describe(`Dash pattern array.`),strokeWidth:hf().default(0).describe(`Stroke width in pixels.`),stroke:Hd().default(`rgba(98, 197, 255, 1)`).describe(`Stroke color.`),cornerRadius:a.cornerRadius},d={...i,...a,type:Bf(`gif`).describe(`Element type identifier.`),duration:hf().default(0).describe(`GIF duration in milliseconds.`),keepRatio:yf().default(!0).describe(`Whether to maintain aspect ratio when resizing.`)},f={...i,...a,type:Bf(`video`).describe(`Element type identifier.`),duration:hf().default(0).describe(`Video duration in milliseconds.`),startTime:hf().default(0).describe(`Start offset (0-1).`),endTime:hf().default(1).describe(`End offset (0-1).`),volume:hf().default(1).describe(`Volume (0-1).`),speed:hf().default(1).describe(`Playback speed multiplier (1 = normal).`)},p=e({color:Hd().optional().describe(`Border color for this side.`),width:hf().optional().describe(`Border width in pixels for this side.`),style:Rf([`solid`,`dashed`,`dotted`,`none`]).optional().describe(`Border style for this side.`)}),m=e({id:Hd().describe(`Unique identifier for the cell.`),type:Bf(`tablecell`).default(`tablecell`).describe(`Cell type identifier.`),text:Hd().default(``).describe(`Visible text shown in the cell.`),opacity:hf().optional().describe(`Opacity level (0-1).`),rowSpan:hf().optional().describe(`Number of rows this cell spans.`),colSpan:hf().optional().describe(`Number of columns this cell spans.`),mergedInto:Hd().optional().describe(`Id of the cell this one is merged into, if any.`),name:Hd().optional().describe(`Display name for the cell.`),custom:xf().optional().describe(`Custom data attached to the cell.`),borders:e({top:p.optional().describe(`Top border override for this cell.`),right:p.optional().describe(`Right border override for this cell.`),bottom:p.optional().describe(`Bottom border override for this cell.`),left:p.optional().describe(`Left border override for this cell.`)}).optional().describe(`Per-side border overrides for this cell.`),fontSize:hf().overwrite(bp).optional().describe(`Font size in pixels (inherits from the table when omitted, minimum 1).`),fontFamily:Hd().optional().describe(`Font family name (inherits from the table when omitted).`),fontWeight:Hd().optional().describe(`Font weight: 'normal', 'bold', or numeric string (inherits from the table when omitted).`),fontStyle:Hd().optional().describe(`Font style: 'normal' or 'italic' (inherits from the table when omitted).`),textDecoration:Hd().optional().describe(`Text decoration, e.g. underline, line-through (inherits from the table when omitted).`),textTransform:Hd().optional().describe(`Text transform: uppercase, lowercase, capitalize, none (inherits from the table when omitted).`),fill:Hd().optional().describe(`Text color (inherits from the table when omitted).`),align:Hd().optional().describe(`Horizontal alignment: left, center, right, justify (inherits from the table when omitted).`),verticalAlign:Hd().optional().describe(`Vertical alignment: top, middle, bottom (inherits from the table when omitted).`),lineHeight:Af([hf(),Hd()]).optional().describe(`Line height multiplier or 'auto' (inherits from the table when omitted).`),letterSpacing:hf().optional().describe(`Letter spacing as a fraction of font size (inherits from the table when omitted).`),strokeWidth:hf().optional().describe(`Stroke width in pixels (inherits from the table when omitted).`),stroke:Hd().optional().describe(`Stroke color (inherits from the table when omitted).`),cellBackground:Hd().optional().describe(`Cell background color (inherits from the table when omitted).`),cellPadding:hf().optional().describe(`Cell padding in pixels (inherits from the table when omitted).`)}),{blurEnabled:h,blurRadius:g,brightnessEnabled:_,brightness:v,sepiaEnabled:y,grayscaleEnabled:b,filters:x,shadowEnabled:S,shadowBlur:C,shadowOffsetX:w,shadowOffsetY:T,shadowColor:E,shadowOpacity:D,...O}=i,k={...O,type:Bf(`table`).describe(`Element type identifier.`),width:hf().default(300).describe(`Width in pixels.`),height:hf().default(200).describe(`Height in pixels.`),rows:hf().default(3).describe(`Number of rows.`),cols:hf().default(3).describe(`Number of columns.`),colWidths:Tf(hf()).default([]).describe(`Column width fractions (sum to 1).`),rowHeights:Tf(hf()).default([]).describe(`Row height fractions (sum to 1).`),cells:Tf(m).default([]).describe(`Flat cell array in row-major order.`),borderColor:Hd().default(`#000000`).describe(`Default border color for the table grid.`),borderWidth:hf().default(1).describe(`Default border width in pixels.`),borderStyle:Rf([`solid`,`dashed`,`dotted`,`none`]).default(`solid`).describe(`Default border style.`),fontSize:hf().overwrite(bp).default(30).describe(`Default font size in pixels for cells (minimum 1).`),fontFamily:Hd().default(`Roboto`).describe(`Default font family name for cells.`),fontWeight:Hd().default(`normal`).describe(`Default font weight: 'normal', 'bold', or numeric string.`),fontStyle:Hd().default(`normal`).describe(`Default font style: 'normal' or 'italic'.`),textDecoration:Hd().default(``).describe(`Default text decoration (e.g. underline, line-through).`),textTransform:Hd().default(`none`).describe(`Default text transform: uppercase, lowercase, capitalize, none.`),fill:Hd().default(`black`).describe(`Default text color for cells.`),align:Hd().default(`center`).describe(`Default horizontal alignment: left, center, right, justify.`),verticalAlign:Hd().default(`middle`).describe(`Default vertical alignment: top, middle, bottom.`),lineHeight:Af([hf(),Hd()]).default(1.2).describe(`Default line height multiplier or 'auto'.`),letterSpacing:hf().default(0).describe(`Default letter spacing as a fraction of font size.`),strokeWidth:hf().default(0).describe(`Default stroke width in pixels.`),stroke:Hd().default(`black`).describe(`Default stroke color.`),cellBackground:Hd().default(`transparent`).describe(`Default cell background color.`),cellPadding:hf().default(4).describe(`Default cell padding in pixels.`)},A=e=>({id:i.id,type:Bf(`group`).describe(`Element type identifier.`),name:i.name,custom:i.custom,opacity:i.opacity,blendMode:Rf(Sp).optional().describe(`How the group composites with the content beneath it. Omitted means pass-through: children blend with that content directly. Any other mode composites the children together first.`),visible:i.visible,selectable:i.selectable,removable:i.removable,alwaysOnTop:i.alwaysOnTop,showInExport:i.showInExport,animations:i.animations,children:Tf(e).default([]).describe(`Child elements in this group.`)}),j=cp(()=>Mf(`type`,[e(o),e(s),e(c),e(l),e(u),e(d),e(f),e(k),e(A(j))])),M={fontFamily:Hd().describe(`Font family name.`),url:Hd().default(``).describe(`URL to load the font from (single-variant fonts).`),styles:Tf(e({src:Hd().describe(`Font source, typically in CSS url() form.`),fontStyle:Hd().optional(),fontWeight:Hd().optional()})).optional().describe(`Per-weight/style variants for multi-variant families.`)},N={id:Hd().describe(`Unique identifier for the audio track.`),name:Hd().default(``).describe(`Display name shown on the timeline.`),src:Hd().default(``).describe(`URL or data URI of the audio file.`),duration:hf().default(0).describe(`Duration in milliseconds.`),startTime:hf().default(0).describe(`Start offset (0-1).`),endTime:hf().default(1).describe(`End offset (0-1).`),volume:hf().default(1).describe(`Volume level (0-1).`),delay:hf().default(0).describe(`Delay before playing, in milliseconds.`),speed:hf().default(1).describe(`Playback speed multiplier (1 = normal).`),custom:xf().optional()},P=e({id:Hd().describe(`Unique identifier for the page.`),width:Af([hf(),Bf(`auto`)]).default(`auto`).describe(`Page width in pixels or 'auto'.`),height:Af([hf(),Bf(`auto`)]).default(`auto`).describe(`Page height in pixels or 'auto'.`),background:Hd().default(`white`).describe(`Background color or image.`),bleed:hf().default(0).describe(`Bleed area in pixels for print (all sides; base value for per-side overrides).`),bleedTop:hf().optional().describe("Per-side bleed override (top), in pixels. Inherits `bleed` when omitted."),bleedRight:hf().optional().describe("Per-side bleed override (right), in pixels. Inherits `bleed` when omitted."),bleedBottom:hf().optional().describe("Per-side bleed override (bottom), in pixels. Inherits `bleed` when omitted."),bleedLeft:hf().optional().describe("Per-side bleed override (left), in pixels. Inherits `bleed` when omitted."),custom:xf().optional(),duration:hf().default(5e3).describe(`Page duration in milliseconds.`),children:Tf(j).default([]).describe(`Elements on this page.`)});return{design:e({schemaVersion:hf().default(4).describe(`Schema version for compatibility / migration.`),width:hf().default(1080).describe(`Canvas width in pixels.`),height:hf().default(1080).describe(`Canvas height in pixels.`),unit:Rf([`px`,`pt`,`mm`,`cm`,`in`]).default(`px`).describe(`Unit type for print measurements.`),dpi:hf().default(72).describe(`Dots per inch for print calculations.`),custom:xf().optional().describe(`Custom data attached to the design.`),fonts:Tf(e(M)).default([]).describe(`Fonts used in the design.`),pages:Tf(P).default([]).describe(`Pages in the design.`),audios:Tf(e(N)).default([]).describe(`Audio tracks in the design.`)}),shapes:{text:o,image:s,svg:c,line:l,figure:u,gif:d,video:f,table:k,font:M,audio:N}}}var Tp=wp(Df),Ep=Tp.design,Dp=wp(Of).design;Df(Tp.shapes.text),Df(Tp.shapes.image),Df(Tp.shapes.svg),Df(Tp.shapes.line),Df(Tp.shapes.figure),Df(Tp.shapes.gif),Df(Tp.shapes.video),Df(Tp.shapes.table),Df(Tp.shapes.font),Df(Tp.shapes.audio);function Op(e){return e.map(e=>({path:e.path.map(String).join(`.`),message:e.message}))}var kp=new Set([`custom`,`data`]),eee=new Set([`filters`,`colorsReplace`]);function Ap(e){if(Array.isArray(e))return e.filter(e=>e!=null).map(Ap);if(e&&typeof e==`object`){let t={};for(let n of Object.keys(e)){let r=e[n];r!=null&&(t[n]=kp.has(n)?JSON.parse(JSON.stringify(r)):eee.has(n)&&Array.isArray(r)?{}:Ap(r))}return t}return e}function jp(e){throw fp(`DESIGN_INVALID`,`Invalid Polotno design:\n${e.slice(0,10).map(e=>` ${e.path}: ${e.message}`).join(`
64
- `)}`,{errors:e})}function Mp(e,t={}){let n=(t.mode===`canonical`?Dp:Ep).safeParse(Ap(e));return n.success||jp(Op(n.error.issues)),n.data}var Np=[`warm`,`cold`,`natural`],Pp=/<\/?(?:p|br|span|strong|em|ol|ul|li)\b[^>]*>/i;function Fp(e){let t=!1;return Ip(e,e=>{t||e.type!==`text`||Pp.test(String(e.text??``))&&(t=!0)}),t}function Ip(e,t){if(!Array.isArray(e))return;let n=e=>{if(Array.isArray(e.children))for(let r of e.children)r&&typeof r==`object`&&(t(r),n(r));if(Array.isArray(e.cells))for(let n of e.cells)n&&typeof n==`object`&&t(n)};for(let t of e)t&&typeof t==`object`&&n(t)}function Lp(e,t={}){let{modernTextRenderer:n=!0,modernizeTextBackground:r}=t;if(!e||typeof e!=`object`)return e;let i=JSON.parse(JSON.stringify(e)),a=i.schemaVersion||0;return a<1&&n&&Ip(i.pages,e=>{if(e.type!==`text`)return;let{letterSpacing:t}=e;if(!Number.isFinite(t))return;let n=Number.isFinite(e.fontSize)?e.fontSize:yp.fontSize;n!==0&&(e.letterSpacing=t*16/n)}),a<2&&Ip(i.pages,e=>{if(e.filters)for(let t of Object.keys(e.filters)){if(Np.includes(t))continue;let n=e.filters[t];n&&typeof n.intensity==`number`&&(n.intensity/=100)}}),a<3&&n&&(r===void 0?Fp(i.pages):!r)&&Ip(i.pages,e=>{e.type===`text`&&e.backgroundEnabled&&(e.legacyBackground=!0)}),i.schemaVersion=4,i}function Rp(e){if(!Array.isArray(e.pages))return;let t=new Set,n=e=>{e&&typeof e==`object`&&(typeof e.id==`string`&&e.id!==``&&t.add(e.id),Array.isArray(e.children)&&e.children.forEach(n),Array.isArray(e.cells)&&e.cells.forEach(n))};e.pages.forEach(n);let r=e=>{let n=e;for(let r=2;t.has(n);r++)n=`${e}_${r}`;return t.add(n),n},i=(e,t,n)=>{e&&typeof e==`object`&&((e.id==null||e.id===``)&&(e.id=r(`${t}-${n.join(`-`)}`)),Array.isArray(e.children)&&e.children.forEach((e,t)=>i(e,`el`,[...n,t])),Array.isArray(e.cells)&&e.cells.forEach((e,t)=>i(e,`cell`,[...n,t])))};e.pages.forEach((e,t)=>i(e,`page`,[t]))}var zp=new Set(Cp);function Bp(e){let t=[],n=(e,r)=>{if(!e||!Array.isArray(e.children))return;let i=[],a=0;for(let o of e.children)o!=null&&(typeof o==`object`&&zp.has(o.type)?(i.push(o),n(o,[...r,a])):typeof o==`object`&&typeof o.type==`string`?t.push({path:[...r,a],element:o}):i.push(o),a++);e.children=i};return Array.isArray(e.pages)&&e.pages.forEach((e,t)=>n(e,[t])),t}function Vp(e,t){for(let{path:n,element:r}of t){let t=e.pages[n[0]].children;for(let e of n.slice(1,-1))t=t[e].children;t.splice(n[n.length-1],0,r)}}function Hp(e,t){let n=(e,t)=>{for(let n of Object.keys(e))e[n]!=null&&!(n in t)&&(t[n]=e[n])},r=(e,t)=>{let r=0;for(let i of e){if(i==null)continue;let e=t[r++];typeof i==`object`&&e&&n(i,e)}},i=(e,t)=>{let a=0;for(let o of e){if(o==null)continue;let e=t[a++];if(typeof o==`object`&&e){if(!zp.has(o.type)){t[a-1]={...o,id:e.id??o.id};continue}n(o,e),Array.isArray(o.children)&&Array.isArray(e.children)&&i(o.children,e.children),Array.isArray(o.cells)&&Array.isArray(e.cells)&&r(o.cells,e.cells)}}};if(n(e,t),Array.isArray(e.audios)&&Array.isArray(t.audios)&&r(e.audios,t.audios),!Array.isArray(e.pages))return;let a=0;for(let r of e.pages){if(r==null)continue;let e=t.pages[a++];typeof r==`object`&&e&&(n(r,e),Array.isArray(r.children)&&Array.isArray(e.children)&&i(r.children,e.children))}}function Up(e,t={}){let n=e,r=Lp(e),i=(t.preserveClientData||t.fillMissingIds)&&r&&typeof r==`object`,a=[];i&&(t.fillMissingIds&&Rp(r),t.preserveClientData&&(a=Bp(r)));let o=Mp(r,t);if(i&&t.preserveClientData&&(a.length&&Vp(o,a),Hp(n,o)),t.requirePages&&o.pages.length===0)throw fp(`DESIGN_INVALID`,"Invalid Polotno design: no pages — did you pass `store.toJSON()`?",{errors:[{path:`pages`,message:`no pages`}]});return o}function Wp(e){let t=e.bleed||0;return{top:e.bleedTop??t,right:e.bleedRight??t,bottom:e.bleedBottom??t,left:e.bleedLeft??t}}var Gp=Object.freeze({top:0,right:0,bottom:0,left:0}),Kp=Math.PI/180;function qp(){return typeof window<`u`&&({}.toString.call(window)===`[object Window]`||{}.toString.call(window)===`[object global]`)}var Jp=typeof global<`u`?global:typeof window<`u`?window:typeof WorkerGlobalScope<`u`?self:{},Yp={_global:Jp,version:`10.7.0`,isBrowser:qp(),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle(e){return Yp.angleDeg?e*Kp:e},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_renderBackend:`web`,legacyTextRendering:!1,pixelRatio:typeof window<`u`&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return Yp.DD.isDragging},isTransforming(){return Yp.Transformer?.isTransforming()??!1},isDragReady(){return!!Yp.DD.node},releaseCanvasOnDestroy:!0,document:Jp.document,_injectGlobal(e){Jp.Konva!==void 0&&console.error(`Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.`),Jp.Konva=e}},Xp=new Set,Zp=(e,t=!1)=>{Yp[e.prototype.getClassName()]=e,t&&Xp.add(e)};Yp._injectGlobal(Yp);var Qp=`Konva.js unsupported environment.
64
+ `)}`,{errors:e})}function Mp(e,t={}){let n=(t.mode===`canonical`?Dp:Ep).safeParse(Ap(e));return n.success||jp(Op(n.error.issues)),n.data}var Np=[`warm`,`cold`,`natural`],Pp=/<\/?(?:p|br|span|strong|em|ol|ul|li)\b[^>]*>/i;function Fp(e){let t=!1;return Ip(e,e=>{t||e.type!==`text`||Pp.test(String(e.text??``))&&(t=!0)}),t}function Ip(e,t){if(!Array.isArray(e))return;let n=e=>{if(Array.isArray(e.children))for(let r of e.children)r&&typeof r==`object`&&(t(r),n(r));if(Array.isArray(e.cells))for(let n of e.cells)n&&typeof n==`object`&&t(n)};for(let t of e)t&&typeof t==`object`&&n(t)}function Lp(e,t={}){let{modernTextRenderer:n=!0,modernizeTextBackground:r}=t;if(!e||typeof e!=`object`)return e;let i=JSON.parse(JSON.stringify(e)),a=i.schemaVersion||0;return a<1&&n&&Ip(i.pages,e=>{if(e.type!==`text`)return;let{letterSpacing:t}=e;if(!Number.isFinite(t))return;let n=Number.isFinite(e.fontSize)?e.fontSize:yp.fontSize;n!==0&&(e.letterSpacing=t*16/n)}),a<2&&Ip(i.pages,e=>{if(e.filters)for(let t of Object.keys(e.filters)){if(Np.includes(t))continue;let n=e.filters[t];n&&typeof n.intensity==`number`&&(n.intensity/=100)}}),a<3&&n&&(r===void 0?Fp(i.pages):!r)&&Ip(i.pages,e=>{e.type===`text`&&e.backgroundEnabled&&(e.legacyBackground=!0)}),i.schemaVersion=4,i}function Rp(e){if(!Array.isArray(e.pages))return;let t=new Set,n=e=>{e&&typeof e==`object`&&(typeof e.id==`string`&&e.id!==``&&t.add(e.id),Array.isArray(e.children)&&e.children.forEach(n),Array.isArray(e.cells)&&e.cells.forEach(n))};e.pages.forEach(n);let r=e=>{let n=e;for(let r=2;t.has(n);r++)n=`${e}_${r}`;return t.add(n),n},i=(e,t,n)=>{e&&typeof e==`object`&&((e.id==null||e.id===``)&&(e.id=r(`${t}-${n.join(`-`)}`)),Array.isArray(e.children)&&e.children.forEach((e,t)=>i(e,`el`,[...n,t])),Array.isArray(e.cells)&&e.cells.forEach((e,t)=>i(e,`cell`,[...n,t])))};e.pages.forEach((e,t)=>i(e,`page`,[t]))}var zp=new Set(Cp);function Bp(e){let t=[],n=(e,r)=>{if(!e||!Array.isArray(e.children))return;let i=[],a=0;for(let o of e.children)o!=null&&(typeof o==`object`&&zp.has(o.type)?(i.push(o),n(o,[...r,a])):typeof o==`object`&&typeof o.type==`string`?t.push({path:[...r,a],element:o}):i.push(o),a++);e.children=i};return Array.isArray(e.pages)&&e.pages.forEach((e,t)=>n(e,[t])),t}function Vp(e,t){for(let{path:n,element:r}of t){let t=e.pages[n[0]].children;for(let e of n.slice(1,-1))t=t[e].children;t.splice(n[n.length-1],0,r)}}function Hp(e,t){let n=(e,t)=>{for(let n of Object.keys(e))e[n]!=null&&!(n in t)&&(t[n]=e[n])},r=(e,t)=>{let r=0;for(let i of e){if(i==null)continue;let e=t[r++];typeof i==`object`&&e&&n(i,e)}},i=(e,t)=>{let a=0;for(let o of e){if(o==null)continue;let e=t[a++];if(typeof o==`object`&&e){if(!zp.has(o.type)){t[a-1]={...o,id:e.id??o.id};continue}n(o,e),Array.isArray(o.children)&&Array.isArray(e.children)&&i(o.children,e.children),Array.isArray(o.cells)&&Array.isArray(e.cells)&&r(o.cells,e.cells)}}};if(n(e,t),Array.isArray(e.audios)&&Array.isArray(t.audios)&&r(e.audios,t.audios),!Array.isArray(e.pages))return;let a=0;for(let r of e.pages){if(r==null)continue;let e=t.pages[a++];typeof r==`object`&&e&&(n(r,e),Array.isArray(r.children)&&Array.isArray(e.children)&&i(r.children,e.children))}}function Up(e,t={}){let n=e,r=Lp(e),i=(t.preserveClientData||t.fillMissingIds)&&r&&typeof r==`object`,a=[];i&&(t.fillMissingIds&&Rp(r),t.preserveClientData&&(a=Bp(r)));let o=Mp(r,t);if(i&&t.preserveClientData&&(a.length&&Vp(o,a),Hp(n,o)),t.requirePages&&o.pages.length===0)throw fp(`DESIGN_INVALID`,"Invalid Polotno design: no pages — did you pass `store.toJSON()`?",{errors:[{path:`pages`,message:`no pages`}]});return o}function Wp(e){let t=e.bleed||0;return{top:e.bleedTop??t,right:e.bleedRight??t,bottom:e.bleedBottom??t,left:e.bleedLeft??t}}var Gp=Object.freeze({top:0,right:0,bottom:0,left:0}),Kp=Math.PI/180;function qp(){return typeof window<`u`&&({}.toString.call(window)===`[object Window]`||{}.toString.call(window)===`[object global]`)}var Jp=typeof global<`u`?global:typeof window<`u`?window:typeof WorkerGlobalScope<`u`?self:{},Yp={_global:Jp,version:`10.7.1`,isBrowser:qp(),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle(e){return Yp.angleDeg?e*Kp:e},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_renderBackend:`web`,legacyTextRendering:!1,pixelRatio:typeof window<`u`&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return Yp.DD.isDragging},isTransforming(){return Yp.Transformer?.isTransforming()??!1},isDragReady(){return!!Yp.DD.node},releaseCanvasOnDestroy:!0,document:Jp.document,_injectGlobal(e){Jp.Konva!==void 0&&console.error(`Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.`),Jp.Konva=e}},Xp=new Set,Zp=(e,t=!1)=>{Yp[e.prototype.getClassName()]=e,t&&Xp.add(e)};Yp._injectGlobal(Yp);var Qp=`Konva.js unsupported environment.
65
65
 
66
66
  Looks like you are trying to use Konva.js in Node.js environment (or in a Web Worker), because "document" object is undefined.
67
67
 
@@ -74,8 +74,8 @@ or
74
74
 
75
75
  bash: npm install skia-canvas
76
76
  js: import "konva/skia-backend";
77
- `,$p=()=>{if(typeof document>`u`)throw Error(Qp)},em=class e{constructor(e){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]}}_getTransformedRect(e){let[t,n,r,i,a,o]=this.m,s=e.x,c=e.y,l=e.x+e.width,u=e.y+e.height,d=[t*s+r*c+a,t*l+r*c+a,t*l+r*u+a,t*s+r*u+a],f=[n*s+i*c+o,n*l+i*c+o,n*l+i*u+o,n*s+i*u+o],p=Math.min(d[0],d[1],d[2],d[3]),m=Math.min(f[0],f[1],f[2],f[3]);return{x:p,y:m,width:Math.max(d[0],d[1],d[2],d[3])-p,height:Math.max(f[0],f[1],f[2],f[3])-m}}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}isInvertible(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]!==0}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=o&&(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=o&&(e*n+t*r)/o}return s.rotation=W._getRotation(s.rotation),s}},tm=`[object Array]`,nm=`[object Number]`,rm=`[object String]`,im=`[object Boolean]`,am=Math.PI/180,om=180/Math.PI,sm=`#`,cm=``,lm=`0`,tee=`Konva warning: `,um=`Konva error: `,nee={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:[0,0,0,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]},dm=null,fm=typeof window<`u`?window:{},pm=new WeakMap,mm=(e,t)=>{typeof e.requestAnimationFrame==`function`?e.requestAnimationFrame(t):typeof requestAnimationFrame<`u`?requestAnimationFrame(t):setTimeout(t,16)},hm=new Map,gm=Object.getPrototypeOf(Int8Array),_m=e=>{let t=e.trim();return t.indexOf(`,`)===-1?t.split(/\s*\/\s*|\s+/):t.split(/\s*,\s*/)},vm=`[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?`,ym=RegExp(`^(${vm})(%?)$`,`i`),bm=(e,t)=>{let n=ym.exec(e);if(!n)return NaN;let r=n[2]?Number(n[1])/100*t:Number(n[1]);return Math.min(Math.max(r,0),t)},xm=/^#[0-9a-f]+$/i,Sm=RegExp(`^(${vm})(deg|grad|rad|turn)?$`,`i`),Cm={deg:1,grad:.9,rad:om,turn:360};function wm(e,t){return Math.min(Math.max(e||0,0),t)}var W={_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)===tm},_isNumber(e){return Object.prototype.toString.call(e)===nm&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===rm},_isBoolean(e){return Object.prototype.toString.call(e)===im},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,t){let n=t&&!t.closed&&t||fm,r=pm.get(n);r||(r=[],pm.set(n,r),mm(n,function(){pm.delete(n),r.forEach(function(e){e()})})),r.push(e)},createCanvasElement(){$p();let e=document.createElement(`canvas`);try{e.style=e.style||{}}catch{}return e},createImageElement(){return $p(),document.createElement(`img`)},_urlToImage(e,t,n){let r=W.createImageElement();r.onload=function(){t(r)},r.onerror=e=>{n?.(e instanceof Error?e:Error(`Unable to load image.`))},r.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(sm,cm);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=lm+e;return sm+e},isCanvasFarblingActive(){if(dm!==null)return dm;if(typeof document>`u`)return dm=!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 dm=r,this.releaseCanvas(e),dm},getHitColor(){let e=()=>Math.random()*256|0;return this.getHitColorKey(e(),e(),e())},getHitColorKey(e,t,n){let r=this.isCanvasFarblingActive()?5:3,i=e=>Math.round(e/r)*r;return sm+this._rgbToHex(i(e),i(t),i(n))},getSnappedHexColor(e){let{r:t,g:n,b:r}=this._hexToRgb(e);return this.getHitColorKey(t,n,r)},getRGB(e){let{r:t=0,g:n=0,b:r=0}=W.colorToRGBA(e)??{};return{r:t,g:n,b:r}},colorToRGBA(e){e=(e||``).trim()||`black`;let t=W._namedColorToRBA(e)||W._hex3ColorToRGBA(e)||W._hex4ColorToRGBA(e)||W._hex6ColorToRGBA(e)||W._hex8ColorToRGBA(e)||W._rgbColorToRGBA(e)||W._hslColorToRGBA(e);if(t&&[t.r,t.g,t.b,t.a].every(W._isNumber))return t},_namedColorToRBA(e){let t=nee[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=_m(t[1]);if(!(n.length<3||n.length>4))return{r:bm(n[0],255),g:bm(n[1],255),b:bm(n[2],255),a:n.length>3?bm(n[3],1):1}},_hex8ColorToRGBA(e){if(e.length===9&&xm.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&&xm.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&&xm.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&&xm.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=_m(t[1]);if(n.length<3||n.length>4)return;let r=Sm.exec(n[0]);if(!r)return;let i=r[2],a=Number(r[1])*(i?Cm[i.toLowerCase()]:1);if(!isFinite(a))return;let o=(a%360+360)%360/360,s=bm(n[1],100)/100,c=bm(n[2],100)/100,l=n.length>3?bm(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}},_getPointsRect(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a=0;a<e.length;a+=2){let o=e[a],s=e[a+1];isNaN(o)||(t=Math.min(t,o),r=Math.max(r,o)),isNaN(s)||(n=Math.min(n,s),i=Math.max(i,s))}return isFinite(t+n)?{x:t,y:n,width:r-t,height:i-n}:{x:0,y:0,width:0,height:0}},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]=W._cloneValue(e[n]);return t},_cloneValue(e){return W._isArray(e)?e.some(e=>typeof e==`object`)?e.map(W._cloneValue):e.slice():W._isPlainObject(e)?W.cloneObject(e):e instanceof gm?e.slice():e},cloneArray(e){return e.slice(0)},degToRad(e){return e*am},radToDeg(e){return e*om},_getRotation(e){return Yp.angleDeg?W.radToDeg(e):e},_capitalize(e){let t=hm.get(e);if(t!==void 0)return t;let n=e.charAt(0).toUpperCase()+e.slice(1);return hm.set(e,n),n},throw(e){throw Error(um+e)},error(e){console.error(um+e)},warn(e){Yp.showWarnings&&console.warn(tee+e)},_batchEvents(e,t){if(!e)return t();let n=!1,r=!0;try{e(()=>{if(n||!r){W.warn(`eventBatchFunc must call its argument exactly once, synchronously.`);return}n=!0,t()})}finally{r=!1,n||W.warn(`eventBatchFunc must call its argument synchronously.`)}},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=W.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=W._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=W._getProjectionToLine(e,r,n);a.push(t.x),a.push(t.y)}),a},_prepareToStringify(e,t=new Set){let n=W._isArray(e)?[]:{};t.add(e);for(let r of Object.keys(e)){let i=e[r];W._isElement(i)||t.has(i)||(n[r]=W._isPlainObject(i)||W._isArray(i)?W._prepareToStringify(i,t):i)}return t.delete(e),n},_assign(e,t){for(let n in t)e[n]=t[n];return e},_getEventType(e){return e.indexOf(`pointer`)>=0?`pointer`:e.indexOf(`touch`)>=0?`touch`:`mouse`},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId??999},releaseCanvas(...e){Yp.releaseCanvasOnDestroy&&e.forEach(e=>{e.width=0,e.height=0})},_cornerRadii(e,t,n){let r=Math.min(t,n)/2;if(typeof e==`number`){let t=wm(e,r);return[t,t,t,t]}return[wm(e[0],r),wm(e[1],r),wm(e[2],r),wm(e[3],r)]},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,s,c,l]=W._cornerRadii(r,t,n);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-c),e.arc(i+t-c,a+n-c,c,0,Math.PI/2,!1),e.lineTo(i+l,a+n),e.arc(i+l,a+n-l,l,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 Tm(e){let t=[],n=e.length,r=W;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 Em=`,`,Dm=`(`,Om=`)`,km=`;`,Am=`()`,jm=`=`,Mm=`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(`.`),Nm=[`fillStyle`,`strokeStyle`,`shadowColor`,`shadowBlur`,`shadowOffsetX`,`shadowOffsetY`,`letterSpacing`,`lineCap`,`lineDashOffset`,`lineJoin`,`lineWidth`,`miterLimit`,`direction`,`font`,`textAlign`,`textBaseline`,`globalAlpha`,`globalCompositeOperation`,`imageSmoothingEnabled`,`imageSmoothingQuality`,`filter`],Pm=100,Fm=null;function Im(){if(Fm!==null)return Fm;try{let e=W.createCanvasElement(),t=e.getContext(`2d`);Fm=!!t&&`filter`in t,W.releaseCanvas(e)}catch{Fm=!1}return Fm}var Lm=class{constructor(e){this.canvas=e,Yp.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+=Am:(t&&(c=c.map(e=>typeof e==`number`?Math.floor(e):e)),i+=Dm+c.join(Em)+Om)):(i+=o.property,e||(i+=jm+o.val)),i+=km;return i}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=Pm&&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)}_drawDeviceBuffer(e){let{x:t,y:n,width:r,height:i}=e._isolationRect;this.setTransform(1,0,0,1,0,0),this.imageSmoothingEnabled=!1,this.drawImage(e._canvas,0,0,r,i,t,n,r,i)}_applyLineCap(e){let t=e.attrs.lineCap;t&&this.setAttr(`lineCap`,t)}_getOpacity(e){if(!this._opacityRoot)return e.getAbsoluteOpacity();let t=e.opacity(),n=e.parent;for(;n&&n!==this._opacityRoot;)t*=n.opacity(),n=n.parent;return t}_applyOpacity(e){let t=this._getOpacity(e);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(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=Mm.length,n=this.setAttr,r,i,a=function(t){let n=e[t],r;e[t]=function(){return i=Tm(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(Mm[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)}};Nm.forEach(function(e){Object.defineProperty(Lm.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var Rm=class extends Lm{constructor(e,{willReadFrequently:t=!1}={}){super(e),this._context=e._canvas.getContext(`2d`,{willReadFrequently:t})}_getFillPattern(e){let t=this._context;return`patternQuality`in t&&(t.patternQuality=t.imageSmoothingEnabled?`good`:`nearest`),e._getFillPattern()}_getFillStyle(e){let t=e.fill(),n=e.fillPriority();if(t&&n===`color`)return t;let r=e.fillPatternImage();if(r&&n===`pattern`)return this._getFillPattern(e);let i=e.fillLinearGradientColorStops();if(i&&n===`linear-gradient`)return e._getLinearGradient();let a=e.fillRadialGradientColorStops();if(a&&n===`radial-gradient`)return e._getRadialGradient();if(t)return t;if(r)return this._getFillPattern(e);if(i)return e._getLinearGradient();if(a)return e._getRadialGradient()}_fill(e){let t=this._getFillStyle(e);t!==void 0&&(this.setAttr(`fillStyle`,t),e._fillFunc(this))}_strokeLinearGradient(e){let t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint();if(!e.getStrokeScaleEnabled()){let{a:e,b:r,c:i,d:a,e:o,f:s}=this._context.getTransform(),c=new em([e,r,i,a,o,s]),l=this.canvas.getPixelRatio(),u=n.x-t.x,d=n.y-t.y,f=a*u-r*d,p=e*d-i*u,m=f*f+p*p,h=m?(u*u+d*d)*(e*a-r*i)/m:0;t=c.point(t),n={x:t.x+f*h,y:t.y+p*h},t={x:t.x/l,y:t.y/l},n={x:n.x/l,y:n.y/l}}let 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)}}_applyStrokeStyle(e){e.strokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr(`strokeStyle`,e.stroke())}_stroke(e){let t=e.dash(),n=e.getStrokeScaleEnabled();n||this.save(),this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr(`lineDashOffset`,e.dashOffset())),this.setAttr(`lineWidth`,e.strokeWidth());let r=this.shadowColor,i=e.getShadowForStrokeEnabled();if(i||this.setAttr(`shadowColor`,`rgba(0,0,0,0)`),this._applyStrokeStyle(e),!n){let e=this.getCanvas().getPixelRatio();this.setTransform(e,0,0,e,0,0)}try{e._strokeFunc(this)}finally{i||this.setAttr(`shadowColor`,r),n||this.restore()}}_applyShadow(e){let t=e.getShadowRGBA()??`black`,n=e.getShadowBlur(),r=e.getShadowOffset(),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)}},zm=class extends Lm{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){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()}},Bm=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this._logicalWidth=0,this._logicalHeight=0,this.isCache=!1;let t=(e||{}).pixelRatio||Yp.pixelRatio||Yp._global.devicePixelRatio||1;this.pixelRatio=t,this._canvas=W.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){this.pixelRatio=e,this.setSize(this._logicalWidth,this._logicalHeight)}setWidth(e){this.setSize(e,this._logicalHeight)}setHeight(e){this.setSize(this._logicalWidth,e)}getWidth(){return this.width}getHeight(){return this.height}_bitmapSize(e){return Math.floor((e||0)*this.pixelRatio)}setSize(e,t){(!isFinite(e??0)||!isFinite(t??0))&&(W.error(`Canvas size must be finite numbers, got ${e}x${t}. The canvas is left empty.`),e=t=0),e||=0,t||=0;let n=this.pixelRatio,r=this.getContext()._context,i=r.imageSmoothingEnabled;this._logicalWidth=e,this._logicalHeight=t,this.width=this._canvas.width=this._bitmapSize(e),this.height=this._canvas.height=this._bitmapSize(t),this._canvas.style.width=e+`px`,this._canvas.style.height=t+`px`,r.scale(n,n),r.imageSmoothingEnabled=i}setSizeIfChanged(e,t){(this.width!==this._bitmapSize(e)||this.height!==this._bitmapSize(t))&&this.setSize(e,t)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(e){throw W.error(`Unable to get data URL. `+e.message+` For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.`),e}}}},Vm=class e extends Bm{_prepareIsolationCanvas(t){let{a:n,b:r,c:i,d:a,e:o,f:s}=this.getContext()._context.getTransform(),c=this._isolationRect||this,l=0,u=0,d=c.width,f=c.height;if(t){let e=new em([n,r,i,a,o,s])._getTransformedRect(t);l=Math.max(0,Math.floor(e.x)-1),u=Math.max(0,Math.floor(e.y)-1),d=Math.min(d,Math.ceil(e.x+e.width)+1)-l,f=Math.min(f,Math.ceil(e.y+e.height)+1)-u}d>0&&f>0||(l=u=0,d=f=1);let p=this._isolationCanvas||=new e({width:0,height:0,pixelRatio:this.pixelRatio});if(p.width<d||p.height<f){let e=this.pixelRatio,t=(t,n,r)=>Math.min(r,Math.ceil((n<t?Math.max(t,n*1.5):n)/e));p.setSize(t(d,p.width,this._logicalWidth),t(f,p.height,this._logicalHeight))}p._isolationRect={x:l,y:u,width:d,height:f};let m=p._isolationPeak;m.width=Math.max(m.width,d),m.height=Math.max(m.height,f);let h=p.getContext();h.setTransform(1,0,0,1,0,0),h.clearRect(0,0,d,f),h.setTransform(n,r,i,a,o-l,s-u);let g=this.getContext();return h.imageSmoothingEnabled=g.imageSmoothingEnabled,h.imageSmoothingQuality=g.imageSmoothingQuality,h.direction=g.direction,p}_trimIsolationCanvas(){let e=this._isolationCanvas;if(!e)return;let t=e._isolationPeak;e._isolationLowFrames=e.width*e.height>4*t.width*t.height?e._isolationLowFrames+1:0,e._isolationLowFrames>=10?this._releaseIsolationCanvas():(t.width=t.height=0,e._trimIsolationCanvas())}_releaseIsolationCanvas(){let e=this._isolationCanvas;e&&(e._releaseIsolationCanvas(),W.releaseCanvas(e._canvas),this._isolationCanvas=void 0)}setSize(e,t){this._releaseIsolationCanvas(),super.setSize(e,t)}constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this._isolationPeak={width:0,height:0},this._isolationLowFrames=0,this.context=new Rm(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},Hm=class extends Bm{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new zm(this),this.context.imageSmoothingEnabled=!1,this.setSize(e.width,e.height)}},Um={get isDragging(){let e=!1;return Um._dragElements.forEach(t=>{t.dragStatus===`dragging`&&(e=!0)}),e},get node(){let e;for(let t of Um._dragElements.values()){if(t.dragStatus===`dragging`)return t.node;e=t.node}return e},_dragElements:new Map,_listenToWindow(e){let t=t=>Um._endDragBefore(t,e),n=t=>Um._batchEvents(()=>Um._drag(t,e),e),r=e=>Um._batchEvents(()=>Um._endDragAfter(e));e.addEventListener(`mouseup`,t,!0),e.addEventListener(`touchend`,t,!0),e.addEventListener(`touchcancel`,t,!0),e.addEventListener(`mousemove`,n),e.addEventListener(`touchmove`,n),e.addEventListener(`mouseup`,r,!1),e.addEventListener(`touchend`,r,!1),e.addEventListener(`touchcancel`,r,!1)},_batchEvents(e,t){if(!Um._dragElements.size)return;let n=new Set;for(let{node:e}of Um._dragElements.values()){let r=e.getStage();if(!r||t&&r._getOwnerWindow()!==t)continue;let i=r.eventBatchFunc();i&&n.add(i)}let r=e;for(let e of n){let t=r;r=()=>W._batchEvents(e,t)}r()},_drag(e,t){let n=[],r=new Set;Um._dragElements.forEach((i,a)=>{let{node:o}=i,s=o.getStage();if(t&&s._getOwnerWindow()!==t||(r.has(s)||(s.setPointersPositions(e),r.add(s)),i.pointerEventType&&i.pointerEventType!==s._pointerEventType))return;i.pointerId===void 0&&(i.pointerId=W._getFirstPointerId(e),i.pointerEventType=s._pointerEventType,i.dragStatus===`dragging`&&s._cancelClick(i.pointerId,i.pointerEventType));let c=s._changedPointerPositions.find(e=>e.id===i.pointerId);if(c){if(i.dragStatus!==`dragging`){let t=o.dragDistance();if(Math.max(Math.abs(c.x-i.startPointerPos.x),Math.abs(c.y-i.startPointerPos.y))<t||(o.startDrag({evt:e}),!o.isDragging()))return}o._setDragPosition(e,i),n.push(o)}}),n.forEach(t=>{t.getStage()&&t.fire(`dragmove`,{type:`dragmove`,target:t,evt:e},!0)})},_endDragBefore(e,t,n){let r=[],i=new Set;Um._dragElements.forEach((a,o)=>{let{node:s}=a;if(n&&a!==n&&a.pointerId!==n.pointerId)return;let c=s.getStage();if(e&&!i.has(c)&&(!t||c._getOwnerWindow()===t)&&(c.setPointersPositions(e),i.add(c)),n||(!e||!a.pointerEventType||a.pointerEventType===W._getEventType(e.type))&&(a.pointerId===void 0||c._changedPointerPositions.some(e=>e.id===a.pointerId))){if(a.dragStatus===`ready`)Um._dragElements.delete(o);else{c._cancelClick(a.pointerId,a.pointerEventType),a.dragStatus=`stopped`;let e=s.getLayer()||c;e&&r.indexOf(e)===-1&&r.push(e)}}}),r.forEach(e=>{e.draw()})},_endDragAfter(e,t){Um._dragElements.forEach((n,r)=>{n.dragStatus!==`stopped`||t&&n!==t&&n.pointerId!==t.pointerId||(n.node.fire(`dragend`,{type:`dragend`,target:n.node,evt:e},!0),n.dragStatus!==`dragging`&&Um._dragElements.delete(r))})}},Wm=new Map,Gm=Yp._global.PointerEvent!==void 0;function Km(e,t){let n=Wm.get(e);return n&&(!t||n.stage===t)?n.shape:void 0}function qm(e,t,n){e._fire(t,{evt:new PointerEvent(t,{pointerId:n}),pointerId:n})}function Jm(e,t){return Wm.get(e)?.shape===t}function Ym(e,t){var n;Zm(e);let r=t.getStage();if(r&&(Wm.set(e,{shape:t,stage:r}),Gm)){try{(n=r.content)==null||n.setPointerCapture(e)}catch{}qm(t,`gotpointercapture`,e)}}function Xm(e){Wm.forEach(({shape:t,stage:n},r)=>{(t===e||n===e)&&Zm(r)})}function Zm(e,t){var n;let r=Wm.get(e);if(!r||t&&r.shape!==t)return;let{shape:i,stage:a}=r;if(Wm.delete(e),Gm){try{(n=a.content)==null||n.releasePointerCapture(e)}catch{}qm(i,`lostpointercapture`,e)}}function Qm(e){return W._isString(e)?`"`+e+`"`:Object.prototype.toString.call(e)===`[object Number]`||W._isBoolean(e)?e:Object.prototype.toString.call(e)}function $m(e){return e>255?255:e<0?0:Math.round(e)}function eh(){if(Yp.isUnminified)return function(e,t){return W._isNumber(e)||W.warn(Qm(e)+` is a not valid value for "`+t+`" attribute. The value should be a number.`),e}}function th(e){if(Yp.isUnminified)return function(t,n){let r=W._isNumber(t),i=W._isArray(t)&&t.length==e;return!r&&!i&&W.warn(Qm(t)+` is a not valid value for "`+n+`" attribute. The value should be a number or Array<number>(`+e+`)`),t}}function nh(){if(Yp.isUnminified)return function(e,t){return W._isNumber(e)||e===`auto`||W.warn(Qm(e)+` is a not valid value for "`+t+`" attribute. The value should be a number or "auto".`),e}}function rh(){if(Yp.isUnminified)return function(e,t){return W._isString(e)||W.warn(Qm(e)+` is a not valid value for "`+t+`" attribute. The value should be a string.`),e}}function ih(){if(Yp.isUnminified)return function(e,t){let n=W._isString(e),r=Object.prototype.toString.call(e)===`[object CanvasGradient]`||e&&e.addColorStop;return n||r||W.warn(Qm(e)+` is a not valid value for "`+t+`" attribute. The value should be a string or a native gradient.`),e}}function ah(){if(Yp.isUnminified)return function(e,t){return e instanceof gm||(W._isArray(e)?e.forEach(function(e){W._isNumber(e)||W.warn(`"`+t+`" attribute has non numeric element `+e+`. Make sure that all elements are numbers.`)}):W.warn(Qm(e)+` is a not valid value for "`+t+`" attribute. The value should be a array of numbers.`)),e}}function oh(){if(Yp.isUnminified)return function(e,t){return e!==!0&&e!==!1&&W.warn(Qm(e)+` is a not valid value for "`+t+`" attribute. The value should be a boolean.`),e}}function sh(e){if(Yp.isUnminified)return function(t,n){return t==null||W.isObject(t)||W.warn(Qm(t)+` is a not valid value for "`+n+`" attribute. The value should be an object with properties `+e),t}}var ch=`get`,lh=`set`,G={addGetterSetter(e,t,n,r,i){G.addGetter(e,t,n),G.addSetter(e,t,r,i),G.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){let r=ch+W._capitalize(t),i=Array.isArray(n),a=function(){let e=this.attrs[t];return e===void 0?i?n.slice():n:e};a._def=n,e.prototype[r]=e.prototype[r]||a},addSetter(e,t,n,r){let i=lh+W._capitalize(t);e.prototype[i]||G.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){let i=lh+W._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=W._capitalize,s=ch+o(t),c=lh+o(t),l=n.map(e=>t+o(e)),u=l.map(e=>ch+o(e));e.prototype[s]=function(){let e={};for(let t=0;t<a;t++){let r=this[u[t]];e[n[t]]=r?r.call(this):this.attrs[l[t]]}return e};let d=sh(n);e.prototype[c]=function(e){let a=this[s]();r&&(e=r.call(this,e,t)),d&&d.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},G.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){let n=W._capitalize(t),r=lh+n,i=ch+n,a=function(){return arguments.length?(this[r](arguments[0]),this):this[i]()};e.prototype[t]=a},backCompat(e,t){W.each(t,function(t,n){let r=e.prototype[n],i=ch+W._capitalize(t),a=lh+W._capitalize(t);function o(){return W.error(`"`+t+`" method is deprecated and will be removed soon. Use ""`+n+`" instead.`),r.apply(this,arguments)}e.prototype[t]=o,e.prototype[i]=o,e.prototype[a]=o})},afterSetFilter(){this._filterUpToDate=!1}};function uh(e){let t=[],n=/(\w+)\(([^)]*)\)/g,r;for(;(r=n.exec(e))!==null;){let[,e,n]=r;if(![`blur`,`brightness`,`contrast`,`grayscale`,`sepia`,`invert`].includes(e)){W.warn(`CSS filter "${e}" is not supported in fallback mode. Consider using function filters for better compatibility.`);continue}let i=n.trim()===``?e===`blur`?0:1:parseFloat(n)/(n.includes(`%`)?100:1);t.push({name:e,value:i})}return function(e,n=1){for(let{name:r,value:i}of t){if([`grayscale`,`sepia`,`invert`].includes(r)){let t=Math.min(1,Math.max(0,i)),n=e.data;for(let e=0;e<n.length;e+=4){let i=n[e],a=n[e+1],o=n[e+2],s,c,l;r===`grayscale`?s=c=l=.2126*i+.7152*a+.0722*o:r===`sepia`?(s=.393*i+.769*a+.189*o,c=.349*i+.686*a+.168*o,l=.272*i+.534*a+.131*o):(s=255-i,c=255-a,l=255-o),n[e]=i+(s-i)*t,n[e+1]=a+(c-a)*t,n[e+2]=o+(l-o)*t}continue}let t=Yp.Filters?.[W._capitalize(r)];if(!t)continue;let a=Object.create(this);a.attrs={...this.attrs},r===`blur`&&(a.attrs.blurRadius=i*.5),r===`brightness`&&(a.attrs.brightness=i),r===`contrast`&&(a.attrs.contrast=100*(Math.sqrt(i)-1)),t.call(a,e,n)}}}var dh=`absoluteOpacity`,fh=`absoluteTransform`,ph=`Change`,mh=`children`,hh=`konva`,gh=`listening`,_h=[`mouseenter`,`mouseleave`,`pointerenter`,`pointerleave`,`touchenter`,`touchleave`],vh=`set`,yh=`Shape`,bh=` `,xh=`stage`,Sh=`transform`,Ch=`Stage`,wh=`visible`,Th=[`xChange.konva`,`yChange.konva`,`scaleXChange.konva`,`scaleYChange.konva`,`skewXChange.konva`,`skewYChange.konva`,`rotationChange.konva`,`offsetXChange.konva`,`offsetYChange.konva`,`transformsEnabledChange.konva`].join(bh),Eh=1,Dh=class e{constructor(e){this._id=Eh++,this.eventListeners={},this.attrs={},this.index=0,this.parent=null,this._cache={},this._canvasCache=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===Sh||e===fh)&&this._cache[e]?this._cache[e].dirty=!0:e?this._cache[e]=void 0:(this._cache={},this._attrsVersion!==void 0&&this._attrsVersion++)}_releaseCanvasCache(){let e=this._canvasCache;e&&(W.releaseCanvas(e.scene._canvas,e.filter._canvas,...e.hit?[e.hit._canvas]:[]),this._canvasCache=null)}_getCache(e,t){let n=this._cache[e];return(n===void 0||(e===Sh||e===fh)&&n.dirty===!0)&&(n=t.call(this),this._cache[e]=n),n}_getCanvasCache(){return this._canvasCache}_clearSelfAndDescendantCache(e){this._clearCache(e),(e===void 0||e===fh)&&this.fire(`absoluteTransformChange`)}static _runAfterAbsTransformCascade(t){e._absTransformCascadeDepth>0?e._pendingAfterCascade.push(t):t()}clearCache(){return this._releaseCanvasCache(),this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){let t=e||{},n={};if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0){let e=this._isUnderCache;this._isUnderCache=!0,n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}),this._isUnderCache=e}let r=t.x===void 0?Math.floor(n.x):t.x,i=t.y===void 0?Math.floor(n.y):t.y,a=Math.ceil(t.width||n.x+n.width-r),o=Math.ceil(t.height||n.y+n.height-i),s=t.pixelRatio,c=t.offset||0,l=t.drawBorder||!1,u=t.hitCanvasPixelRatio||1;if(a<=0||o<=0||!isFinite(r+i+a+o))return W.error(`Can not cache the node. Its size is 0 or its bounds are not finite numbers (${r}, ${i}, ${a}x${o}). Caching is skipped.`),this;a+=c*2,o+=c*2,r-=c,i-=c;let d=new Vm({pixelRatio:s,width:a,height:o}),f=new Vm({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),p=d.getContext();d.isCache=!0,this._releaseCanvasCache(),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(d.getContext()._context.imageSmoothingEnabled=!1,f.getContext()._context.imageSmoothingEnabled=!1),p.save(),p.translate(-r,-i),this._isUnderCache=!0,this._clearSelfAndDescendantCache(dh);try{this.drawScene(d,this)}catch(e){throw W.releaseCanvas(d._canvas),e}finally{this._isUnderCache=!1,this._clearSelfAndDescendantCache(dh),p.restore(),d._releaseIsolationCanvas()}return l&&(p.save(),p.beginPath(),p.rect(0,0,a,o),p.closePath(),p.setAttr(`strokeStyle`,`red`),p.setAttr(`lineWidth`,5),p.stroke(),p.restore()),this._canvasCache={scene:d,filter:f,hit:null,hitConfig:{pixelRatio:u,width:a,height:o},x:r,y:i},this._clearSelfAndDescendantCache(),this._requestDraw(),this}_getCachedHitCanvas(e){if(e===this)return null;let t=this._getCanvasCache();if(!t)return null;if(t.hit)return t.hit;let n=new Hm(t.hitConfig);n.isCache=!0;let r=n.getContext();return r.save(),r.translate(-t.x,-t.y),this.drawHit(n,this),r.restore(),t.hit=n,n}isCached(){return!!this._canvasCache}getClientRect(e){throw Error(`abstract "getClientRect" method call`)}_getCachedSceneRect(e){let t=e._forDrawing&&!this._isUnderCache&&this._getCanvasCache();if(!t)return;let n={x:t.x,y:t.y,width:t.scene.width/t.scene.pixelRatio,height:t.scene.height/t.scene.pixelRatio};return e.skipTransform?n:this._transformedRect(n,e.relativeTo)}_transformedRect(e,t){return this.getAbsoluteTransform(t)._getTransformedRect(e)}_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,t){let n=this._getCanvasCache();e.save(),e.translate(n.x,n.y),e.drawImage(t._canvas,0,0,t.width/t.pixelRatio,t.height/t.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`||!Im()){l=!1;break}let u=n.pixelRatio;if(r.setSizeIfChanged(n._logicalWidth,n._logicalHeight),l){let t=e.join(` `).replace(/url\((?:[^()"']|"[^"]*"|'[^']*')*\)|"[^"]*"|'[^']*'|([-+]?(?:\d*\.)?\d+(?:e[-+]?\d+)?)(px|em|rem|ex|ch|cap|ic|lh|rlh|vw|vh|vmin|vmax|cm|mm|q|in|pt|pc)\b/gi,(e,t,n)=>t===void 0?e:`${Number(t)*u}${n}`);return i.clear(),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=uh(c)),c.call(this,o,u);i.putImageData(o,0,0)}catch(e){W.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){this._prepareListeners();let t=e[0],n=e[1];if(e[2],e.length===3)return this._delegate.apply(this,e);let r=t.split(bh);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}_prepareListeners(){this===this.constructor.prototype&&(this.hasOwnProperty(`eventListeners`)||(this.eventListeners={}),e.protoListenerMap=new WeakMap)}off(e,t){this._prepareListeners();let n=(e||``).split(bh),r=n.length,i,a,o,s,c,l;if(!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=W.cloneObject(e),e.currentTarget=i[t],n.call(i[t],e)}),this}remove(){return this.isDragging()&&this.stopDrag(),Um._dragElements.delete(this._id),Um._dragElements.forEach((e,t)=>{this.isAncestorOf(e.node)&&Um._dragElements.delete(t)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(fh),this._clearSelfAndDescendantCache(dh),this._clearSelfAndDescendantCache(xh),this._clearSelfAndDescendantCache(wh),this._clearSelfAndDescendantCache(gh)}_remove(){let e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null),this._clearCaches()}destroy(){return this._fire(`destroy`,{target:this}),Xm(this),this.remove(),this.clearCache(),this}getAttr(e){let t=`get`+W._capitalize(e);return W._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!==mh&&(n=vh+W._capitalize(t),W._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(gh,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(wh,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){return e?this._isVisible(e)&&this._isListening(e):this.isListening()&&this.isVisible()}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!==yh&&(r=r.concat(o.children)),o._id===t._id&&(a=i);r.length>0&&r[0].getDepth()<=e&&s(r)}let c=this.getStage();return t.nodeType!==Ch&&c&&s(c.children),n}getDepth(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}_batchTransformChanges(e){if(this._batchingTransformChange){e();return}this._batchingTransformChange=!0;try{e()}finally{this._batchingTransformChange=!1,this._needClearTransformCache&&(this._needClearTransformCache=!1,this._clearCache(Sh),this._clearSelfAndDescendantCache(fh))}}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=this.getAbsoluteTransform(e).getMatrix(),n=new em,r=this.offset();return n.m=t.slice(),n.translate(r.x,r.y),n.getTranslation()}setAbsolutePosition(e){let{x:t,y:n,...r}=this._clearTransform();this.attrs.x=t,this.attrs.y=n,this._clearCache(Sh);let i=this._getAbsoluteTransform().copy(),a=i.isInvertible();i.invert(),i.translate(e.x,e.y);let{x:o,y:s}=i.getTranslation();return this._setTransform(r),a?this.setPosition({x:this.attrs.x+o,y:this.attrs.y+s}):W.warn(`Cannot set the absolute position: the absolute transform is not invertible (an ancestor has a zero scale).`),this._clearCache(Sh),this._clearSelfAndDescendantCache(fh),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}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return W.warn(`Node has no parent. moveToTop function is ignored.`),!1;let e=this.index;return e<this.parent.children.length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return W.warn(`Node has no parent. moveUp function is ignored.`),!1;let e=this.index;return e<this.parent.children.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 W.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 W.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 W.warn(`Node has no parent. zIndex parameter is ignored.`),this;(e<0||e>=this.parent.children.length)&&W.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(dh,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={attrs:{},className:this.getClassName()};for(t in e)n=e[t],r=W.isObject(n)&&!W._isPlainObject(n)&&!W._isArray(n),!r&&(this[`get`+W._capitalize(t)]?._def!==n||t===`brightness`||t===`threshold`)&&(i.attrs[t]=t===`filters`&&W._isArray(n)?n.filter(e=>typeof e==`string`):W.isObject(n)?W._prepareToStringify(n):n);return i}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],W.isValidSelector(i)||(W.warn(`Selector "`+i+`" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".`),W.warn(`If you have a custom shape with such className, please change it to start with upper letter like "Triangle".`),W.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(xh,this._getStage)}_getStage(){let e=this.getParent();return e?e.getStage():null}fire(e,t,n){return t||={},t.target=t.target||this,n?this._fireAndBubble(e,t):this._fire(e,t),this}getAbsoluteTransform(e){return e||this._hasCachedAncestor()?this._getAbsoluteTransform(e):this._getCache(fh,this._getCachedAbsoluteTransform)}_hasCachedAncestor(){let e=this.parent;for(;e;){if(e.isCached())return!0;e=e.parent}return!1}_getAbsoluteTransform(e){let t=new em;return this===e?t:(this.parent&&this.parent!==e&&this.parent.getAbsoluteTransform(e).copyInto(t),this._multiplyOwnTransform(t))}_getCachedAbsoluteTransform(){let e=this._cache[fh]||new em;return this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset(),this._multiplyOwnTransform(e),e.dirty=!1,e}_multiplyOwnTransform(e){let t=this.transformsEnabled();if(t===`all`)e.multiply(this.getTransform());else if(t===`position`){let t=this.attrs.x||0,n=this.attrs.y||0,r=this.attrs.offsetX||0,i=this.attrs.offsetY||0;e.translate(t-r,n-i)}return e}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(Sh,this._getTransform)}_getTransform(){let e=this._cache[Sh]||new em;e.reset();let t=this.x(),n=this.y(),r=Yp.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=W.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(hh)<0&&(s.eventListeners[n]||(s.eventListeners[n]=[]),s.eventListeners[n].push(o));return s}_toKonvaCanvas(e){e||={};let t=e.x===void 0||e.y===void 0||!e.width||!e.height?this.getClientRect():{x:0,y:0,width:0,height:0};isFinite(t.x+t.y+t.width+t.height)||W.error(`Cannot find the bounds of the node to export, its client rect is ${t.x}, ${t.y}, ${t.width}x${t.height}. Check its position, size and points.`);let 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 Vm({width:e.width||Math.max(0,Math.ceil(t.x+t.width-r))||(n?n.width():0),height:e.height||Math.max(0,Math.ceil(t.y+t.height-i))||(n?n.height():0),pixelRatio:a}),s=o.getContext();return e.imageSmoothingEnabled===!1&&(s._context.imageSmoothingEnabled=!1),s.save(),(r||i)&&s.translate(-1*r,-1*i),this.drawScene(o),s.restore(),o._releaseIsolationCanvas(),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{callback:r,...i}=e||{};W._urlToImage(this.toDataURL(i),function(e){t(e),r?.(e)},n)}catch(e){n(e)}})}toBlob(e){return new Promise((t,n)=>{try{this.toCanvas(e).toBlob(r=>{var i;if(!r){n(Error(`Konva: toBlob() failed, the canvas was not encoded`));return}t(r),(i=e?.callback)==null||i.call(e,r)},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():Yp.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+ph,{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[vh+W._capitalize(e)];return W._isFunction(n)?n.call(this,t):this._setAttr(e,t),this}_requestDraw(){Yp.autoDrawEnabled&&(this.getLayer()||this.getStage())?.batchDraw()}_setAttr(e,t){let n=this.attrs[e];(n!==t||W.isObject(t))&&(t==null?delete this.attrs[e]:this.attrs[e]=t,this._attrsVersion!==void 0&&this._attrsVersion++,this._shouldFireChangeEvents&&this._fireChangeEvent(e,n,t),this._requestDraw())}_fireAndBubble(e,t,n){t&&this.nodeType===yh&&(t.target=this);let r=_h.indexOf(e)!==-1;if(!(r&&(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||this.nodeType===`Stage`&&!n))){this._fire(e,t);let i=r&&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 n=Object.getPrototypeOf(this),r=e.protoListenerMap.get(n);r||(r={},e.protoListenerMap.set(n,r));let i=r[t];if(i===void 0){i=[];let e=new Set,n=Object.getPrototypeOf(this);for(;n;){let r=n.eventListeners?.[t]??[];for(let t=0;t<r.length;t++){let n=r[t];e.has(n)||(e.add(n),i.push(n))}n=Object.getPrototypeOf(n)}r[t]=i}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,a=e?.evt?.type?W._getEventType(e.evt.type):n._pointerEventType,o=a!==`pointer`;Um._dragElements.set(this._id,{node:this,startPointerPos:i,offset:{x:i.x-r.x,y:i.y-r.y},dragStatus:`ready`,pointerId:o?t??(`id`in i?i.id:void 0):void 0,pointerEventType:o?a:void 0,startEvent:e})}startDrag(e,t=!0){var n;Um._dragElements.has(this._id)||this._createDragElement(e);let r=Um._dragElements.get(this._id);r&&(r.dragStatus=`dragging`,(n=this.getStage())==null||n._cancelClick(r.pointerId,r.pointerEventType),this.fire(`dragstart`,{type:`dragstart`,target:this,evt:r.startEvent&&r.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);if(!t)W.warn(`dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.`);else if(!W._isNumber(t.x)||!W._isNumber(t.y)){W.warn(`dragBoundFunc returned a position with a non-finite x or y (${t.x}, ${t.y}). The node was not moved.`);return}else r=t}let a=t.lastPos;(!a||a.x!==r.x||a.y!==r.y)&&(this.setAbsolutePosition(r),this._requestDraw()),t.lastPos=r}stopDrag(e){let t=Um._dragElements.get(this._id);t&&(t.dragStatus=`stopped`,Um._endDragBefore(e,void 0,t),Um._endDragAfter(e,t))}setDraggable(e){this._setAttr(`draggable`,e),this._dragChange()}isDragging(){let e=Um._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||Yp.dragButtons.indexOf(e.evt.button)>=0)||Um._dragElements.has(this._id))return;let t=!1;Um._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=Um._dragElements.get(this._id),t=e&&e.dragStatus===`dragging`,n=e&&e.dragStatus===`ready`;t?this.stopDrag():n&&Um._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 W.haveIntersection(n,this.getClientRect())}static create(e,t){return W._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;if(n&&(t.attrs.container=n),!Yp[r]){let e=i?`Group`:`Shape`;W.warn(`Can not find a node with class name "`+r+`". Fallback to "${e}".`),r=e}let c=Yp[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}};Dh._absTransformCascadeDepth=0,Dh._pendingAfterCascade=[],Dh.protoListenerMap=new WeakMap,Dh.prototype.nodeType=`Node`,Dh.prototype._attrsAffectingSize=[],Dh.prototype.on(Th,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(Sh),this._clearSelfAndDescendantCache(fh)}),Dh.prototype.on(`visibleChange.konva`,function(){this._clearSelfAndDescendantCache(wh)}),Dh.prototype.on(`listeningChange.konva`,function(){this._clearSelfAndDescendantCache(gh);for(let e=this.getParent();e;e=e.getParent()){let t=e._getCanvasCache();t?.hit&&(W.releaseCanvas(t.hit._canvas),t.hit=null)}}),Dh.prototype.on(`opacityChange.konva`,function(){this._clearSelfAndDescendantCache(dh)});var Oh=G.addGetterSetter;Oh(Dh,`zIndex`),Oh(Dh,`absolutePosition`),Oh(Dh,`position`),Oh(Dh,`x`,0,eh()),Oh(Dh,`y`,0,eh()),Oh(Dh,`globalCompositeOperation`,`source-over`,rh()),Oh(Dh,`opacity`,1,eh()),Oh(Dh,`name`,``,rh()),Oh(Dh,`id`,``,rh()),Oh(Dh,`rotation`,0,eh()),G.addComponentsGetterSetter(Dh,`scale`,[`x`,`y`]),Oh(Dh,`scaleX`,1,eh()),Oh(Dh,`scaleY`,1,eh()),G.addComponentsGetterSetter(Dh,`skew`,[`x`,`y`]),Oh(Dh,`skewX`,0,eh()),Oh(Dh,`skewY`,0,eh()),G.addComponentsGetterSetter(Dh,`offset`,[`x`,`y`]),Oh(Dh,`offsetX`,0,eh()),Oh(Dh,`offsetY`,0,eh()),Oh(Dh,`dragDistance`,void 0,eh()),Oh(Dh,`width`,0,eh()),Oh(Dh,`height`,0,eh()),Oh(Dh,`listening`,!0,oh()),Oh(Dh,`preventDefault`,!0,oh()),Oh(Dh,`filters`,void 0,function(e){return this._filterUpToDate=!1,e}),Oh(Dh,`visible`,!0,oh()),Oh(Dh,`transformsEnabled`,`all`,rh()),Oh(Dh,`size`),Oh(Dh,`dragBoundFunc`),Oh(Dh,`draggable`,!1,oh()),G.backCompat(Dh,{rotateDeg:`rotate`,setRotationDeg:`setRotation`,getRotationDeg:`getRotation`});var kh=class extends Dh{constructor(){super(...arguments),this.children=[]}getChildren(e){let t=this.children||[];return e?t.filter(e):t.slice()}hasChildren(){return this.children.length>0}removeChildren(){return this.children.forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.children.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.children.length,t.parent=this,t._clearCaches(),this.children.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;for(let n of this.children)if(t=e(n),t||n.hasChildren()&&(t=n._descendants(e),t))return!0;return!1}toObject(){let e=Dh.prototype.toObject.call(this);return e.children=[],this.children.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=Dh.prototype.clone.call(this,e);return this.children.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===void 0||e===`absoluteTransform`;n&&Dh._absTransformCascadeDepth++;try{if(super._clearSelfAndDescendantCache(e),e===`absoluteTransform`&&this.isCached())return;(t=this.children)==null||t.forEach(function(t){t._clearSelfAndDescendantCache(e)})}finally{if(n&&--Dh._absTransformCascadeDepth===0){let e=Dh._pendingAfterCascade;if(e.length){Dh._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){let n=this.getLayer(),r=e||n&&n.getCanvas(),i=r&&r.getContext(),a=this._getCanvasCache(),o=a&&a.scene,s=t===this;if(!(t?this._isVisible(t):this.isVisible())&&!s)return this;if(o){i.save();let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(i),i.restore()}else this._drawChildren(`drawScene`,r,t);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._getCachedHitCanvas(t);if(a){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,a),i.restore()}else this._drawChildren(`drawHit`,r,t);return this}_drawChildren(e,t,n){let r=t&&t.getContext(),i=this.clipWidth(),a=this.clipHeight(),o=this.clipFunc(),s=typeof i==`number`&&typeof a==`number`||o,c=n===this;if(s){r.save();let e=this.getAbsoluteTransform(n),t=e.getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),r.beginPath();let s;if(o)s=o.call(this,r,this);else{let e=this.clipX(),t=this.clipY();r.rect(e||0,t||0,i,a)}r.clip.apply(r,s),t=e.copy().invert().getMatrix(),r.transform(t[0],t[1],t[2],t[3],t[4],t[5])}let l=!c&&this.globalCompositeOperation()!==`source-over`&&e===`drawScene`;l&&(r.save(),r._applyGlobalCompositeOperation(this));try{this._drawChildNodes(e,t,n)}finally{l&&r.restore(),s&&r.restore()}}_drawChildNodes(e,t,n){var r;(r=this.children)==null||r.forEach(function(r){r[e](t,n)})}getClientRect(e={}){var t;let n=this._getCachedSceneRect(e);if(n)return n;let r=e.skipTransform,i=e.relativeTo,[a,o,s,c]=this.getAbsoluteTransform().getMatrix(),l=!r&&(e._forDrawing||a*c-o*s===0),u,d,f,p,m={x:1/0,y:1/0,width:0,height:0},h=this;return(t=this.children)==null||t.forEach(function(t){if(!t.visible())return;let n=t.getClientRect({relativeTo:l?i:h,_forDrawing:e._forDrawing,skipShadow:e.skipShadow,skipStroke:e.skipStroke});n.width===0&&n.height===0||!isFinite(n.x+n.y+n.width+n.height)||(u===void 0?(u=n.x,d=n.y,f=n.x+n.width,p=n.y+n.height):(u=Math.min(u,n.x),d=Math.min(d,n.y),f=Math.max(f,n.x+n.width),p=Math.max(p,n.y+n.height)))}),m=u===void 0?{x:0,y:0,width:0,height:0}:{x:u,y:d,width:f-u,height:p-d},!r&&!l?this._transformedRect(m,i):m}};G.addComponentsGetterSetter(kh,`clip`,[`x`,`y`,`width`,`height`]),G.addGetterSetter(kh,`clipX`,void 0,eh()),G.addGetterSetter(kh,`clipY`,void 0,eh()),G.addGetterSetter(kh,`clipWidth`,void 0,eh()),G.addGetterSetter(kh,`clipHeight`,void 0,eh()),G.addGetterSetter(kh,`clipFunc`);var Ah=`Stage`,jh=`string`,Mh=`px`,Nh=`mouseout`,Ph=`mouseleave`,Fh=`mouseover`,Ih=`mouseenter`,Lh=`mousemove`,Rh=`mousedown`,zh=`mouseup`,Bh=`pointermove`,Vh=`pointerdown`,Hh=`pointerup`,Uh=`pointercancel`,Wh=`lostpointercapture`,Gh=`pointerout`,Kh=`pointerleave`,qh=`pointerover`,Jh=`pointerenter`,Yh=`contextmenu`,Xh=`touchstart`,Zh=`touchend`,Qh=`touchmove`,$h=`touchcancel`,eg=`wheel`,ree=5,iee=[[Ih,`_pointerenter`],[Rh,`_pointerdown`],[Lh,`_pointermove`],[zh,`_pointerup`],[Ph,`_pointerleave`],[Xh,`_pointerdown`],[Qh,`_pointermove`],[Zh,`_pointerup`],[$h,`_pointercancel`],[Fh,`_pointerover`],[eg,`_wheel`],[Yh,`_contextmenu`],[Vh,`_pointerdown`],[Bh,`_pointermove`],[Hh,`_pointerup`],[Uh,`_pointercancel`],[Kh,`_pointerleave`],[Wh,`_lostpointercapture`]],tg={mouse:{[Gh]:Nh,[Kh]:Ph,[qh]:Fh,[Jh]:Ih,[Bh]:Lh,[Vh]:Rh,[Hh]:zh,[Uh]:`mousecancel`,pointerclick:`click`,pointerdblclick:`dblclick`},touch:{[Gh]:`touchout`,[Kh]:`touchleave`,[qh]:`touchover`,[Jh]:`touchenter`,[Bh]:Qh,[Vh]:Xh,[Hh]:Zh,[Uh]:$h,pointerclick:`tap`,pointerdblclick:`dbltap`},pointer:{[Gh]:Gh,[Kh]:Kh,[qh]:qh,[Jh]:Jh,[Bh]:Bh,[Vh]:Vh,[Hh]:Hh,[Uh]:Uh,pointerclick:`pointerclick`,pointerdblclick:`pointerdblclick`}},ng=e=>{let t=W._getEventType(e);if(t===`pointer`)return Yp.pointerEventsEnabled&&tg.pointer;if(t===`touch`)return tg.touch;if(t===`mouse`)return tg.mouse};function rg(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&W.warn(`Stage does not support clipping. Please use clip for Layers or Groups.`),e}var aee=`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);`,ig=[],ag=new WeakSet,og=e=>{e&&!ag.has(e)&&(ag.add(e),Um._listenToWindow(e),e.document.addEventListener(`visibilitychange`,()=>{ig.forEach(e=>{e.batchDraw()})}))},sg=class extends kh{constructor(e){super(rg(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._pointerStates=new Map,this._lastClicks={},this._buildDOM(),this._bindContentEvents(),ig.push(this),this.on(`widthChange.konva heightChange.konva`,this._resizeDOM),this.on(`visibleChange.konva`,this._checkVisibility),this.on(`clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva`,()=>{rg(this.attrs)}),this._checkVisibility()}_validateAdd(e){let t=e.getType()===`Layer`,n=e.getType()===`FastLayer`;t||n||W.throw(`You may only add layers to the stage.`)}_checkVisibility(){if(!this.content)return;let e=this.visible()?``:`none`;this.content.style.display=e}_getOwnerWindow(){return(this.content||this.container())?.ownerDocument?.defaultView||(Yp.isBrowser?window:null)}setContainer(e){if(typeof e===jh){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),og(this._getOwnerWindow())),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`),kh.prototype.clone.call(this,e)}destroy(){var e;super.destroy(),this._pointerStates.clear(),this._lastClicks={};let t=this.content;(e=t?.parentNode)==null||e.removeChild(t);let n=ig.indexOf(this);return n>-1&&ig.splice(n,1),W.releaseCanvas(this.bufferHitCanvas._canvas),this}getPointerPosition(){let e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(W.warn(aee),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 Vm({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()),W.releaseCanvas(r._canvas)}),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+Mh,this.content.style.height=t+Mh),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>ree&&W.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(),Yp.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return Jm(e,this)}setPointerCapture(e){Ym(e,this)}releaseCapture(e){Zm(e,this)}getLayers(){return this.getChildren()}_bindContentEvents(){Yp.isBrowser&&iee.forEach(([e,t])=>{this.content.addEventListener(e,e=>{this._batchEvents(()=>this[t](e))},{passive:!1})})}_batchEvents(e){W._batchEvents(this.eventBatchFunc(),e)}_pointerenter(e){this.setPointersPositions(e);let t=ng(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);let t=ng(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_pointerEventsEnabled(){if(Yp.hitOnDragEnabled)return!0;for(let{node:e,dragStatus:t}of Um._dragElements.values())if(t===`dragging`&&e.getStage()===this)return!1;return!this.getLayers().some(e=>Yp.Transformer?._isLayerTransforming(e))}_cancelClick(e,t){let n=t?[t]:[`mouse`,`touch`,`pointer`];for(let t of n){let n=this._pointerStates.get(`${t}:${e}`);n&&(n.clickStartShape=void 0,n.relatedPointer&&(n.relatedPointer.clickStartShape=void 0))}}_pointerleave(e){let t=ng(e.type),n=W._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r=this._changedPointerPositions[0]?.id,i=`${n}:${r}`,a=this._pointerStates.get(i),o=(a?.targetShape)?.getStage()===this?a.targetShape:void 0,s=this._pointerEventsEnabled()||e.pointerType===`touch`&&!a?.downPosition;s&&(a?.clickStartShape===void 0?this._pointerStates.delete(i):a.targetShape=void 0),o&&s?(o._fireAndBubble(t.pointerout,{evt:e,pointerId:r}),o._fireAndBubble(t.pointerleave,{evt:e,pointerId:r}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this})):s&&(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=[],this._changedPointerPositions=[],this._pointerEventType=void 0}_pointerdown(e){let t=ng(e.type),n=W._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(i=>{let a=this.getIntersection(i),o=`${n}:${i.id}`,s={targetShape:this._pointerStates.get(o)?.targetShape,clickStartShape:a&&a.isListening()?a:null,lastClick:this._lastClicks[n],downPosition:i,pointerType:e.pointerType};if(this._pointerStates.delete(o),n!==`pointer`){for(let[e,t]of[...this._pointerStates].reverse())if(!(!e.startsWith(`pointer:`)||!t.downPosition||n===`touch`&&t.relatedPointer)&&(n===`mouse`?t.pointerType!==`touch`:t.pointerType===`touch`&&t.downPosition.x===i.x&&t.downPosition.y===i.y)){s.relatedPointer=t,t.relatedPointer=s,t.clickStartShape===void 0&&(s.clickStartShape=void 0);break}}this._pointerStates.set(o,s);for(let e of Um._dragElements.values())e.dragStatus===`dragging`&&(e.pointerId===void 0||e.pointerEventType===n&&e.pointerId===i.id||e.pointerEventType===`mouse`&&n===`pointer`&&s.pointerType!==`touch`)&&e.node.getStage()===this&&(e.pointerId===void 0&&n!==`pointer`&&(e.pointerId=i.id,e.pointerEventType=n),this._cancelClick(i.id,n));if(!a||!a.isListening())return;Yp.capturePointerEventsEnabled&&a.setPointerCapture(i.id),a._fireAndBubble(t.pointerdown,{evt:e,pointerId:i.id}),r=!0;let c=e.type.indexOf(`touch`)>=0;a.preventDefault()&&e.cancelable&&c&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointermove(e){let t=ng(e.type),n=W._getEventType(e.type);if(!t)return;let r=e.type.indexOf(`touch`)>=0||e.pointerType===`touch`;if(e.cancelable&&r){for(let{node:t,dragStatus:n}of Um._dragElements.values())if(n===`dragging`&&t.getStage()===this&&t.preventDefault()){e.preventDefault();break}}if(this.setPointersPositions(e),!this._pointerEventsEnabled())return;let i={},a=!1;this._changedPointerPositions.forEach(r=>{let o=`${n}:${r.id}`,s=this._pointerStates.get(o);s||(s={},this._pointerStates.set(o,s));let c=Km(r.id)||this.getIntersection(r),l=s.targetShape===c||s.targetShape?.getStage()===this?s.targetShape:void 0,u=r.id,d={evt:e,pointerId:u},f=l!==c;s.targetShape=c&&c.isListening()?c:void 0,f&&l&&(l._fireAndBubble(t.pointerout,{...d},c),l._fireAndBubble(t.pointerleave,{...d},c)),c&&c.isListening()?(a=!0,f&&(c._fireAndBubble(t.pointerover,{...d},l),c._fireAndBubble(t.pointerenter,{...d},l)),i[c._id]||(i[c._id]=!0,c._fireAndBubble(t.pointermove,{...d}))):l&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:u})}),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){let t=ng(e.type),n=W._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r={},i=!1;this._changedPointerPositions.forEach(a=>{let o=`${n}:${a.id}`,s=this._pointerStates.get(o),c=s?.clickStartShape!==void 0,l=s?.clickStartShape;s?.targetShape&&n!==`touch`?this._pointerStates.set(o,{targetShape:s.targetShape}):this._pointerStates.delete(o);let u=Km(a.id)||this.getIntersection(a),d=u&&r[u._id];u&&(u.releaseCapture(a.id),r[u._id]=!0);let f=a.id,p={evt:e,pointerId:f},m=u&&u.isListening()?u:null,h=this._lastClicks[n],g=c&&(!m||l===m),_=g&&h&&s?.lastClick===h&&h.shape===m&&Date.now()-h.time<Yp.dblClickWindow;g&&(this._lastClicks[n]=_?void 0:{shape:m,time:Date.now()}),u&&u.isListening()?(i=!0,d||u._fireAndBubble(t.pointerup,{...p}),c&&l===u&&(u._fireAndBubble(t.pointerclick,{...p}),_&&u._fireAndBubble(t.pointerdblclick,{...p}))):(i||=(this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),!0),c&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:f}),_&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:f})),n===`touch`&&(s?.targetShape)?.getStage()===this&&(s.targetShape._fireAndBubble(t.pointerout,{...p}),s.targetShape._fireAndBubble(t.pointerleave,{...p}))}),i||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),e.cancelable&&n!==`touch`&&n!==`pointer`&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(Yh,{evt:e}):this._fire(Yh,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(eg,{evt:e}):this._fire(eg,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);let t=ng(e.type);this._changedPointerPositions.forEach(n=>{let r=W._getEventType(e.type),i=`${r}:${n.id}`;this._cancelClick(n.id,r);let a=this._pointerStates.get(i)?.targetShape;a&&r!==`touch`?this._pointerStates.set(i,{targetShape:a}):this._pointerStates.delete(i);let o=Km(n.id)||this.getIntersection(n),s={evt:e,pointerId:n.id};o?(t&&o._fireAndBubble(t.pointercancel,{...s}),o._fireAndBubble(Hh,{...s})):t&&this._fire(t.pointercancel,{...s,target:this,currentTarget:this}),Zm(n.id),t&&r===`touch`&&a?.getStage()===this&&(a._fireAndBubble(t.pointerout,{...s}),a._fireAndBubble(t.pointerleave,{...s}))})}_lostpointercapture(e){Km(e.pointerId,this)&&Zm(e.pointerId)}setPointersPositions(e){let t=this._getContentPosition(),n=null,r=null;e||=window.event,e.touches===void 0?(this._pointerEventType=e.pointerId===void 0?`mouse`:`pointer`,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:W._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:W._getFirstPointerId(e)}]):(this._pointerEventType=`touch`,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){W.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.bufferHitCanvas=new Hm({pixelRatio:1,width:0,height:0}),!Yp.isBrowser)return;let e=this.container();if(!e)throw`Stage has no container. A container is required.`;e.innerHTML=``,this.content=e.ownerDocument.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),og(this._getOwnerWindow()),this._resizeDOM()}cache(){return W.warn(`Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.`),this}clearCache(){return this}batchDraw(){var e;return(e=this.children)==null||e.forEach(function(e){e.batchDraw()}),this}};sg.prototype.nodeType=Ah,Zp(sg),G.addGetterSetter(sg,`container`),G.addGetterSetter(sg,`eventBatchFunc`);var oee=`hasShadow`,see=`hasFill`,cee=`hasStroke`,lee=`shadowRGBA`,uee=`patternImage`,dee=`linearGradient`,fee=`radialGradient`,cg;function lg(){return cg||(cg=W.createCanvasElement().getContext(`2d`),cg)}var ug={};function pee(e){let t=this.attrs.fillRule;t?e.fill(t):e.fill()}function mee(e){e.stroke()}function hee(){this._clearCache(oee)}function gee(){this._clearCache(see)}function _ee(){this._clearCache(cee)}function vee(){this._clearCache(lee)}function yee(){this._clearCache(uee)}function bee(){this._clearCache(dee)}function xee(){this._clearCache(fee)}var dg=class e extends Dh{constructor(e){super(e);let t,n=0;for(;t=W.getHitColor(),!t||t in ug;)if(n++,n>=1e4){W.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=W.getRandomColor();break}this.colorKey=t,ug[t]=this}getContext(){return W.warn(`shape.getContext() method is deprecated. Please do not use it.`),this.getLayer().getContext()}getCanvas(){return W.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(oee,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(uee,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){let e=lg().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||`repeat`);if(e&&e.setTransform){let t=new em;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(Yp.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(dee,this.__getLinearGradient)}__getLinearGradient(){let e=this.fillLinearGradientColorStops();if(e){let t=lg(),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(fee,this.__getRadialGradient)}__getRadialGradient(){let e=this.fillRadialGradientColorStops();if(e){let t=lg(),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(lee,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;let e=W.colorToRGBA(this.shadowColor());if(e)return`rgba(`+e.r+`,`+e.g+`,`+e.b+`,`+e.a*(this.shadowOpacity()||1)+`)`}hasFill(){return this._getCache(see,this._hasFill)}_hasFill(){return this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())}hasStroke(){return this._getCache(cee,this._hasStroke)}_hasStroke(){return 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.setSizeIfChanged(t.width(),t.height()),n.getContext().clear(),this.drawHit(n),n.context.getImageData(Math.floor(e.x),Math.floor(e.y),1,1).data[3]>0}destroy(){return Dh.prototype.destroy.call(this),delete ug[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(!(this.attrs.perfectDrawEnabled??!0))return!1;let n=e||this.hasFill(),r=this.hasStroke(),i=!this._isUnderCache&&t!==1;if(n&&r&&i)return!0;let a=this.hasShadow(),o=this.shadowForStrokeEnabled();return!!(n&&r&&a&&o)}setStrokeHitEnabled(e){W.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.attrs.selfRectFunc;if(e)return{...e.call(this,this)};let t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}_getSelfRectForDrawing(){return this.getSelfRect()}getClientRect(e={}){let t=this._getCachedSceneRect(e);if(t)return t;let n=e.skipTransform,r=e.relativeTo,i=e._forDrawing,a=i?this.strokeScaleEnabled()?new em()._getTransformedRect(this._getSelfRectForDrawing()):this._transformedRect(this._getSelfRectForDrawing(),r):this.getSelfRect(),o=!e.skipStroke&&this.hasStroke()?i?this._getStrokePadding()*2:this.strokeWidth():0,s=o,c=o,l;if(!i&&o&&!this.strokeScaleEnabled()){let e=this;for(;e&&!e.isCached()&&!e._isUnderCache;)e=e.parent;let[t,i,a,o]=this.getAbsoluteTransform(e).getMatrix(),u=Math.abs(t*o-i*a);if(u)s*=Math.hypot(a,o)/u,c*=Math.hypot(t,i)/u;else if(!n&&(s=c=0,l=e?e.getAbsoluteTransform().copy():new em,r)){let e=r.getAbsoluteTransform(),[t,n,i,a]=e.getMatrix();l=t*a-n*i?e.copy().invert().multiply(l):new em}}let u={x:a.x-s/2,y:a.y-c/2,width:a.width+s,height:a.height+c};if(i&&this.strokeScaleEnabled()&&(u=this._transformedRect(u,r)),!e.skipShadow&&this.hasShadow()){let e=i?this.getAbsoluteScale():{x:1,y:1},t=this.shadowOffsetX()*e.x,n=this.shadowOffsetY()*e.y,r=this.shadowBlur()*(i?2*Math.min(Math.abs(e.x),Math.abs(e.y)):1);u.x+=Math.min(0,t)-r,u.y+=Math.min(0,n)-r,u.width+=Math.abs(t)+r*2,u.height+=Math.abs(n)+r*2}if(i)return u;if(!n){let e=this._transformedRect(u,r);if(l){let[t,n,r,i]=l.getMatrix(),a=o*Math.hypot(t,r)/2,s=o*Math.hypot(n,i)/2;e.x-=a,e.y-=s,e.width+=a*2,e.height+=s*2}return e}return u}_getStrokePadding(e=this.miterLimit()||10){return this.attrs.sceneFunc&&(e=this.miterLimit()||10),Math.abs(this.strokeWidth())/2*Math.max(this.lineCap()===`square`?Math.SQRT2:1,(this.lineJoin()||`miter`)===`miter`?e:1)}drawScene(t,n){let r=this.getLayer(),i=t||r.getCanvas(),a=i.getContext(),o=this._getCanvasCache(),s=this.getSceneFunc(),c=this.hasShadow(),l=n===this;if(!(n?this._isVisible(n):this.isVisible())&&!l)return this;if(o){a.save();let e=this.getAbsoluteTransform(n).getMatrix();return a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(a),a.restore(),this}if(!s)return this;a.save();try{if(i.width&&i.height&&this._useBufferCanvas(void 0,a._getOpacity(this))){let t=!!a._opacityRoot||!!this.attrs.selfRectFunc&&this.getSelfRect===e.prototype.getSelfRect||!this.attrs.sceneFunc&&!this.attrs.charRenderFunc&&Xp.has(this.constructor),r=i._prepareIsolationCanvas(t?this.getClientRect({_forDrawing:!0,relativeTo:n,skipShadow:!0}):void 0),o=r.getContext();o.save(),o._applyLineJoin(this),o._applyMiterLimit(this);let u=this.getAbsoluteTransform(n).getMatrix();o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),s.call(this,o,this),o.restore(),c&&a._applyShadow(this),l||(a._applyOpacity(this),a._applyGlobalCompositeOperation(this)),a._drawDeviceBuffer(r)}else{if(a._applyLineJoin(this),a._applyMiterLimit(this),!l){let e=this.getAbsoluteTransform(n).getMatrix();a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),a._applyOpacity(this),a._applyGlobalCompositeOperation(this)}c&&a._applyShadow(this),s.call(this,a,this)}}catch(e){throw i._releaseIsolationCanvas(),e}finally{a.restore()}return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let n=this.getLayer(),r=e||n.hitCanvas,i=r&&r.getContext(),a=this.hitFunc()||this.sceneFunc(),o=this._getCachedHitCanvas(t);if(this.colorKey||W.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()`),o){i.save();let e=this.getAbsoluteTransform(t).getMatrix();return i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(i,o),i.restore(),this}if(!a)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5])}try{a.call(this,i,this)}finally{i.restore()}return this}drawHitFromCache(e=0){let t=this._getCachedSceneCanvas(),n=this._getCachedHitCanvas(),r=n.getContext(),i=n.getWidth(),a=n.getHeight();r.clear(),r.drawImage(t._canvas,0,0,i/n.pixelRatio,a/n.pixelRatio);try{let t=r.getImageData(0,0,i,a),n=t.data,o=n.length,s=W._hexToRgb(this.colorKey);for(let t=0;t<o;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;r.putImageData(t,0,0)}catch(e){W.error(`Unable to draw hit graph from cached scene canvas. `+e.message)}return this}hasPointerCapture(e){return Jm(e,this)}setPointerCapture(e){Ym(e,this)}releaseCapture(e){Zm(e,this)}};dg.prototype._fillFunc=pee,dg.prototype._strokeFunc=mee,dg.prototype._fillFuncHit=pee,dg.prototype._strokeFuncHit=mee,dg.prototype._centroid=!1,dg.prototype.nodeType=`Shape`,Zp(dg),dg.prototype.on(`shadowColorChange.konva shadowBlurChange.konva shadowOffsetXChange.konva shadowOffsetYChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,hee),dg.prototype.on(`shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,vee),dg.prototype.on(`fillEnabledChange.konva fillChange.konva fillPatternImageChange.konva fillLinearGradientColorStopsChange.konva fillRadialGradientColorStopsChange.konva`,gee),dg.prototype.on(`strokeEnabledChange.konva strokeWidthChange.konva strokeChange.konva strokeLinearGradientColorStopsChange.konva`,_ee),dg.prototype.on(`fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva`,yee),dg.prototype.on(`fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva`,bee),dg.prototype.on(`fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva`,xee),G.addGetterSetter(dg,`stroke`,void 0,ih()),G.addGetterSetter(dg,`strokeWidth`,2,eh()),G.addGetterSetter(dg,`fillAfterStrokeEnabled`,!1),G.addGetterSetter(dg,`hitStrokeWidth`,`auto`,nh()),G.addGetterSetter(dg,`strokeHitEnabled`,!0,oh()),G.addGetterSetter(dg,`perfectDrawEnabled`,!0,oh()),G.addGetterSetter(dg,`shadowForStrokeEnabled`,!0,oh()),G.addGetterSetter(dg,`lineJoin`),G.addGetterSetter(dg,`lineCap`),G.addGetterSetter(dg,`miterLimit`),G.addGetterSetter(dg,`sceneFunc`),G.addGetterSetter(dg,`hitFunc`),G.addGetterSetter(dg,`selfRectFunc`),G.addGetterSetter(dg,`dash`),G.addGetterSetter(dg,`dashOffset`,0,eh()),G.addGetterSetter(dg,`shadowColor`,void 0,rh()),G.addGetterSetter(dg,`shadowBlur`,0,eh()),G.addGetterSetter(dg,`shadowOpacity`,1,eh()),G.addComponentsGetterSetter(dg,`shadowOffset`,[`x`,`y`]),G.addGetterSetter(dg,`shadowOffsetX`,0,eh()),G.addGetterSetter(dg,`shadowOffsetY`,0,eh()),G.addGetterSetter(dg,`fillPatternImage`),G.addGetterSetter(dg,`fill`,void 0,ih()),G.addGetterSetter(dg,`fillPatternX`,0,eh()),G.addGetterSetter(dg,`fillPatternY`,0,eh()),G.addGetterSetter(dg,`fillLinearGradientColorStops`),G.addGetterSetter(dg,`strokeLinearGradientColorStops`),G.addGetterSetter(dg,`fillRadialGradientStartRadius`,0),G.addGetterSetter(dg,`fillRadialGradientEndRadius`,0),G.addGetterSetter(dg,`fillRadialGradientColorStops`),G.addGetterSetter(dg,`fillPatternRepeat`,`repeat`),G.addGetterSetter(dg,`fillEnabled`,!0),G.addGetterSetter(dg,`strokeEnabled`,!0),G.addGetterSetter(dg,`shadowEnabled`,!0),G.addGetterSetter(dg,`dashEnabled`,!0),G.addGetterSetter(dg,`strokeScaleEnabled`,!0),G.addGetterSetter(dg,`fillPriority`,`color`),G.addComponentsGetterSetter(dg,`fillPatternOffset`,[`x`,`y`]),G.addGetterSetter(dg,`fillPatternOffsetX`,0,eh()),G.addGetterSetter(dg,`fillPatternOffsetY`,0,eh()),G.addComponentsGetterSetter(dg,`fillPatternScale`,[`x`,`y`]),G.addGetterSetter(dg,`fillPatternScaleX`,1,eh()),G.addGetterSetter(dg,`fillPatternScaleY`,1,eh()),G.addComponentsGetterSetter(dg,`fillLinearGradientStartPoint`,[`x`,`y`]),G.addComponentsGetterSetter(dg,`strokeLinearGradientStartPoint`,[`x`,`y`]),G.addGetterSetter(dg,`fillLinearGradientStartPointX`,0),G.addGetterSetter(dg,`strokeLinearGradientStartPointX`,0),G.addGetterSetter(dg,`fillLinearGradientStartPointY`,0),G.addGetterSetter(dg,`strokeLinearGradientStartPointY`,0),G.addComponentsGetterSetter(dg,`fillLinearGradientEndPoint`,[`x`,`y`]),G.addComponentsGetterSetter(dg,`strokeLinearGradientEndPoint`,[`x`,`y`]),G.addGetterSetter(dg,`fillLinearGradientEndPointX`,0),G.addGetterSetter(dg,`strokeLinearGradientEndPointX`,0),G.addGetterSetter(dg,`fillLinearGradientEndPointY`,0),G.addGetterSetter(dg,`strokeLinearGradientEndPointY`,0),G.addComponentsGetterSetter(dg,`fillRadialGradientStartPoint`,[`x`,`y`]),G.addGetterSetter(dg,`fillRadialGradientStartPointX`,0),G.addGetterSetter(dg,`fillRadialGradientStartPointY`,0),G.addComponentsGetterSetter(dg,`fillRadialGradientEndPoint`,[`x`,`y`]),G.addGetterSetter(dg,`fillRadialGradientEndPointX`,0),G.addGetterSetter(dg,`fillRadialGradientEndPointY`,0),G.addGetterSetter(dg,`fillPatternRotation`,0),G.addGetterSetter(dg,`fillRule`,void 0,rh()),G.backCompat(dg,{dashArray:`dash`,getDashArray:`getDash`,setDashArray:`setDash`,drawFunc:`sceneFunc`,getDrawFunc:`getSceneFunc`,setDrawFunc:`setSceneFunc`,drawHitFunc:`hitFunc`,getDrawHitFunc:`getHitFunc`,setDrawHitFunc:`setHitFunc`});var See=`beforeDraw`,Cee=`draw`,wee=10,fg=256;function pg(e,t){return e[t+3]>=128?ug[W.getHitColorKey(e[t],e[t+1],e[t+2])]:void 0}var mg=class extends kh{constructor(e){super(e),this.canvas=new Vm,this.hitCanvas=new Hm({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(){Dh.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(!Dh.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(Dh.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(Dh.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(){var e,t;super.remove();let n=this.getNativeCanvasElement(),r=this.getHitCanvas()._canvas;return(e=n.parentNode)==null||e.removeChild(n),(t=r.parentNode)==null||t.removeChild(r),this}getStage(){return this.parent}_setSize({width:e,height:t}){return this.canvas.setSize(e,t),this._syncHitCanvasSize(),this._setSmoothEnabled(),this}_syncHitCanvasSize(){let e=this.isListening();this.hitCanvas.setSizeIfChanged((e?this.getWidth():0)||0,(e?this.getHeight():0)||0)}_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&W.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,Dh.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(){W.warn(`Can not change width of layer. Use "stage.width(value)" function instead.`)}getHeight(){if(this.parent)return this.parent.height()}setHeight(){W.warn(`Can not change height of layer. Use "stage.height(value)" function instead.`)}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,W.requestAnimFrame(()=>{this._waitingForDraw=!1,this.draw()},this.getStage()?._getOwnerWindow())),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=this._getIntersection(e);if(t.shape)return t.shape;if(!t.antialiased)return null;let n=this.hitCanvas.pixelRatio,r=Math.floor(e.x*n),i=Math.floor(e.y*n),a=e=>this.hitCanvas.context.getImageData(r-e,i-e,e*2+1,e*2+1).data,o=wee,s=o*2+1,c=a(o),l=c[(o*s+o)*4+3];for(let e=1;e<=fg;e++){e>o&&(o=Math.min(fg,o*2),s=o*2+1,c=a(o));let t=0;for(let n=-e;n<=e;n++){let r=Math.abs(n)===e?1:e*2;for(let i=-e;i<=e;i+=r){let e=((n+o)*s+i+o)*4,r=pg(c,e);if(r)return r;t=Math.max(t,c[e+3])}}if(t<=l&&t!==255)return null;l=t}return null}_getIntersection(e){if(!this.hitCanvas.width||!this.hitCanvas.height)return{};let t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.floor(e.x*t),Math.floor(e.y*t),1,1).data,r=pg(n,0);return r?{shape:r}:n[3]>0?{antialiased:!0}:{}}drawScene(e,t){let n=this.getLayer(),r=e||n&&n.getCanvas();return this._fire(See,{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),kh.prototype.drawScene.call(this,r,t),r._trimIsolationCanvas(),this._fire(Cee,{node:this}),this}shouldDrawHit(e){if(!super.shouldDrawHit(e))return!1;if(e||Yp.hitOnDragEnabled)return!0;let t=!1;return Um._dragElements.forEach(e=>{e.dragStatus===`dragging`&&(e.node===this.getStage()||e.node.getLayer()===this)&&(t=!0)}),!t&&!Yp.Transformer?._isLayerTransforming(this)}drawHit(e,t){let n=this.getLayer(),r=e||n&&n.hitCanvas;return!e&&n&&(n._syncHitCanvasSize(),n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear()),kh.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){W.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening(e)}getHitGraphEnabled(e){return W.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 this.getCanvas()._releaseIsolationCanvas(),W.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};mg.prototype.nodeType=`Layer`,Zp(mg),G.addGetterSetter(mg,`imageSmoothingEnabled`,!0),G.addGetterSetter(mg,`clearBeforeDraw`,!0),G.addOverloadedGetterSetter(mg,`hitGraphEnabled`);var hg=class extends mg{constructor(e){super(e),this.listening(!1),W.warn(`Konva.FastLayer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.`)}};hg.prototype.nodeType=`FastLayer`,Zp(hg);var gg=class extends kh{_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&W.throw(`You may only add groups and shapes to groups.`)}_drawChildNodes(e,t,n){if(e!==`drawScene`||!this.isolated()||n===this)return super._drawChildNodes(e,t,n);if(!t.width||!t.height)return;let r=t.getContext(),i=t._prepareIsolationCanvas(this.getClientRect({_forDrawing:!0,relativeTo:n})),a=i.getContext();a._opacityRoot=this,r.save();try{super._drawChildNodes(e,i,n),r._applyOpacity(this),r._drawDeviceBuffer(i)}catch(e){throw t._releaseIsolationCanvas(),e}finally{r.restore(),a._opacityRoot=void 0}}};G.addGetterSetter(gg,`isolated`,!1,oh()),gg.prototype.nodeType=`Group`,Zp(gg);var _g=Jp.performance?.now?()=>Jp.performance.now():Date.now,vg=class e{constructor(t,n){this.id=e.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:_g(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(e){return this.layers=e?[].concat(e):[],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(){return e.animations.has(this)}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=_g(),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.add(e),this._handleAnimation()}static _removeAnimation(e){this.animations.delete(e)}static _runFrames(){let e=new Set;Array.from(this.animations).forEach(t=>{this.animations.has(t)&&(t._updateFrameObject(_g()),!(t.func&&t.func.call(t,t.frame)===!1)&&t.layers.forEach(t=>t&&e.add(t)))}),e.forEach(e=>e.batchDraw())}static _animationLoop(){let t=e;t.animations.size?(t._runFrames(),W.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,W.requestAnimFrame(this._animationLoop))}};vg.animations=new Set,vg.animIdCounter=0,vg.animRunning=!1;var Tee={node:1,duration:1,easing:1,onFinish:1,onUpdate:1,onReset:1,yoyo:1},Eee=1,yg=2,bg=3,xg=[`fill`,`stroke`,`shadowColor`],Dee=0;function Sg(e){return W.colorToRGBA(e)||W.throw(`can not tween the color "`+e+`", because it is not a valid color.`)}function Cg(e,t){return{r:t.r-e.r,g:t.g-e.g,b:t.b-e.b,a:t.a-e.a}}function wg(e,t,n){return`rgba(`+Math.round(e.r+t.r*n)+`,`+Math.round(e.g+t.g*n)+`,`+Math.round(e.b+t.b*n)+`,`+(e.a+t.a*n)+`)`}var Oee=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=yg,this._startTime=this.getTimer()-this._time,this.fire(`onPlay`),this.onEnterFrame()}reverse(){this.state=bg,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.fire(`onReverse`),this.onEnterFrame()}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===yg?this.setTime(e):this.state===bg&&this.setTime(this.duration-e)}pause(){this.state=Eee,this.fire(`onPause`)}getTimer(){return Date.now()}},Tg=class e{constructor(t){let n=this,r=t.node,i=r._id,a=t.easing||Eg.Linear,o=!!t.yoyo,s,c;s=t.duration===void 0?.3:t.duration===0?.001:t.duration,this.node=r,this._id=Dee++;let l=r.getLayer()||(r instanceof Yp.Stage?r.getLayers():null);for(c in l||W.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new vg(function(){n.tween.onEnterFrame()},l),this.tween=new Oee(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)Tee[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){if(W._isPlainObject(n)){for(let e in n)this._addAttr(t+W._capitalize(e),n[e]);return}let r=this.node,i=r._id,a,o,s,c,l=e.tweens[i][t];l!==void 0&&delete e.attrs[i][l][t];let u=r.getAttr(t);if(W._isArray(n)||W._isArray(u)){if(a=[],c=u,s=n,u=W._isArray(u)?u.slice():Array(n.length).fill(u||0),W._isArray(n)||(n=Array(u.length).fill(n)),o=Math.max(n.length,u.length),t===`points`&&n.length!==u.length&&(n.length>u.length?u=W._prepareArrayForTween(u,n,r.closed()):n=W._prepareArrayForTween(n,u,r.closed())),t.endsWith(`ColorStops`))for(let e=0;e<o;e++)if(e%2==0)a.push((n[e]||0)-(u[e]||0));else{let t=Sg(u[e]);u[e]=t,a.push(Cg(t,Sg(n[e])))}else for(let e=0;e<o;e++)a.push((n[e]||0)-(u[e]||0))}else xg.indexOf(t)===-1?a=n-u:(u=Sg(u),a=Cg(u,Sg(n)));e.attrs[i][this._id][t]={start:u,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,W._isArray(o)){if(c=[],u=Math.max(o.length,d.length),i.endsWith(`ColorStops`))for(l=0;l<u;l++)l%2==0?c.push((o[l]||0)+s[l]*t):c.push(wg(o[l],s[l],t));else for(l=0;l<u;l++)c.push((o[l]||0)+s[l]*t)}else c=xg.indexOf(i)===-1?o+s*t:wg(o,s,t);n.setAttr(i,c)}}_addListeners(){let t=`destroy.konva-tween${this._id}`,n=()=>this.destroy(),r=()=>{this.node.off(t).on(t,n),this.anim.start()};this.tween.onPlay=r,this.tween.onReverse=r,this.tween.onPause=()=>{this.node.off(t),this.anim.stop()};let i=(t,n)=>{let r=e.attrs[this.node._id]?.[this._id];if(r){for(let e in r)r[e][t]!==void 0&&this.node.setAttr(e,r[e][t]);n?.call(this)}};this.tween.onFinish=()=>i(`trueEnd`,this.onFinish),this.tween.onReset=()=>i(`trueStart`,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.attrs[t]?.[n],i=e.tweens[t];if(this.pause(),this.anim&&this.anim.stop(),r){if(i){for(let e in r)delete i[e];Object.keys(i).length===0&&delete e.tweens[t]}delete e.attrs[t][n],Object.keys(e.attrs[t]).length===0&&delete e.attrs[t]}}};Tg.attrs={},Tg.tweens={},Dh.prototype.to=function(e){let t=e.onFinish,n=new Tg({...e,node:this,onFinish(){n.destroy(),t&&t()}});return n.play(),n};var Eg={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-Eg.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?Eg.BounceEaseIn(e*2,0,n,r)*.5+t:Eg.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}},Dg=W._assign(Yp,{Util:W,Transform:em,Node:Dh,Container:kh,Stage:sg,stages:ig,Layer:mg,FastLayer:hg,Group:gg,DD:Um,Shape:dg,shapes:ug,Animation:vg,Tween:Tg,Easings:Eg,Context:Lm,Canvas:Bm}),Og=class extends dg{_sceneFunc(e){let t=Yp.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,Math.abs(this.outerRadius()),0,t,n),e.arc(0,0,Math.abs(this.innerRadius()),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.outerRadius())*2}getHeight(){return Math.abs(this.outerRadius())*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){let e=Math.abs(this.innerRadius()),t=Math.abs(this.outerRadius()),n=Math.min(e,t),r=Math.max(e,t),i=this.clockwise(),a=Yp.getAngle(this.angle());if(a%(Math.PI*2)==0)return a===0?{x:n,y:0,width:r-n,height:0}:{x:-r,y:-r,width:r*2,height:r*2};let o=Math.PI*2,s=i?-a:a,c=s>=o?o:(s%o+o)%o,l=Math.cos(Math.min(c,Math.PI)),u=Math.sin(Math.min(Math.max(Math.PI,c),3*Math.PI/2)),d=Math.sin(Math.min(c,Math.PI/2)),f=l*(l>0?n:r),p=1*r,m=u*(u>0?n:r),h=d*(d>0?r:n);return{x:f,y:i?-1*h:m,width:p-f,height:h-m}}};Og.prototype._centroid=!0,Og.prototype.className=`Arc`,Og.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`,`angle`,`clockwise`],Zp(Og,!0),G.addGetterSetter(Og,`innerRadius`,0,eh()),G.addGetterSetter(Og,`outerRadius`,0,eh()),G.addGetterSetter(Og,`angle`,0,eh()),G.addGetterSetter(Og,`clockwise`,!1,oh());var kg=[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],kee=[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],Ag=(e,t,n)=>{let r=n/2,i=0;for(let n=0;n<kg.length;n++){let a=r*kg[n]+r;i+=kee[n]*Aee(e,t,a)}return r*i},jg=(e,t,n=1)=>Ag([e[0],e[0]+2/3*(e[1]-e[0]),e[2]+2/3*(e[1]-e[2]),e[2]],[t[0],t[0]+2/3*(t[1]-t[0]),t[2]+2/3*(t[1]-t[2]),t[2]],n);function Aee(e,t,n){let r=1-n,i=r*r,a=2*r*n,o=n*n,s=i*(3*(e[1]-e[0]))+a*(3*(e[2]-e[1]))+o*(3*(e[3]-e[2])),c=i*(3*(t[1]-t[0]))+a*(3*(t[2]-t[1]))+o*(3*(t[3]-t[2]));return Math.sqrt(s*s+c*c)}var Mg=(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},Ng=(e,t,n,r)=>{let i=1-r;return i*i*e+2*i*r*t+r*r*n},Pg=(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(Ng(e,n,i,c),Ng(t,r,a,c))}return o},Fg=(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},Ig=(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(Fg(e,n,i,o,l),Fg(t,r,a,s,l))}return c};function Lg(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 Rg(e,t){let n=e.length,r=[];for(let i=2;i<n-2;i+=2){let n=Lg(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 jee(e){let t=[];for(let n=0;n+7<e.length;n+=6)t.push(e[n+6],e[n+7],...Ig(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 zg=class extends dg{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])}_getStrokePadding(e=this.points().length===4&&!this.closed()?1:void 0){return super._getStrokePadding(e)}_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():Rg(this.points(),this.tension())}_getTensionPointsClosed(){let e=this.points(),t=e.length,n=this.tension(),r=Lg(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),i=Lg(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),a=Rg(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,...Pg(e,n,r,i,a,o)),(e,n,r,i,a,o,s,c)=>t.push(s,c,...Ig(e,n,r,i,a,o,s,c))),e=t}else this.bezier()&&(e=[e[0],e[1],...jee(e)]);return W._getPointsRect(e)}};zg.prototype.className=`Line`,zg.prototype._attrsAffectingSize=[`points`,`bezier`,`tension`,`closed`],Zp(zg,!0),G.addGetterSetter(zg,`closed`,!1),G.addGetterSetter(zg,`bezier`,!1),G.addGetterSetter(zg,`tension`,0,eh()),G.addGetterSetter(zg,`points`,[],ah());var Mee={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7,z:0},Bg=Math.PI*2,Vg=class e extends dg{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`:e.ellipse(a[0],a[1],a[2],a[3],a[6],a[4],a[4]+a[5],!a[7]);break;case`z`:n=!0,e.closePath()}}!n&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=[];return this.dataArray.forEach(function(n){if(n.command===`A`){let[r,i,a,o,s,c,l]=n.points,u=Math.cos(l),d=Math.sin(l),f=e.getPointOnEllipticalArc(r,i,a,o,s+c,l);t.push(n.start.x,n.start.y,f.x,f.y);let p=Math.atan2(-o*d,a*u),m=Math.atan2(o*u,a*d);[p,p+Math.PI,m,m+Math.PI].forEach(n=>{if(((n-s)*Math.sign(c)%Bg+Bg)%Bg<Math.abs(c)){let s=e.getPointOnEllipticalArc(r,i,a,o,n,l);t.push(s.x,s.y)}})}else n.command===`C`?t.push(n.start.x,n.start.y,n.points[4],n.points[5],...Ig(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],...Pg(n.start.x,n.start.y,n.points[0],n.points[1],n.points[2],n.points[3])):t.push(...n.points)}),W._getPointsRect(t)}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,r){let i,a=r?.index??0,o=r?.offset??0,s=n.length;if(!s)return null;for(;a>0&&t<=o;)o-=n[--a].pathLength;for(t-=o;a<s&&t>n[a].pathLength;){let e=n[a].pathLength;t-=e,o+=e,++a}if(r&&a<s&&(r.index=a,r.offset=o),a===s&&(a--,t=n[a].pathLength),t<.01)return n[a].command===`M`?(i=n[a].points.slice(0,2),{x:i[0],y:i[1]}):{x:n[a].start.x,y:n[a].start.y};let c=n[a],l=c.points;switch(c.command){case`L`:case`z`:return e.getPointOnLine(t,c.start.x,c.start.y,l[0],l[1]);case`C`:return e.getPointOnCubicBezier(Mg(t,c.pathLength,e=>Ag([c.start.x,l[0],l[2],l[4]],[c.start.y,l[1],l[3],l[5]],e)),c.start.x,c.start.y,l[0],l[1],l[2],l[3],l[4],l[5]);case`Q`:return e.getPointOnQuadraticBezier(Mg(t,c.pathLength,e=>jg([c.start.x,l[0],l[2]],[c.start.y,l[1],l[3]],e)),c.start.x,c.start.y,l[0],l[1],l[2],l[3]);case`A`:return e.getPointOnEllipticalArc(l[0],l[1],l[2],l[3],l[2]===l[3]?l[4]+l[5]*t/c.pathLength:e._walkArc(l,t).theta,l[6])}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=0,l=0,u=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,d;for(let e=1;e<r.length;e++){let t=r[e],n=t.charAt(0);for(t=t.slice(1),a.length=0;d=u.exec(t);)a.push(d[0]);let f=[],p=n===`A`||n===`a`?0:-1;for(let e=0,t=a.length;e<t;e++){let t=a[e];for(;(p===3||p===4)&&t.length>1&&(t[0]===`0`||t[0]===`1`);)f.push(+t[0]),p++,t=t.slice(1);let n=parseFloat(t);f.push(isNaN(n)?0:n),p>=0&&(p=(p+1)%7)}let m=0;for(;m<f.length&&!(f.length-m<Mee[n.toLowerCase()]||n===`z`||n===`Z`);){let e=``,t=[],r=o,a=s,u,d,p,h,g,_,v,y,b,x;switch(n){case`l`:o+=f[m++],s+=f[m++],e=`L`,t.push(o,s);break;case`L`:o=f[m++],s=f[m++],t.push(o,s);break;case`m`:o+=f[m++],s+=f[m++],e=`M`,c=o,l=s,t.push(o,s),n=`l`;break;case`M`:o=f[m++],s=f[m++],e=`M`,c=o,l=s,t.push(o,s),n=`L`;break;case`h`:o+=f[m++],e=`L`,t.push(o,s);break;case`H`:o=f[m++],e=`L`,t.push(o,s);break;case`v`:s+=f[m++],e=`L`,t.push(o,s);break;case`V`:s=f[m++],e=`L`,t.push(o,s);break;case`C`:t.push(f[m++],f[m++],f[m++],f[m++]),o=f[m++],s=f[m++],t.push(o,s);break;case`c`:t.push(o+f[m++],s+f[m++],o+f[m++],s+f[m++]),o+=f[m++],s+=f[m++],e=`C`,t.push(o,s);break;case`S`:d=o,p=s,u=i[i.length-1],u?.command===`C`&&(d=o+(o-u.points[2]),p=s+(s-u.points[3])),t.push(d,p,f[m++],f[m++]),o=f[m++],s=f[m++],e=`C`,t.push(o,s);break;case`s`:d=o,p=s,u=i[i.length-1],u?.command===`C`&&(d=o+(o-u.points[2]),p=s+(s-u.points[3])),t.push(d,p,o+f[m++],s+f[m++]),o+=f[m++],s+=f[m++],e=`C`,t.push(o,s);break;case`Q`:t.push(f[m++],f[m++]),o=f[m++],s=f[m++],t.push(o,s);break;case`q`:t.push(o+f[m++],s+f[m++]),o+=f[m++],s+=f[m++],e=`Q`,t.push(o,s);break;case`T`:d=o,p=s,u=i[i.length-1],u?.command===`Q`&&(d=o+(o-u.points[0]),p=s+(s-u.points[1])),o=f[m++],s=f[m++],e=`Q`,t.push(d,p,o,s);break;case`t`:d=o,p=s,u=i[i.length-1],u?.command===`Q`&&(d=o+(o-u.points[0]),p=s+(s-u.points[1])),o+=f[m++],s+=f[m++],e=`Q`,t.push(d,p,o,s);break;case`A`:case`a`:if(h=Math.abs(f[m++]),g=Math.abs(f[m++]),_=f[m++],v=f[m++],y=f[m++],b=o,x=s,n===`a`?(o+=f[m++],s+=f[m++]):(o=f[m++],s=f[m++]),e=`A`,o===b&&s===x)continue;!h||!g?(e=`L`,t.push(o,s)):t=this.convertEndpointToCenterParameterization(b,x,o,s,v,y,h,g,_)}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:[c,l],start:{x:o,y:s},pathLength:this.getLineLength(o,s,c,l)}),o=c,s=l)}return i}static _walkArc(t,n){let[r,i,a,o,s,c]=t,l=Math.max(1,Math.ceil(Math.abs(c)/(Math.PI/180))),u=e.getPointOnEllipticalArc(r,i,a,o,s,0),d=s,f=0;for(let t=1;t<=l;t++){let p=s+c*t/l,m=e.getPointOnEllipticalArc(r,i,a,o,p,0),h=e.getLineLength(u.x,u.y,m.x,m.y);if(f+h>=n)return{theta:d+(p-d)*((n-f)/h),length:n};f+=h,u=m,d=p}return{theta:d,length:f}}static calcLength(t,n,r,i){let a=e;switch(r){case`L`:return a.getLineLength(t,n,i[0],i[1]);case`C`:return Ag([t,i[0],i[2],i[4]],[n,i[1],i[3],i[5]],1);case`Q`:return jg([t,i[0],i[2]],[n,i[1],i[3]],1);case`A`:return a._walkArc(i,1/0).length}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]}};Vg.prototype.className=`Path`,Vg.prototype._attrsAffectingSize=[`data`],Zp(Vg,!0),G.addGetterSetter(Vg,`data`);var Hg=class extends zg{_getStrokePadding(){return super._getStrokePadding(this.pointerAtBeginning()||this.pointerAtEnding()?this.miterLimit()||10:void 0)}_sceneFunc(e){super._sceneFunc(e);let t=this.points(),n=t.length;if(n<4)return;let r=this.pointerLength(),i=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(t[n-2],t[n-1]),e.rotate(this._getPointerAngle(!1)),e.moveTo(0,0),e.lineTo(-r,i/2),e.lineTo(-r,-i/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(t[0],t[1]),e.rotate(this._getPointerAngle(!0)),e.moveTo(0,0),e.lineTo(-r,i/2),e.lineTo(-r,-i/2),e.closePath(),e.restore(),this.__fillStroke(e))}_getPointerAngle(e){let t=this.points(),n=t.length,r=this.tension()!==0&&n>4,i=r?this.getTensionPoints():t,a=e?t[0]:t[n-2],o=e?t[1]:t[n-1],s=0,c=0;if(r&&e)s=a-(i[0]+i[2])/2,c=o-(i[1]+i[3])/2;else if(r){let e=i[i.length-4],t=i[i.length-3],n=i[i.length-2],r=i[i.length-1],l=Vg.calcLength(e,t,`Q`,[n,r,a,o]),u=Vg.getPointOnQuadraticBezier(l?Math.max(0,1-this.pointerLength()/l):0,e,t,n,r,a,o);s=a-u.x,c=o-u.y}for(let t=e?0:i.length-2;!s&&!c&&t>=0&&t<i.length;t+=e?2:-2)s=a-i[t],c=o-i[t+1];let l=Math.PI*2;return(Math.atan2(c,s)+l)%l}__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.points();if(t.length<4)return e;let n=e.x,r=e.y,i=n+e.width,a=r+e.height;for(let e of[!1,!0]){if(!(e?this.pointerAtBeginning():this.pointerAtEnding()))continue;let o=e?0:t.length-2,s=this._getPointerAngle(e),c=Math.cos(s),l=Math.sin(s),u=t[o]-this.pointerLength()*c,d=t[o+1]-this.pointerLength()*l,f=Math.abs(this.pointerWidth()*l/2),p=Math.abs(this.pointerWidth()*c/2);n=Math.min(n,u-f),r=Math.min(r,d-p),i=Math.max(i,u+f),a=Math.max(a,d+p)}return{x:n,y:r,width:i-n,height:a-r}}};Hg.prototype.className=`Arrow`,Hg.prototype._attrsAffectingSize=[...zg.prototype._attrsAffectingSize,`pointerLength`,`pointerWidth`,`pointerAtBeginning`,`pointerAtEnding`],Zp(Hg,!0),G.addGetterSetter(Hg,`pointerLength`,10,eh()),G.addGetterSetter(Hg,`pointerWidth`,10,eh()),G.addGetterSetter(Hg,`pointerAtBeginning`,!1),G.addGetterSetter(Hg,`pointerAtEnding`,!0);var Ug=class extends dg{_getStrokePadding(){return super._getStrokePadding(1)}_sceneFunc(e){e.beginPath(),e.arc(0,0,Math.abs(this.attrs.radius||0),0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.radius())*2}getHeight(){return Math.abs(this.radius())*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Ug.prototype._centroid=!0,Ug.prototype.className=`Circle`,Ug.prototype._attrsAffectingSize=[`radius`],Zp(Ug,!0),G.addGetterSetter(Ug,`radius`,0,eh());var Wg=class extends dg{_getStrokePadding(){return super._getStrokePadding(1)}_sceneFunc(e){let t=Math.abs(this.radiusX()),n=Math.abs(this.radiusY());e.beginPath(),e.ellipse(0,0,t,n,0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.radiusX())*2}getHeight(){return Math.abs(this.radiusY())*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}};Wg.prototype.className=`Ellipse`,Wg.prototype._centroid=!0,Wg.prototype._attrsAffectingSize=[`radiusX`,`radiusY`],Zp(Wg,!0),G.addComponentsGetterSetter(Wg,`radius`,[`x`,`y`]),G.addGetterSetter(Wg,`radiusX`,0,eh()),G.addGetterSetter(Wg,`radiusY`,0,eh());var Gg=class e extends dg{constructor(e){super(e),this._loadListener=()=>{this._requestDraw()},this.on(`imageChange.konva`,e=>{this._removeImageLoad(e.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){var e;let t=this.image();t?.complete&&t.src||t?.readyState>=2||(e=t?.addEventListener)==null||e.call(t,`videoWidth`in t?`loadeddata`:`load`,this._loadListener)}_removeImageLoad(e){var t;(t=e?.removeEventListener)==null||t.call(e,`videoWidth`in e?`loadeddata`:`load`,this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(this.attrs.perfectDrawEnabled===!1)return!1;let n=!!this.cornerRadius(),r=this.hasShadow();return n&&r?!0:super._useBufferCanvas(!0,t)}_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),i=this.attrs.image;if((this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?W.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),i){r&&e.clip();let a=this.attrs.cropWidth,o=this.attrs.cropHeight;a&&o?e.drawImage(i,this.cropX(),this.cropY(),a,o,0,0,t,n):e.drawImage(i,0,0,t,n)}}_hitFunc(e){let t=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?W.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){let e=this.image();return this.attrs.width??e?.videoWidth??e?.width??0}getHeight(){let e=this.image();return this.attrs.height??e?.videoHeight??e?.height??0}static fromURL(t,n,r=null){let i=W.createImageElement();i.onload=()=>{i.onload=i.onerror=null,n(new e({image:i}))},i.onerror=r,i.crossOrigin=`Anonymous`,i.src=t}};Gg.prototype.className=`Image`,Gg.prototype._attrsAffectingSize=[`image`],Zp(Gg,!0),G.addGetterSetter(Gg,`cornerRadius`,0,th(4)),G.addGetterSetter(Gg,`image`),G.addComponentsGetterSetter(Gg,`crop`,[`x`,`y`,`width`,`height`]),G.addGetterSetter(Gg,`cropX`,0,eh()),G.addGetterSetter(Gg,`cropY`,0,eh()),G.addGetterSetter(Gg,`cropWidth`,0,eh()),G.addGetterSetter(Gg,`cropHeight`,0,eh());var Kg=typeof Intl<`u`&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:`grapheme`}):null;function qg(e){return e/15}function Jg(e){return Kg?Array.from(Kg.segment(e),e=>e.segment):e.match(/\p{RI}\p{RI}|\P{M}(?:\p{M}|\p{Emoji_Modifier}|\uFE0F|\u200D\P{M})*|\p{M}+/gu)||[]}var Yg=`auto`,Xg=`center`,Zg=`inherit`,Qg=`justify`,Nee=`Change.konva`,$g=`2d`,Pee=`-`,e_=`left`,Fee=`text`,Iee=`Text`,Lee=`top`,Ree=`bottom`,t_=`middle`,n_=`normal`,zee=`px `,r_=` `,i_=`right`,a_=`rtl`,Bee=`word`,Vee=`char`,o_=`none`,s_=`…`,c_=[`direction`,`fontFamily`,`fontSize`,`fontStyle`,`fontVariant`,`padding`,`align`,`verticalAlign`,`lineHeight`,`text`,`width`,`height`,`wrap`,`ellipsis`,`letterSpacing`],l_=null;function Hee(){if(l_!==null)return l_;l_=!1;let e;try{e=W.createCanvasElement(),e.width=10,e.height=10;let t=e.getContext($g);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){l_=!0;break}}}catch{}finally{e&&W.releaseCanvas(e)}return l_}function Uee(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 u_;function d_(){return u_||(u_=W.createCanvasElement().getContext($g),u_)}function Wee(e){this._partialFillStyle&&e.setAttr(`fillStyle`,this._partialFillStyle),e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function Gee(e){e.setAttr(`miterLimit`,2),this._partialStrokeStyle&&e.setAttr(`strokeStyle`,this._partialStrokeStyle),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function Kee(e){return e||={},e.fill||e.fillLinearGradientColorStops||e.fillRadialGradientColorStops||e.fillPatternImage?e:{...e,fill:`black`}}var f_=class extends dg{constructor(e){super(Kee(e)),this._partialTextX=0,this._partialTextY=0,this._baselineShift=0,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.direction(),s=this.align(),c=this.getWidth(),l=this.letterSpacing(),u=this.charRenderFunc(),d=this.textDecoration(),f=d.indexOf(`underline`)!==-1,p=d.indexOf(`line-through`)!==-1,m,h=a/2,g=t_;if(!Yp.legacyTextRendering){let e=this.measureSize(`M`);g=`alphabetic`,h=((e.fontBoundingBoxAscent??e.actualBoundingBoxAscent)-(e.fontBoundingBoxDescent??e.actualBoundingBoxDescent))/2+a/2}if(o===Zg?o=e.direction:e.setAttr(`direction`,o),e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,g),e.setAttr(`textAlign`,e_),e.translate(r,this._getTextTop()),u){let t=e._getFillStyle(this);t!==void 0&&(e.fillStyle=t),this.hasStroke()&&e._applyStrokeStyle(this)}let _=u?e.fillStyle:void 0,v=u?e.strokeStyle:void 0,y=0;for(m=0;m<n;m++){let d=0,g=t[m],b=g.text,x=g.width,S=g.lastInParagraph;if(e.save(),s===i_?d+=c-x-r*2:s===Xg&&(d+=(c-x-r*2)/2),f){e.save(),e.beginPath();let t=this._getUnderlineOffset(),n=d,a=h+0+t;e.moveTo(n,a);let o=s===Qg&&!S?c-r*2:x;e.lineTo(n+Math.round(o),a),e.lineWidth=qg(i),e.strokeStyle=e._getFillStyle(this),e.stroke(),e.restore()}let C=d;if(o!==a_&&(l!==0||s===Qg||u)){let t=b.split(` `).length-1,n=Jg(b);for(let i=0;i<n.length;i++){let a=n[i];a===` `&&!S&&s===Qg&&(d+=(c-r*2-x)/t),this._partialTextX=d,this._partialTextY=h+0,this._partialText=a;let o=e.measureText(a).width;if(u){e.save(),u({char:a,index:y,x:d,y:h+0,lineIndex:m,column:i,isLastInLine:i===n.length-1,width:o,context:e});let t=e.fillStyle;t!==_&&(this._partialFillStyle=t);let r=e.strokeStyle;r!==v&&(this._partialStrokeStyle=r)}e.fillStrokeShape(this),u&&(this._partialFillStyle=void 0,this._partialStrokeStyle=void 0,e.restore()),d+=o+l,y++}}else l!==0&&e.setAttr(`letterSpacing`,`${l}px`),this._partialTextX=d,this._partialTextY=h+0,this._partialText=b,e.fillStrokeShape(this);if(p){e.save(),e.beginPath();let t=Yp.legacyTextRendering?0:-Math.round(i/4),n=C;e.moveTo(n,h+0+t);let a=s===Qg&&!S?c-r*2:x;e.lineTo(n+Math.round(a),h+0+t),e.lineWidth=qg(i),e.strokeStyle=e._getFillStyle(this),e.stroke(),e.restore()}e.restore(),n>1&&(h+=a)}}_getTextTop(){let e=this.padding(),t=this.getHeight()-this.textArr.length*this.lineHeight()*this.fontSize()-e*2,n=this.verticalAlign();return n===t_?e+t/2:n===Ree?e+t:e}_getUnderlineOffset(){return this.underlineOffset()??Math.round(this.fontSize()/(Yp.legacyTextRendering?2:4))}getSelfRect(){let e=super.getSelfRect(),t=this.textArr.length;if(!t||this.textDecoration().indexOf(`underline`)===-1)return e;let n=this.fontSize(),r=this.lineHeight()*n,i=this._getTextTop()+t*r-r/2;return Yp.legacyTextRendering||(i+=this._baselineShift),i+=this._getUnderlineOffset()+qg(n)/2,e.height=Math.max(e.y+e.height,i)-e.y,e}_getSelfRectForDrawing(){let e=this.getSelfRect(),t=this.fontSize(),n=this.padding(),r=this.lineHeight()*t,i=this.getWidth()-n*2,a=this.align(),o=this.textArr.length*r,s=this._getTextTop(),c=e.x,l=e.x+e.width;for(let{text:e,width:t}of this.textArr){let r=n+(a===i_?i-t:a===Xg?(i-t)/2:0),o=Math.min(0,this.letterSpacing())*e.length;c=Math.min(c,r+o),l=Math.max(l,r+t-o)}let u=this.textDecoration().includes(`underline`),d=Math.min(e.y,s+(u?Math.min(0,this._getUnderlineOffset()):0));return{x:c-t,y:d-t,width:l-c+t*2,height:Math.max(e.y+e.height,s+o)-d+t*2}}_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=W._isString(e)?e:e==null?``:e+``;return this._setAttr(Fee,t),this}getWidth(){return this.attrs.width===Yg||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===Yg||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return W.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=d_(),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()+r_+this.fontVariant()+r_+(this.fontSize()+zee)+Uee(this.fontFamily())}_addTextLine(e){this.align()===Qg&&(e=e.trim());let t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e,t){let n=this.letterSpacing(),r=n?n*(t??Jg(e).length):0;return d_().measureText(e).width+r}_setTextData(){let e=this.text().split(`
78
- `),t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.width,i=this.attrs.height,a=r!==Yg&&r!==void 0,o=i!==Yg&&i!==void 0,s=this.padding(),c=r-s*2,l=i-s*2,u=0,d=this.wrap(),f=d!==Vee&&d!==o_,p=this.ellipsis(),m=this.measureSize(`M`);this._baselineShift=(m.fontBoundingBoxAscent-m.fontBoundingBoxDescent)/2,this.textArr=[];let h=d_();h.font=this._getContextFont(),h.fontKerning=this.direction()!==a_&&(this.letterSpacing()!==0||this.align()===Qg||this.charRenderFunc())?`none`:`auto`;let g=p?this._getTextWidth(s_):0;for(let t=0,r=e.length;t<r;++t){let i=e[t],s=this._getTextWidth(i);if(a&&s>c){let e=Jg(i),a=e.length,d=0,m=t=>e.slice(d,t).join(``),h=e=>e===r_||e===Pee,_=Math.max(1,Math.ceil(a*c/s));for(;d<a;){let i=p&&o&&u+n>l?g:0,s=e=>!(this._getTextWidth(m(e),e-d)+i>c),v=d,y=Math.min(a,d+_);for(;s(y)&&(v=y,y!==a);)y=Math.min(a,y+(y-d));for(;y-v>1;){let e=v+y>>>1;s(e)?v=e:y=e}if(v===d)break;if(v===a){this._addTextLine(m(a)),u+=n,o&&u+n>l&&t<r-1&&this._tryToAddEllipsisToLastLine();break}if(f&&!h(e[v])){let t=v-1;for(;t>=d&&!h(e[t]);)t--;t>=d&&(v=t+1)}if(this._addTextLine(m(v).trimRight()),u+=n,this._shouldHandleEllipsis(u)){this._tryToAddEllipsisToLastLine();break}for(d=v;d<a&&!e[d].trim();)d++}}else this._addTextLine(i),u+=n,o&&u+n>l&&t<r-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&u+n>l)break}this.textHeight=t,this.textWidth=this.textArr.reduce((e,t)=>Math.max(e,t.width),0)}_shouldHandleEllipsis(e){let t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==Yg&&r!==void 0,a=r-this.padding()*2;return this.wrap()===o_||i&&e+n>a}_tryToAddEllipsisToLastLine(){let e=this.attrs.width,t=e!==Yg&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];if(!i||!r)return;let a=i.text+s_;if(t){let e=Jg(i.text);for(;e.length&&this._getTextWidth(a)>n;)e.pop(),a=e.join(``)+s_;this._getTextWidth(a)>n&&(a=``)}i.text=a,i.width=this._getTextWidth(a)}getStrokeScaleEnabled(){return!0}_getStrokePadding(){return super._getStrokePadding(2)}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(this.attrs.perfectDrawEnabled===!1)return!1;let n=this.textDecoration().indexOf(`underline`)!==-1||this.textDecoration().indexOf(`line-through`)!==-1,r=this.hasShadow();return n&&r||r&&t!==1&&Hee()?!0:super._useBufferCanvas(e,t)}};f_.prototype._fillFunc=Wee,f_.prototype._strokeFunc=Gee,f_.prototype.className=Iee,f_.prototype._attrsAffectingSize=c_.filter(e=>e!==`width`&&e!==`height`).concat([`textDecoration`,`underlineOffset`]),Zp(f_,!0),f_.prototype.on(c_.map(e=>e+Nee).join(` `),function(){this._setTextData()}),G.overWriteSetter(f_,`width`,nh()),G.overWriteSetter(f_,`height`,nh()),G.addGetterSetter(f_,`direction`,Zg),G.addGetterSetter(f_,`fontFamily`,`Arial`),G.addGetterSetter(f_,`fontSize`,12,eh()),G.addGetterSetter(f_,`fontStyle`,n_),G.addGetterSetter(f_,`fontVariant`,n_),G.addGetterSetter(f_,`padding`,0,eh()),G.addGetterSetter(f_,`align`,e_),G.addGetterSetter(f_,`verticalAlign`,Lee),G.addGetterSetter(f_,`lineHeight`,1,eh()),G.addGetterSetter(f_,`wrap`,Bee),G.addGetterSetter(f_,`ellipsis`,!1,oh()),G.addGetterSetter(f_,`letterSpacing`,0,eh()),G.addGetterSetter(f_,`text`,``,rh()),G.addGetterSetter(f_,`textDecoration`,``),G.addGetterSetter(f_,`underlineOffset`,void 0,eh()),G.addGetterSetter(f_,`charRenderFunc`,void 0);var qee=[...f_.prototype._attrsAffectingSize,`width`,`height`,`pointerDirection`,`pointerWidth`,`pointerHeight`].map(e=>e+`Change.konva`).join(` `),Jee=`none`,p_=`up`,m_=`right`,h_=`down`,g_=`left`,__=class extends gg{constructor(e){super(e),this._sync=this._sync.bind(this),this.on(`add.konva`,function(e){e.child.off(qee,this._sync).on(qee,this._sync),this._sync()})}getText(){return this.find(`Text`)[0]}getTag(){return this.find(`Tag`)[0]}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 p_:o=n/2,s=-1*c;break;case m_:o=n+a,s=r/2;break;case h_:o=n/2,s=r+c;break;case g_: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})}}};__.prototype.className=`Label`,Zp(__);var v_=class extends dg{_sceneFunc(e){let t=this.width(),n=this.height(),r=this.pointerDirection(),i=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius(),[s,c,l,u]=W._cornerRadii(o,t,n);e.beginPath(),e.moveTo(s,0),r===p_&&(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===m_&&(e.lineTo(t,(n-a)/2),e.lineTo(t+i,n/2),e.lineTo(t,(n+a)/2)),e.lineTo(t,n-l),e.arc(t-l,n-l,l,0,Math.PI/2,!1),r===h_&&(e.lineTo((t+i)/2,n),e.lineTo(t/2,n+a),e.lineTo((t-i)/2,n)),e.lineTo(u,n),e.arc(u,n-u,u,Math.PI/2,Math.PI,!1),r===g_&&(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=this.pointerWidth(),t=this.pointerHeight(),n=this.pointerDirection(),r=this.width(),i=this.height();return n===p_||n===h_?{x:Math.min(0,(r-e)/2),y:n===p_?-t:0,width:Math.max(r,e),height:i+t}:n===g_||n===m_?{x:n===g_?-e:0,y:Math.min(0,(i-t)/2),width:r+e,height:Math.max(i,t)}:{x:0,y:0,width:r,height:i}}};v_.prototype.className=`Tag`,Zp(v_,!0),G.addGetterSetter(v_,`pointerDirection`,Jee),G.addGetterSetter(v_,`pointerWidth`,0,eh()),G.addGetterSetter(v_,`pointerHeight`,0,eh()),G.addGetterSetter(v_,`cornerRadius`,0,th(4));var y_=class extends dg{_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?W.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};y_.prototype.className=`Rect`,Zp(y_,!0),G.addGetterSetter(y_,`cornerRadius`,0,th(4));var b_=class extends dg{_sceneFunc(e){let t=this._getPoints(),n=this.radius(),r=this.sides(),i=this.cornerRadius();if(t.length){if(e.beginPath(),i)W.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();if(!e.length)return{x:0,y:0,width:0,height:0};let 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)}};b_.prototype.className=`RegularPolygon`,b_.prototype._centroid=!0,b_.prototype._attrsAffectingSize=[`radius`,`sides`],Zp(b_,!0),G.addGetterSetter(b_,`radius`,0,eh()),G.addGetterSetter(b_,`sides`,0,eh()),G.addGetterSetter(b_,`cornerRadius`,0,th(4));var Yee=Math.PI*2,x_=class extends dg{_getStrokePadding(){return super._getStrokePadding(1)}_sceneFunc(e){let t=Math.abs(this.innerRadius()),n=Math.abs(this.outerRadius());e.beginPath(),e.arc(0,0,t,0,Yee,!1),e.moveTo(n,0),e.arc(0,0,n,Yee,0,!0),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=Math.max(Math.abs(this.innerRadius()),Math.abs(this.outerRadius()));return{x:-e,y:-e,width:e*2,height:e*2}}getWidth(){return Math.abs(this.outerRadius())*2}getHeight(){return Math.abs(this.outerRadius())*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};x_.prototype.className=`Ring`,x_.prototype._centroid=!0,x_.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],Zp(x_,!0),G.addGetterSetter(x_,`innerRadius`,0,eh()),G.addGetterSetter(x_,`outerRadius`,0,eh());var S_=class extends dg{constructor(e){super(e),this._updated=!0,this.anim=new vg(()=>{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())})}_getFrame(){let e=this.animation(),t=this.animations()?.[e],n=this.frameIndex(),r=n*4;if(!t||!Number.isInteger(n)||r<0||r+4>t.length)return;let i=this.frameOffsets()?.[e]||[];return{x:t[r],y:t[r+1],width:t[r+2],height:t[r+3],offsetX:i[n*2]||0,offsetY:i[n*2+1]||0}}_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this._getFrame();if(!t)return;let{x:n,y:r,width:i,height:a,offsetX:o,offsetY:s}=t,c=this.image();(this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(o,s,i,a),e.closePath(),e.fillStrokeShape(this)),c&&e.drawImage(c,n,r,i,a,o,s,i,a)}_hitFunc(e){let{x:t,y:n,width:r,height:i}=this.getSelfRect();e.beginPath(),e.rect(t,n,r,i),e.closePath(),e.fillShape(this)}getSelfRect(){let e=this._getFrame();return e?{x:e.offsetX,y:e.offsetY,width:e.width,height:e.height}:{x:0,y:0,width:0,height:0}}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){return super._useBufferCanvas(!0,t)}_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)}destroy(){return this.stop(),super.destroy()}isRunning(){return this.anim.isRunning()}_updateIndex(){let e=this.frameIndex(),t=this.animations()?.[this.animation()],n=t?t.length/4:0;this.frameIndex(e<n-1?e+1:0)}};S_.prototype.className=`Sprite`,Zp(S_,!0),G.addGetterSetter(S_,`animation`),G.addGetterSetter(S_,`animations`),G.addGetterSetter(S_,`frameOffsets`),G.addGetterSetter(S_,`image`),G.addGetterSetter(S_,`frameIndex`,0,eh()),G.addGetterSetter(S_,`frameRate`,17,eh()),G.backCompat(S_,{index:`frameIndex`,getIndex:`getFrameIndex`,setIndex:`setFrameIndex`});var C_=class extends dg{_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)}getSelfRect(){let e=Math.max(Math.abs(this.innerRadius()),Math.abs(this.outerRadius()));return{x:-e,y:-e,width:e*2,height:e*2}}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};C_.prototype.className=`Star`,C_.prototype._centroid=!0,C_.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],Zp(C_,!0),G.addGetterSetter(C_,`numPoints`,5,eh()),G.addGetterSetter(C_,`innerRadius`,0,eh()),G.addGetterSetter(C_,`outerRadius`,0,eh());var Xee=``,w_=`normal`;function T_(e){e.fillText(this.partialText,0,0)}function E_(e){e.strokeText(this.partialText,0,0)}var D_=class extends dg{constructor(e){super(e),this.dataArray=[],this._readDataAttribute(),this._setTextData()}_getTextPathLength(){return Vg.getPathLength(this.dataArray)}_getPointAtLength(e,t){return!this.attrs.data||e>this.pathLength?null:Vg.getPointAtLengthOfDataArray(e,this.dataArray,t)}_readDataAttribute(){this.dataArray=Vg.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=qg(r),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=qg(r),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 W.warn(`text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.`),this.textHeight}setText(e){return f_.prototype.setText.call(this,e)}_getContextFont(){return f_.prototype._getContextFont.call(this)}_getTextSize(e){let t=d_();t.save(),t.font=this._getContextFont(),t.fontKerning=`auto`;let n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){let e=Jg(this.text());this.direction()===`rtl`&&e.reverse();let t=this.kerningFunc(),n=[],r=0;for(let i=0;i<e.length;i++){let a=0;if(t&&i>0)try{a=t(e[i-1],e[i])*this.fontSize()}catch{}n.push({char:e[i],width:this._getTextSize(e[i]).width,kern:a}),r+=n[i].width+a}let{width:i,height:a}=this._getTextSize(this.attrs.text);if(this.textWidth=r,this.textHeight=a,this.glyphInfo=[],!this.attrs.data)return null;let o=this.letterSpacing(),s=this.align(),c=s===`justify`?this.text().split(` `).length-1:0,l=Math.max(0,r-i),u=Math.max(this.textWidth+(e.length-1)*o,0),d=0;s===`center`&&(d=Math.max(0,this.pathLength/2-u/2)),s===`right`&&(d=Math.max(0,this.pathLength-u));let f=d,p=this.dataArray.some((e,t)=>t>0&&e.command===`M`)?void 0:{index:0,offset:0};for(let t=0;t<n.length;t++){f+=n[t].kern;let r=this._getPointAtLength(f,p);if(!r)return;let i=n[t].char,a=n[t].width+(t<n.length-1?o:0);i===` `&&s===`justify`&&(a+=(this.pathLength-u)/c);let d=f+a,m=this._getPointAtLength(d>this.pathLength&&d-this.pathLength<=l?this.pathLength:d,p);if(!m)return;let h=Vg.getLineLength(r.x,r.y,m.x,m.y),g=Math.atan2(m.y-r.y,m.x-r.x);this.glyphInfo.push({text:e[t],rotation:g,p0:r,p1:m,width:h}),f+=a}}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=W._getPointsRect(e),n=this.fontSize();return{x:t.x-n/2,y:t.y-n/2,width:t.width+n,height:t.height+n}}getStrokeScaleEnabled(){return!0}_getSelfRectForDrawing(){let e=this.getSelfRect(),t=this.fontSize();return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}};D_.prototype._fillFunc=T_,D_.prototype._strokeFunc=E_,D_.prototype._fillFuncHit=T_,D_.prototype._strokeFuncHit=E_,D_.prototype.className=`TextPath`,D_.prototype._attrsAffectingSize=[`text`,`fontSize`,`data`,`align`,`letterSpacing`,`kerningFunc`,`fontFamily`,`fontStyle`,`fontVariant`,`direction`],Zp(D_,!0),D_.prototype.on(`dataChange.konva`,function(){this._readDataAttribute(),this._setTextData()}),D_.prototype.on(D_.prototype._attrsAffectingSize.filter(e=>e!==`data`).map(e=>e+`Change.konva`).join(` `),function(){this._setTextData()}),G.addGetterSetter(D_,`data`),G.addGetterSetter(D_,`fontFamily`,`Arial`),G.addGetterSetter(D_,`fontSize`,12,eh()),G.addGetterSetter(D_,`fontStyle`,w_),G.addGetterSetter(D_,`align`,`left`),G.addGetterSetter(D_,`letterSpacing`,0,eh()),G.addGetterSetter(D_,`textBaseline`,`middle`),G.addGetterSetter(D_,`fontVariant`,w_),G.addGetterSetter(D_,`text`,Xee),G.addGetterSetter(D_,`textDecoration`,``),G.addGetterSetter(D_,`kerningFunc`,void 0),G.addGetterSetter(D_,`direction`,`inherit`);var O_=`tr-konva`,Zee=[`resizeEnabledChange`,`rotateAnchorOffsetChange`,`rotateAnchorAngleChange`,`rotateEnabledChange`,`enabledAnchorsChange`,`anchorSizeChange`,`borderEnabledChange`,`shouldOverdrawWholeAreaChange`,`borderStrokeChange`,`borderStrokeWidthChange`,`borderDashChange`,`anchorStrokeChange`,`anchorStrokeWidthChange`,`anchorFillChange`,`anchorCornerRadiusChange`,`ignoreStrokeChange`,`anchorStyleFuncChange`,`paddingChange`].map(e=>e+`.${O_}`).join(` `),k_=`nodesRect`,Qee=[`widthChange`,`heightChange`,`scaleXChange`,`scaleYChange`,`skewXChange`,`skewYChange`,`rotationChange`,`offsetXChange`,`offsetYChange`,`transformsEnabledChange`,`strokeWidthChange`,`strokeChange`,`selfRectFuncChange`,`strokeLinearGradientColorStopsChange`,`strokeScaleEnabledChange`,`strokeEnabledChange`,`draggableChange`],$ee={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},ete=`ontouchstart`in Yp._global;function tte(e,t,n){if(e===`rotater`)return n;t+=W.degToRad($ee[e]||0);let r=(W.radToDeg(t)%360+360)%360;return W._inRange(r,337.5,360)||W._inRange(r,0,22.5)?`ns-resize`:W._inRange(r,22.5,67.5)?`nesw-resize`:W._inRange(r,67.5,112.5)?`ew-resize`:W._inRange(r,112.5,157.5)?`nwse-resize`:W._inRange(r,157.5,202.5)?`ns-resize`:W._inRange(r,202.5,247.5)?`nesw-resize`:W._inRange(r,247.5,292.5)?`ew-resize`:W._inRange(r,292.5,337.5)?`nwse-resize`:(W.error(`Transformer has unknown angle for cursor detection: `+r),`pointer`)}var A_=[`top-left`,`top-center`,`top-right`,`middle-right`,`middle-left`,`bottom-left`,`bottom-center`,`bottom-right`];function nte(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 rte(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 ite(e,t){return rte(e,t,nte(e))}function ate(e,t,n){let r=t,i=n;for(let n=0;n<e.length;n++){let a=Yp.getAngle(e[n]),o=Math.abs(a-t)%(Math.PI*2),s=Math.min(o,Math.PI*2-o);s<i&&(i=s,r=a)}return r}function j_(e,t,n){let r=W.degToRad(e.rotateAnchorAngle()),i=Math.sin(r),a=-Math.cos(r),o=t/2,s=n/2,c=1/0;a<0?c=Math.min(c,-s/a):a>0&&(c=Math.min(c,(n-s)/a)),i<0?c=Math.min(c,-o/i):i>0&&(c=Math.min(c,(t-o)/i));let l=o+i*c,u=s+a*c,d=e.rotateAnchorOffset()+e.padding();return{edgeX:l,edgeY:u,endX:l+i*d,endY:u+a*d}}var M_=new Set,N_=class extends gg{static _isLayerTransforming(e){for(let t of M_)if(t.getLayer()===e||t._nodes.some(t=>t.getLayer()===e))return!0;return!1}constructor(e){super(e),this._movingAnchorName=null,this._anchors={},this._transforming=!1,this._fitting=!1,this._transformWindow=null,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(Zee,e=>{e.type===`ignoreStrokeChange`&&this._resetTransformCache(),this.update()}),this.on(`rotationChange.${O_}`,()=>this._clearCache(k_)),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return W.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 O_+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();let t=new Set(e);for(let e of t)e.isAncestorOf(this)&&(W.error(`Konva.Transformer cannot be an a child of the node you are trying to attach`),t.delete(e));let n=Array.from(t).filter(e=>{for(let n=e.getParent();n;n=n.getParent())if(t.has(n))return!1;return!0});return this._nodes=e=n,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(e=>{let t=()=>{var t;if(this._fitting){(t=this._nodeRectCache)==null||t.delete(e);return}this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(e),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(Qee.map(e=>e+`.${this._getEventNamespace()}`).join(` `),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),e.on(`destroy.${this._getEventNamespace()}`,()=>{this.setNodes(this._nodes.filter(t=>t!==e))}),this._proxyDrag(e)}),this._resetTransformCache(),this._elementsCreated&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this._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(){var e;this._nodes&&this._nodes.forEach(e=>{e.off(`.`+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache(),(e=this.getLayer())==null||e.batchDraw()}_resetTransformCache(e){var t,n;e?(t=this._nodeRectCache)==null||t.delete(e):(n=this._nodeRectCache)==null||n.clear(),this._clearCache(k_),this._clearCache(`transform`),this._clearSelfAndDescendantCache(`absoluteTransform`)}_getNodeRect(){return this._getCache(k_,this.__getNodeRect)}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};let e=Yp.getAngle(this.rotation()),t=this.ignoreStroke(),n=new em;n.rotate(-e);let r=this._nodeRectCache||=new Map,i=1/0,a=1/0,o=-1/0,s=-1/0;for(let c of this.nodes()){let l=c instanceof dg&&c.getSelfRect===dg.prototype.getSelfRect&&!c.attrs.selfRectFunc&&!c._hasCachedAncestor(),u=l?c.width():0,d=l?c.height():0;l&&(c._attrsVersion??=0);let f=l?r.get(c):void 0;if(!f||f.rotation!==e||f.ignoreStroke!==t||f.version!==c._attrsVersion||f.width!==u||f.height!==d){let i=c.getAbsoluteTransform(),[a,o,s,p]=i.getMatrix(),m=a*p-o*s===0,h=c.getClientRect({skipTransform:!m,skipShadow:!0,skipStroke:t}),g=[{x:h.x,y:h.y},{x:h.x+h.width,y:h.y},{x:h.x+h.width,y:h.y+h.height},{x:h.x,y:h.y+h.height}];m&&(i=new em),f={rotation:e,ignoreStroke:t,width:u,height:d,version:c._attrsVersion||0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(let e of g){let t=n.point(i.point(e));f.minX=Math.min(f.minX,t.x),f.minY=Math.min(f.minY,t.y),f.maxX=Math.max(f.maxX,t.x),f.maxY=Math.max(f.maxY,t.y)}l&&r.set(c,f)}i=Math.min(i,f.minX),a=Math.min(a,f.minY),o=Math.max(o,f.maxX),s=Math.max(s,f.maxY)}n.invert();let c=n.point({x:i,y:a});return{x:c.x,y:c.y,width:o-i,height:s-a,rotation:Yp.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(),A_.forEach(e=>{this._createAnchor(e)}),this._createAnchor(`rotater`),this._elementsCreated=!0}_createAnchor(e){let t=new y_({stroke:`rgb(0, 161, 255)`,fill:`white`,strokeWidth:1,name:e+` _anchor`,dragDistance:0,draggable:!0,hitStrokeWidth:ete?10:`auto`});this._anchors[e]=t;let 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`,()=>{if(this.isTransforming())return;let n=tte(e,Yp.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=n),this._cursorChange=!0}),t.on(`mouseout`,()=>{this._cursorChange=!1,!this.isTransforming()&&t.getStage().content&&(t.getStage().content.style.cursor=``)}),this.add(t)}_createBack(){let e=new dg({name:`back`,width:0,height:0,sceneFunc(e,t){let n=t.getParent();if(!n.borderEnabled())return;let 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=j_(n,i,a);e.moveTo(t.edgeX,t.edgeY),e.lineTo(t.endX,t.endY)}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._back=e,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(e.evt.button!==void 0&&!Yp.dragButtons.includes(e.evt.button)||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);let a=this.getStage()?._getOwnerWindow();this._transformWindow=a||null,a&&(a.addEventListener(`mousemove`,this._handleMouseMove),a.addEventListener(`touchmove`,this._handleMouseMove),a.addEventListener(`mouseup`,this._handleMouseUp,!0),a.addEventListener(`touchend`,this._handleMouseUp,!0),a.addEventListener(`touchcancel`,this._handleMouseUp,!0)),this._transforming=!0,this._pointerId=e.pointerId??W._getFirstPointerId(e.evt);let o=e.target.getAbsolutePosition(),s=e.target.getStage()._getPointerById(this._pointerId);this._anchorDragOffset={x:s.x-o.x,y:s.y-o.y},M_.add(this),this._fire(`transformstart`,{evt:e.evt,target:this.getNode()}),this._nodes.forEach(t=>{t._fire(`transformstart`,{evt:e.evt,target:t})})}_handleMouseMove(e){var t;(t=this.getStage())==null||t._batchEvents(()=>this._moveTransform(e))}_moveTransform(e){let t,n,r,i=this._anchors[this._movingAnchorName],a=i.getStage();a.setPointersPositions(e);let o=a._getPointerById(this._pointerId);if(!o)return;let 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=W.degToRad(this.rotateAnchorAngle()),o=Math.atan2(-n,t)+Math.PI/2-a,s=Yp.getAngle(this.rotation())+o,c=Yp.getAngle(this.rotationSnapTolerance()),l=ite(r,ate(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,p=!1;if(this._movingAnchorName===`top-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-right`].x(),y:this._anchors[`bottom-right`].y()};r=Math.sqrt((e.x-i.x())**2+(e.y-i.y())**2);let a=this._anchors[`top-left`].x()>e.x?-1:1,o=this._anchors[`top-left`].y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-left`].x(e.x-t),this._anchors[`top-left`].y(e.y-n)}}else if(this._movingAnchorName===`top-center`)this._anchors[`top-left`].y(i.y());else if(this._movingAnchorName===`top-right`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-left`].x(),y:this._anchors[`bottom-left`].y()};r=Math.sqrt((i.x()-e.x)**2+(e.y-i.y())**2);let a=this._anchors[`top-right`].x()<e.x?-1:1,o=this._anchors[`top-right`].y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-right`].x(e.x+t),this._anchors[`top-right`].y(e.y-n)}var m=i.position();this._anchors[`top-left`].y(m.y),this._anchors[`bottom-right`].x(m.x)}else if(this._movingAnchorName===`middle-left`)this._anchors[`top-left`].x(i.x());else if(this._movingAnchorName===`middle-right`)this._anchors[`bottom-right`].x(i.x());else if(this._movingAnchorName===`bottom-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`top-right`].x(),y:this._anchors[`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)}m=i.position(),this._anchors[`top-left`].x(m.x),this._anchors[`bottom-right`].y(m.y)}else if(this._movingAnchorName===`bottom-center`)this._anchors[`bottom-right`].y(i.y());else if(this._movingAnchorName===`bottom-right`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`top-left`].x(),y:this._anchors[`top-left`].y()};r=Math.sqrt((i.x()-e.x)**2+(i.y()-e.y)**2);let a=this._anchors[`bottom-right`].x()<e.x?-1:1,o=this._anchors[`bottom-right`].y()<e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`bottom-right`].x(e.x+t),this._anchors[`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._anchors[`top-left`],t=this._anchors[`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 h=this._anchors[`top-left`].getAbsolutePosition();t=h.x,n=h.y;let g=this._anchors[`bottom-right`].x()-this._anchors[`top-left`].x(),_=this._anchors[`bottom-right`].y()-this._anchors[`top-left`].y();this._fitNodesInto({x:t,y:n,width:g,height:_,rotation:Yp.getAngle(this.rotation())},e,p)}_handleMouseUp(e){let t=this.getStage();t&&(t.setPointersPositions(e),!t._changedPointerPositions.some(e=>e.id===this._pointerId))||(t?t._batchEvents(()=>this._removeEvents(e)):this._removeEvents(e))}getAbsoluteTransform(e){let t=this.getTransform();return e?e.getAbsoluteTransform().copy().invert().multiply(t):t}_removeEvents(e){var t;if(this._transforming){this._transforming=!1;let n=this.getStage()?.content;n&&!this._cursorChange&&(n.style.cursor=``);let r=this._transformWindow;this._transformWindow=null,r&&(r.removeEventListener(`mousemove`,this._handleMouseMove),r.removeEventListener(`touchmove`,this._handleMouseMove),r.removeEventListener(`mouseup`,this._handleMouseUp,!0),r.removeEventListener(`touchend`,this._handleMouseUp,!0),r.removeEventListener(`touchcancel`,this._handleMouseUp,!0));let i=this.getNode();M_.delete(this),this._fire(`transformend`,{evt:e,target:i}),(t=this.getLayer())==null||t.batchDraw(),i&&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,n=!1){this._fitting=!0;try{return this._doFitNodesInto(e,t,n)}finally{this._fitting=!1}}_doFitNodesInto(e,t,n=!1){let r=this._getNodeRect();if(!r.width||!r.height||W._inRange(e.width,-this.padding()*2-1,1)||W._inRange(e.height,-this.padding()*2-1,1)){this.update();return}let i=new em;i.rotate(Yp.getAngle(this.rotation()));let a=n?0:this.padding()*2,o=null,s=null;if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`left`)>=0){let t=i.point({x:-a,y:0});e.x+=t.x,e.y+=t.y,e.width+=a,o={axis:`width`,from:`left`,to:`right`,offset:t}}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`right`)>=0){let t=i.point({x:a,y:0});e.width+=a,o={axis:`width`,from:`right`,to:`left`,offset:t}}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`top`)>=0){let t=i.point({x:0,y:-a});e.x+=t.x,e.y+=t.y,e.height+=a,s={axis:`height`,from:`top`,to:`bottom`,offset:t}}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`bottom`)>=0){let t=i.point({x:0,y:a});e.height+=a,s={axis:`height`,from:`bottom`,to:`top`,offset:t}}if(this.boundBoxFunc()){let t=this.boundBoxFunc()(r,e);t?e=t:W.warn(`boundBoxFunc returned falsy. You should return new bound rect from it!`)}for(let t of[o,s])t&&e[t.axis]<0&&this._movingAnchorName&&(this._movingAnchorName=this._movingAnchorName.replace(t.from,t.to),this._anchorDragOffset.x-=t.offset.x,this._anchorDragOffset.y-=t.offset.y);let c=1e7,l=new em;l.translate(r.x,r.y),l.rotate(r.rotation),l.scale(r.width/c,r.height/c);let u=new em,d=e.width/c,f=e.height/c;this.flipEnabled()===!1?(u.translate(e.x,e.y),u.rotate(e.rotation),u.translate(e.width<0?e.width:0,e.height<0?e.height:0),u.scale(Math.abs(d),Math.abs(f))):(u.translate(e.x,e.y),u.rotate(e.rotation),u.scale(d,f));let p=u.multiply(l.invert()),m=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 em;r.multiply(t.copy().invert()).multiply(p).multiply(t).multiply(n);let i=r.decompose();e.setAttrs(i);let a=e.getLayer();a&&m.add(a)}),this.rotation(W._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(),m.add(this.getLayer()),m.forEach(e=>e&&e.batchDraw())}_scheduleUpdate(){this._updateScheduled||(this._updateScheduled=!0,Dh._runAfterAbsTransformCascade(()=>{this._updateScheduled=!1,!(!this._nodes?.length||this._fitting||this.isDragging())&&this._update()}))}forceUpdate(){this._resetTransformCache(),this.update()}update(){this._lastNodeRect=void 0,this._update()}_update(){var e;let t=this._getNodeRect();this._updateElements(t);let n=this.nodes().some(e=>e.draggable());this._back.draggable()!==n&&this._back.draggable(n);let r=this.anchorStyleFunc();r&&Object.values(this._anchors).forEach(e=>r(e)),(e=this.getLayer())==null||e.batchDraw()}_updateElements(e){let t=this._lastNodeRect;if(t&&!this.anchorStyleFunc()&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height&&e.rotation===t.rotation)return;this._lastNodeRect={...e};let n=e.width,r=e.height,i=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),s=this.anchorSize();Object.values(this._anchors).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._anchors[`top-left`].setAttrs({x:0,y:0,offsetX:s/2+o,offsetY:s/2+o,visible:a&&i.indexOf(`top-left`)>=0}),this._anchors[`top-center`].setAttrs({x:n/2,y:0,offsetY:s/2+o,visible:a&&i.indexOf(`top-center`)>=0}),this._anchors[`top-right`].setAttrs({x:n,y:0,offsetX:s/2-o,offsetY:s/2+o,visible:a&&i.indexOf(`top-right`)>=0}),this._anchors[`middle-left`].setAttrs({x:0,y:r/2,offsetX:s/2+o,visible:a&&i.indexOf(`middle-left`)>=0}),this._anchors[`middle-right`].setAttrs({x:n,y:r/2,offsetX:s/2-o,visible:a&&i.indexOf(`middle-right`)>=0}),this._anchors[`bottom-left`].setAttrs({x:0,y:r,offsetX:s/2+o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-left`)>=0}),this._anchors[`bottom-center`].setAttrs({x:n/2,y:r,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-center`)>=0}),this._anchors[`bottom-right`].setAttrs({x:n,y:r,offsetX:s/2-o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-right`)>=0});let c=j_(this,n,r);this._anchors.rotater.setAttrs({x:c.endX,y:c.endY,visible:this.rotateEnabled()}),this._back.setAttrs({width:n,height:r,visible:this.borderEnabled()||this.shouldOverdrawWholeArea(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0})}isTransforming(){return this._transforming}stopTransform(){this._transforming&&this._removeEvents()}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=``),gg.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(W.error(`You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead.`),this):super.add(...e)}toObject(){return Dh.prototype.toObject.call(this)}clone(e){return Dh.prototype.clone.call(this,e)}getClientRect(e){return this.nodes().length>0?super.getClientRect(e):{x:0,y:0,width:0,height:0}}};N_.isTransforming=()=>M_.size>0;function ote(e){return e instanceof Array||W.warn(`enabledAnchors value should be an array`),e instanceof Array&&e.forEach(function(e){A_.indexOf(e)===-1&&W.warn(`Unknown anchor name: `+e+`. Available names are: `+A_.join(`, `))}),e||[]}N_.prototype.className=`Transformer`,Zp(N_),G.addGetterSetter(N_,`enabledAnchors`,A_,ote),G.addGetterSetter(N_,`flipEnabled`,!0,oh()),G.addGetterSetter(N_,`resizeEnabled`,!0),G.addGetterSetter(N_,`anchorSize`,10,eh()),G.addGetterSetter(N_,`rotateEnabled`,!0),G.addGetterSetter(N_,`rotateLineVisible`,!0),G.addGetterSetter(N_,`rotationSnaps`,[]),G.addGetterSetter(N_,`rotateAnchorOffset`,50,eh()),G.addGetterSetter(N_,`rotateAnchorAngle`,0,eh()),G.addGetterSetter(N_,`rotateAnchorCursor`,`crosshair`),G.addGetterSetter(N_,`rotationSnapTolerance`,5,eh()),G.addGetterSetter(N_,`borderEnabled`,!0),G.addGetterSetter(N_,`anchorStroke`,`rgb(0, 161, 255)`),G.addGetterSetter(N_,`anchorStrokeWidth`,1,eh()),G.addGetterSetter(N_,`anchorFill`,`white`),G.addGetterSetter(N_,`anchorCornerRadius`,0,eh()),G.addGetterSetter(N_,`borderStroke`,`rgb(0, 161, 255)`),G.addGetterSetter(N_,`borderStrokeWidth`,1,eh()),G.addGetterSetter(N_,`borderDash`),G.addGetterSetter(N_,`keepRatio`,!0),G.addGetterSetter(N_,`shiftBehavior`,`default`),G.addGetterSetter(N_,`centeredScaling`,!1),G.addGetterSetter(N_,`ignoreStroke`,!1),G.addGetterSetter(N_,`padding`,0,eh()),G.addGetterSetter(N_,`nodes`),G.addGetterSetter(N_,`node`),G.addGetterSetter(N_,`boundBoxFunc`),G.addGetterSetter(N_,`anchorDragBoundFunc`),G.addGetterSetter(N_,`anchorStyleFunc`),G.addGetterSetter(N_,`shouldOverdrawWholeArea`,!1),G.addGetterSetter(N_,`useSingleNodeRotation`,!0),G.backCompat(N_,{lineEnabled:`borderEnabled`,rotateHandlerOffset:`rotateAnchorOffset`,enabledHandlers:`enabledAnchors`});var P_=class extends dg{_sceneFunc(e){e.beginPath(),e.arc(0,0,Math.abs(this.radius()),0,Yp.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.radius())*2}getHeight(){return Math.abs(this.radius())*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};P_.prototype.className=`Wedge`,P_.prototype._centroid=!0,P_.prototype._attrsAffectingSize=[`radius`],Zp(P_,!0),G.addGetterSetter(P_,`radius`,0,eh()),G.addGetterSetter(P_,`angle`,0,eh()),G.addGetterSetter(P_,`clockwise`,!1),G.backCompat(P_,{angleDeg:`angle`,getAngleDeg:`getAngle`,setAngleDeg:`setAngle`});function F_(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var ste=[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],cte=[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 I_(e,t){return t===255?e:e*t/255}var L_=180;function lte(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,T=t+t+1,E=r-1,D=i-1,O=t+1,k=O*(O+1)/2,A=new F_,j=t<=L_?ste[t]/2**cte[t]:1/(O*O),M=null,N=A,P=null,F=null;for(let e=1;e<T;e++)N=N.next=new F_,e===O&&(M=N);N.next=A,s=o=0;for(let e=0;e<i;e++){g=_=v=y=c=l=u=d=0,C=n[o+3],b=I_(n[o],C),x=I_(n[o+1],C),S=I_(n[o+2],C),f=O*b,p=O*x,m=O*S,h=O*C,c+=k*b,l+=k*x,u+=k*S,d+=k*C,N=A;for(let e=0;e<O;e++)N.r=b,N.g=x,N.b=S,N.a=C,N=N.next;for(let e=1;e<O;e++)a=o+((E<e?E:e)<<2),C=n[a+3],c+=(N.r=b=I_(n[a],C))*(w=O-e),l+=(N.g=x=I_(n[a+1],C))*w,u+=(N.b=S=I_(n[a+2],C))*w,d+=(N.a=C)*w,g+=b,_+=x,v+=S,y+=C,N=N.next;P=A,F=M;for(let e=0;e<r;e++)n[o]=Math.floor(c*j),n[o+1]=Math.floor(l*j),n[o+2]=Math.floor(u*j),n[o+3]=Math.floor(d*j),c-=f,l-=p,u-=m,d-=h,f-=P.r,p-=P.g,m-=P.b,h-=P.a,a=s+((a=e+t+1)<E?a:E)<<2,C=n[a+3],g+=P.r=I_(n[a],C),_+=P.g=I_(n[a+1],C),v+=P.b=I_(n[a+2],C),y+=P.a=C,c+=g,l+=_,u+=v,d+=y,P=P.next,f+=b=F.r,p+=x=F.g,m+=S=F.b,h+=C=F.a,g-=b,_-=x,v-=S,y-=C,F=F.next,o+=4;s+=r}for(let e=0;e<r;e++){_=v=y=g=l=u=d=c=0,o=e<<2,f=O*(b=n[o]),p=O*(x=n[o+1]),m=O*(S=n[o+2]),h=O*(C=n[o+3]),c+=k*b,l+=k*x,u+=k*S,d+=k*C,N=A;for(let e=0;e<O;e++)N.r=b,N.g=x,N.b=S,N.a=C,N=N.next;let s=Math.min(1,D)*r;for(let i=1;i<=t;i++)o=s+e<<2,c+=(N.r=b=n[o])*(w=O-i),l+=(N.g=x=n[o+1])*w,u+=(N.b=S=n[o+2])*w,d+=(N.a=C=n[o+3])*w,g+=b,_+=x,v+=S,y+=C,N=N.next,i<D&&(s+=r);o=e,P=A,F=M;for(let t=0;t<i;t++)a=o<<2,n[a+3]=C=Math.floor(d*j),C>0?(C=255/C,n[a]=Math.floor(c*j)*C,n[a+1]=Math.floor(l*j)*C,n[a+2]=Math.floor(u*j)*C):n[a]=n[a+1]=n[a+2]=0,c-=f,l-=p,u-=m,d-=h,f-=P.r,p-=P.g,m-=P.b,h-=P.a,a=e+((a=t+O)<D?a:D)*r<<2,c+=g+=P.r=n[a],l+=_+=P.g=n[a+1],u+=v+=P.b=n[a+2],d+=y+=P.a=n[a+3],P=P.next,f+=b=F.r,p+=x=F.g,m+=S=F.b,h+=C=F.a,g-=b,_-=x,v-=S,y-=C,F=F.next,o+=r}}var ute=function(e,t=1){let n=Math.round(Math.min(this.blurRadius(),L_)*t);n>0&&lte(e,n)};G.addGetterSetter(Dh,`blurRadius`,0,eh(),G.afterSetFilter);var dte=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};G.addGetterSetter(Dh,`brightness`,0,eh(),G.afterSetFilter);var fte=function(e){let t=this.attrs.brightness===void 0?1: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)},pte=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};G.addGetterSetter(Dh,`contrast`,0,eh(),G.afterSetFilter);var mte=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 Float32Array(n*r);for(let e=0,n=0;n<t.length;n+=4,e++)m[e]=.2126*t[n]+.7152*t[n+1]+.0722*t[n+2];let h=[-1,0,1,-2,0,2,-1,0,1],g=[-1,-2,-1,0,0,0,1,2,1],_=e=>e<0?0:e>255?255:e;for(let e=0;e<r;e++)for(let i=0;i<n;i++){let a=0,o=0,c=0;for(let t=-1;t<=1;t++){let s=Math.max(0,Math.min(r-1,e+t))*n;for(let e=-1;e<=1;e++,c++){let t=m[s+Math.max(0,Math.min(n-1,i+e))];a+=t*h[c],o+=t*g[c]}}let u=e*n+i,v=_(l+(d*a+f*o)*p),y=u*4;if(s){let e=v-l;t[y]=_(t[y]+e),t[y+1]=_(t[y+1]+e),t[y+2]=_(t[y+2]+e)}else t[y]=t[y+1]=t[y+2]=v}return e};G.addGetterSetter(Dh,`embossStrength`,.5,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`embossWhiteLevel`,.5,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`embossDirection`,`top-left`,void 0,G.afterSetFilter),G.addGetterSetter(Dh,`embossBlend`,!1,void 0,G.afterSetFilter);function R_(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 hte=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]=R_(t[e+0],r,i,m,p),t[e+1]=R_(t[e+1],o,s,g,h),t[e+2]=R_(t[e+2],l,u,v,_)};G.addGetterSetter(Dh,`enhance`,0,eh(),G.afterSetFilter);var gte=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}};G.addGetterSetter(Dh,`hue`,0,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`saturation`,0,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`luminance`,0,eh(),G.afterSetFilter);var _te=function(e){let t=e.data,n=t.length,r=2**this.saturation(),i=(this.hue()%360+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+.168*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+.292*s,m=.299-.3*o+1.25*s,h=.587-.588*o-1.05*s,g=.114+.886*o-.203*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},vte=function(e){let t=e.data,n=t.length,r=2**this.value(),i=2**this.saturation(),a=(this.hue()%360+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+.168*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+.292*s,m=.299*r-.3*o+1.25*s,h=.587*r-.588*o-1.05*s,g=.114*r+.886*o-.203*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}};G.addGetterSetter(Dh,`hue`,0,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`saturation`,0,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`value`,0,eh(),G.afterSetFilter);var yte=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]},bte=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]=_}}},xte=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}},Ste=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(t*((m%360+360)%360)/360);if(p<1)return;let g={width:t,height:n,data:new Uint8ClampedArray(t*n*4)};bte(e,g,{polarCenterX:t/2,polarCenterY:n/2});let _=t/2**p;for(;_<=8;)_*=2,--p;_=Math.ceil(_);let v=_,y=0,b=v,x=1;for(h+_>t&&(y=v,b=0,x=-1),i=0;i<n;i+=1)for(r=y;r!==b;r+=x)a=Math.round(r+h)%t,d=(t*i+a)*4,s=g.data[d+0],c=g.data[d+1],l=g.data[d+2],u=g.data[d+3],f=(t*i+r)*4,g.data[f+0]=s,g.data[f+1]=c,g.data[f+2]=l,g.data[f+3]=u;for(i=0;i<n;i+=1)for(v=Math.floor(_),o=0;o<p;o+=1){for(r=0;r<v+1;r+=1)d=(t*i+r)*4,s=g.data[d+0],c=g.data[d+1],l=g.data[d+2],u=g.data[d+3],f=(t*i+v*2-r-1)*4,g.data[f+0]=s,g.data[f+1]=c,g.data[f+2]=l,g.data[f+3]=u;v*=2}xte(g,e,{polarRotation:0})};G.addGetterSetter(Dh,`kaleidoscopePower`,2,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`kaleidoscopeAngle`,0,eh(),G.afterSetFilter);function z_(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 B_(e,t){return Math.sqrt((e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2)}function Cte(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 wte(e,t){let n=z_(e,0,0),r=z_(e,e.width-1,0),i=z_(e,0,e.height-1),a=z_(e,e.width-1,e.height-1);if(B_(n,r)<t&&B_(r,a)<t&&B_(a,i)<t&&B_(i,n)<t){let o=Cte([r,n,a,i]),s=[];for(let n=0;n<e.width*e.height;n++){let r=B_(o,[e.data[n*4],e.data[n*4+1],e.data[n*4+2]]);s[n]=r<t?0:255}return s}}function Tte(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function Ete(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 Dte(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 Ote(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 kte=function(e){let t=wte(e,this.attrs.threshold??10);return t&&(t=Ete(t,e.width,e.height),t=Dte(t,e.width,e.height),t=Ote(t,e.width,e.height),Tte(e,t)),e};G.addGetterSetter(Dh,`threshold`,.5,eh(),G.afterSetFilter);var Ate=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()};G.addGetterSetter(Dh,`noise`,.2,eh(),G.afterSetFilter);var jte=function(e,t=1){let n=Math.ceil(this.pixelSize()*t),r=e.width,i=e.height,a=Math.ceil(r/n),o=Math.ceil(i/n),s=e.data;if(n<=0){W.error(`pixelSize value can not be <= 0`);return}for(let e=0;e<a;e+=1)for(let t=0;t<o;t+=1){let a=0,o=0,c=0,l=0,u=e*n,d=Math.min(u+n,r),f=t*n,p=Math.min(f+n,i);for(let e=u;e<d;e+=1)for(let t=f;t<p;t+=1){let n=(r*t+e)*4,i=s[n+3];a+=s[n+0]*i,o+=s[n+1]*i,c+=s[n+2]*i,l+=i}l&&(a/=l,o/=l,c/=l),l/=(d-u)*(p-f);for(let e=u;e<d;e+=1)for(let t=f;t<p;t+=1){let n=(r*t+e)*4;s[n+0]=a,s[n+1]=o,s[n+2]=c,s[n+3]=l}}};G.addGetterSetter(Dh,`pixelSize`,8,eh(),G.afterSetFilter);var Mte=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};G.addGetterSetter(Dh,`levels`,.5,eh(),G.afterSetFilter);var Nte=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]}};G.addGetterSetter(Dh,`red`,0,$m,G.afterSetFilter),G.addGetterSetter(Dh,`green`,0,$m,G.afterSetFilter),G.addGetterSetter(Dh,`blue`,0,$m,G.afterSetFilter);var Pte=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}};G.addGetterSetter(Dh,`alpha`,1,e=>Math.min(1,Math.max(0,e)),G.afterSetFilter);var Fte=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)}},Ite=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},Lte=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};G.addGetterSetter(Dh,`threshold`,.5,eh(),G.afterSetFilter);var V_=Dg.Util._assign(Dg,{Arc:Og,Arrow:Hg,Circle:Ug,Ellipse:Wg,Image:Gg,Label:__,Tag:v_,Line:zg,Path:Vg,Rect:y_,RegularPolygon:b_,Ring:x_,Sprite:S_,Star:C_,Text:f_,TextPath:D_,Transformer:N_,Wedge:P_,Filters:{Blur:ute,Brightness:fte,Brighten:dte,Contrast:pte,Emboss:mte,Enhance:hte,Grayscale:gte,HSL:_te,HSV:vte,Invert:yte,Kaleidoscope:Ste,Mask:kte,Noise:Ate,Pixelate:jte,Posterize:Mte,RGB:Nte,RGBA:Pte,Sepia:Fte,Solarize:Ite,Threshold:Lte}}),H_=Dg,Rte=c(((e,t)=>{t.exports=function(e){function t(e,t,n,r){return new no(e,t,n,r)}function n(){}function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function a(e){if(i(e)!==e)throw Error(r(188))}function o(e){var t=e.alternate;if(!t){if(t=i(e),t===null)throw Error(r(188));return t===e?e:null}for(var n=e,o=t;;){var s=n.return;if(s===null)break;var c=s.alternate;if(c===null){if(o=s.return,o!==null){n=o;continue}break}if(s.child===c.child){for(c=s.child;c;){if(c===n)return a(s),e;if(c===o)return a(s),t;c=c.sibling}throw Error(r(188))}if(n.return!==o.return)n=s,o=c;else{for(var l=!1,u=s.child;u;){if(u===n){l=!0,n=s,o=c;break}if(u===o){l=!0,o=s,n=c;break}u=u.sibling}if(!l){for(u=c.child;u;){if(u===n){l=!0,n=c,o=s;break}if(u===o){l=!0,o=c,n=s;break}u=u.sibling}if(!l)throw Error(r(189))}}if(n.alternate!==o)throw Error(r(190))}if(n.tag!==3)throw Error(r(188));return n.stateNode.current===n?e:t}function s(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=s(e),t!==null)return t;e=e.sibling}return null}function c(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(e.tag!==4&&(t=c(e),t!==null))return t;e=e.sibling}return null}function l(e){return typeof e!=`object`||!e?null:(e=Vo&&e[Vo]||e[`@@iterator`],typeof e==`function`?e:null)}function u(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===Uo?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case Eo:return`Fragment`;case Oo:return`Profiler`;case Do:return`StrictMode`;case Mo:return`Suspense`;case No:return`SuspenseList`;case Io:return`Activity`;case zo:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case To:return`Portal`;case Ao:return e.displayName||`Context`;case ko:return(e._context.displayName||`Context`)+`.Consumer`;case jo:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case Po:return t=e.displayName||null,t===null?u(e.type)||`Memo`:t;case Fo:t=e._payload,e=e._init;try{return u(e(t))}catch{}}return null}function d(e){return{current:e}}function f(e){0>kl||(e.current=Ol[kl],Ol[kl]=null,kl--)}function p(e,t){kl++,Ol[kl]=e.current,e.current=t}function h(e){return e>>>=0,e===0?32:31-(Ml(e)/Nl|0)|0}function _(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function v(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=_(n))):i=_(o):i=_(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=_(n))):i=_(o)):i=_(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function y(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function b(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-jl(n),i=1<<r;t|=e[r],n&=~i}return t}function x(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function S(){var e=Il;return Il<<=1,!(Il&62914560)&&(Il=4194304),e}function C(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function w(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function T(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-jl(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&E(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function E(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-jl(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function D(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-jl(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function O(e,t){var n=t&-t;return n=n&42?1:k(n),(n&(e.suspendedLanes|t))===0?n:0}function k(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function A(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function j(e){if(typeof Kl==`function`&&ql(e),Yl&&typeof Yl.setStrictMode==`function`)try{Yl.setStrictMode(Jl,e)}catch{}}function M(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=Ef.identifierPrefix;var n=Xl++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function N(e){if(e==null||typeof e==`string`)return e;var t=null,n=Pf;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function P(e,t){return e=N(e),t=N(t),t==null?e===`auto`?null:e:t===`auto`?null:t}function F(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}function I(e){if(eu===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);eu=t&&t[1]||``,tu=-1<e.stack.indexOf(`
77
+ `,$p=()=>{if(typeof document>`u`)throw Error(Qp)},em=class e{constructor(e){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]}}_getTransformedRect(e){let[t,n,r,i,a,o]=this.m,s=e.x,c=e.y,l=e.x+e.width,u=e.y+e.height,d=[t*s+r*c+a,t*l+r*c+a,t*l+r*u+a,t*s+r*u+a],f=[n*s+i*c+o,n*l+i*c+o,n*l+i*u+o,n*s+i*u+o],p=Math.min(d[0],d[1],d[2],d[3]),m=Math.min(f[0],f[1],f[2],f[3]);return{x:p,y:m,width:Math.max(d[0],d[1],d[2],d[3])-p,height:Math.max(f[0],f[1],f[2],f[3])-m}}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}isInvertible(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]!==0}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=o&&(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=o&&(e*n+t*r)/o}return s.rotation=W._getRotation(s.rotation),s}},tm=`[object Array]`,nm=`[object Number]`,rm=`[object String]`,im=`[object Boolean]`,am=Math.PI/180,om=180/Math.PI,sm=`#`,cm=``,lm=`0`,tee=`Konva warning: `,um=`Konva error: `,nee={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:[0,0,0,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]},dm=null,fm=typeof window<`u`?window:{},pm=new WeakMap,mm=(e,t)=>{typeof e.requestAnimationFrame==`function`?e.requestAnimationFrame(t):typeof requestAnimationFrame<`u`?requestAnimationFrame(t):setTimeout(t,16)},hm=new Map,gm=Object.getPrototypeOf(Int8Array),_m=e=>{let t=e.trim();return t.indexOf(`,`)===-1?t.split(/\s*\/\s*|\s+/):t.split(/\s*,\s*/)},vm=`[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?`,ym=RegExp(`^(${vm})(%?)$`,`i`),bm=(e,t)=>{let n=ym.exec(e);if(!n)return NaN;let r=n[2]?Number(n[1])/100*t:Number(n[1]);return Math.min(Math.max(r,0),t)},xm=/^#[0-9a-f]+$/i,Sm=RegExp(`^(${vm})(deg|grad|rad|turn)?$`,`i`),Cm={deg:1,grad:.9,rad:om,turn:360};function wm(e,t){return Math.min(Math.max(e||0,0),t)}var W={_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)===tm},_isNumber(e){return Object.prototype.toString.call(e)===nm&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===rm},_isBoolean(e){return Object.prototype.toString.call(e)===im},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,t){let n=t&&!t.closed&&t||fm,r=pm.get(n);r||(r=[],pm.set(n,r),mm(n,function(){pm.delete(n),r.forEach(function(e){e()})})),r.push(e)},createCanvasElement(){$p();let e=document.createElement(`canvas`);try{e.style=e.style||{}}catch{}return e},createImageElement(){return $p(),document.createElement(`img`)},_urlToImage(e,t,n){let r=W.createImageElement();r.onload=function(){t(r)},r.onerror=e=>{n?.(e instanceof Error?e:Error(`Unable to load image.`))},r.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(sm,cm);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=lm+e;return sm+e},isCanvasFarblingActive(){if(dm!==null)return dm;if(typeof document>`u`)return dm=!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 dm=r,this.releaseCanvas(e),dm},getHitColor(){let e=()=>Math.random()*256|0;return this.getHitColorKey(e(),e(),e())},getHitColorKey(e,t,n){let r=this.isCanvasFarblingActive()?5:3,i=e=>Math.round(e/r)*r;return sm+this._rgbToHex(i(e),i(t),i(n))},getSnappedHexColor(e){let{r:t,g:n,b:r}=this._hexToRgb(e);return this.getHitColorKey(t,n,r)},getRGB(e){let{r:t=0,g:n=0,b:r=0}=W.colorToRGBA(e)??{};return{r:t,g:n,b:r}},colorToRGBA(e){e=(e||``).trim()||`black`;let t=W._namedColorToRBA(e)||W._hex3ColorToRGBA(e)||W._hex4ColorToRGBA(e)||W._hex6ColorToRGBA(e)||W._hex8ColorToRGBA(e)||W._rgbColorToRGBA(e)||W._hslColorToRGBA(e);if(t&&[t.r,t.g,t.b,t.a].every(W._isNumber))return t},_namedColorToRBA(e){let t=nee[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=_m(t[1]);if(!(n.length<3||n.length>4))return{r:bm(n[0],255),g:bm(n[1],255),b:bm(n[2],255),a:n.length>3?bm(n[3],1):1}},_hex8ColorToRGBA(e){if(e.length===9&&xm.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&&xm.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&&xm.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&&xm.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=_m(t[1]);if(n.length<3||n.length>4)return;let r=Sm.exec(n[0]);if(!r)return;let i=r[2],a=Number(r[1])*(i?Cm[i.toLowerCase()]:1);if(!isFinite(a))return;let o=(a%360+360)%360/360,s=bm(n[1],100)/100,c=bm(n[2],100)/100,l=n.length>3?bm(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}},_getPointsRect(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a=0;a<e.length;a+=2){let o=e[a],s=e[a+1];isNaN(o)||(t=Math.min(t,o),r=Math.max(r,o)),isNaN(s)||(n=Math.min(n,s),i=Math.max(i,s))}return isFinite(t+n)?{x:t,y:n,width:r-t,height:i-n}:{x:0,y:0,width:0,height:0}},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]=W._cloneValue(e[n]);return t},_cloneValue(e){return W._isArray(e)?e.some(e=>typeof e==`object`)?e.map(W._cloneValue):e.slice():W._isPlainObject(e)?W.cloneObject(e):e instanceof gm?e.slice():e},cloneArray(e){return e.slice(0)},degToRad(e){return e*am},radToDeg(e){return e*om},_getRotation(e){return Yp.angleDeg?W.radToDeg(e):e},_capitalize(e){let t=hm.get(e);if(t!==void 0)return t;let n=e.charAt(0).toUpperCase()+e.slice(1);return hm.set(e,n),n},throw(e){throw Error(um+e)},error(e){console.error(um+e)},warn(e){Yp.showWarnings&&console.warn(tee+e)},_batchEvents(e,t){if(!e)return t();let n=!1,r=!0;try{e(()=>{if(n||!r){W.warn(`eventBatchFunc must call its argument exactly once, synchronously.`);return}n=!0,t()})}finally{r=!1,n||W.warn(`eventBatchFunc must call its argument synchronously.`)}},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=W.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=W._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=W._getProjectionToLine(e,r,n);a.push(t.x),a.push(t.y)}),a},_prepareToStringify(e,t=new Set){let n=W._isArray(e)?[]:{};t.add(e);for(let r of Object.keys(e)){let i=e[r];W._isElement(i)||t.has(i)||(n[r]=W._isPlainObject(i)||W._isArray(i)?W._prepareToStringify(i,t):i)}return t.delete(e),n},_assign(e,t){for(let n in t)e[n]=t[n];return e},_getEventType(e){return e.indexOf(`pointer`)>=0?`pointer`:e.indexOf(`touch`)>=0?`touch`:`mouse`},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId??999},releaseCanvas(...e){Yp.releaseCanvasOnDestroy&&e.forEach(e=>{e.width=0,e.height=0})},_cornerRadii(e,t,n){let r=Math.min(t,n)/2;if(typeof e==`number`){let t=wm(e,r);return[t,t,t,t]}return[wm(e[0],r),wm(e[1],r),wm(e[2],r),wm(e[3],r)]},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,s,c,l]=W._cornerRadii(r,t,n);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-c),e.arc(i+t-c,a+n-c,c,0,Math.PI/2,!1),e.lineTo(i+l,a+n),e.arc(i+l,a+n-l,l,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 Tm(e){let t=[],n=e.length,r=W;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 Em=`,`,Dm=`(`,Om=`)`,km=`;`,Am=`()`,jm=`=`,Mm=`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(`.`),Nm=[`fillStyle`,`strokeStyle`,`shadowColor`,`shadowBlur`,`shadowOffsetX`,`shadowOffsetY`,`letterSpacing`,`lineCap`,`lineDashOffset`,`lineJoin`,`lineWidth`,`miterLimit`,`direction`,`font`,`textAlign`,`textBaseline`,`globalAlpha`,`globalCompositeOperation`,`imageSmoothingEnabled`,`imageSmoothingQuality`,`filter`],Pm=100,Fm=null;function Im(){if(Fm!==null)return Fm;try{let e=W.createCanvasElement(),t=e.getContext(`2d`);Fm=!!t&&`filter`in t,W.releaseCanvas(e)}catch{Fm=!1}return Fm}var Lm=class{constructor(e){this.canvas=e,Yp.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+=Am:(t&&(c=c.map(e=>typeof e==`number`?Math.floor(e):e)),i+=Dm+c.join(Em)+Om)):(i+=o.property,e||(i+=jm+o.val)),i+=km;return i}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=Pm&&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)}_drawDeviceBuffer(e){let{x:t,y:n,width:r,height:i}=e._isolationRect;this.setTransform(1,0,0,1,0,0),this.imageSmoothingEnabled=!1,this.drawImage(e._canvas,0,0,r,i,t,n,r,i)}_applyLineCap(e){let t=e.attrs.lineCap;t&&this.setAttr(`lineCap`,t)}_getOpacity(e){if(!this._opacityRoot)return e.getAbsoluteOpacity();let t=e.opacity(),n=e.parent;for(;n&&n!==this._opacityRoot;)t*=n.opacity(),n=n.parent;return t}_applyOpacity(e){let t=this._getOpacity(e);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(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=Mm.length,n=this.setAttr,r,i,a=function(t){let n=e[t],r;e[t]=function(){return i=Tm(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(Mm[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)}};Nm.forEach(function(e){Object.defineProperty(Lm.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var Rm=class extends Lm{constructor(e,{willReadFrequently:t=!1}={}){super(e),this._context=e._canvas.getContext(`2d`,{willReadFrequently:t})}_getFillPattern(e){let t=this._context;return`patternQuality`in t&&(t.patternQuality=t.imageSmoothingEnabled?`good`:`nearest`),e._getFillPattern()}_getFillStyle(e){let t=e.fill(),n=e.fillPriority();if(t&&n===`color`)return t;let r=e.fillPatternImage();if(r&&n===`pattern`)return this._getFillPattern(e);let i=e.fillLinearGradientColorStops();if(i&&n===`linear-gradient`)return e._getLinearGradient();let a=e.fillRadialGradientColorStops();if(a&&n===`radial-gradient`)return e._getRadialGradient();if(t)return t;if(r)return this._getFillPattern(e);if(i)return e._getLinearGradient();if(a)return e._getRadialGradient()}_fill(e){let t=this._getFillStyle(e);t!==void 0&&(this.setAttr(`fillStyle`,t),e._fillFunc(this))}_strokeLinearGradient(e){let t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint();if(!e.getStrokeScaleEnabled()){let{a:e,b:r,c:i,d:a,e:o,f:s}=this._context.getTransform(),c=new em([e,r,i,a,o,s]),l=this.canvas.getPixelRatio(),u=n.x-t.x,d=n.y-t.y,f=a*u-r*d,p=e*d-i*u,m=f*f+p*p,h=m?(u*u+d*d)*(e*a-r*i)/m:0;t=c.point(t),n={x:t.x+f*h,y:t.y+p*h},t={x:t.x/l,y:t.y/l},n={x:n.x/l,y:n.y/l}}let 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)}}_applyStrokeStyle(e){e.strokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr(`strokeStyle`,e.stroke())}_stroke(e){let t=e.dash(),n=e.getStrokeScaleEnabled();n||this.save(),this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr(`lineDashOffset`,e.dashOffset())),this.setAttr(`lineWidth`,e.strokeWidth());let r=this.shadowColor,i=e.getShadowForStrokeEnabled();if(i||this.setAttr(`shadowColor`,`rgba(0,0,0,0)`),this._applyStrokeStyle(e),!n){let e=this.getCanvas().getPixelRatio();this.setTransform(e,0,0,e,0,0)}try{e._strokeFunc(this)}finally{i||this.setAttr(`shadowColor`,r),n||this.restore()}}_applyShadow(e){let t=e.getShadowRGBA()??`black`,n=e.getShadowBlur(),r=e.getShadowOffset(),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)}},zm=class extends Lm{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){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()}},Bm=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this._logicalWidth=0,this._logicalHeight=0,this.isCache=!1;let t=(e||{}).pixelRatio||Yp.pixelRatio||Yp._global.devicePixelRatio||1;this.pixelRatio=t,this._canvas=W.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){this.pixelRatio=e,this.setSize(this._logicalWidth,this._logicalHeight)}setWidth(e){this.setSize(e,this._logicalHeight)}setHeight(e){this.setSize(this._logicalWidth,e)}getWidth(){return this.width}getHeight(){return this.height}_bitmapSize(e){return Math.floor((e||0)*this.pixelRatio)}setSize(e,t){(!isFinite(e??0)||!isFinite(t??0))&&(W.error(`Canvas size must be finite numbers, got ${e}x${t}. The canvas is left empty.`),e=t=0),e||=0,t||=0;let n=this.pixelRatio,r=this.getContext()._context,i=r.imageSmoothingEnabled;this._logicalWidth=e,this._logicalHeight=t,this.width=this._canvas.width=this._bitmapSize(e),this.height=this._canvas.height=this._bitmapSize(t),this._canvas.style.width=e+`px`,this._canvas.style.height=t+`px`,r.scale(n,n),r.imageSmoothingEnabled=i}setSizeIfChanged(e,t){(this.width!==this._bitmapSize(e)||this.height!==this._bitmapSize(t))&&this.setSize(e,t)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(e){throw W.error(`Unable to get data URL. `+e.message+` For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.`),e}}}},Vm=class e extends Bm{_prepareIsolationCanvas(t){let{a:n,b:r,c:i,d:a,e:o,f:s}=this.getContext()._context.getTransform(),c=this._isolationRect||this,l=0,u=0,d=c.width,f=c.height;if(t){let e=new em([n,r,i,a,o,s])._getTransformedRect(t);l=Math.max(0,Math.floor(e.x)-1),u=Math.max(0,Math.floor(e.y)-1),d=Math.min(d,Math.ceil(e.x+e.width)+1)-l,f=Math.min(f,Math.ceil(e.y+e.height)+1)-u}d>0&&f>0||(l=u=0,d=f=1);let p=this._isolationCanvas||=new e({width:0,height:0,pixelRatio:this.pixelRatio});if(p.width<d||p.height<f){let e=this.pixelRatio,t=(t,n,r)=>Math.min(r,Math.ceil((n<t?Math.max(t,n*1.5):n)/e));p.setSize(t(d,p.width,this._logicalWidth),t(f,p.height,this._logicalHeight))}p._isolationRect={x:l,y:u,width:d,height:f};let m=p._isolationPeak;m.width=Math.max(m.width,d),m.height=Math.max(m.height,f);let h=p.getContext();h.setTransform(1,0,0,1,0,0),h.clearRect(0,0,d,f),h.setTransform(n,r,i,a,o-l,s-u);let g=this.getContext();return h.imageSmoothingEnabled=g.imageSmoothingEnabled,h.imageSmoothingQuality=g.imageSmoothingQuality,h.direction=g.direction,p}_trimIsolationCanvas(){let e=this._isolationCanvas;if(!e)return;let t=e._isolationPeak;e._isolationLowFrames=e.width*e.height>4*t.width*t.height?e._isolationLowFrames+1:0,e._isolationLowFrames>=10?this._releaseIsolationCanvas():(t.width=t.height=0,e._trimIsolationCanvas())}_releaseIsolationCanvas(){let e=this._isolationCanvas;e&&(e._releaseIsolationCanvas(),W.releaseCanvas(e._canvas),this._isolationCanvas=void 0)}setSize(e,t){this._releaseIsolationCanvas(),super.setSize(e,t)}constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this._isolationPeak={width:0,height:0},this._isolationLowFrames=0,this.context=new Rm(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},Hm=class extends Bm{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new zm(this),this.context.imageSmoothingEnabled=!1,this.setSize(e.width,e.height)}},Um={get isDragging(){let e=!1;return Um._dragElements.forEach(t=>{t.dragStatus===`dragging`&&(e=!0)}),e},get node(){let e;for(let t of Um._dragElements.values()){if(t.dragStatus===`dragging`)return t.node;e=t.node}return e},_dragElements:new Map,_listenToWindow(e){let t=t=>Um._endDragBefore(t,e),n=t=>Um._batchEvents(()=>Um._drag(t,e),e),r=e=>Um._batchEvents(()=>Um._endDragAfter(e));e.addEventListener(`mouseup`,t,!0),e.addEventListener(`touchend`,t,!0),e.addEventListener(`touchcancel`,t,!0),e.addEventListener(`mousemove`,n),e.addEventListener(`touchmove`,n),e.addEventListener(`mouseup`,r,!1),e.addEventListener(`touchend`,r,!1),e.addEventListener(`touchcancel`,r,!1)},_batchEvents(e,t){if(!Um._dragElements.size)return;let n=new Set;for(let{node:e}of Um._dragElements.values()){let r=e.getStage();if(!r||t&&r._getOwnerWindow()!==t)continue;let i=r.eventBatchFunc();i&&n.add(i)}let r=e;for(let e of n){let t=r;r=()=>W._batchEvents(e,t)}r()},_drag(e,t){let n=[],r=new Set;Um._dragElements.forEach((i,a)=>{let{node:o}=i,s=o.getStage();if(t&&s._getOwnerWindow()!==t||(r.has(s)||(s.setPointersPositions(e),r.add(s)),i.pointerEventType&&i.pointerEventType!==s._pointerEventType))return;i.pointerId===void 0&&(i.pointerId=W._getFirstPointerId(e),i.pointerEventType=s._pointerEventType,i.dragStatus===`dragging`&&s._cancelClick(i.pointerId,i.pointerEventType));let c=s._changedPointerPositions.find(e=>e.id===i.pointerId);if(c){if(i.dragStatus!==`dragging`){let t=o.dragDistance();if(Math.max(Math.abs(c.x-i.startPointerPos.x),Math.abs(c.y-i.startPointerPos.y))<t||(o.startDrag({evt:e}),!o.isDragging()))return}o._setDragPosition(e,i),n.push(o)}}),n.forEach(t=>{t.getStage()&&t.fire(`dragmove`,{type:`dragmove`,target:t,evt:e},!0)})},_endDragBefore(e,t,n){let r=[],i=new Set;Um._dragElements.forEach((a,o)=>{let{node:s}=a;if(n&&a!==n&&a.pointerId!==n.pointerId)return;let c=s.getStage();if(e&&!i.has(c)&&(!t||c._getOwnerWindow()===t)&&(c.setPointersPositions(e),i.add(c)),n||(!e||!a.pointerEventType||a.pointerEventType===W._getEventType(e.type))&&(a.pointerId===void 0||c._changedPointerPositions.some(e=>e.id===a.pointerId))){if(a.dragStatus===`ready`)Um._dragElements.delete(o);else{c._cancelClick(a.pointerId,a.pointerEventType),a.dragStatus=`stopped`;let e=s.getLayer()||c;e&&r.indexOf(e)===-1&&r.push(e)}}}),r.forEach(e=>{e.draw()})},_endDragAfter(e,t){Um._dragElements.forEach((n,r)=>{n.dragStatus!==`stopped`||t&&n!==t&&n.pointerId!==t.pointerId||(n.node.fire(`dragend`,{type:`dragend`,target:n.node,evt:e},!0),n.dragStatus!==`dragging`&&Um._dragElements.delete(r))})}},Wm=new Map,Gm=Yp._global.PointerEvent!==void 0;function Km(e,t){let n=Wm.get(e);return n&&(!t||n.stage===t)?n.shape:void 0}function qm(e,t,n){e._fire(t,{evt:new PointerEvent(t,{pointerId:n}),pointerId:n})}function Jm(e,t){return Wm.get(e)?.shape===t}function Ym(e,t){var n;Zm(e);let r=t.getStage();if(r&&(Wm.set(e,{shape:t,stage:r}),Gm)){try{(n=r.content)==null||n.setPointerCapture(e)}catch{}qm(t,`gotpointercapture`,e)}}function Xm(e){Wm.forEach(({shape:t,stage:n},r)=>{(t===e||n===e)&&Zm(r)})}function Zm(e,t){var n;let r=Wm.get(e);if(!r||t&&r.shape!==t)return;let{shape:i,stage:a}=r;if(Wm.delete(e),Gm){try{(n=a.content)==null||n.releasePointerCapture(e)}catch{}qm(i,`lostpointercapture`,e)}}function Qm(e){return W._isString(e)?`"`+e+`"`:Object.prototype.toString.call(e)===`[object Number]`||W._isBoolean(e)?e:Object.prototype.toString.call(e)}function $m(e){return e>255?255:e<0?0:Math.round(e)}function eh(){if(Yp.isUnminified)return function(e,t){return W._isNumber(e)||W.warn(Qm(e)+` is a not valid value for "`+t+`" attribute. The value should be a number.`),e}}function th(e){if(Yp.isUnminified)return function(t,n){let r=W._isNumber(t),i=W._isArray(t)&&t.length==e;return!r&&!i&&W.warn(Qm(t)+` is a not valid value for "`+n+`" attribute. The value should be a number or Array<number>(`+e+`)`),t}}function nh(){if(Yp.isUnminified)return function(e,t){return W._isNumber(e)||e===`auto`||W.warn(Qm(e)+` is a not valid value for "`+t+`" attribute. The value should be a number or "auto".`),e}}function rh(){if(Yp.isUnminified)return function(e,t){return W._isString(e)||W.warn(Qm(e)+` is a not valid value for "`+t+`" attribute. The value should be a string.`),e}}function ih(){if(Yp.isUnminified)return function(e,t){let n=W._isString(e),r=Object.prototype.toString.call(e)===`[object CanvasGradient]`||e&&e.addColorStop;return n||r||W.warn(Qm(e)+` is a not valid value for "`+t+`" attribute. The value should be a string or a native gradient.`),e}}function ah(){if(Yp.isUnminified)return function(e,t){return e instanceof gm||(W._isArray(e)?e.forEach(function(e){W._isNumber(e)||W.warn(`"`+t+`" attribute has non numeric element `+e+`. Make sure that all elements are numbers.`)}):W.warn(Qm(e)+` is a not valid value for "`+t+`" attribute. The value should be a array of numbers.`)),e}}function oh(){if(Yp.isUnminified)return function(e,t){return e!==!0&&e!==!1&&W.warn(Qm(e)+` is a not valid value for "`+t+`" attribute. The value should be a boolean.`),e}}function sh(e){if(Yp.isUnminified)return function(t,n){return t==null||W.isObject(t)||W.warn(Qm(t)+` is a not valid value for "`+n+`" attribute. The value should be an object with properties `+e),t}}var ch=`get`,lh=`set`,G={addGetterSetter(e,t,n,r,i){G.addGetter(e,t,n),G.addSetter(e,t,r,i),G.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){let r=ch+W._capitalize(t),i=Array.isArray(n),a=function(){let e=this.attrs[t];return e===void 0?i?n.slice():n:e};a._def=n,e.prototype[r]=e.prototype[r]||a},addSetter(e,t,n,r){let i=lh+W._capitalize(t);e.prototype[i]||G.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){let i=lh+W._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=W._capitalize,s=ch+o(t),c=lh+o(t),l=n.map(e=>t+o(e)),u=l.map(e=>ch+o(e));e.prototype[s]=function(){let e={};for(let t=0;t<a;t++){let r=this[u[t]];e[n[t]]=r?r.call(this):this.attrs[l[t]]}return e};let d=sh(n);e.prototype[c]=function(e){let a=this[s]();r&&(e=r.call(this,e,t)),d&&d.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},G.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){let n=W._capitalize(t),r=lh+n,i=ch+n,a=function(){return arguments.length?(this[r](arguments[0]),this):this[i]()};e.prototype[t]=a},backCompat(e,t){W.each(t,function(t,n){let r=e.prototype[n],i=ch+W._capitalize(t),a=lh+W._capitalize(t);function o(){return W.error(`"`+t+`" method is deprecated and will be removed soon. Use ""`+n+`" instead.`),r.apply(this,arguments)}e.prototype[t]=o,e.prototype[i]=o,e.prototype[a]=o})},afterSetFilter(){this._filterUpToDate=!1}};function uh(e){let t=[],n=/(\w+)\(([^)]*)\)/g,r;for(;(r=n.exec(e))!==null;){let[,e,n]=r;if(![`blur`,`brightness`,`contrast`,`grayscale`,`sepia`,`invert`].includes(e)){W.warn(`CSS filter "${e}" is not supported in fallback mode. Consider using function filters for better compatibility.`);continue}let i=n.trim()===``?e===`blur`?0:1:parseFloat(n)/(n.includes(`%`)?100:1);t.push({name:e,value:i})}return function(e,n=1){for(let{name:r,value:i}of t){if([`grayscale`,`sepia`,`invert`].includes(r)){let t=Math.min(1,Math.max(0,i)),n=e.data;for(let e=0;e<n.length;e+=4){let i=n[e],a=n[e+1],o=n[e+2],s,c,l;r===`grayscale`?s=c=l=.2126*i+.7152*a+.0722*o:r===`sepia`?(s=.393*i+.769*a+.189*o,c=.349*i+.686*a+.168*o,l=.272*i+.534*a+.131*o):(s=255-i,c=255-a,l=255-o),n[e]=i+(s-i)*t,n[e+1]=a+(c-a)*t,n[e+2]=o+(l-o)*t}continue}let t=Yp.Filters?.[W._capitalize(r)];if(!t)continue;let a=Object.create(this);a.attrs={...this.attrs},r===`blur`&&(a.attrs.blurRadius=i*.5),r===`brightness`&&(a.attrs.brightness=i),r===`contrast`&&(a.attrs.contrast=100*(Math.sqrt(i)-1)),t.call(a,e,n)}}}var dh=`absoluteOpacity`,fh=`absoluteTransform`,ph=`Change`,mh=`children`,hh=`konva`,gh=`listening`,_h=[`mouseenter`,`mouseleave`,`pointerenter`,`pointerleave`,`touchenter`,`touchleave`],vh=`set`,yh=`Shape`,bh=` `,xh=`stage`,Sh=`transform`,Ch=`Stage`,wh=`visible`,Th=[`xChange.konva`,`yChange.konva`,`scaleXChange.konva`,`scaleYChange.konva`,`skewXChange.konva`,`skewYChange.konva`,`rotationChange.konva`,`offsetXChange.konva`,`offsetYChange.konva`,`transformsEnabledChange.konva`].join(bh),Eh=1,Dh=class e{constructor(e){this._id=Eh++,this.eventListeners={},this.attrs={},this.index=0,this.parent=null,this._cache={},this._canvasCache=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===Sh||e===fh)&&this._cache[e]?this._cache[e].dirty=!0:e?this._cache[e]=void 0:(this._cache={},this._attrsVersion!==void 0&&this._attrsVersion++)}_releaseCanvasCache(){let e=this._canvasCache;e&&(W.releaseCanvas(e.scene._canvas,e.filter._canvas,...e.hit?[e.hit._canvas]:[]),this._canvasCache=null)}_getCache(e,t){let n=this._cache[e];return(n===void 0||(e===Sh||e===fh)&&n.dirty===!0)&&(n=t.call(this),this._cache[e]=n),n}_getCanvasCache(){return this._canvasCache}_clearSelfAndDescendantCache(e){this._clearCache(e),(e===void 0||e===fh)&&this.fire(`absoluteTransformChange`)}static _runAfterAbsTransformCascade(t){e._absTransformCascadeDepth>0?e._pendingAfterCascade.push(t):t()}clearCache(){return this._releaseCanvasCache(),this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){let t=e||{},n={};if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0){let e=this._isUnderCache;this._isUnderCache=!0,n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}),this._isUnderCache=e}let r=t.x===void 0?Math.floor(n.x):t.x,i=t.y===void 0?Math.floor(n.y):t.y,a=Math.ceil(t.width||n.x+n.width-r),o=Math.ceil(t.height||n.y+n.height-i),s=t.pixelRatio,c=t.offset||0,l=t.drawBorder||!1,u=t.hitCanvasPixelRatio||1;if(a<=0||o<=0||!isFinite(r+i+a+o))return W.error(`Can not cache the node. Its size is 0 or its bounds are not finite numbers (${r}, ${i}, ${a}x${o}). Caching is skipped.`),this;a+=c*2,o+=c*2,r-=c,i-=c;let d=new Vm({pixelRatio:s,width:a,height:o}),f=new Vm({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),p=d.getContext();d.isCache=!0,this._releaseCanvasCache(),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(d.getContext()._context.imageSmoothingEnabled=!1,f.getContext()._context.imageSmoothingEnabled=!1),p.save(),p.translate(-r,-i),this._isUnderCache=!0,this._clearSelfAndDescendantCache(dh);try{this.drawScene(d,this)}catch(e){throw W.releaseCanvas(d._canvas),e}finally{this._isUnderCache=!1,this._clearSelfAndDescendantCache(dh),p.restore(),d._releaseIsolationCanvas()}return l&&(p.save(),p.beginPath(),p.rect(0,0,a,o),p.closePath(),p.setAttr(`strokeStyle`,`red`),p.setAttr(`lineWidth`,5),p.stroke(),p.restore()),this._canvasCache={scene:d,filter:f,hit:null,hitConfig:{pixelRatio:u,width:a,height:o},x:r,y:i},this._clearSelfAndDescendantCache(),this._requestDraw(),this}_getCachedHitCanvas(e){if(e===this)return null;let t=this._getCanvasCache();if(!t)return null;if(t.hit)return t.hit;let n=new Hm(t.hitConfig);n.isCache=!0;let r=n.getContext();return r.save(),r.translate(-t.x,-t.y),this.drawHit(n,this),r.restore(),t.hit=n,n}isCached(){return!!this._canvasCache}getClientRect(e){throw Error(`abstract "getClientRect" method call`)}_getCachedSceneRect(e){let t=e._forDrawing&&!this._isUnderCache&&this._getCanvasCache();if(!t)return;let n={x:t.x,y:t.y,width:t.scene.width/t.scene.pixelRatio,height:t.scene.height/t.scene.pixelRatio};return e.skipTransform?n:this._transformedRect(n,e.relativeTo)}_transformedRect(e,t){return this.getAbsoluteTransform(t)._getTransformedRect(e)}_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,t){let n=this._getCanvasCache();e.save(),e.translate(n.x,n.y),e.drawImage(t._canvas,0,0,t.width/t.pixelRatio,t.height/t.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`||!Im()){l=!1;break}let u=n.pixelRatio;if(r.setSizeIfChanged(n._logicalWidth,n._logicalHeight),l){let t=e.join(` `).replace(/url\((?:[^()"']|"[^"]*"|'[^']*')*\)|"[^"]*"|'[^']*'|([-+]?(?:\d*\.)?\d+(?:e[-+]?\d+)?)(px|em|rem|ex|ch|cap|ic|lh|rlh|vw|vh|vmin|vmax|cm|mm|q|in|pt|pc)\b/gi,(e,t,n)=>t===void 0?e:`${Number(t)*u}${n}`);return i.clear(),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=uh(c)),c.call(this,o,u);i.putImageData(o,0,0)}catch(e){W.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){this._prepareListeners();let t=e[0],n=e[1];if(e[2],e.length===3)return this._delegate.apply(this,e);let r=t.split(bh);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}_prepareListeners(){this===this.constructor.prototype&&(this.hasOwnProperty(`eventListeners`)||(this.eventListeners={}),e.protoListenerMap=new WeakMap)}off(e,t){this._prepareListeners();let n=(e||``).split(bh),r=n.length,i,a,o,s,c,l;if(!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=W.cloneObject(e),e.currentTarget=i[t],n.call(i[t],e)}),this}remove(){return this.isDragging()&&this.stopDrag(),Um._dragElements.delete(this._id),Um._dragElements.forEach((e,t)=>{this.isAncestorOf(e.node)&&Um._dragElements.delete(t)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(fh),this._clearSelfAndDescendantCache(dh),this._clearSelfAndDescendantCache(xh),this._clearSelfAndDescendantCache(wh),this._clearSelfAndDescendantCache(gh)}_remove(){let e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null),this._clearCaches()}destroy(){return this._fire(`destroy`,{target:this}),Xm(this),this.remove(),this.clearCache(),this}getAttr(e){let t=`get`+W._capitalize(e);return W._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!==mh&&(n=vh+W._capitalize(t),W._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(gh,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(wh,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){return e?this._isVisible(e)&&this._isListening(e):this.isListening()&&this.isVisible()}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!==yh&&(r=r.concat(o.children)),o._id===t._id&&(a=i);r.length>0&&r[0].getDepth()<=e&&s(r)}let c=this.getStage();return t.nodeType!==Ch&&c&&s(c.children),n}getDepth(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}_batchTransformChanges(e){if(this._batchingTransformChange){e();return}this._batchingTransformChange=!0;try{e()}finally{this._batchingTransformChange=!1,this._needClearTransformCache&&(this._needClearTransformCache=!1,this._clearCache(Sh),this._clearSelfAndDescendantCache(fh))}}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=this.getAbsoluteTransform(e).getMatrix(),n=new em,r=this.offset();return n.m=t.slice(),n.translate(r.x,r.y),n.getTranslation()}setAbsolutePosition(e){let{x:t,y:n,...r}=this._clearTransform();this.attrs.x=t,this.attrs.y=n,this._clearCache(Sh);let i=this._getAbsoluteTransform().copy(),a=i.isInvertible();i.invert(),i.translate(e.x,e.y);let{x:o,y:s}=i.getTranslation();return this._setTransform(r),a?this.setPosition({x:this.attrs.x+o,y:this.attrs.y+s}):W.warn(`Cannot set the absolute position: the absolute transform is not invertible (an ancestor has a zero scale).`),this._clearCache(Sh),this._clearSelfAndDescendantCache(fh),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}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return W.warn(`Node has no parent. moveToTop function is ignored.`),!1;let e=this.index;return e<this.parent.children.length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return W.warn(`Node has no parent. moveUp function is ignored.`),!1;let e=this.index;return e<this.parent.children.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 W.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 W.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 W.warn(`Node has no parent. zIndex parameter is ignored.`),this;(e<0||e>=this.parent.children.length)&&W.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(dh,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={attrs:{},className:this.getClassName()};for(t in e)n=e[t],n instanceof gm&&(n=Array.from(n)),r=W.isObject(n)&&!W._isPlainObject(n)&&!W._isArray(n),!r&&(this[`get`+W._capitalize(t)]?._def!==n||t===`brightness`||t===`threshold`)&&(i.attrs[t]=t===`filters`&&W._isArray(n)?n.filter(e=>typeof e==`string`):W.isObject(n)?W._prepareToStringify(n):n);return i}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],W.isValidSelector(i)||(W.warn(`Selector "`+i+`" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".`),W.warn(`If you have a custom shape with such className, please change it to start with upper letter like "Triangle".`),W.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(xh,this._getStage)}_getStage(){let e=this.getParent();return e?e.getStage():null}fire(e,t,n){return t||={},t.target=t.target||this,n?this._fireAndBubble(e,t):this._fire(e,t),this}getAbsoluteTransform(e){return e||this._hasCachedAncestor()?this._getAbsoluteTransform(e):this._getCache(fh,this._getCachedAbsoluteTransform)}_hasCachedAncestor(){let e=this.parent;for(;e;){if(e.isCached())return!0;e=e.parent}return!1}_getAbsoluteTransform(e){let t=new em;return this===e?t:(this.parent&&this.parent!==e&&this.parent.getAbsoluteTransform(e).copyInto(t),this._multiplyOwnTransform(t))}_getCachedAbsoluteTransform(){let e=this._cache[fh]||new em;return this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset(),this._multiplyOwnTransform(e),e.dirty=!1,e}_multiplyOwnTransform(e){let t=this.transformsEnabled();if(t===`all`)e.multiply(this.getTransform());else if(t===`position`){let t=this.attrs.x||0,n=this.attrs.y||0,r=this.attrs.offsetX||0,i=this.attrs.offsetY||0;e.translate(t-r,n-i)}return e}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(Sh,this._getTransform)}_getTransform(){let e=this._cache[Sh]||new em;e.reset();let t=this.x(),n=this.y(),r=Yp.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=W.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(hh)<0&&(s.eventListeners[n]||(s.eventListeners[n]=[]),s.eventListeners[n].push(o));return s}_toKonvaCanvas(e){e||={};let t=e.x===void 0||e.y===void 0||!e.width||!e.height?this.getClientRect():{x:0,y:0,width:0,height:0};isFinite(t.x+t.y+t.width+t.height)||W.error(`Cannot find the bounds of the node to export, its client rect is ${t.x}, ${t.y}, ${t.width}x${t.height}. Check its position, size and points.`);let 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 Vm({width:e.width||Math.max(0,Math.ceil(t.x+t.width-r))||(n?n.width():0),height:e.height||Math.max(0,Math.ceil(t.y+t.height-i))||(n?n.height():0),pixelRatio:a}),s=o.getContext();return e.imageSmoothingEnabled===!1&&(s._context.imageSmoothingEnabled=!1),s.save(),(r||i)&&s.translate(-1*r,-1*i),this.drawScene(o),s.restore(),o._releaseIsolationCanvas(),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{callback:r,...i}=e||{};W._urlToImage(this.toDataURL(i),function(e){t(e),r?.(e)},n)}catch(e){n(e)}})}toBlob(e){return new Promise((t,n)=>{try{this.toCanvas(e).toBlob(r=>{var i;if(!r){n(Error(`Konva: toBlob() failed, the canvas was not encoded`));return}t(r),(i=e?.callback)==null||i.call(e,r)},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():Yp.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+ph,{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[vh+W._capitalize(e)];return W._isFunction(n)?n.call(this,t):this._setAttr(e,t),this}_addSubtreeObserver(t){(this._subtreeObservers??=new Set).add(t),e._subtreeObserverCount++}_removeSubtreeObserver(t){this._subtreeObservers?.delete(t)&&e._subtreeObserverCount--}_notifySubtreeChange(){if(e._subtreeObserverCount)for(let e=this;e;e=e.parent){let t=e._subtreeObservers;if(t)for(let n of t)n._onSubtreeChange(e)}}_requestDraw(){var e;(e=this.parent)==null||e._notifySubtreeChange(),Yp.autoDrawEnabled&&(this.getLayer()||this.getStage())?.batchDraw()}_setAttr(e,t){let n=this.attrs[e];(n!==t||W.isObject(t))&&(t==null?delete this.attrs[e]:this.attrs[e]=t,this._attrsVersion!==void 0&&this._attrsVersion++,this._shouldFireChangeEvents&&this._fireChangeEvent(e,n,t),this._requestDraw())}_fireAndBubble(e,t,n){t&&this.nodeType===yh&&(t.target=this);let r=_h.indexOf(e)!==-1;if(!(r&&(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||this.nodeType===`Stage`&&!n))){this._fire(e,t);let i=r&&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 n=Object.getPrototypeOf(this),r=e.protoListenerMap.get(n);r||(r={},e.protoListenerMap.set(n,r));let i=r[t];if(i===void 0){i=[];let e=new Set,n=Object.getPrototypeOf(this);for(;n;){let r=n.eventListeners?.[t]??[];for(let t=0;t<r.length;t++){let n=r[t];e.has(n)||(e.add(n),i.push(n))}n=Object.getPrototypeOf(n)}r[t]=i}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,a=e?.evt?.type?W._getEventType(e.evt.type):n._pointerEventType,o=a!==`pointer`;Um._dragElements.set(this._id,{node:this,startPointerPos:i,offset:{x:i.x-r.x,y:i.y-r.y},dragStatus:`ready`,pointerId:o?t??(`id`in i?i.id:void 0):void 0,pointerEventType:o?a:void 0,startEvent:e})}startDrag(e,t=!0){var n;Um._dragElements.has(this._id)||this._createDragElement(e);let r=Um._dragElements.get(this._id);r&&(r.dragStatus=`dragging`,(n=this.getStage())==null||n._cancelClick(r.pointerId,r.pointerEventType),this.fire(`dragstart`,{type:`dragstart`,target:this,evt:r.startEvent&&r.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);if(!t)W.warn(`dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.`);else if(!W._isNumber(t.x)||!W._isNumber(t.y)){W.warn(`dragBoundFunc returned a position with a non-finite x or y (${t.x}, ${t.y}). The node was not moved.`);return}else r=t}let a=t.lastPos;(!a||a.x!==r.x||a.y!==r.y)&&(this.setAbsolutePosition(r),this._requestDraw()),t.lastPos=r}stopDrag(e){let t=Um._dragElements.get(this._id);t&&(t.dragStatus=`stopped`,Um._endDragBefore(e,void 0,t),Um._endDragAfter(e,t))}setDraggable(e){this._setAttr(`draggable`,e),this._dragChange()}isDragging(){let e=Um._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||Yp.dragButtons.indexOf(e.evt.button)>=0)||Um._dragElements.has(this._id))return;let t=!1;Um._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=Um._dragElements.get(this._id),t=e&&e.dragStatus===`dragging`,n=e&&e.dragStatus===`ready`;t?this.stopDrag():n&&Um._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 W.haveIntersection(n,this.getClientRect())}static create(e,t){return W._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;if(n&&(t.attrs.container=n),!Yp[r]){let e=i?`Group`:`Shape`;W.warn(`Can not find a node with class name "`+r+`". Fallback to "${e}".`),r=e}let c=Yp[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}};Dh._subtreeObserverCount=0,Dh._absTransformCascadeDepth=0,Dh._pendingAfterCascade=[],Dh.protoListenerMap=new WeakMap,Dh.prototype.nodeType=`Node`,Dh.prototype._attrsAffectingSize=[],Dh.prototype.on(Th,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(Sh),this._clearSelfAndDescendantCache(fh)}),Dh.prototype.on(`visibleChange.konva`,function(){this._clearSelfAndDescendantCache(wh)}),Dh.prototype.on(`listeningChange.konva`,function(){this._clearSelfAndDescendantCache(gh);for(let e=this.getParent();e;e=e.getParent()){let t=e._getCanvasCache();t?.hit&&(W.releaseCanvas(t.hit._canvas),t.hit=null)}}),Dh.prototype.on(`opacityChange.konva`,function(){this._clearSelfAndDescendantCache(dh)});var Oh=G.addGetterSetter;Oh(Dh,`zIndex`),Oh(Dh,`absolutePosition`),Oh(Dh,`position`),Oh(Dh,`x`,0,eh()),Oh(Dh,`y`,0,eh()),Oh(Dh,`globalCompositeOperation`,`source-over`,rh()),Oh(Dh,`opacity`,1,eh()),Oh(Dh,`name`,``,rh()),Oh(Dh,`id`,``,rh()),Oh(Dh,`rotation`,0,eh()),G.addComponentsGetterSetter(Dh,`scale`,[`x`,`y`]),Oh(Dh,`scaleX`,1,eh()),Oh(Dh,`scaleY`,1,eh()),G.addComponentsGetterSetter(Dh,`skew`,[`x`,`y`]),Oh(Dh,`skewX`,0,eh()),Oh(Dh,`skewY`,0,eh()),G.addComponentsGetterSetter(Dh,`offset`,[`x`,`y`]),Oh(Dh,`offsetX`,0,eh()),Oh(Dh,`offsetY`,0,eh()),Oh(Dh,`dragDistance`,void 0,eh()),Oh(Dh,`width`,0,eh()),Oh(Dh,`height`,0,eh()),Oh(Dh,`listening`,!0,oh()),Oh(Dh,`preventDefault`,!0,oh()),Oh(Dh,`filters`,void 0,function(e){return this._filterUpToDate=!1,e}),Oh(Dh,`visible`,!0,oh()),Oh(Dh,`transformsEnabled`,`all`,rh()),Oh(Dh,`size`),Oh(Dh,`dragBoundFunc`),Oh(Dh,`draggable`,!1,oh()),G.backCompat(Dh,{rotateDeg:`rotate`,setRotationDeg:`setRotation`,getRotationDeg:`getRotation`});var kh=class extends Dh{constructor(){super(...arguments),this.children=[]}getChildren(e){let t=this.children||[];return e?t.filter(e):t.slice()}hasChildren(){return this.children.length>0}removeChildren(){return this.children.forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._notifySubtreeChange(),this._requestDraw(),this}destroyChildren(){return this.children.forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._notifySubtreeChange(),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.children.length,t.parent=this,t._clearCaches(),this.children.push(t),this._fire(`add`,{child:t}),this._notifySubtreeChange(),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;for(let n of this.children)if(t=e(n),t||n.hasChildren()&&(t=n._descendants(e),t))return!0;return!1}toObject(){let e=Dh.prototype.toObject.call(this);return e.children=[],this.children.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=Dh.prototype.clone.call(this,e);return this.children.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===void 0||e===`absoluteTransform`;n&&Dh._absTransformCascadeDepth++;try{if(super._clearSelfAndDescendantCache(e),e===`absoluteTransform`&&this.isCached())return;(t=this.children)==null||t.forEach(function(t){t._clearSelfAndDescendantCache(e)})}finally{if(n&&--Dh._absTransformCascadeDepth===0){let e=Dh._pendingAfterCascade;if(e.length){Dh._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._notifySubtreeChange(),this._requestDraw()}drawScene(e,t){let n=this.getLayer(),r=e||n&&n.getCanvas(),i=r&&r.getContext(),a=this._getCanvasCache(),o=a&&a.scene,s=t===this;if(!(t?this._isVisible(t):this.isVisible())&&!s)return this;if(o){i.save();let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(i),i.restore()}else this._drawChildren(`drawScene`,r,t);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._getCachedHitCanvas(t);if(a){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,a),i.restore()}else this._drawChildren(`drawHit`,r,t);return this}_drawChildren(e,t,n){let r=t&&t.getContext(),i=this.clipWidth(),a=this.clipHeight(),o=this.clipFunc(),s=typeof i==`number`&&typeof a==`number`||o,c=n===this;if(s){r.save();let e=this.getAbsoluteTransform(n),t=e.getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),r.beginPath();let s;if(o)s=o.call(this,r,this);else{let e=this.clipX(),t=this.clipY();r.rect(e||0,t||0,i,a)}r.clip.apply(r,s),t=e.copy().invert().getMatrix(),r.transform(t[0],t[1],t[2],t[3],t[4],t[5])}let l=!c&&this.globalCompositeOperation()!==`source-over`&&e===`drawScene`;l&&(r.save(),r._applyGlobalCompositeOperation(this));try{this._drawChildNodes(e,t,n)}finally{l&&r.restore(),s&&r.restore()}}_drawChildNodes(e,t,n){var r;(r=this.children)==null||r.forEach(function(r){r[e](t,n)})}getClientRect(e={}){var t;let n=this._getCachedSceneRect(e);if(n)return n;let r=e.skipTransform,i=e.relativeTo,[a,o,s,c]=this.getAbsoluteTransform().getMatrix(),l=!r&&(e._forDrawing||a*c-o*s===0),u,d,f,p,m={x:1/0,y:1/0,width:0,height:0},h=this;return(t=this.children)==null||t.forEach(function(t){if(!t.visible())return;let n=t.getClientRect({relativeTo:l?i:h,_forDrawing:e._forDrawing,skipShadow:e.skipShadow,skipStroke:e.skipStroke});n.width===0&&n.height===0||!isFinite(n.x+n.y+n.width+n.height)||(u===void 0?(u=n.x,d=n.y,f=n.x+n.width,p=n.y+n.height):(u=Math.min(u,n.x),d=Math.min(d,n.y),f=Math.max(f,n.x+n.width),p=Math.max(p,n.y+n.height)))}),m=u===void 0?{x:0,y:0,width:0,height:0}:{x:u,y:d,width:f-u,height:p-d},!r&&!l?this._transformedRect(m,i):m}};G.addComponentsGetterSetter(kh,`clip`,[`x`,`y`,`width`,`height`]),G.addGetterSetter(kh,`clipX`,void 0,eh()),G.addGetterSetter(kh,`clipY`,void 0,eh()),G.addGetterSetter(kh,`clipWidth`,void 0,eh()),G.addGetterSetter(kh,`clipHeight`,void 0,eh()),G.addGetterSetter(kh,`clipFunc`);var Ah=`Stage`,jh=`string`,Mh=`px`,Nh=`mouseout`,Ph=`mouseleave`,Fh=`mouseover`,Ih=`mouseenter`,Lh=`mousemove`,Rh=`mousedown`,zh=`mouseup`,Bh=`pointermove`,Vh=`pointerdown`,Hh=`pointerup`,Uh=`pointercancel`,Wh=`lostpointercapture`,Gh=`pointerout`,Kh=`pointerleave`,qh=`pointerover`,Jh=`pointerenter`,Yh=`contextmenu`,Xh=`touchstart`,Zh=`touchend`,Qh=`touchmove`,$h=`touchcancel`,eg=`wheel`,ree=5,iee=[[Ih,`_pointerenter`],[Rh,`_pointerdown`],[Lh,`_pointermove`],[zh,`_pointerup`],[Ph,`_pointerleave`],[Xh,`_pointerdown`],[Qh,`_pointermove`],[Zh,`_pointerup`],[$h,`_pointercancel`],[Fh,`_pointerover`],[eg,`_wheel`],[Yh,`_contextmenu`],[Vh,`_pointerdown`],[Bh,`_pointermove`],[Hh,`_pointerup`],[Uh,`_pointercancel`],[Kh,`_pointerleave`],[Wh,`_lostpointercapture`]],tg={mouse:{[Gh]:Nh,[Kh]:Ph,[qh]:Fh,[Jh]:Ih,[Bh]:Lh,[Vh]:Rh,[Hh]:zh,[Uh]:`mousecancel`,pointerclick:`click`,pointerdblclick:`dblclick`},touch:{[Gh]:`touchout`,[Kh]:`touchleave`,[qh]:`touchover`,[Jh]:`touchenter`,[Bh]:Qh,[Vh]:Xh,[Hh]:Zh,[Uh]:$h,pointerclick:`tap`,pointerdblclick:`dbltap`},pointer:{[Gh]:Gh,[Kh]:Kh,[qh]:qh,[Jh]:Jh,[Bh]:Bh,[Vh]:Vh,[Hh]:Hh,[Uh]:Uh,pointerclick:`pointerclick`,pointerdblclick:`pointerdblclick`}},ng=e=>{let t=W._getEventType(e);if(t===`pointer`)return Yp.pointerEventsEnabled&&tg.pointer;if(t===`touch`)return tg.touch;if(t===`mouse`)return tg.mouse};function rg(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&W.warn(`Stage does not support clipping. Please use clip for Layers or Groups.`),e}var aee=`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);`,ig=[],ag=new WeakSet,og=e=>{e&&!ag.has(e)&&(ag.add(e),Um._listenToWindow(e),e.document.addEventListener(`visibilitychange`,()=>{ig.forEach(e=>{e.batchDraw()})}))},sg=class extends kh{constructor(e){super(rg(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._pointerStates=new Map,this._lastClicks={},this._buildDOM(),this._bindContentEvents(),ig.push(this),this.on(`widthChange.konva heightChange.konva`,this._resizeDOM),this.on(`visibleChange.konva`,this._checkVisibility),this.on(`clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva`,()=>{rg(this.attrs)}),this._checkVisibility()}_validateAdd(e){let t=e.getType()===`Layer`,n=e.getType()===`FastLayer`;t||n||W.throw(`You may only add layers to the stage.`)}_checkVisibility(){if(!this.content)return;let e=this.visible()?``:`none`;this.content.style.display=e}_getOwnerWindow(){return(this.content||this.container())?.ownerDocument?.defaultView||(Yp.isBrowser?window:null)}setContainer(e){if(typeof e===jh){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),og(this._getOwnerWindow())),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`),kh.prototype.clone.call(this,e)}destroy(){var e;super.destroy(),this._pointerStates.clear(),this._lastClicks={};let t=this.content;(e=t?.parentNode)==null||e.removeChild(t);let n=ig.indexOf(this);return n>-1&&ig.splice(n,1),W.releaseCanvas(this.bufferHitCanvas._canvas),this}getPointerPosition(){let e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(W.warn(aee),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 Vm({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()),W.releaseCanvas(r._canvas)}),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+Mh,this.content.style.height=t+Mh),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>ree&&W.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(),Yp.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return Jm(e,this)}setPointerCapture(e){Ym(e,this)}releaseCapture(e){Zm(e,this)}getLayers(){return this.getChildren()}_bindContentEvents(){Yp.isBrowser&&iee.forEach(([e,t])=>{this.content.addEventListener(e,e=>{this._batchEvents(()=>this[t](e))},{passive:!1})})}_batchEvents(e){W._batchEvents(this.eventBatchFunc(),e)}_pointerenter(e){this.setPointersPositions(e);let t=ng(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);let t=ng(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_pointerEventsEnabled(){if(Yp.hitOnDragEnabled)return!0;for(let{node:e,dragStatus:t}of Um._dragElements.values())if(t===`dragging`&&e.getStage()===this)return!1;return!this.getLayers().some(e=>Yp.Transformer?._isLayerTransforming(e))}_cancelClick(e,t){let n=t?[t]:[`mouse`,`touch`,`pointer`];for(let t of n){let n=this._pointerStates.get(`${t}:${e}`);n&&(n.clickStartShape=void 0,n.relatedPointer&&(n.relatedPointer.clickStartShape=void 0))}}_pointerleave(e){let t=ng(e.type),n=W._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r=this._changedPointerPositions[0]?.id,i=`${n}:${r}`,a=this._pointerStates.get(i),o=(a?.targetShape)?.getStage()===this?a.targetShape:void 0,s=this._pointerEventsEnabled()||e.pointerType===`touch`&&!a?.downPosition;s&&(a?.clickStartShape===void 0?this._pointerStates.delete(i):a.targetShape=void 0),o&&s?(o._fireAndBubble(t.pointerout,{evt:e,pointerId:r}),o._fireAndBubble(t.pointerleave,{evt:e,pointerId:r}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this})):s&&(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=[],this._changedPointerPositions=[],this._pointerEventType=void 0}_pointerdown(e){let t=ng(e.type),n=W._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(i=>{let a=this.getIntersection(i),o=`${n}:${i.id}`,s={targetShape:this._pointerStates.get(o)?.targetShape,clickStartShape:a&&a.isListening()?a:null,lastClick:this._lastClicks[n],downPosition:i,pointerType:e.pointerType};if(this._pointerStates.delete(o),n!==`pointer`){for(let[e,t]of[...this._pointerStates].reverse())if(!(!e.startsWith(`pointer:`)||!t.downPosition||n===`touch`&&t.relatedPointer)&&(n===`mouse`?t.pointerType!==`touch`:t.pointerType===`touch`&&t.downPosition.x===i.x&&t.downPosition.y===i.y)){s.relatedPointer=t,t.relatedPointer=s,t.clickStartShape===void 0&&(s.clickStartShape=void 0);break}}this._pointerStates.set(o,s);for(let e of Um._dragElements.values())e.dragStatus===`dragging`&&(e.pointerId===void 0||e.pointerEventType===n&&e.pointerId===i.id||e.pointerEventType===`mouse`&&n===`pointer`&&s.pointerType!==`touch`)&&e.node.getStage()===this&&(e.pointerId===void 0&&n!==`pointer`&&(e.pointerId=i.id,e.pointerEventType=n),this._cancelClick(i.id,n));if(!a||!a.isListening())return;Yp.capturePointerEventsEnabled&&a.setPointerCapture(i.id),a._fireAndBubble(t.pointerdown,{evt:e,pointerId:i.id}),r=!0;let c=e.type.indexOf(`touch`)>=0;a.preventDefault()&&e.cancelable&&c&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointermove(e){let t=ng(e.type),n=W._getEventType(e.type);if(!t)return;let r=e.type.indexOf(`touch`)>=0||e.pointerType===`touch`;if(e.cancelable&&r){for(let{node:t,dragStatus:n}of Um._dragElements.values())if(n===`dragging`&&t.getStage()===this&&t.preventDefault()){e.preventDefault();break}}if(this.setPointersPositions(e),!this._pointerEventsEnabled())return;let i={},a=!1;this._changedPointerPositions.forEach(r=>{let o=`${n}:${r.id}`,s=this._pointerStates.get(o);s||(s={},this._pointerStates.set(o,s));let c=Km(r.id)||this.getIntersection(r),l=s.targetShape===c||s.targetShape?.getStage()===this?s.targetShape:void 0,u=r.id,d={evt:e,pointerId:u},f=l!==c;s.targetShape=c&&c.isListening()?c:void 0,f&&l&&(l._fireAndBubble(t.pointerout,{...d},c),l._fireAndBubble(t.pointerleave,{...d},c)),c&&c.isListening()?(a=!0,f&&(c._fireAndBubble(t.pointerover,{...d},l),c._fireAndBubble(t.pointerenter,{...d},l)),i[c._id]||(i[c._id]=!0,c._fireAndBubble(t.pointermove,{...d}))):l&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:u})}),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){let t=ng(e.type),n=W._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r={},i=!1;this._changedPointerPositions.forEach(a=>{let o=`${n}:${a.id}`,s=this._pointerStates.get(o),c=s?.clickStartShape!==void 0,l=s?.clickStartShape;s?.targetShape&&n!==`touch`?this._pointerStates.set(o,{targetShape:s.targetShape}):this._pointerStates.delete(o);let u=Km(a.id)||this.getIntersection(a),d=u&&r[u._id];u&&(u.releaseCapture(a.id),r[u._id]=!0);let f=a.id,p={evt:e,pointerId:f},m=u&&u.isListening()?u:null,h=this._lastClicks[n],g=c&&(!m||l===m),_=g&&h&&s?.lastClick===h&&h.shape===m&&Date.now()-h.time<Yp.dblClickWindow;g&&(this._lastClicks[n]=_?void 0:{shape:m,time:Date.now()}),u&&u.isListening()?(i=!0,d||u._fireAndBubble(t.pointerup,{...p}),c&&l===u&&(u._fireAndBubble(t.pointerclick,{...p}),_&&u._fireAndBubble(t.pointerdblclick,{...p}))):(i||=(this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),!0),c&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:f}),_&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:f})),n===`touch`&&(s?.targetShape)?.getStage()===this&&(s.targetShape._fireAndBubble(t.pointerout,{...p}),s.targetShape._fireAndBubble(t.pointerleave,{...p}))}),i||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),e.cancelable&&n!==`touch`&&n!==`pointer`&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(Yh,{evt:e}):this._fire(Yh,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(eg,{evt:e}):this._fire(eg,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);let t=ng(e.type);this._changedPointerPositions.forEach(n=>{let r=W._getEventType(e.type),i=`${r}:${n.id}`;this._cancelClick(n.id,r);let a=this._pointerStates.get(i)?.targetShape;a&&r!==`touch`?this._pointerStates.set(i,{targetShape:a}):this._pointerStates.delete(i);let o=Km(n.id)||this.getIntersection(n),s={evt:e,pointerId:n.id};o?(t&&o._fireAndBubble(t.pointercancel,{...s}),o._fireAndBubble(Hh,{...s})):t&&this._fire(t.pointercancel,{...s,target:this,currentTarget:this}),Zm(n.id),t&&r===`touch`&&a?.getStage()===this&&(a._fireAndBubble(t.pointerout,{...s}),a._fireAndBubble(t.pointerleave,{...s}))})}_lostpointercapture(e){Km(e.pointerId,this)&&Zm(e.pointerId)}setPointersPositions(e){let t=this._getContentPosition(),n=null,r=null;e||=window.event,e.touches===void 0?(this._pointerEventType=e.pointerId===void 0?`mouse`:`pointer`,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:W._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:W._getFirstPointerId(e)}]):(this._pointerEventType=`touch`,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){W.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.bufferHitCanvas=new Hm({pixelRatio:1,width:0,height:0}),!Yp.isBrowser)return;let e=this.container();if(!e)throw`Stage has no container. A container is required.`;e.innerHTML=``,this.content=e.ownerDocument.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),og(this._getOwnerWindow()),this._resizeDOM()}cache(){return W.warn(`Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.`),this}clearCache(){return this}batchDraw(){var e;return(e=this.children)==null||e.forEach(function(e){e.batchDraw()}),this}};sg.prototype.nodeType=Ah,Zp(sg),G.addGetterSetter(sg,`container`),G.addGetterSetter(sg,`eventBatchFunc`);var oee=`hasShadow`,see=`hasFill`,cee=`hasStroke`,lee=`shadowRGBA`,uee=`patternImage`,dee=`linearGradient`,fee=`radialGradient`,cg;function lg(){return cg||(cg=W.createCanvasElement().getContext(`2d`),cg)}var ug={};function pee(e){let t=this.attrs.fillRule;t?e.fill(t):e.fill()}function mee(e){e.stroke()}function hee(){this._clearCache(oee)}function gee(){this._clearCache(see)}function _ee(){this._clearCache(cee)}function vee(){this._clearCache(lee)}function yee(){this._clearCache(uee)}function bee(){this._clearCache(dee)}function xee(){this._clearCache(fee)}var dg=class e extends Dh{constructor(e){super(e);let t,n=0;for(;t=W.getHitColor(),!t||t in ug;)if(n++,n>=1e4){W.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=W.getRandomColor();break}this.colorKey=t,ug[t]=this}getContext(){return W.warn(`shape.getContext() method is deprecated. Please do not use it.`),this.getLayer().getContext()}getCanvas(){return W.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(oee,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(uee,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){let e=lg().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||`repeat`);if(e&&e.setTransform){let t=new em;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(Yp.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(dee,this.__getLinearGradient)}__getLinearGradient(){let e=this.fillLinearGradientColorStops();if(e){let t=lg(),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(fee,this.__getRadialGradient)}__getRadialGradient(){let e=this.fillRadialGradientColorStops();if(e){let t=lg(),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(lee,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;let e=W.colorToRGBA(this.shadowColor());if(e)return`rgba(`+e.r+`,`+e.g+`,`+e.b+`,`+e.a*(this.shadowOpacity()||1)+`)`}hasFill(){return this._getCache(see,this._hasFill)}_hasFill(){return this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())}hasStroke(){return this._getCache(cee,this._hasStroke)}_hasStroke(){return 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.setSizeIfChanged(t.width(),t.height()),n.getContext().clear(),this.drawHit(n),n.context.getImageData(Math.floor(e.x),Math.floor(e.y),1,1).data[3]>0}destroy(){return Dh.prototype.destroy.call(this),delete ug[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(!(this.attrs.perfectDrawEnabled??!0))return!1;let n=e||this.hasFill(),r=this.hasStroke(),i=!this._isUnderCache&&t!==1;if(n&&r&&i)return!0;let a=this.hasShadow(),o=this.shadowForStrokeEnabled();return!!(n&&r&&a&&o)}setStrokeHitEnabled(e){W.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.attrs.selfRectFunc;if(e)return{...e.call(this,this)};let t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}_getSelfRectForDrawing(){return this.getSelfRect()}getClientRect(e={}){let t=this._getCachedSceneRect(e);if(t)return t;let n=e.skipTransform,r=e.relativeTo,i=e._forDrawing,a=i?this.strokeScaleEnabled()?new em()._getTransformedRect(this._getSelfRectForDrawing()):this._transformedRect(this._getSelfRectForDrawing(),r):this.getSelfRect(),o=!e.skipStroke&&this.hasStroke()?i?this._getStrokePadding()*2:this.strokeWidth():0,s=o,c=o,l;if(!i&&o&&!this.strokeScaleEnabled()){let e=this;for(;e&&!e.isCached()&&!e._isUnderCache;)e=e.parent;let[t,i,a,o]=this.getAbsoluteTransform(e).getMatrix(),u=Math.abs(t*o-i*a);if(u)s*=Math.hypot(a,o)/u,c*=Math.hypot(t,i)/u;else if(!n&&(s=c=0,l=e?e.getAbsoluteTransform().copy():new em,r)){let e=r.getAbsoluteTransform(),[t,n,i,a]=e.getMatrix();l=t*a-n*i?e.copy().invert().multiply(l):new em}}let u={x:a.x-s/2,y:a.y-c/2,width:a.width+s,height:a.height+c};if(i&&this.strokeScaleEnabled()&&(u=this._transformedRect(u,r)),!e.skipShadow&&this.hasShadow()){let e=i?this.getAbsoluteScale():{x:1,y:1},t=this.shadowOffsetX()*e.x,n=this.shadowOffsetY()*e.y,r=this.shadowBlur()*(i?2*Math.min(Math.abs(e.x),Math.abs(e.y)):1);u.x+=Math.min(0,t)-r,u.y+=Math.min(0,n)-r,u.width+=Math.abs(t)+r*2,u.height+=Math.abs(n)+r*2}if(i)return u;if(!n){let e=this._transformedRect(u,r);if(l){let[t,n,r,i]=l.getMatrix(),a=o*Math.hypot(t,r)/2,s=o*Math.hypot(n,i)/2;e.x-=a,e.y-=s,e.width+=a*2,e.height+=s*2}return e}return u}_getStrokePadding(e=this.miterLimit()||10){return this.attrs.sceneFunc&&(e=this.miterLimit()||10),Math.abs(this.strokeWidth())/2*Math.max(this.lineCap()===`square`?Math.SQRT2:1,(this.lineJoin()||`miter`)===`miter`?e:1)}drawScene(t,n){let r=this.getLayer(),i=t||r.getCanvas(),a=i.getContext(),o=this._getCanvasCache(),s=this.getSceneFunc(),c=this.hasShadow(),l=n===this;if(!(n?this._isVisible(n):this.isVisible())&&!l)return this;if(o){a.save();let e=this.getAbsoluteTransform(n).getMatrix();return a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(a),a.restore(),this}if(!s)return this;a.save();try{if(i.width&&i.height&&this._useBufferCanvas(void 0,a._getOpacity(this))){let t=!!a._opacityRoot||!!this.attrs.selfRectFunc&&this.getSelfRect===e.prototype.getSelfRect||!this.attrs.sceneFunc&&!this.attrs.charRenderFunc&&Xp.has(this.constructor),r=i._prepareIsolationCanvas(t?this.getClientRect({_forDrawing:!0,relativeTo:n,skipShadow:!0}):void 0),o=r.getContext();o.save(),o._applyLineJoin(this),o._applyMiterLimit(this);let u=this.getAbsoluteTransform(n).getMatrix();o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),s.call(this,o,this),o.restore(),c&&a._applyShadow(this),l||(a._applyOpacity(this),a._applyGlobalCompositeOperation(this)),a._drawDeviceBuffer(r)}else{if(a._applyLineJoin(this),a._applyMiterLimit(this),!l){let e=this.getAbsoluteTransform(n).getMatrix();a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),a._applyOpacity(this),a._applyGlobalCompositeOperation(this)}c&&a._applyShadow(this),s.call(this,a,this)}}catch(e){throw i._releaseIsolationCanvas(),e}finally{a.restore()}return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let n=this.getLayer(),r=e||n.hitCanvas,i=r&&r.getContext(),a=this.hitFunc()||this.sceneFunc(),o=this._getCachedHitCanvas(t);if(this.colorKey||W.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()`),o){i.save();let e=this.getAbsoluteTransform(t).getMatrix();return i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(i,o),i.restore(),this}if(!a)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5])}try{a.call(this,i,this)}finally{i.restore()}return this}drawHitFromCache(e=0){let t=this._getCachedSceneCanvas(),n=this._getCachedHitCanvas(),r=n.getContext(),i=n.getWidth(),a=n.getHeight();r.clear(),r.drawImage(t._canvas,0,0,i/n.pixelRatio,a/n.pixelRatio);try{let t=r.getImageData(0,0,i,a),n=t.data,o=n.length,s=W._hexToRgb(this.colorKey);for(let t=0;t<o;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;r.putImageData(t,0,0)}catch(e){W.error(`Unable to draw hit graph from cached scene canvas. `+e.message)}return this}hasPointerCapture(e){return Jm(e,this)}setPointerCapture(e){Ym(e,this)}releaseCapture(e){Zm(e,this)}};dg.prototype._fillFunc=pee,dg.prototype._strokeFunc=mee,dg.prototype._fillFuncHit=pee,dg.prototype._strokeFuncHit=mee,dg.prototype._centroid=!1,dg.prototype.nodeType=`Shape`,Zp(dg),dg.prototype.on(`shadowColorChange.konva shadowBlurChange.konva shadowOffsetXChange.konva shadowOffsetYChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,hee),dg.prototype.on(`shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,vee),dg.prototype.on(`fillEnabledChange.konva fillChange.konva fillPatternImageChange.konva fillLinearGradientColorStopsChange.konva fillRadialGradientColorStopsChange.konva`,gee),dg.prototype.on(`strokeEnabledChange.konva strokeWidthChange.konva strokeChange.konva strokeLinearGradientColorStopsChange.konva`,_ee),dg.prototype.on(`fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva`,yee),dg.prototype.on(`fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva`,bee),dg.prototype.on(`fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva`,xee),G.addGetterSetter(dg,`stroke`,void 0,ih()),G.addGetterSetter(dg,`strokeWidth`,2,eh()),G.addGetterSetter(dg,`fillAfterStrokeEnabled`,!1),G.addGetterSetter(dg,`hitStrokeWidth`,`auto`,nh()),G.addGetterSetter(dg,`strokeHitEnabled`,!0,oh()),G.addGetterSetter(dg,`perfectDrawEnabled`,!0,oh()),G.addGetterSetter(dg,`shadowForStrokeEnabled`,!0,oh()),G.addGetterSetter(dg,`lineJoin`),G.addGetterSetter(dg,`lineCap`),G.addGetterSetter(dg,`miterLimit`),G.addGetterSetter(dg,`sceneFunc`),G.addGetterSetter(dg,`hitFunc`),G.addGetterSetter(dg,`selfRectFunc`),G.addGetterSetter(dg,`dash`),G.addGetterSetter(dg,`dashOffset`,0,eh()),G.addGetterSetter(dg,`shadowColor`,void 0,rh()),G.addGetterSetter(dg,`shadowBlur`,0,eh()),G.addGetterSetter(dg,`shadowOpacity`,1,eh()),G.addComponentsGetterSetter(dg,`shadowOffset`,[`x`,`y`]),G.addGetterSetter(dg,`shadowOffsetX`,0,eh()),G.addGetterSetter(dg,`shadowOffsetY`,0,eh()),G.addGetterSetter(dg,`fillPatternImage`),G.addGetterSetter(dg,`fill`,void 0,ih()),G.addGetterSetter(dg,`fillPatternX`,0,eh()),G.addGetterSetter(dg,`fillPatternY`,0,eh()),G.addGetterSetter(dg,`fillLinearGradientColorStops`),G.addGetterSetter(dg,`strokeLinearGradientColorStops`),G.addGetterSetter(dg,`fillRadialGradientStartRadius`,0),G.addGetterSetter(dg,`fillRadialGradientEndRadius`,0),G.addGetterSetter(dg,`fillRadialGradientColorStops`),G.addGetterSetter(dg,`fillPatternRepeat`,`repeat`),G.addGetterSetter(dg,`fillEnabled`,!0),G.addGetterSetter(dg,`strokeEnabled`,!0),G.addGetterSetter(dg,`shadowEnabled`,!0),G.addGetterSetter(dg,`dashEnabled`,!0),G.addGetterSetter(dg,`strokeScaleEnabled`,!0),G.addGetterSetter(dg,`fillPriority`,`color`),G.addComponentsGetterSetter(dg,`fillPatternOffset`,[`x`,`y`]),G.addGetterSetter(dg,`fillPatternOffsetX`,0,eh()),G.addGetterSetter(dg,`fillPatternOffsetY`,0,eh()),G.addComponentsGetterSetter(dg,`fillPatternScale`,[`x`,`y`]),G.addGetterSetter(dg,`fillPatternScaleX`,1,eh()),G.addGetterSetter(dg,`fillPatternScaleY`,1,eh()),G.addComponentsGetterSetter(dg,`fillLinearGradientStartPoint`,[`x`,`y`]),G.addComponentsGetterSetter(dg,`strokeLinearGradientStartPoint`,[`x`,`y`]),G.addGetterSetter(dg,`fillLinearGradientStartPointX`,0),G.addGetterSetter(dg,`strokeLinearGradientStartPointX`,0),G.addGetterSetter(dg,`fillLinearGradientStartPointY`,0),G.addGetterSetter(dg,`strokeLinearGradientStartPointY`,0),G.addComponentsGetterSetter(dg,`fillLinearGradientEndPoint`,[`x`,`y`]),G.addComponentsGetterSetter(dg,`strokeLinearGradientEndPoint`,[`x`,`y`]),G.addGetterSetter(dg,`fillLinearGradientEndPointX`,0),G.addGetterSetter(dg,`strokeLinearGradientEndPointX`,0),G.addGetterSetter(dg,`fillLinearGradientEndPointY`,0),G.addGetterSetter(dg,`strokeLinearGradientEndPointY`,0),G.addComponentsGetterSetter(dg,`fillRadialGradientStartPoint`,[`x`,`y`]),G.addGetterSetter(dg,`fillRadialGradientStartPointX`,0),G.addGetterSetter(dg,`fillRadialGradientStartPointY`,0),G.addComponentsGetterSetter(dg,`fillRadialGradientEndPoint`,[`x`,`y`]),G.addGetterSetter(dg,`fillRadialGradientEndPointX`,0),G.addGetterSetter(dg,`fillRadialGradientEndPointY`,0),G.addGetterSetter(dg,`fillPatternRotation`,0),G.addGetterSetter(dg,`fillRule`,void 0,rh()),G.backCompat(dg,{dashArray:`dash`,getDashArray:`getDash`,setDashArray:`setDash`,drawFunc:`sceneFunc`,getDrawFunc:`getSceneFunc`,setDrawFunc:`setSceneFunc`,drawHitFunc:`hitFunc`,getDrawHitFunc:`getHitFunc`,setDrawHitFunc:`setHitFunc`});var See=`beforeDraw`,Cee=`draw`,wee=10,fg=256;function pg(e,t){return e[t+3]>=128?ug[W.getHitColorKey(e[t],e[t+1],e[t+2])]:void 0}var mg=class extends kh{constructor(e){super(e),this.canvas=new Vm,this.hitCanvas=new Hm({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(){Dh.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(!Dh.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(Dh.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(Dh.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(){var e,t;super.remove();let n=this.getNativeCanvasElement(),r=this.getHitCanvas()._canvas;return(e=n.parentNode)==null||e.removeChild(n),(t=r.parentNode)==null||t.removeChild(r),this}getStage(){return this.parent}_setSize({width:e,height:t}){return this.canvas.setSize(e,t),this._syncHitCanvasSize(),this._setSmoothEnabled(),this}_syncHitCanvasSize(){let e=this.isListening();this.hitCanvas.setSizeIfChanged((e?this.getWidth():0)||0,(e?this.getHeight():0)||0)}_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&W.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,Dh.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(){W.warn(`Can not change width of layer. Use "stage.width(value)" function instead.`)}getHeight(){if(this.parent)return this.parent.height()}setHeight(){W.warn(`Can not change height of layer. Use "stage.height(value)" function instead.`)}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,W.requestAnimFrame(()=>{this._waitingForDraw=!1,this.draw()},this.getStage()?._getOwnerWindow())),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=this._getIntersection(e);if(t.shape)return t.shape;if(!t.antialiased)return null;let n=this.hitCanvas.pixelRatio,r=Math.floor(e.x*n),i=Math.floor(e.y*n),a=e=>this.hitCanvas.context.getImageData(r-e,i-e,e*2+1,e*2+1).data,o=wee,s=o*2+1,c=a(o),l=c[(o*s+o)*4+3];for(let e=1;e<=fg;e++){e>o&&(o=Math.min(fg,o*2),s=o*2+1,c=a(o));let t=0;for(let n=-e;n<=e;n++){let r=Math.abs(n)===e?1:e*2;for(let i=-e;i<=e;i+=r){let e=((n+o)*s+i+o)*4,r=pg(c,e);if(r)return r;t=Math.max(t,c[e+3])}}if(t<=l&&t!==255)return null;l=t}return null}_getIntersection(e){if(!this.hitCanvas.width||!this.hitCanvas.height)return{};let t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.floor(e.x*t),Math.floor(e.y*t),1,1).data,r=pg(n,0);return r?{shape:r}:n[3]>0?{antialiased:!0}:{}}drawScene(e,t){let n=this.getLayer(),r=e||n&&n.getCanvas();return this._fire(See,{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),kh.prototype.drawScene.call(this,r,t),r._trimIsolationCanvas(),this._fire(Cee,{node:this}),this}shouldDrawHit(e){if(!super.shouldDrawHit(e))return!1;if(e||Yp.hitOnDragEnabled)return!0;let t=!1;return Um._dragElements.forEach(e=>{e.dragStatus===`dragging`&&(e.node===this.getStage()||e.node.getLayer()===this)&&(t=!0)}),!t&&!Yp.Transformer?._isLayerTransforming(this)}drawHit(e,t){let n=this.getLayer(),r=e||n&&n.hitCanvas;return!e&&n&&(n._syncHitCanvasSize(),n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear()),kh.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){W.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening(e)}getHitGraphEnabled(e){return W.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 this.getCanvas()._releaseIsolationCanvas(),W.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};mg.prototype.nodeType=`Layer`,Zp(mg),G.addGetterSetter(mg,`imageSmoothingEnabled`,!0),G.addGetterSetter(mg,`clearBeforeDraw`,!0),G.addOverloadedGetterSetter(mg,`hitGraphEnabled`);var hg=class extends mg{constructor(e){super(e),this.listening(!1),W.warn(`Konva.FastLayer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.`)}};hg.prototype.nodeType=`FastLayer`,Zp(hg);var gg=class extends kh{_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&W.throw(`You may only add groups and shapes to groups.`)}_drawChildNodes(e,t,n){if(e!==`drawScene`||!this.isolated()||n===this)return super._drawChildNodes(e,t,n);if(!t.width||!t.height)return;let r=t.getContext(),i=t._prepareIsolationCanvas(this.getClientRect({_forDrawing:!0,relativeTo:n})),a=i.getContext();a._opacityRoot=this,r.save();try{super._drawChildNodes(e,i,n),r._applyOpacity(this),r._drawDeviceBuffer(i)}catch(e){throw t._releaseIsolationCanvas(),e}finally{r.restore(),a._opacityRoot=void 0}}};G.addGetterSetter(gg,`isolated`,!1,oh()),gg.prototype.nodeType=`Group`,Zp(gg);var _g=Jp.performance?.now?()=>Jp.performance.now():Date.now,vg=class e{constructor(t,n){this.id=e.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:_g(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(e){return this.layers=e?[].concat(e):[],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(){return e.animations.has(this)}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=_g(),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.add(e),this._handleAnimation()}static _removeAnimation(e){this.animations.delete(e)}static _runFrames(){let e=new Set;Array.from(this.animations).forEach(t=>{this.animations.has(t)&&(t._updateFrameObject(_g()),!(t.func&&t.func.call(t,t.frame)===!1)&&t.layers.forEach(t=>t&&e.add(t)))}),e.forEach(e=>e.batchDraw())}static _animationLoop(){let t=e;t.animations.size?(t._runFrames(),W.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,W.requestAnimFrame(this._animationLoop))}};vg.animations=new Set,vg.animIdCounter=0,vg.animRunning=!1;var Tee={node:1,duration:1,easing:1,onFinish:1,onUpdate:1,onReset:1,yoyo:1},Eee=1,yg=2,bg=3,xg=[`fill`,`stroke`,`shadowColor`],Dee=0;function Sg(e){return W.colorToRGBA(e)||W.throw(`can not tween the color "`+e+`", because it is not a valid color.`)}function Cg(e,t){return{r:t.r-e.r,g:t.g-e.g,b:t.b-e.b,a:t.a-e.a}}function wg(e,t,n){return`rgba(`+Math.round(e.r+t.r*n)+`,`+Math.round(e.g+t.g*n)+`,`+Math.round(e.b+t.b*n)+`,`+(e.a+t.a*n)+`)`}var Oee=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=yg,this._startTime=this.getTimer()-this._time,this.fire(`onPlay`),this.onEnterFrame()}reverse(){this.state=bg,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.fire(`onReverse`),this.onEnterFrame()}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===yg?this.setTime(e):this.state===bg&&this.setTime(this.duration-e)}pause(){this.state=Eee,this.fire(`onPause`)}getTimer(){return Date.now()}},Tg=class e{constructor(t){let n=this,r=t.node,i=r._id,a=t.easing||Eg.Linear,o=!!t.yoyo,s,c;s=t.duration===void 0?.3:t.duration===0?.001:t.duration,this.node=r,this._id=Dee++;let l=r.getLayer()||(r instanceof Yp.Stage?r.getLayers():null);for(c in l||W.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new vg(function(){n.tween.onEnterFrame()},l),this.tween=new Oee(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)Tee[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){if(W._isPlainObject(n)){for(let e in n)this._addAttr(t+W._capitalize(e),n[e]);return}let r=this.node,i=r._id,a,o,s,c,l=e.tweens[i][t];l!==void 0&&delete e.attrs[i][l][t];let u=r.getAttr(t);if(W._isArray(n)||W._isArray(u)){if(a=[],c=u,s=n,u=W._isArray(u)?u.slice():Array(n.length).fill(u||0),W._isArray(n)||(n=Array(u.length).fill(n)),o=Math.max(n.length,u.length),t===`points`&&n.length!==u.length&&(n.length>u.length?u=W._prepareArrayForTween(u,n,r.closed()):n=W._prepareArrayForTween(n,u,r.closed())),t.endsWith(`ColorStops`))for(let e=0;e<o;e++)if(e%2==0)a.push((n[e]||0)-(u[e]||0));else{let t=Sg(u[e]);u[e]=t,a.push(Cg(t,Sg(n[e])))}else for(let e=0;e<o;e++)a.push((n[e]||0)-(u[e]||0))}else xg.indexOf(t)===-1?a=n-u:(u=Sg(u),a=Cg(u,Sg(n)));e.attrs[i][this._id][t]={start:u,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,W._isArray(o)){if(c=[],u=Math.max(o.length,d.length),i.endsWith(`ColorStops`))for(l=0;l<u;l++)l%2==0?c.push((o[l]||0)+s[l]*t):c.push(wg(o[l],s[l],t));else for(l=0;l<u;l++)c.push((o[l]||0)+s[l]*t)}else c=xg.indexOf(i)===-1?o+s*t:wg(o,s,t);n.setAttr(i,c)}}_addListeners(){let t=`destroy.konva-tween${this._id}`,n=()=>this.destroy(),r=()=>{this.node.off(t).on(t,n),this.anim.start()};this.tween.onPlay=r,this.tween.onReverse=r,this.tween.onPause=()=>{this.node.off(t),this.anim.stop()};let i=(t,n)=>{let r=e.attrs[this.node._id]?.[this._id];if(r){for(let e in r)r[e][t]!==void 0&&this.node.setAttr(e,r[e][t]);n?.call(this)}};this.tween.onFinish=()=>i(`trueEnd`,this.onFinish),this.tween.onReset=()=>i(`trueStart`,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.attrs[t]?.[n],i=e.tweens[t];if(this.pause(),this.anim&&this.anim.stop(),r){if(i){for(let e in r)delete i[e];Object.keys(i).length===0&&delete e.tweens[t]}delete e.attrs[t][n],Object.keys(e.attrs[t]).length===0&&delete e.attrs[t]}}};Tg.attrs={},Tg.tweens={},Dh.prototype.to=function(e){let t=e.onFinish,n=new Tg({...e,node:this,onFinish(){n.destroy(),t&&t()}});return n.play(),n};var Eg={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-Eg.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?Eg.BounceEaseIn(e*2,0,n,r)*.5+t:Eg.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}},Dg=W._assign(Yp,{Util:W,Transform:em,Node:Dh,Container:kh,Stage:sg,stages:ig,Layer:mg,FastLayer:hg,Group:gg,DD:Um,Shape:dg,shapes:ug,Animation:vg,Tween:Tg,Easings:Eg,Context:Lm,Canvas:Bm}),Og=class extends dg{_sceneFunc(e){let t=Yp.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,Math.abs(this.outerRadius()),0,t,n),e.arc(0,0,Math.abs(this.innerRadius()),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.outerRadius())*2}getHeight(){return Math.abs(this.outerRadius())*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){let e=Math.abs(this.innerRadius()),t=Math.abs(this.outerRadius()),n=Math.min(e,t),r=Math.max(e,t),i=this.clockwise(),a=Yp.getAngle(this.angle());if(a%(Math.PI*2)==0)return a===0?{x:n,y:0,width:r-n,height:0}:{x:-r,y:-r,width:r*2,height:r*2};let o=Math.PI*2,s=i?-a:a,c=s>=o?o:(s%o+o)%o,l=Math.cos(Math.min(c,Math.PI)),u=Math.sin(Math.min(Math.max(Math.PI,c),3*Math.PI/2)),d=Math.sin(Math.min(c,Math.PI/2)),f=l*(l>0?n:r),p=1*r,m=u*(u>0?n:r),h=d*(d>0?r:n);return{x:f,y:i?-1*h:m,width:p-f,height:h-m}}};Og.prototype._centroid=!0,Og.prototype.className=`Arc`,Og.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`,`angle`,`clockwise`],Zp(Og,!0),G.addGetterSetter(Og,`innerRadius`,0,eh()),G.addGetterSetter(Og,`outerRadius`,0,eh()),G.addGetterSetter(Og,`angle`,0,eh()),G.addGetterSetter(Og,`clockwise`,!1,oh());var kg=[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],kee=[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],Ag=(e,t,n)=>{let r=n/2,i=0;for(let n=0;n<kg.length;n++){let a=r*kg[n]+r;i+=kee[n]*Aee(e,t,a)}return r*i},jg=(e,t,n=1)=>Ag([e[0],e[0]+2/3*(e[1]-e[0]),e[2]+2/3*(e[1]-e[2]),e[2]],[t[0],t[0]+2/3*(t[1]-t[0]),t[2]+2/3*(t[1]-t[2]),t[2]],n);function Aee(e,t,n){let r=1-n,i=r*r,a=2*r*n,o=n*n,s=i*(3*(e[1]-e[0]))+a*(3*(e[2]-e[1]))+o*(3*(e[3]-e[2])),c=i*(3*(t[1]-t[0]))+a*(3*(t[2]-t[1]))+o*(3*(t[3]-t[2]));return Math.sqrt(s*s+c*c)}var Mg=(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},Ng=(e,t,n,r)=>{let i=1-r;return i*i*e+2*i*r*t+r*r*n},Pg=(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(Ng(e,n,i,c),Ng(t,r,a,c))}return o},Fg=(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},Ig=(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(Fg(e,n,i,o,l),Fg(t,r,a,s,l))}return c};function Lg(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 Rg(e,t){let n=e.length,r=[];for(let i=2;i<n-2;i+=2){let n=Lg(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 jee(e){let t=[];for(let n=0;n+7<e.length;n+=6)t.push(e[n+6],e[n+7],...Ig(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 zg=class extends dg{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])}_getStrokePadding(e=this.points().length===4&&!this.closed()?1:void 0){return super._getStrokePadding(e)}_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():Rg(this.points(),this.tension())}_getTensionPointsClosed(){let e=this.points(),t=e.length,n=this.tension(),r=Lg(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),i=Lg(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),a=Rg(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,...Pg(e,n,r,i,a,o)),(e,n,r,i,a,o,s,c)=>t.push(s,c,...Ig(e,n,r,i,a,o,s,c))),e=t}else this.bezier()&&(e=[e[0],e[1],...jee(e)]);return W._getPointsRect(e)}};zg.prototype.className=`Line`,zg.prototype._attrsAffectingSize=[`points`,`bezier`,`tension`,`closed`],Zp(zg,!0),G.addGetterSetter(zg,`closed`,!1),G.addGetterSetter(zg,`bezier`,!1),G.addGetterSetter(zg,`tension`,0,eh()),G.addGetterSetter(zg,`points`,[],ah());var Mee={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7,z:0},Bg=Math.PI*2,Vg=class e extends dg{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`:e.ellipse(a[0],a[1],a[2],a[3],a[6],a[4],a[4]+a[5],!a[7]);break;case`z`:n=!0,e.closePath()}}!n&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=[];return this.dataArray.forEach(function(n){if(n.command===`A`){let[r,i,a,o,s,c,l]=n.points,u=Math.cos(l),d=Math.sin(l),f=e.getPointOnEllipticalArc(r,i,a,o,s+c,l);t.push(n.start.x,n.start.y,f.x,f.y);let p=Math.atan2(-o*d,a*u),m=Math.atan2(o*u,a*d);[p,p+Math.PI,m,m+Math.PI].forEach(n=>{if(((n-s)*Math.sign(c)%Bg+Bg)%Bg<Math.abs(c)){let s=e.getPointOnEllipticalArc(r,i,a,o,n,l);t.push(s.x,s.y)}})}else n.command===`C`?t.push(n.start.x,n.start.y,n.points[4],n.points[5],...Ig(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],...Pg(n.start.x,n.start.y,n.points[0],n.points[1],n.points[2],n.points[3])):t.push(...n.points)}),W._getPointsRect(t)}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,r){let i,a=r?.index??0,o=r?.offset??0,s=n.length;if(!s)return null;for(;a>0&&t<=o;)o-=n[--a].pathLength;for(t-=o;a<s&&t>n[a].pathLength;){let e=n[a].pathLength;t-=e,o+=e,++a}if(r&&a<s&&(r.index=a,r.offset=o),a===s&&(a--,t=n[a].pathLength),t<.01)return n[a].command===`M`?(i=n[a].points.slice(0,2),{x:i[0],y:i[1]}):{x:n[a].start.x,y:n[a].start.y};let c=n[a],l=c.points;switch(c.command){case`L`:case`z`:return e.getPointOnLine(t,c.start.x,c.start.y,l[0],l[1]);case`C`:return e.getPointOnCubicBezier(Mg(t,c.pathLength,e=>Ag([c.start.x,l[0],l[2],l[4]],[c.start.y,l[1],l[3],l[5]],e)),c.start.x,c.start.y,l[0],l[1],l[2],l[3],l[4],l[5]);case`Q`:return e.getPointOnQuadraticBezier(Mg(t,c.pathLength,e=>jg([c.start.x,l[0],l[2]],[c.start.y,l[1],l[3]],e)),c.start.x,c.start.y,l[0],l[1],l[2],l[3]);case`A`:return e.getPointOnEllipticalArc(l[0],l[1],l[2],l[3],l[2]===l[3]?l[4]+l[5]*t/c.pathLength:e._walkArc(l,t).theta,l[6])}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=0,l=0,u=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,d;for(let e=1;e<r.length;e++){let t=r[e],n=t.charAt(0);for(t=t.slice(1),a.length=0;d=u.exec(t);)a.push(d[0]);let f=[],p=n===`A`||n===`a`?0:-1;for(let e=0,t=a.length;e<t;e++){let t=a[e];for(;(p===3||p===4)&&t.length>1&&(t[0]===`0`||t[0]===`1`);)f.push(+t[0]),p++,t=t.slice(1);let n=parseFloat(t);f.push(isNaN(n)?0:n),p>=0&&(p=(p+1)%7)}let m=0;for(;m<f.length&&!(f.length-m<Mee[n.toLowerCase()]||n===`z`||n===`Z`);){let e=``,t=[],r=o,a=s,u,d,p,h,g,_,v,y,b,x;switch(n){case`l`:o+=f[m++],s+=f[m++],e=`L`,t.push(o,s);break;case`L`:o=f[m++],s=f[m++],t.push(o,s);break;case`m`:o+=f[m++],s+=f[m++],e=`M`,c=o,l=s,t.push(o,s),n=`l`;break;case`M`:o=f[m++],s=f[m++],e=`M`,c=o,l=s,t.push(o,s),n=`L`;break;case`h`:o+=f[m++],e=`L`,t.push(o,s);break;case`H`:o=f[m++],e=`L`,t.push(o,s);break;case`v`:s+=f[m++],e=`L`,t.push(o,s);break;case`V`:s=f[m++],e=`L`,t.push(o,s);break;case`C`:t.push(f[m++],f[m++],f[m++],f[m++]),o=f[m++],s=f[m++],t.push(o,s);break;case`c`:t.push(o+f[m++],s+f[m++],o+f[m++],s+f[m++]),o+=f[m++],s+=f[m++],e=`C`,t.push(o,s);break;case`S`:d=o,p=s,u=i[i.length-1],u?.command===`C`&&(d=o+(o-u.points[2]),p=s+(s-u.points[3])),t.push(d,p,f[m++],f[m++]),o=f[m++],s=f[m++],e=`C`,t.push(o,s);break;case`s`:d=o,p=s,u=i[i.length-1],u?.command===`C`&&(d=o+(o-u.points[2]),p=s+(s-u.points[3])),t.push(d,p,o+f[m++],s+f[m++]),o+=f[m++],s+=f[m++],e=`C`,t.push(o,s);break;case`Q`:t.push(f[m++],f[m++]),o=f[m++],s=f[m++],t.push(o,s);break;case`q`:t.push(o+f[m++],s+f[m++]),o+=f[m++],s+=f[m++],e=`Q`,t.push(o,s);break;case`T`:d=o,p=s,u=i[i.length-1],u?.command===`Q`&&(d=o+(o-u.points[0]),p=s+(s-u.points[1])),o=f[m++],s=f[m++],e=`Q`,t.push(d,p,o,s);break;case`t`:d=o,p=s,u=i[i.length-1],u?.command===`Q`&&(d=o+(o-u.points[0]),p=s+(s-u.points[1])),o+=f[m++],s+=f[m++],e=`Q`,t.push(d,p,o,s);break;case`A`:case`a`:if(h=Math.abs(f[m++]),g=Math.abs(f[m++]),_=f[m++],v=f[m++],y=f[m++],b=o,x=s,n===`a`?(o+=f[m++],s+=f[m++]):(o=f[m++],s=f[m++]),e=`A`,o===b&&s===x)continue;!h||!g?(e=`L`,t.push(o,s)):t=this.convertEndpointToCenterParameterization(b,x,o,s,v,y,h,g,_)}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:[c,l],start:{x:o,y:s},pathLength:this.getLineLength(o,s,c,l)}),o=c,s=l)}return i}static _walkArc(t,n){let[r,i,a,o,s,c]=t,l=Math.max(1,Math.ceil(Math.abs(c)/(Math.PI/180))),u=e.getPointOnEllipticalArc(r,i,a,o,s,0),d=s,f=0;for(let t=1;t<=l;t++){let p=s+c*t/l,m=e.getPointOnEllipticalArc(r,i,a,o,p,0),h=e.getLineLength(u.x,u.y,m.x,m.y);if(f+h>=n)return{theta:d+(p-d)*((n-f)/h),length:n};f+=h,u=m,d=p}return{theta:d,length:f}}static calcLength(t,n,r,i){let a=e;switch(r){case`L`:return a.getLineLength(t,n,i[0],i[1]);case`C`:return Ag([t,i[0],i[2],i[4]],[n,i[1],i[3],i[5]],1);case`Q`:return jg([t,i[0],i[2]],[n,i[1],i[3]],1);case`A`:return a._walkArc(i,1/0).length}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]}};Vg.prototype.className=`Path`,Vg.prototype._attrsAffectingSize=[`data`],Zp(Vg,!0),G.addGetterSetter(Vg,`data`);var Hg=class extends zg{_getStrokePadding(){return super._getStrokePadding(this.pointerAtBeginning()||this.pointerAtEnding()?this.miterLimit()||10:void 0)}_sceneFunc(e){super._sceneFunc(e);let t=this.points(),n=t.length;if(n<4)return;let r=this.pointerLength(),i=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(t[n-2],t[n-1]),e.rotate(this._getPointerAngle(!1)),e.moveTo(0,0),e.lineTo(-r,i/2),e.lineTo(-r,-i/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(t[0],t[1]),e.rotate(this._getPointerAngle(!0)),e.moveTo(0,0),e.lineTo(-r,i/2),e.lineTo(-r,-i/2),e.closePath(),e.restore(),this.__fillStroke(e))}_getPointerAngle(e){let t=this.points(),n=t.length,r=this.tension()!==0&&n>4,i=r?this.getTensionPoints():t,a=e?t[0]:t[n-2],o=e?t[1]:t[n-1],s=0,c=0;if(r&&e)s=a-(i[0]+i[2])/2,c=o-(i[1]+i[3])/2;else if(r){let e=i[i.length-4],t=i[i.length-3],n=i[i.length-2],r=i[i.length-1],l=Vg.calcLength(e,t,`Q`,[n,r,a,o]),u=Vg.getPointOnQuadraticBezier(l?Math.max(0,1-this.pointerLength()/l):0,e,t,n,r,a,o);s=a-u.x,c=o-u.y}for(let t=e?0:i.length-2;!s&&!c&&t>=0&&t<i.length;t+=e?2:-2)s=a-i[t],c=o-i[t+1];let l=Math.PI*2;return(Math.atan2(c,s)+l)%l}__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.points();if(t.length<4)return e;let n=e.x,r=e.y,i=n+e.width,a=r+e.height;for(let e of[!1,!0]){if(!(e?this.pointerAtBeginning():this.pointerAtEnding()))continue;let o=e?0:t.length-2,s=this._getPointerAngle(e),c=Math.cos(s),l=Math.sin(s),u=t[o]-this.pointerLength()*c,d=t[o+1]-this.pointerLength()*l,f=Math.abs(this.pointerWidth()*l/2),p=Math.abs(this.pointerWidth()*c/2);n=Math.min(n,u-f),r=Math.min(r,d-p),i=Math.max(i,u+f),a=Math.max(a,d+p)}return{x:n,y:r,width:i-n,height:a-r}}};Hg.prototype.className=`Arrow`,Hg.prototype._attrsAffectingSize=[...zg.prototype._attrsAffectingSize,`pointerLength`,`pointerWidth`,`pointerAtBeginning`,`pointerAtEnding`],Zp(Hg,!0),G.addGetterSetter(Hg,`pointerLength`,10,eh()),G.addGetterSetter(Hg,`pointerWidth`,10,eh()),G.addGetterSetter(Hg,`pointerAtBeginning`,!1),G.addGetterSetter(Hg,`pointerAtEnding`,!0);var Ug=class extends dg{_getStrokePadding(){return super._getStrokePadding(1)}_sceneFunc(e){e.beginPath(),e.arc(0,0,Math.abs(this.attrs.radius||0),0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.radius())*2}getHeight(){return Math.abs(this.radius())*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Ug.prototype._centroid=!0,Ug.prototype.className=`Circle`,Ug.prototype._attrsAffectingSize=[`radius`],Zp(Ug,!0),G.addGetterSetter(Ug,`radius`,0,eh());var Wg=class extends dg{_getStrokePadding(){return super._getStrokePadding(1)}_sceneFunc(e){let t=Math.abs(this.radiusX()),n=Math.abs(this.radiusY());e.beginPath(),e.ellipse(0,0,t,n,0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.radiusX())*2}getHeight(){return Math.abs(this.radiusY())*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}};Wg.prototype.className=`Ellipse`,Wg.prototype._centroid=!0,Wg.prototype._attrsAffectingSize=[`radiusX`,`radiusY`],Zp(Wg,!0),G.addComponentsGetterSetter(Wg,`radius`,[`x`,`y`]),G.addGetterSetter(Wg,`radiusX`,0,eh()),G.addGetterSetter(Wg,`radiusY`,0,eh());var Gg=class e extends dg{constructor(e){super(e),this._loadListener=()=>{this._requestDraw()},this.on(`imageChange.konva`,e=>{this._removeImageLoad(e.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){var e;let t=this.image();t?.complete&&t.src||t?.readyState>=2||(e=t?.addEventListener)==null||e.call(t,`videoWidth`in t?`loadeddata`:`load`,this._loadListener)}_removeImageLoad(e){var t;(t=e?.removeEventListener)==null||t.call(e,`videoWidth`in e?`loadeddata`:`load`,this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(this.attrs.perfectDrawEnabled===!1)return!1;let n=!!this.cornerRadius(),r=this.hasShadow();return n&&r?!0:super._useBufferCanvas(!0,t)}_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),i=this.attrs.image;if((this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?W.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),i){r&&e.clip();let a=this.attrs.cropWidth,o=this.attrs.cropHeight;a&&o?e.drawImage(i,this.cropX(),this.cropY(),a,o,0,0,t,n):e.drawImage(i,0,0,t,n)}}_hitFunc(e){let t=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?W.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){let e=this.image();return this.attrs.width??e?.videoWidth??e?.width??0}getHeight(){let e=this.image();return this.attrs.height??e?.videoHeight??e?.height??0}static fromURL(t,n,r=null){let i=W.createImageElement();i.onload=()=>{i.onload=i.onerror=null,n(new e({image:i}))},i.onerror=r,i.crossOrigin=`Anonymous`,i.src=t}};Gg.prototype.className=`Image`,Gg.prototype._attrsAffectingSize=[`image`],Zp(Gg,!0),G.addGetterSetter(Gg,`cornerRadius`,0,th(4)),G.addGetterSetter(Gg,`image`),G.addComponentsGetterSetter(Gg,`crop`,[`x`,`y`,`width`,`height`]),G.addGetterSetter(Gg,`cropX`,0,eh()),G.addGetterSetter(Gg,`cropY`,0,eh()),G.addGetterSetter(Gg,`cropWidth`,0,eh()),G.addGetterSetter(Gg,`cropHeight`,0,eh());var Kg=typeof Intl<`u`&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:`grapheme`}):null;function qg(e){return e/15}function Jg(e){return Kg?Array.from(Kg.segment(e),e=>e.segment):e.match(/\p{RI}\p{RI}|\P{M}(?:\p{M}|\p{Emoji_Modifier}|\uFE0F|\u200D\P{M})*|\p{M}+/gu)||[]}var Yg=`auto`,Xg=`center`,Zg=`inherit`,Qg=`justify`,Nee=`Change.konva`,$g=`2d`,Pee=`-`,e_=`left`,Fee=`text`,Iee=`Text`,Lee=`top`,Ree=`bottom`,t_=`middle`,n_=`normal`,zee=`px `,r_=` `,i_=`right`,a_=`rtl`,Bee=`word`,Vee=`char`,o_=`none`,s_=`…`,c_=[`direction`,`fontFamily`,`fontSize`,`fontStyle`,`fontVariant`,`padding`,`align`,`verticalAlign`,`lineHeight`,`text`,`width`,`height`,`wrap`,`ellipsis`,`letterSpacing`],l_=null;function Hee(){if(l_!==null)return l_;l_=!1;let e;try{e=W.createCanvasElement(),e.width=10,e.height=10;let t=e.getContext($g);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){l_=!0;break}}}catch{}finally{e&&W.releaseCanvas(e)}return l_}function Uee(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 u_;function d_(){return u_||(u_=W.createCanvasElement().getContext($g),u_)}function Wee(e){this._partialFillStyle&&e.setAttr(`fillStyle`,this._partialFillStyle),e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function Gee(e){e.setAttr(`miterLimit`,2),this._partialStrokeStyle&&e.setAttr(`strokeStyle`,this._partialStrokeStyle),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function Kee(e){return e||={},e.fill||e.fillLinearGradientColorStops||e.fillRadialGradientColorStops||e.fillPatternImage?e:{...e,fill:`black`}}var f_=class extends dg{constructor(e){super(Kee(e)),this._partialTextX=0,this._partialTextY=0,this._baselineShift=0,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.direction(),s=this.align(),c=this.getWidth(),l=this.letterSpacing(),u=this.charRenderFunc(),d=this.textDecoration(),f=d.indexOf(`underline`)!==-1,p=d.indexOf(`line-through`)!==-1,m,h=a/2,g=t_;if(!Yp.legacyTextRendering){let e=this.measureSize(`M`);g=`alphabetic`,h=((e.fontBoundingBoxAscent??e.actualBoundingBoxAscent)-(e.fontBoundingBoxDescent??e.actualBoundingBoxDescent))/2+a/2}if(o===Zg?o=e.direction:e.setAttr(`direction`,o),e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,g),e.setAttr(`textAlign`,e_),e.translate(r,this._getTextTop()),u){let t=e._getFillStyle(this);t!==void 0&&(e.fillStyle=t),this.hasStroke()&&e._applyStrokeStyle(this)}let _=u?e.fillStyle:void 0,v=u?e.strokeStyle:void 0,y=0;for(m=0;m<n;m++){let d=0,g=t[m],b=g.text,x=g.width,S=g.lastInParagraph;if(e.save(),s===i_?d+=c-x-r*2:s===Xg&&(d+=(c-x-r*2)/2),f){e.save(),e.beginPath();let t=this._getUnderlineOffset(),n=d,a=h+0+t;e.moveTo(n,a);let o=s===Qg&&!S?c-r*2:x;e.lineTo(n+Math.round(o),a),e.lineWidth=qg(i),e.strokeStyle=e._getFillStyle(this),e.stroke(),e.restore()}let C=d;if(o!==a_&&(l!==0||s===Qg||u)){let t=b.split(` `).length-1,n=Jg(b);for(let i=0;i<n.length;i++){let a=n[i];a===` `&&!S&&s===Qg&&(d+=(c-r*2-x)/t),this._partialTextX=d,this._partialTextY=h+0,this._partialText=a;let o=e.measureText(a).width;if(u){e.save(),u({char:a,index:y,x:d,y:h+0,lineIndex:m,column:i,isLastInLine:i===n.length-1,width:o,context:e});let t=e.fillStyle;t!==_&&(this._partialFillStyle=t);let r=e.strokeStyle;r!==v&&(this._partialStrokeStyle=r)}e.fillStrokeShape(this),u&&(this._partialFillStyle=void 0,this._partialStrokeStyle=void 0,e.restore()),d+=o+l,y++}}else l!==0&&e.setAttr(`letterSpacing`,`${l}px`),this._partialTextX=d,this._partialTextY=h+0,this._partialText=b,e.fillStrokeShape(this);if(p){e.save(),e.beginPath();let t=Yp.legacyTextRendering?0:-Math.round(i/4),n=C;e.moveTo(n,h+0+t);let a=s===Qg&&!S?c-r*2:x;e.lineTo(n+Math.round(a),h+0+t),e.lineWidth=qg(i),e.strokeStyle=e._getFillStyle(this),e.stroke(),e.restore()}e.restore(),n>1&&(h+=a)}}_getTextTop(){let e=this.padding(),t=this.getHeight()-this.textArr.length*this.lineHeight()*this.fontSize()-e*2,n=this.verticalAlign();return n===t_?e+t/2:n===Ree?e+t:e}_getUnderlineOffset(){return this.underlineOffset()??Math.round(this.fontSize()/(Yp.legacyTextRendering?2:4))}getSelfRect(){let e=super.getSelfRect(),t=this.textArr.length;if(!t||this.textDecoration().indexOf(`underline`)===-1)return e;let n=this.fontSize(),r=this.lineHeight()*n,i=this._getTextTop()+t*r-r/2;return Yp.legacyTextRendering||(i+=this._baselineShift),i+=this._getUnderlineOffset()+qg(n)/2,e.height=Math.max(e.y+e.height,i)-e.y,e}_getSelfRectForDrawing(){let e=this.getSelfRect(),t=this.fontSize(),n=this.padding(),r=this.lineHeight()*t,i=this.getWidth()-n*2,a=this.align(),o=this.textArr.length*r,s=this._getTextTop(),c=e.x,l=e.x+e.width;for(let{text:e,width:t}of this.textArr){let r=n+(a===i_?i-t:a===Xg?(i-t)/2:0),o=Math.min(0,this.letterSpacing())*e.length;c=Math.min(c,r+o),l=Math.max(l,r+t-o)}let u=this.textDecoration().includes(`underline`),d=Math.min(e.y,s+(u?Math.min(0,this._getUnderlineOffset()):0));return{x:c-t,y:d-t,width:l-c+t*2,height:Math.max(e.y+e.height,s+o)-d+t*2}}_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=W._isString(e)?e:e==null?``:e+``;return this._setAttr(Fee,t),this}getWidth(){return this.attrs.width===Yg||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===Yg||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return W.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=d_(),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()+r_+this.fontVariant()+r_+(this.fontSize()+zee)+Uee(this.fontFamily())}_addTextLine(e){this.align()===Qg&&(e=e.trim());let t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e,t){let n=this.letterSpacing(),r=n?n*(t??Jg(e).length):0;return d_().measureText(e).width+r}_setTextData(){let e=this.text().split(`
78
+ `),t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.width,i=this.attrs.height,a=r!==Yg&&r!==void 0,o=i!==Yg&&i!==void 0,s=this.padding(),c=r-s*2,l=i-s*2,u=0,d=this.wrap(),f=d!==Vee&&d!==o_,p=this.ellipsis(),m=this.measureSize(`M`);this._baselineShift=(m.fontBoundingBoxAscent-m.fontBoundingBoxDescent)/2,this.textArr=[];let h=d_();h.font=this._getContextFont(),h.fontKerning=this.direction()!==a_&&(this.letterSpacing()!==0||this.align()===Qg||this.charRenderFunc())?`none`:`auto`;let g=p?this._getTextWidth(s_):0;for(let t=0,r=e.length;t<r;++t){let i=e[t],s=this._getTextWidth(i);if(a&&s>c){let e=Jg(i),a=e.length,d=0,m=t=>e.slice(d,t).join(``),h=e=>e===r_||e===Pee,_=Math.max(1,Math.ceil(a*c/s));for(;d<a;){let i=p&&o&&u+n>l?g:0,s=e=>!(this._getTextWidth(m(e),e-d)+i>c),v=d,y=Math.min(a,d+_);for(;s(y)&&(v=y,y!==a);)y=Math.min(a,y+(y-d));for(;y-v>1;){let e=v+y>>>1;s(e)?v=e:y=e}if(v===d)break;if(v===a){this._addTextLine(m(a)),u+=n,o&&u+n>l&&t<r-1&&this._tryToAddEllipsisToLastLine();break}if(f&&!h(e[v])){let t=v-1;for(;t>=d&&!h(e[t]);)t--;t>=d&&(v=t+1)}if(this._addTextLine(m(v).trimRight()),u+=n,this._shouldHandleEllipsis(u)){this._tryToAddEllipsisToLastLine();break}for(d=v;d<a&&!e[d].trim();)d++}}else this._addTextLine(i),u+=n,o&&u+n>l&&t<r-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&u+n>l)break}this.textHeight=t,this.textWidth=this.textArr.reduce((e,t)=>Math.max(e,t.width),0)}_shouldHandleEllipsis(e){let t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==Yg&&r!==void 0,a=r-this.padding()*2;return this.wrap()===o_||i&&e+n>a}_tryToAddEllipsisToLastLine(){let e=this.attrs.width,t=e!==Yg&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];if(!i||!r)return;let a=i.text+s_;if(t){let e=Jg(i.text);for(;e.length&&this._getTextWidth(a)>n;)e.pop(),a=e.join(``)+s_;this._getTextWidth(a)>n&&(a=``)}i.text=a,i.width=this._getTextWidth(a)}getStrokeScaleEnabled(){return!0}_getStrokePadding(){return super._getStrokePadding(2)}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(this.attrs.perfectDrawEnabled===!1)return!1;let n=this.textDecoration().indexOf(`underline`)!==-1||this.textDecoration().indexOf(`line-through`)!==-1,r=this.hasShadow();return n&&r||r&&t!==1&&Hee()?!0:super._useBufferCanvas(e,t)}};f_.prototype._fillFunc=Wee,f_.prototype._strokeFunc=Gee,f_.prototype.className=Iee,f_.prototype._attrsAffectingSize=c_.filter(e=>e!==`width`&&e!==`height`).concat([`textDecoration`,`underlineOffset`]),Zp(f_,!0),f_.prototype.on(c_.map(e=>e+Nee).join(` `),function(){this._setTextData()}),G.overWriteSetter(f_,`width`,nh()),G.overWriteSetter(f_,`height`,nh()),G.addGetterSetter(f_,`direction`,Zg),G.addGetterSetter(f_,`fontFamily`,`Arial`),G.addGetterSetter(f_,`fontSize`,12,eh()),G.addGetterSetter(f_,`fontStyle`,n_),G.addGetterSetter(f_,`fontVariant`,n_),G.addGetterSetter(f_,`padding`,0,eh()),G.addGetterSetter(f_,`align`,e_),G.addGetterSetter(f_,`verticalAlign`,Lee),G.addGetterSetter(f_,`lineHeight`,1,eh()),G.addGetterSetter(f_,`wrap`,Bee),G.addGetterSetter(f_,`ellipsis`,!1,oh()),G.addGetterSetter(f_,`letterSpacing`,0,eh()),G.addGetterSetter(f_,`text`,``,rh()),G.addGetterSetter(f_,`textDecoration`,``),G.addGetterSetter(f_,`underlineOffset`,void 0,eh()),G.addGetterSetter(f_,`charRenderFunc`,void 0);var qee=[...f_.prototype._attrsAffectingSize,`width`,`height`,`pointerDirection`,`pointerWidth`,`pointerHeight`].map(e=>e+`Change.konva`).join(` `),Jee=`none`,p_=`up`,m_=`right`,h_=`down`,g_=`left`,__=class extends gg{constructor(e){super(e),this._sync=this._sync.bind(this),this.on(`add.konva`,function(e){e.child.off(qee,this._sync).on(qee,this._sync),this._sync()})}getText(){return this.find(`Text`)[0]}getTag(){return this.find(`Tag`)[0]}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 p_:o=n/2,s=-1*c;break;case m_:o=n+a,s=r/2;break;case h_:o=n/2,s=r+c;break;case g_: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})}}};__.prototype.className=`Label`,Zp(__);var v_=class extends dg{_sceneFunc(e){let t=this.width(),n=this.height(),r=this.pointerDirection(),i=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius(),[s,c,l,u]=W._cornerRadii(o,t,n);e.beginPath(),e.moveTo(s,0),r===p_&&(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===m_&&(e.lineTo(t,(n-a)/2),e.lineTo(t+i,n/2),e.lineTo(t,(n+a)/2)),e.lineTo(t,n-l),e.arc(t-l,n-l,l,0,Math.PI/2,!1),r===h_&&(e.lineTo((t+i)/2,n),e.lineTo(t/2,n+a),e.lineTo((t-i)/2,n)),e.lineTo(u,n),e.arc(u,n-u,u,Math.PI/2,Math.PI,!1),r===g_&&(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=this.pointerWidth(),t=this.pointerHeight(),n=this.pointerDirection(),r=this.width(),i=this.height();return n===p_||n===h_?{x:Math.min(0,(r-e)/2),y:n===p_?-t:0,width:Math.max(r,e),height:i+t}:n===g_||n===m_?{x:n===g_?-e:0,y:Math.min(0,(i-t)/2),width:r+e,height:Math.max(i,t)}:{x:0,y:0,width:r,height:i}}};v_.prototype.className=`Tag`,Zp(v_,!0),G.addGetterSetter(v_,`pointerDirection`,Jee),G.addGetterSetter(v_,`pointerWidth`,0,eh()),G.addGetterSetter(v_,`pointerHeight`,0,eh()),G.addGetterSetter(v_,`cornerRadius`,0,th(4));var y_=class extends dg{_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?W.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};y_.prototype.className=`Rect`,Zp(y_,!0),G.addGetterSetter(y_,`cornerRadius`,0,th(4));var b_=class extends dg{_sceneFunc(e){let t=this._getPoints(),n=this.radius(),r=this.sides(),i=this.cornerRadius();if(t.length){if(e.beginPath(),i)W.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();if(!e.length)return{x:0,y:0,width:0,height:0};let 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)}};b_.prototype.className=`RegularPolygon`,b_.prototype._centroid=!0,b_.prototype._attrsAffectingSize=[`radius`,`sides`],Zp(b_,!0),G.addGetterSetter(b_,`radius`,0,eh()),G.addGetterSetter(b_,`sides`,0,eh()),G.addGetterSetter(b_,`cornerRadius`,0,th(4));var Yee=Math.PI*2,x_=class extends dg{_getStrokePadding(){return super._getStrokePadding(1)}_sceneFunc(e){let t=Math.abs(this.innerRadius()),n=Math.abs(this.outerRadius());e.beginPath(),e.arc(0,0,t,0,Yee,!1),e.moveTo(n,0),e.arc(0,0,n,Yee,0,!0),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=Math.max(Math.abs(this.innerRadius()),Math.abs(this.outerRadius()));return{x:-e,y:-e,width:e*2,height:e*2}}getWidth(){return Math.abs(this.outerRadius())*2}getHeight(){return Math.abs(this.outerRadius())*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};x_.prototype.className=`Ring`,x_.prototype._centroid=!0,x_.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],Zp(x_,!0),G.addGetterSetter(x_,`innerRadius`,0,eh()),G.addGetterSetter(x_,`outerRadius`,0,eh());var S_=class extends dg{constructor(e){super(e),this._updated=!0,this.anim=new vg(()=>{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())})}_getFrame(){let e=this.animation(),t=this.animations()?.[e],n=this.frameIndex(),r=n*4;if(!t||!Number.isInteger(n)||r<0||r+4>t.length)return;let i=this.frameOffsets()?.[e]||[];return{x:t[r],y:t[r+1],width:t[r+2],height:t[r+3],offsetX:i[n*2]||0,offsetY:i[n*2+1]||0}}_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this._getFrame();if(!t)return;let{x:n,y:r,width:i,height:a,offsetX:o,offsetY:s}=t,c=this.image();(this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(o,s,i,a),e.closePath(),e.fillStrokeShape(this)),c&&e.drawImage(c,n,r,i,a,o,s,i,a)}_hitFunc(e){let{x:t,y:n,width:r,height:i}=this.getSelfRect();e.beginPath(),e.rect(t,n,r,i),e.closePath(),e.fillShape(this)}getSelfRect(){let e=this._getFrame();return e?{x:e.offsetX,y:e.offsetY,width:e.width,height:e.height}:{x:0,y:0,width:0,height:0}}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){return super._useBufferCanvas(!0,t)}_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)}destroy(){return this.stop(),super.destroy()}isRunning(){return this.anim.isRunning()}_updateIndex(){let e=this.frameIndex(),t=this.animations()?.[this.animation()],n=t?t.length/4:0;this.frameIndex(e<n-1?e+1:0)}};S_.prototype.className=`Sprite`,Zp(S_,!0),G.addGetterSetter(S_,`animation`),G.addGetterSetter(S_,`animations`),G.addGetterSetter(S_,`frameOffsets`),G.addGetterSetter(S_,`image`),G.addGetterSetter(S_,`frameIndex`,0,eh()),G.addGetterSetter(S_,`frameRate`,17,eh()),G.backCompat(S_,{index:`frameIndex`,getIndex:`getFrameIndex`,setIndex:`setFrameIndex`});var C_=class extends dg{_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)}getSelfRect(){let e=Math.max(Math.abs(this.innerRadius()),Math.abs(this.outerRadius()));return{x:-e,y:-e,width:e*2,height:e*2}}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};C_.prototype.className=`Star`,C_.prototype._centroid=!0,C_.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],Zp(C_,!0),G.addGetterSetter(C_,`numPoints`,5,eh()),G.addGetterSetter(C_,`innerRadius`,0,eh()),G.addGetterSetter(C_,`outerRadius`,0,eh());var Xee=``,w_=`normal`;function T_(e){e.fillText(this.partialText,0,0)}function E_(e){e.strokeText(this.partialText,0,0)}var D_=class extends dg{constructor(e){super(e),this.dataArray=[],this._readDataAttribute(),this._setTextData()}_getTextPathLength(){return Vg.getPathLength(this.dataArray)}_getPointAtLength(e,t){return!this.attrs.data||e>this.pathLength?null:Vg.getPointAtLengthOfDataArray(e,this.dataArray,t)}_readDataAttribute(){this.dataArray=Vg.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=qg(r),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=qg(r),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 W.warn(`text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.`),this.textHeight}setText(e){return f_.prototype.setText.call(this,e)}_getContextFont(){return f_.prototype._getContextFont.call(this)}_getTextSize(e){let t=d_();t.save(),t.font=this._getContextFont(),t.fontKerning=`auto`;let n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){let e=Jg(this.text());this.direction()===`rtl`&&e.reverse();let t=this.kerningFunc(),n=[],r=0;for(let i=0;i<e.length;i++){let a=0;if(t&&i>0)try{a=t(e[i-1],e[i])*this.fontSize()}catch{}n.push({char:e[i],width:this._getTextSize(e[i]).width,kern:a}),r+=n[i].width+a}let{width:i,height:a}=this._getTextSize(this.attrs.text);if(this.textWidth=r,this.textHeight=a,this.glyphInfo=[],!this.attrs.data)return null;let o=this.letterSpacing(),s=this.align(),c=s===`justify`?this.text().split(` `).length-1:0,l=Math.max(0,r-i),u=Math.max(this.textWidth+(e.length-1)*o,0),d=0;s===`center`&&(d=Math.max(0,this.pathLength/2-u/2)),s===`right`&&(d=Math.max(0,this.pathLength-u));let f=d,p=this.dataArray.some((e,t)=>t>0&&e.command===`M`)?void 0:{index:0,offset:0};for(let t=0;t<n.length;t++){f+=n[t].kern;let r=this._getPointAtLength(f,p);if(!r)return;let i=n[t].char,a=n[t].width+(t<n.length-1?o:0);i===` `&&s===`justify`&&(a+=(this.pathLength-u)/c);let d=f+a,m=this._getPointAtLength(d>this.pathLength&&d-this.pathLength<=l?this.pathLength:d,p);if(!m)return;let h=Vg.getLineLength(r.x,r.y,m.x,m.y),g=Math.atan2(m.y-r.y,m.x-r.x);this.glyphInfo.push({text:e[t],rotation:g,p0:r,p1:m,width:h}),f+=a}}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=W._getPointsRect(e),n=this.fontSize();return{x:t.x-n/2,y:t.y-n/2,width:t.width+n,height:t.height+n}}getStrokeScaleEnabled(){return!0}_getSelfRectForDrawing(){let e=this.getSelfRect(),t=this.fontSize();return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}};D_.prototype._fillFunc=T_,D_.prototype._strokeFunc=E_,D_.prototype._fillFuncHit=T_,D_.prototype._strokeFuncHit=E_,D_.prototype.className=`TextPath`,D_.prototype._attrsAffectingSize=[`text`,`fontSize`,`data`,`align`,`letterSpacing`,`kerningFunc`,`fontFamily`,`fontStyle`,`fontVariant`,`direction`],Zp(D_,!0),D_.prototype.on(`dataChange.konva`,function(){this._readDataAttribute(),this._setTextData()}),D_.prototype.on(D_.prototype._attrsAffectingSize.filter(e=>e!==`data`).map(e=>e+`Change.konva`).join(` `),function(){this._setTextData()}),G.addGetterSetter(D_,`data`),G.addGetterSetter(D_,`fontFamily`,`Arial`),G.addGetterSetter(D_,`fontSize`,12,eh()),G.addGetterSetter(D_,`fontStyle`,w_),G.addGetterSetter(D_,`align`,`left`),G.addGetterSetter(D_,`letterSpacing`,0,eh()),G.addGetterSetter(D_,`textBaseline`,`middle`),G.addGetterSetter(D_,`fontVariant`,w_),G.addGetterSetter(D_,`text`,Xee),G.addGetterSetter(D_,`textDecoration`,``),G.addGetterSetter(D_,`kerningFunc`,void 0),G.addGetterSetter(D_,`direction`,`inherit`);var O_=`tr-konva`,Zee=[`resizeEnabledChange`,`rotateAnchorOffsetChange`,`rotateAnchorAngleChange`,`rotateEnabledChange`,`enabledAnchorsChange`,`anchorSizeChange`,`borderEnabledChange`,`shouldOverdrawWholeAreaChange`,`borderStrokeChange`,`borderStrokeWidthChange`,`borderDashChange`,`anchorStrokeChange`,`anchorStrokeWidthChange`,`anchorFillChange`,`anchorCornerRadiusChange`,`ignoreStrokeChange`,`anchorStyleFuncChange`,`paddingChange`].map(e=>e+`.${O_}`).join(` `),k_=`nodesRect`,Qee=[`widthChange`,`heightChange`,`scaleXChange`,`scaleYChange`,`skewXChange`,`skewYChange`,`rotationChange`,`offsetXChange`,`offsetYChange`,`transformsEnabledChange`,`strokeWidthChange`,`strokeChange`,`selfRectFuncChange`,`strokeLinearGradientColorStopsChange`,`strokeScaleEnabledChange`,`strokeEnabledChange`,`draggableChange`],$ee={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},ete=`ontouchstart`in Yp._global;function tte(e,t,n){if(e===`rotater`)return n;t+=W.degToRad($ee[e]||0);let r=(W.radToDeg(t)%360+360)%360;return W._inRange(r,337.5,360)||W._inRange(r,0,22.5)?`ns-resize`:W._inRange(r,22.5,67.5)?`nesw-resize`:W._inRange(r,67.5,112.5)?`ew-resize`:W._inRange(r,112.5,157.5)?`nwse-resize`:W._inRange(r,157.5,202.5)?`ns-resize`:W._inRange(r,202.5,247.5)?`nesw-resize`:W._inRange(r,247.5,292.5)?`ew-resize`:W._inRange(r,292.5,337.5)?`nwse-resize`:(W.error(`Transformer has unknown angle for cursor detection: `+r),`pointer`)}var A_=[`top-left`,`top-center`,`top-right`,`middle-right`,`middle-left`,`bottom-left`,`bottom-center`,`bottom-right`];function nte(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 rte(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 ite(e,t){return rte(e,t,nte(e))}function ate(e,t,n){let r=t,i=n;for(let n=0;n<e.length;n++){let a=Yp.getAngle(e[n]),o=Math.abs(a-t)%(Math.PI*2),s=Math.min(o,Math.PI*2-o);s<i&&(i=s,r=a)}return r}function j_(e,t,n){let r=W.degToRad(e.rotateAnchorAngle()),i=Math.sin(r),a=-Math.cos(r),o=t/2,s=n/2,c=1/0;a<0?c=Math.min(c,-s/a):a>0&&(c=Math.min(c,(n-s)/a)),i<0?c=Math.min(c,-o/i):i>0&&(c=Math.min(c,(t-o)/i));let l=o+i*c,u=s+a*c,d=e.rotateAnchorOffset()+e.padding();return{edgeX:l,edgeY:u,endX:l+i*d,endY:u+a*d}}var M_=new Set,N_=class extends gg{static _isLayerTransforming(e){for(let t of M_)if(t.getLayer()===e||t._nodes.some(t=>t.getLayer()===e))return!0;return!1}constructor(e){super(e),this._movingAnchorName=null,this._anchors={},this._transforming=!1,this._fitting=!1,this._transformWindow=null,this._elementsCreated=!1,this._updateScheduled=!1,this._subtreeChanged=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(Zee,e=>{e.type===`ignoreStrokeChange`&&this._resetTransformCache(),this.update()}),this.on(`rotationChange.${O_}`,()=>this._clearCache(k_)),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return W.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 O_+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();let t=new Set(e);for(let e of t)e.isAncestorOf(this)&&(W.error(`Konva.Transformer cannot be an a child of the node you are trying to attach`),t.delete(e));let n=Array.from(t).filter(e=>{for(let n=e.getParent();n;n=n.getParent())if(t.has(n))return!1;return!0});return this._nodes=e=n,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(e=>{let t=()=>{var t;if(this._fitting){(t=this._nodeRectCache)==null||t.delete(e);return}this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(e),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(Qee.map(e=>e+`.${this._getEventNamespace()}`).join(` `),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),e instanceof kh&&e._addSubtreeObserver(this),e.on(`destroy.${this._getEventNamespace()}`,()=>{this.setNodes(this._nodes.filter(t=>t!==e))}),this._proxyDrag(e)}),this._resetTransformCache(),this._elementsCreated&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this._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(){var e;this._nodes&&this._nodes.forEach(e=>{e.off(`.`+this._getEventNamespace()),e._removeSubtreeObserver(this)}),this._nodes=[],this._resetTransformCache(),(e=this.getLayer())==null||e.batchDraw()}_resetTransformCache(e){var t,n;e?(t=this._nodeRectCache)==null||t.delete(e):(n=this._nodeRectCache)==null||n.clear(),this._clearCache(k_),this._clearCache(`transform`),this._clearSelfAndDescendantCache(`absoluteTransform`)}_onSubtreeChange(e){var t;this._fitting||(!this._subtreeChanged||this._cache[k_])&&(this._resetTransformCache(e),this._subtreeChanged||(this._subtreeChanged=!0,W.requestAnimFrame(()=>this._syncSubtreeChange(),this.getStage()?._getOwnerWindow()),(t=this.getLayer())==null||t.batchDraw()))}_syncSubtreeChange(){this._subtreeChanged&&this._nodes?.length&&!this.isDragging()&&this._update()}drawScene(e,t){return this._syncSubtreeChange(),super.drawScene(e,t)}drawHit(e,t){return this._syncSubtreeChange(),super.drawHit(e,t)}_getNodeRect(){return this._getCache(k_,this.__getNodeRect)}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};let e=Yp.getAngle(this.rotation()),t=this.ignoreStroke(),n=new em;n.rotate(-e);let r=this._nodeRectCache||=new Map,i=1/0,a=1/0,o=-1/0,s=-1/0;for(let c of this.nodes()){let l=c instanceof dg&&c.getSelfRect===dg.prototype.getSelfRect&&!c.attrs.selfRectFunc&&!c._hasCachedAncestor(),u=l?c.width():0,d=l?c.height():0;l&&(c._attrsVersion??=0);let f=l?r.get(c):void 0;if(!f||f.rotation!==e||f.ignoreStroke!==t||f.version!==c._attrsVersion||f.width!==u||f.height!==d){let i=c.getAbsoluteTransform(),[a,o,s,p]=i.getMatrix(),m=a*p-o*s===0,h=c.getClientRect({skipTransform:!m,skipShadow:!0,skipStroke:t}),g=[{x:h.x,y:h.y},{x:h.x+h.width,y:h.y},{x:h.x+h.width,y:h.y+h.height},{x:h.x,y:h.y+h.height}];m&&(i=new em),f={rotation:e,ignoreStroke:t,width:u,height:d,version:c._attrsVersion||0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(let e of g){let t=n.point(i.point(e));f.minX=Math.min(f.minX,t.x),f.minY=Math.min(f.minY,t.y),f.maxX=Math.max(f.maxX,t.x),f.maxY=Math.max(f.maxY,t.y)}l&&r.set(c,f)}i=Math.min(i,f.minX),a=Math.min(a,f.minY),o=Math.max(o,f.maxX),s=Math.max(s,f.maxY)}n.invert();let c=n.point({x:i,y:a});return{x:c.x,y:c.y,width:o-i,height:s-a,rotation:Yp.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(),A_.forEach(e=>{this._createAnchor(e)}),this._createAnchor(`rotater`),this._elementsCreated=!0}_createAnchor(e){let t=new y_({stroke:`rgb(0, 161, 255)`,fill:`white`,strokeWidth:1,name:e+` _anchor`,dragDistance:0,draggable:!0,hitStrokeWidth:ete?10:`auto`});this._anchors[e]=t;let 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`,()=>{if(this.isTransforming())return;let n=tte(e,Yp.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=n),this._cursorChange=!0}),t.on(`mouseout`,()=>{this._cursorChange=!1,!this.isTransforming()&&t.getStage().content&&(t.getStage().content.style.cursor=``)}),this.add(t)}_createBack(){let e=new dg({name:`back`,width:0,height:0,sceneFunc(e,t){let n=t.getParent();if(!n.borderEnabled())return;let 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=j_(n,i,a);e.moveTo(t.edgeX,t.edgeY),e.lineTo(t.endX,t.endY)}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._back=e,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(e.evt.button!==void 0&&!Yp.dragButtons.includes(e.evt.button)||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);let a=this.getStage()?._getOwnerWindow();this._transformWindow=a||null,a&&(a.addEventListener(`mousemove`,this._handleMouseMove),a.addEventListener(`touchmove`,this._handleMouseMove),a.addEventListener(`mouseup`,this._handleMouseUp,!0),a.addEventListener(`touchend`,this._handleMouseUp,!0),a.addEventListener(`touchcancel`,this._handleMouseUp,!0)),this._transforming=!0,this._pointerId=e.pointerId??W._getFirstPointerId(e.evt);let o=e.target.getAbsolutePosition(),s=e.target.getStage()._getPointerById(this._pointerId);this._anchorDragOffset={x:s.x-o.x,y:s.y-o.y},M_.add(this),this._fire(`transformstart`,{evt:e.evt,target:this.getNode()}),this._nodes.forEach(t=>{t._fire(`transformstart`,{evt:e.evt,target:t})})}_handleMouseMove(e){var t;(t=this.getStage())==null||t._batchEvents(()=>this._moveTransform(e))}_moveTransform(e){this._syncSubtreeChange();let t,n,r,i=this._anchors[this._movingAnchorName],a=i.getStage();a.setPointersPositions(e);let o=a._getPointerById(this._pointerId);if(!o)return;let 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=W.degToRad(this.rotateAnchorAngle()),o=Math.atan2(-n,t)+Math.PI/2-a,s=Yp.getAngle(this.rotation())+o,c=Yp.getAngle(this.rotationSnapTolerance()),l=ite(r,ate(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,p=!1;if(this._movingAnchorName===`top-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-right`].x(),y:this._anchors[`bottom-right`].y()};r=Math.sqrt((e.x-i.x())**2+(e.y-i.y())**2);let a=this._anchors[`top-left`].x()>e.x?-1:1,o=this._anchors[`top-left`].y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-left`].x(e.x-t),this._anchors[`top-left`].y(e.y-n)}}else if(this._movingAnchorName===`top-center`)this._anchors[`top-left`].y(i.y());else if(this._movingAnchorName===`top-right`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-left`].x(),y:this._anchors[`bottom-left`].y()};r=Math.sqrt((i.x()-e.x)**2+(e.y-i.y())**2);let a=this._anchors[`top-right`].x()<e.x?-1:1,o=this._anchors[`top-right`].y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-right`].x(e.x+t),this._anchors[`top-right`].y(e.y-n)}var m=i.position();this._anchors[`top-left`].y(m.y),this._anchors[`bottom-right`].x(m.x)}else if(this._movingAnchorName===`middle-left`)this._anchors[`top-left`].x(i.x());else if(this._movingAnchorName===`middle-right`)this._anchors[`bottom-right`].x(i.x());else if(this._movingAnchorName===`bottom-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`top-right`].x(),y:this._anchors[`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)}m=i.position(),this._anchors[`top-left`].x(m.x),this._anchors[`bottom-right`].y(m.y)}else if(this._movingAnchorName===`bottom-center`)this._anchors[`bottom-right`].y(i.y());else if(this._movingAnchorName===`bottom-right`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`top-left`].x(),y:this._anchors[`top-left`].y()};r=Math.sqrt((i.x()-e.x)**2+(i.y()-e.y)**2);let a=this._anchors[`bottom-right`].x()<e.x?-1:1,o=this._anchors[`bottom-right`].y()<e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`bottom-right`].x(e.x+t),this._anchors[`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._anchors[`top-left`],t=this._anchors[`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 h=this._anchors[`top-left`].getAbsolutePosition();t=h.x,n=h.y;let g=this._anchors[`bottom-right`].x()-this._anchors[`top-left`].x(),_=this._anchors[`bottom-right`].y()-this._anchors[`top-left`].y();this._fitNodesInto({x:t,y:n,width:g,height:_,rotation:Yp.getAngle(this.rotation())},e,p)}_handleMouseUp(e){let t=this.getStage();t&&(t.setPointersPositions(e),!t._changedPointerPositions.some(e=>e.id===this._pointerId))||(t?t._batchEvents(()=>this._removeEvents(e)):this._removeEvents(e))}getAbsoluteTransform(e){let t=this.getTransform();return e?e.getAbsoluteTransform().copy().invert().multiply(t):t}_removeEvents(e){var t;if(this._transforming){this._transforming=!1;let n=this.getStage()?.content;n&&!this._cursorChange&&(n.style.cursor=``);let r=this._transformWindow;this._transformWindow=null,r&&(r.removeEventListener(`mousemove`,this._handleMouseMove),r.removeEventListener(`touchmove`,this._handleMouseMove),r.removeEventListener(`mouseup`,this._handleMouseUp,!0),r.removeEventListener(`touchend`,this._handleMouseUp,!0),r.removeEventListener(`touchcancel`,this._handleMouseUp,!0));let i=this.getNode();M_.delete(this),this._fire(`transformend`,{evt:e,target:i}),(t=this.getLayer())==null||t.batchDraw(),i&&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,n=!1){this._fitting=!0;try{return this._doFitNodesInto(e,t,n)}finally{this._fitting=!1}}_doFitNodesInto(e,t,n=!1){let r=this._getNodeRect();if(!r.width||!r.height||W._inRange(e.width,-this.padding()*2-1,1)||W._inRange(e.height,-this.padding()*2-1,1)){this.update();return}let i=new em;i.rotate(Yp.getAngle(this.rotation()));let a=n?0:this.padding()*2,o=null,s=null;if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`left`)>=0){let t=i.point({x:-a,y:0});e.x+=t.x,e.y+=t.y,e.width+=a,o={axis:`width`,from:`left`,to:`right`,offset:t}}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`right`)>=0){let t=i.point({x:a,y:0});e.width+=a,o={axis:`width`,from:`right`,to:`left`,offset:t}}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`top`)>=0){let t=i.point({x:0,y:-a});e.x+=t.x,e.y+=t.y,e.height+=a,s={axis:`height`,from:`top`,to:`bottom`,offset:t}}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`bottom`)>=0){let t=i.point({x:0,y:a});e.height+=a,s={axis:`height`,from:`bottom`,to:`top`,offset:t}}if(this.boundBoxFunc()){let t=this.boundBoxFunc()(r,e);t?e=t:W.warn(`boundBoxFunc returned falsy. You should return new bound rect from it!`)}for(let t of[o,s])t&&e[t.axis]<0&&this._movingAnchorName&&(this._movingAnchorName=this._movingAnchorName.replace(t.from,t.to),this._anchorDragOffset.x-=t.offset.x,this._anchorDragOffset.y-=t.offset.y);let c=1e7,l=new em;l.translate(r.x,r.y),l.rotate(r.rotation),l.scale(r.width/c,r.height/c);let u=new em,d=e.width/c,f=e.height/c;this.flipEnabled()===!1?(u.translate(e.x,e.y),u.rotate(e.rotation),u.translate(e.width<0?e.width:0,e.height<0?e.height:0),u.scale(Math.abs(d),Math.abs(f))):(u.translate(e.x,e.y),u.rotate(e.rotation),u.scale(d,f));let p=u.multiply(l.invert()),m=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 em;r.multiply(t.copy().invert()).multiply(p).multiply(t).multiply(n);let i=r.decompose();e.setAttrs(i);let a=e.getLayer();a&&m.add(a)}),this.rotation(W._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(),m.add(this.getLayer()),m.forEach(e=>e&&e.batchDraw())}_scheduleUpdate(){this._updateScheduled||(this._updateScheduled=!0,Dh._runAfterAbsTransformCascade(()=>{this._updateScheduled=!1,!(!this._nodes?.length||this._fitting||this.isDragging())&&this._update()}))}forceUpdate(){this._resetTransformCache(),this.update()}update(){this._lastNodeRect=void 0,this._update()}_update(){var e;this._subtreeChanged=!1;let t=this._getNodeRect();this._updateElements(t);let n=this.nodes().some(e=>e.draggable());this._back.draggable()!==n&&this._back.draggable(n);let r=this.anchorStyleFunc();r&&Object.values(this._anchors).forEach(e=>r(e)),(e=this.getLayer())==null||e.batchDraw()}_updateElements(e){let t=this._lastNodeRect;if(t&&!this.anchorStyleFunc()&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height&&e.rotation===t.rotation)return;this._lastNodeRect={...e};let n=e.width,r=e.height,i=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),s=this.anchorSize();Object.values(this._anchors).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._anchors[`top-left`].setAttrs({x:0,y:0,offsetX:s/2+o,offsetY:s/2+o,visible:a&&i.indexOf(`top-left`)>=0}),this._anchors[`top-center`].setAttrs({x:n/2,y:0,offsetY:s/2+o,visible:a&&i.indexOf(`top-center`)>=0}),this._anchors[`top-right`].setAttrs({x:n,y:0,offsetX:s/2-o,offsetY:s/2+o,visible:a&&i.indexOf(`top-right`)>=0}),this._anchors[`middle-left`].setAttrs({x:0,y:r/2,offsetX:s/2+o,visible:a&&i.indexOf(`middle-left`)>=0}),this._anchors[`middle-right`].setAttrs({x:n,y:r/2,offsetX:s/2-o,visible:a&&i.indexOf(`middle-right`)>=0}),this._anchors[`bottom-left`].setAttrs({x:0,y:r,offsetX:s/2+o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-left`)>=0}),this._anchors[`bottom-center`].setAttrs({x:n/2,y:r,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-center`)>=0}),this._anchors[`bottom-right`].setAttrs({x:n,y:r,offsetX:s/2-o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-right`)>=0});let c=j_(this,n,r);this._anchors.rotater.setAttrs({x:c.endX,y:c.endY,visible:this.rotateEnabled()}),this._back.setAttrs({width:n,height:r,visible:this.borderEnabled()||this.shouldOverdrawWholeArea(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0})}isTransforming(){return this._transforming}stopTransform(){this._transforming&&this._removeEvents()}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=``),gg.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(W.error(`You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead.`),this):super.add(...e)}toObject(){return Dh.prototype.toObject.call(this)}clone(e){return Dh.prototype.clone.call(this,e)}getClientRect(e){return this.nodes().length>0?super.getClientRect(e):{x:0,y:0,width:0,height:0}}};N_.isTransforming=()=>M_.size>0;function ote(e){return e instanceof Array||W.warn(`enabledAnchors value should be an array`),e instanceof Array&&e.forEach(function(e){A_.indexOf(e)===-1&&W.warn(`Unknown anchor name: `+e+`. Available names are: `+A_.join(`, `))}),e||[]}N_.prototype.className=`Transformer`,Zp(N_),G.addGetterSetter(N_,`enabledAnchors`,A_,ote),G.addGetterSetter(N_,`flipEnabled`,!0,oh()),G.addGetterSetter(N_,`resizeEnabled`,!0),G.addGetterSetter(N_,`anchorSize`,10,eh()),G.addGetterSetter(N_,`rotateEnabled`,!0),G.addGetterSetter(N_,`rotateLineVisible`,!0),G.addGetterSetter(N_,`rotationSnaps`,[]),G.addGetterSetter(N_,`rotateAnchorOffset`,50,eh()),G.addGetterSetter(N_,`rotateAnchorAngle`,0,eh()),G.addGetterSetter(N_,`rotateAnchorCursor`,`crosshair`),G.addGetterSetter(N_,`rotationSnapTolerance`,5,eh()),G.addGetterSetter(N_,`borderEnabled`,!0),G.addGetterSetter(N_,`anchorStroke`,`rgb(0, 161, 255)`),G.addGetterSetter(N_,`anchorStrokeWidth`,1,eh()),G.addGetterSetter(N_,`anchorFill`,`white`),G.addGetterSetter(N_,`anchorCornerRadius`,0,eh()),G.addGetterSetter(N_,`borderStroke`,`rgb(0, 161, 255)`),G.addGetterSetter(N_,`borderStrokeWidth`,1,eh()),G.addGetterSetter(N_,`borderDash`),G.addGetterSetter(N_,`keepRatio`,!0),G.addGetterSetter(N_,`shiftBehavior`,`default`),G.addGetterSetter(N_,`centeredScaling`,!1),G.addGetterSetter(N_,`ignoreStroke`,!1),G.addGetterSetter(N_,`padding`,0,eh()),G.addGetterSetter(N_,`nodes`),G.addGetterSetter(N_,`node`),G.addGetterSetter(N_,`boundBoxFunc`),G.addGetterSetter(N_,`anchorDragBoundFunc`),G.addGetterSetter(N_,`anchorStyleFunc`),G.addGetterSetter(N_,`shouldOverdrawWholeArea`,!1),G.addGetterSetter(N_,`useSingleNodeRotation`,!0),G.backCompat(N_,{lineEnabled:`borderEnabled`,rotateHandlerOffset:`rotateAnchorOffset`,enabledHandlers:`enabledAnchors`});var P_=class extends dg{_sceneFunc(e){e.beginPath(),e.arc(0,0,Math.abs(this.radius()),0,Yp.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.radius())*2}getHeight(){return Math.abs(this.radius())*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};P_.prototype.className=`Wedge`,P_.prototype._centroid=!0,P_.prototype._attrsAffectingSize=[`radius`],Zp(P_,!0),G.addGetterSetter(P_,`radius`,0,eh()),G.addGetterSetter(P_,`angle`,0,eh()),G.addGetterSetter(P_,`clockwise`,!1),G.backCompat(P_,{angleDeg:`angle`,getAngleDeg:`getAngle`,setAngleDeg:`setAngle`});function F_(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var ste=[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],cte=[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 I_(e,t){return t===255?e:e*t/255}var L_=180;function lte(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,T=t+t+1,E=r-1,D=i-1,O=t+1,k=O*(O+1)/2,A=new F_,j=t<=L_?ste[t]/2**cte[t]:1/(O*O),M=null,N=A,P=null,F=null;for(let e=1;e<T;e++)N=N.next=new F_,e===O&&(M=N);N.next=A,s=o=0;for(let e=0;e<i;e++){g=_=v=y=c=l=u=d=0,C=n[o+3],b=I_(n[o],C),x=I_(n[o+1],C),S=I_(n[o+2],C),f=O*b,p=O*x,m=O*S,h=O*C,c+=k*b,l+=k*x,u+=k*S,d+=k*C,N=A;for(let e=0;e<O;e++)N.r=b,N.g=x,N.b=S,N.a=C,N=N.next;for(let e=1;e<O;e++)a=o+((E<e?E:e)<<2),C=n[a+3],c+=(N.r=b=I_(n[a],C))*(w=O-e),l+=(N.g=x=I_(n[a+1],C))*w,u+=(N.b=S=I_(n[a+2],C))*w,d+=(N.a=C)*w,g+=b,_+=x,v+=S,y+=C,N=N.next;P=A,F=M;for(let e=0;e<r;e++)n[o]=Math.floor(c*j),n[o+1]=Math.floor(l*j),n[o+2]=Math.floor(u*j),n[o+3]=Math.floor(d*j),c-=f,l-=p,u-=m,d-=h,f-=P.r,p-=P.g,m-=P.b,h-=P.a,a=s+((a=e+t+1)<E?a:E)<<2,C=n[a+3],g+=P.r=I_(n[a],C),_+=P.g=I_(n[a+1],C),v+=P.b=I_(n[a+2],C),y+=P.a=C,c+=g,l+=_,u+=v,d+=y,P=P.next,f+=b=F.r,p+=x=F.g,m+=S=F.b,h+=C=F.a,g-=b,_-=x,v-=S,y-=C,F=F.next,o+=4;s+=r}for(let e=0;e<r;e++){_=v=y=g=l=u=d=c=0,o=e<<2,f=O*(b=n[o]),p=O*(x=n[o+1]),m=O*(S=n[o+2]),h=O*(C=n[o+3]),c+=k*b,l+=k*x,u+=k*S,d+=k*C,N=A;for(let e=0;e<O;e++)N.r=b,N.g=x,N.b=S,N.a=C,N=N.next;let s=Math.min(1,D)*r;for(let i=1;i<=t;i++)o=s+e<<2,c+=(N.r=b=n[o])*(w=O-i),l+=(N.g=x=n[o+1])*w,u+=(N.b=S=n[o+2])*w,d+=(N.a=C=n[o+3])*w,g+=b,_+=x,v+=S,y+=C,N=N.next,i<D&&(s+=r);o=e,P=A,F=M;for(let t=0;t<i;t++)a=o<<2,n[a+3]=C=Math.floor(d*j),C>0?(C=255/C,n[a]=Math.floor(c*j)*C,n[a+1]=Math.floor(l*j)*C,n[a+2]=Math.floor(u*j)*C):n[a]=n[a+1]=n[a+2]=0,c-=f,l-=p,u-=m,d-=h,f-=P.r,p-=P.g,m-=P.b,h-=P.a,a=e+((a=t+O)<D?a:D)*r<<2,c+=g+=P.r=n[a],l+=_+=P.g=n[a+1],u+=v+=P.b=n[a+2],d+=y+=P.a=n[a+3],P=P.next,f+=b=F.r,p+=x=F.g,m+=S=F.b,h+=C=F.a,g-=b,_-=x,v-=S,y-=C,F=F.next,o+=r}}var ute=function(e,t=1){let n=Math.round(Math.min(this.blurRadius(),L_)*t);n>0&&lte(e,n)};G.addGetterSetter(Dh,`blurRadius`,0,eh(),G.afterSetFilter);var dte=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};G.addGetterSetter(Dh,`brightness`,0,eh(),G.afterSetFilter);var fte=function(e){let t=this.attrs.brightness===void 0?1: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)},pte=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};G.addGetterSetter(Dh,`contrast`,0,eh(),G.afterSetFilter);var mte=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 Float32Array(n*r);for(let e=0,n=0;n<t.length;n+=4,e++)m[e]=.2126*t[n]+.7152*t[n+1]+.0722*t[n+2];let h=[-1,0,1,-2,0,2,-1,0,1],g=[-1,-2,-1,0,0,0,1,2,1],_=e=>e<0?0:e>255?255:e;for(let e=0;e<r;e++)for(let i=0;i<n;i++){let a=0,o=0,c=0;for(let t=-1;t<=1;t++){let s=Math.max(0,Math.min(r-1,e+t))*n;for(let e=-1;e<=1;e++,c++){let t=m[s+Math.max(0,Math.min(n-1,i+e))];a+=t*h[c],o+=t*g[c]}}let u=e*n+i,v=_(l+(d*a+f*o)*p),y=u*4;if(s){let e=v-l;t[y]=_(t[y]+e),t[y+1]=_(t[y+1]+e),t[y+2]=_(t[y+2]+e)}else t[y]=t[y+1]=t[y+2]=v}return e};G.addGetterSetter(Dh,`embossStrength`,.5,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`embossWhiteLevel`,.5,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`embossDirection`,`top-left`,void 0,G.afterSetFilter),G.addGetterSetter(Dh,`embossBlend`,!1,void 0,G.afterSetFilter);function R_(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 hte=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]=R_(t[e+0],r,i,m,p),t[e+1]=R_(t[e+1],o,s,g,h),t[e+2]=R_(t[e+2],l,u,v,_)};G.addGetterSetter(Dh,`enhance`,0,eh(),G.afterSetFilter);var gte=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}};G.addGetterSetter(Dh,`hue`,0,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`saturation`,0,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`luminance`,0,eh(),G.afterSetFilter);var _te=function(e){let t=e.data,n=t.length,r=2**this.saturation(),i=(this.hue()%360+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+.168*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+.292*s,m=.299-.3*o+1.25*s,h=.587-.588*o-1.05*s,g=.114+.886*o-.203*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},vte=function(e){let t=e.data,n=t.length,r=2**this.value(),i=2**this.saturation(),a=(this.hue()%360+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+.168*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+.292*s,m=.299*r-.3*o+1.25*s,h=.587*r-.588*o-1.05*s,g=.114*r+.886*o-.203*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}};G.addGetterSetter(Dh,`hue`,0,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`saturation`,0,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`value`,0,eh(),G.afterSetFilter);var yte=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]},bte=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]=_}}},xte=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}},Ste=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(t*((m%360+360)%360)/360);if(p<1)return;let g={width:t,height:n,data:new Uint8ClampedArray(t*n*4)};bte(e,g,{polarCenterX:t/2,polarCenterY:n/2});let _=t/2**p;for(;_<=8;)_*=2,--p;_=Math.ceil(_);let v=_,y=0,b=v,x=1;for(h+_>t&&(y=v,b=0,x=-1),i=0;i<n;i+=1)for(r=y;r!==b;r+=x)a=Math.round(r+h)%t,d=(t*i+a)*4,s=g.data[d+0],c=g.data[d+1],l=g.data[d+2],u=g.data[d+3],f=(t*i+r)*4,g.data[f+0]=s,g.data[f+1]=c,g.data[f+2]=l,g.data[f+3]=u;for(i=0;i<n;i+=1)for(v=Math.floor(_),o=0;o<p;o+=1){for(r=0;r<v+1;r+=1)d=(t*i+r)*4,s=g.data[d+0],c=g.data[d+1],l=g.data[d+2],u=g.data[d+3],f=(t*i+v*2-r-1)*4,g.data[f+0]=s,g.data[f+1]=c,g.data[f+2]=l,g.data[f+3]=u;v*=2}xte(g,e,{polarRotation:0})};G.addGetterSetter(Dh,`kaleidoscopePower`,2,eh(),G.afterSetFilter),G.addGetterSetter(Dh,`kaleidoscopeAngle`,0,eh(),G.afterSetFilter);function z_(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 B_(e,t){return Math.sqrt((e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2)}function Cte(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 wte(e,t){let n=z_(e,0,0),r=z_(e,e.width-1,0),i=z_(e,0,e.height-1),a=z_(e,e.width-1,e.height-1);if(B_(n,r)<t&&B_(r,a)<t&&B_(a,i)<t&&B_(i,n)<t){let o=Cte([r,n,a,i]),s=[];for(let n=0;n<e.width*e.height;n++){let r=B_(o,[e.data[n*4],e.data[n*4+1],e.data[n*4+2]]);s[n]=r<t?0:255}return s}}function Tte(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function Ete(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 Dte(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 Ote(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 kte=function(e){let t=wte(e,this.attrs.threshold??10);return t&&(t=Ete(t,e.width,e.height),t=Dte(t,e.width,e.height),t=Ote(t,e.width,e.height),Tte(e,t)),e};G.addGetterSetter(Dh,`threshold`,.5,eh(),G.afterSetFilter);var Ate=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()};G.addGetterSetter(Dh,`noise`,.2,eh(),G.afterSetFilter);var jte=function(e,t=1){let n=Math.ceil(this.pixelSize()*t),r=e.width,i=e.height,a=Math.ceil(r/n),o=Math.ceil(i/n),s=e.data;if(n<=0){W.error(`pixelSize value can not be <= 0`);return}for(let e=0;e<a;e+=1)for(let t=0;t<o;t+=1){let a=0,o=0,c=0,l=0,u=e*n,d=Math.min(u+n,r),f=t*n,p=Math.min(f+n,i);for(let e=u;e<d;e+=1)for(let t=f;t<p;t+=1){let n=(r*t+e)*4,i=s[n+3];a+=s[n+0]*i,o+=s[n+1]*i,c+=s[n+2]*i,l+=i}l&&(a/=l,o/=l,c/=l),l/=(d-u)*(p-f);for(let e=u;e<d;e+=1)for(let t=f;t<p;t+=1){let n=(r*t+e)*4;s[n+0]=a,s[n+1]=o,s[n+2]=c,s[n+3]=l}}};G.addGetterSetter(Dh,`pixelSize`,8,eh(),G.afterSetFilter);var Mte=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};G.addGetterSetter(Dh,`levels`,.5,eh(),G.afterSetFilter);var Nte=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]}};G.addGetterSetter(Dh,`red`,0,$m,G.afterSetFilter),G.addGetterSetter(Dh,`green`,0,$m,G.afterSetFilter),G.addGetterSetter(Dh,`blue`,0,$m,G.afterSetFilter);var Pte=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}};G.addGetterSetter(Dh,`alpha`,1,e=>Math.min(1,Math.max(0,e)),G.afterSetFilter);var Fte=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)}},Ite=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},Lte=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};G.addGetterSetter(Dh,`threshold`,.5,eh(),G.afterSetFilter);var V_=Dg.Util._assign(Dg,{Arc:Og,Arrow:Hg,Circle:Ug,Ellipse:Wg,Image:Gg,Label:__,Tag:v_,Line:zg,Path:Vg,Rect:y_,RegularPolygon:b_,Ring:x_,Sprite:S_,Star:C_,Text:f_,TextPath:D_,Transformer:N_,Wedge:P_,Filters:{Blur:ute,Brightness:fte,Brighten:dte,Contrast:pte,Emboss:mte,Enhance:hte,Grayscale:gte,HSL:_te,HSV:vte,Invert:yte,Kaleidoscope:Ste,Mask:kte,Noise:Ate,Pixelate:jte,Posterize:Mte,RGB:Nte,RGBA:Pte,Sepia:Fte,Solarize:Ite,Threshold:Lte}}),H_=Dg,Rte=c(((e,t)=>{t.exports=function(e){function t(e,t,n,r){return new no(e,t,n,r)}function n(){}function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function a(e){if(i(e)!==e)throw Error(r(188))}function o(e){var t=e.alternate;if(!t){if(t=i(e),t===null)throw Error(r(188));return t===e?e:null}for(var n=e,o=t;;){var s=n.return;if(s===null)break;var c=s.alternate;if(c===null){if(o=s.return,o!==null){n=o;continue}break}if(s.child===c.child){for(c=s.child;c;){if(c===n)return a(s),e;if(c===o)return a(s),t;c=c.sibling}throw Error(r(188))}if(n.return!==o.return)n=s,o=c;else{for(var l=!1,u=s.child;u;){if(u===n){l=!0,n=s,o=c;break}if(u===o){l=!0,o=s,n=c;break}u=u.sibling}if(!l){for(u=c.child;u;){if(u===n){l=!0,n=c,o=s;break}if(u===o){l=!0,o=c,n=s;break}u=u.sibling}if(!l)throw Error(r(189))}}if(n.alternate!==o)throw Error(r(190))}if(n.tag!==3)throw Error(r(188));return n.stateNode.current===n?e:t}function s(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=s(e),t!==null)return t;e=e.sibling}return null}function c(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(e.tag!==4&&(t=c(e),t!==null))return t;e=e.sibling}return null}function l(e){return typeof e!=`object`||!e?null:(e=Vo&&e[Vo]||e[`@@iterator`],typeof e==`function`?e:null)}function u(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===Uo?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case Eo:return`Fragment`;case Oo:return`Profiler`;case Do:return`StrictMode`;case Mo:return`Suspense`;case No:return`SuspenseList`;case Io:return`Activity`;case zo:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case To:return`Portal`;case Ao:return e.displayName||`Context`;case ko:return(e._context.displayName||`Context`)+`.Consumer`;case jo:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case Po:return t=e.displayName||null,t===null?u(e.type)||`Memo`:t;case Fo:t=e._payload,e=e._init;try{return u(e(t))}catch{}}return null}function d(e){return{current:e}}function f(e){0>kl||(e.current=Ol[kl],Ol[kl]=null,kl--)}function p(e,t){kl++,Ol[kl]=e.current,e.current=t}function h(e){return e>>>=0,e===0?32:31-(Ml(e)/Nl|0)|0}function _(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function v(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=_(n))):i=_(o):i=_(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=_(n))):i=_(o)):i=_(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function y(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function b(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-jl(n),i=1<<r;t|=e[r],n&=~i}return t}function x(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function S(){var e=Il;return Il<<=1,!(Il&62914560)&&(Il=4194304),e}function C(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function w(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function T(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-jl(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&E(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function E(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-jl(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function D(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-jl(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function O(e,t){var n=t&-t;return n=n&42?1:k(n),(n&(e.suspendedLanes|t))===0?n:0}function k(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function A(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function j(e){if(typeof Kl==`function`&&ql(e),Yl&&typeof Yl.setStrictMode==`function`)try{Yl.setStrictMode(Jl,e)}catch{}}function M(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=Ef.identifierPrefix;var n=Xl++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function N(e){if(e==null||typeof e==`string`)return e;var t=null,n=Pf;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function P(e,t){return e=N(e),t=N(t),t==null?e===`auto`?null:e:t===`auto`?null:t}function F(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}function I(e){if(eu===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);eu=t&&t[1]||``,tu=-1<e.stack.indexOf(`
79
79
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
80
80
  `+eu+e+tu}function L(e,t){if(!e||nu)return``;nu=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
81
81
  `),l=s.split(`
@@ -1 +1 @@
1
- import*as e from"mobx";import{getAPI as o}from"./api.js";import{removeBackgroundState as t}from"./flags.js";const n=e.observable({value:!1}),a=e.observable({value:"v1"});export const ___=()=>a.value;const i=e.observable({value:0});export const ____=()=>i.value;export const isCreditVisible=()=>n.value;const r=e.action(()=>{n.value=!0});let s="";export const getKey=()=>s||"";export const setKey=e=>{s=e||""};let l="undefined"!=typeof window?window.location.origin:"";const c="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,d="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===l&&c&&(l="headless"),"file://"===l&&d&&(l="electron");const u=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${l}" here: https://polotno.com/cabinet`;let p=fetch;export const __=e=>{p=e};export async function isKeyPaid(n){for(let s=0;s<5;s++){try{const r=await p(o()+"/validate-key",{method:"POST",body:JSON.stringify({key:n,site:location.host,skdVersion:"4.15.2"})});if(e.runInAction(()=>{a.value=r.headers.get("x-api-version")||""}),!n){return console.error("Polotno API is initialized without API key. It may lead to unexpected behavior and stop working. Please create API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1}),!1}if(200!==r.status){await new Promise(e=>setTimeout(e,3e3));continue}const s=await r.json();return s.is_valid||(console.error("Polotno API key is not valid. Please get new API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1})),s.is_paid||(console.log("%cPolotno Free Version. For development usage only. https://polotno.com/","background: rgb(0, 161, 255); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{0===i.value&&(i.value=2)})),s.is_domain_valid||console.log(u,"background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{t.defaultEnabled=s.remove_background_enabled}),s.is_paid||!1}catch(r){await new Promise(e=>setTimeout(e,3e3))}}return console.error("Can not validate Polotno API key. Please report to anton@polotno.com immediately."),!0}export async function validateKey(e){await isKeyPaid(s)&&!e||r()}
1
+ import*as e from"mobx";import{getAPI as o}from"./api.js";import{removeBackgroundState as t}from"./flags.js";const n=e.observable({value:!1}),a=e.observable({value:"v1"});export const ___=()=>a.value;const i=e.observable({value:0});export const ____=()=>i.value;export const isCreditVisible=()=>n.value;const r=e.action(()=>{n.value=!0});let s="";export const getKey=()=>s||"";export const setKey=e=>{s=e||""};let l="undefined"!=typeof window?window.location.origin:"";const c="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,d="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===l&&c&&(l="headless"),"file://"===l&&d&&(l="electron");const u=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${l}" here: https://polotno.com/cabinet`;let p=fetch;export const __=e=>{p=e};export async function isKeyPaid(n){for(let s=0;s<5;s++){try{const r=await p(o()+"/validate-key",{method:"POST",body:JSON.stringify({key:n,site:location.host,skdVersion:"4.15.3"})});if(e.runInAction(()=>{a.value=r.headers.get("x-api-version")||""}),!n){return console.error("Polotno API is initialized without API key. It may lead to unexpected behavior and stop working. Please create API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1}),!1}if(200!==r.status){await new Promise(e=>setTimeout(e,3e3));continue}const s=await r.json();return s.is_valid||(console.error("Polotno API key is not valid. Please get new API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1})),s.is_paid||(console.log("%cPolotno Free Version. For development usage only. https://polotno.com/","background: rgb(0, 161, 255); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{0===i.value&&(i.value=2)})),s.is_domain_valid||console.log(u,"background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{t.defaultEnabled=s.remove_background_enabled}),s.is_paid||!1}catch(r){await new Promise(e=>setTimeout(e,3e3))}}return console.error("Can not validate Polotno API key. Please report to anton@polotno.com immediately."),!0}export async function validateKey(e){await isKeyPaid(s)&&!e||r()}