peaks-player
Version:
A Web Component for peaks.js
1,461 lines • 311 kB
JavaScript
var Bn = Object.defineProperty;
var Hn = (e, t, i) => t in e ? Bn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
var li = (e, t, i) => Hn(e, typeof t != "symbol" ? t + "" : t, i);
const Vn = `<style>
#m-zoomview, #m-overview {
height: 100px;
background: var(--pp-color-bg, #111);
}
#m-audio, #m-zoomview, #m-overview {
width: 1000px;
}
#m-root {
display: flex;
flex-direction: column;
}
</style>
<div id="m-root">
<audio controls id="m-audio"></audio>
<div id="m-zoomview"></div>
<div id="m-overview"></div>
</div>
`;
var Mi = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Un(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var mi = { exports: {} }, vi = {}, J = {};
(function(e) {
Object.defineProperty(e, "__esModule", { value: !0 }), e._registerNode = e.Konva = e.glob = void 0;
const t = Math.PI / 180;
function i() {
return typeof window < "u" && ({}.toString.call(window) === "[object Window]" || {}.toString.call(window) === "[object global]");
}
e.glob = typeof Mi < "u" ? Mi : typeof window < "u" ? window : typeof WorkerGlobalScope < "u" ? self : {}, e.Konva = {
_global: e.glob,
version: "9.3.18",
isBrowser: i(),
isUnminified: /param/.test((function(r) {
}).toString()),
dblClickWindow: 400,
getAngle(r) {
return e.Konva.angleDeg ? r * t : r;
},
enableTrace: !1,
pointerEventsEnabled: !0,
autoDrawEnabled: !0,
hitOnDragEnabled: !1,
capturePointerEventsEnabled: !1,
_mouseListenClick: !1,
_touchListenClick: !1,
_pointerListenClick: !1,
_mouseInDblClickWindow: !1,
_touchInDblClickWindow: !1,
_pointerInDblClickWindow: !1,
_mouseDblClickPointerId: null,
_touchDblClickPointerId: null,
_pointerDblClickPointerId: null,
_fixTextRendering: !1,
pixelRatio: typeof window < "u" && window.devicePixelRatio || 1,
dragDistance: 3,
angleDeg: !0,
showWarnings: !0,
dragButtons: [0, 1],
isDragging() {
return e.Konva.DD.isDragging;
},
isTransforming() {
var r;
return (r = e.Konva.Transformer) === null || r === void 0 ? void 0 : r.isTransforming();
},
isDragReady() {
return !!e.Konva.DD.node;
},
releaseCanvasOnDestroy: !0,
document: e.glob.document,
_injectGlobal(r) {
e.glob.Konva = r;
}
};
const n = (r) => {
e.Konva[r.prototype.getClassName()] = r;
};
e._registerNode = n, e.Konva._injectGlobal(e.Konva);
})(J);
var dt = {};
(function(e) {
Object.defineProperty(e, "__esModule", { value: !0 }), e.Util = e.Transform = void 0;
const t = J;
class i {
constructor(d = [1, 0, 0, 1, 0, 0]) {
this.dirty = !1, this.m = d && d.slice() || [1, 0, 0, 1, 0, 0];
}
reset() {
this.m[0] = 1, this.m[1] = 0, this.m[2] = 0, this.m[3] = 1, this.m[4] = 0, this.m[5] = 0;
}
copy() {
return new i(this.m);
}
copyInto(d) {
d.m[0] = this.m[0], d.m[1] = this.m[1], d.m[2] = this.m[2], d.m[3] = this.m[3], d.m[4] = this.m[4], d.m[5] = this.m[5];
}
point(d) {
const v = this.m;
return {
x: v[0] * d.x + v[2] * d.y + v[4],
y: v[1] * d.x + v[3] * d.y + v[5]
};
}
translate(d, v) {
return this.m[4] += this.m[0] * d + this.m[2] * v, this.m[5] += this.m[1] * d + this.m[3] * v, this;
}
scale(d, v) {
return this.m[0] *= d, this.m[1] *= d, this.m[2] *= v, this.m[3] *= v, this;
}
rotate(d) {
const v = Math.cos(d), C = Math.sin(d), E = this.m[0] * v + this.m[2] * C, p = this.m[1] * v + this.m[3] * C, x = this.m[0] * -C + this.m[2] * v, S = this.m[1] * -C + this.m[3] * v;
return this.m[0] = E, this.m[1] = p, this.m[2] = x, this.m[3] = S, this;
}
getTranslation() {
return {
x: this.m[4],
y: this.m[5]
};
}
skew(d, v) {
const C = this.m[0] + this.m[2] * v, E = this.m[1] + this.m[3] * v, p = this.m[2] + this.m[0] * d, x = this.m[3] + this.m[1] * d;
return this.m[0] = C, this.m[1] = E, this.m[2] = p, this.m[3] = x, this;
}
multiply(d) {
const v = this.m[0] * d.m[0] + this.m[2] * d.m[1], C = this.m[1] * d.m[0] + this.m[3] * d.m[1], E = this.m[0] * d.m[2] + this.m[2] * d.m[3], p = this.m[1] * d.m[2] + this.m[3] * d.m[3], x = this.m[0] * d.m[4] + this.m[2] * d.m[5] + this.m[4], S = this.m[1] * d.m[4] + this.m[3] * d.m[5] + this.m[5];
return this.m[0] = v, this.m[1] = C, this.m[2] = E, this.m[3] = p, this.m[4] = x, this.m[5] = S, this;
}
invert() {
const d = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]), v = this.m[3] * d, C = -this.m[1] * d, E = -this.m[2] * d, p = this.m[0] * d, x = d * (this.m[2] * this.m[5] - this.m[3] * this.m[4]), S = d * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);
return this.m[0] = v, this.m[1] = C, this.m[2] = E, this.m[3] = p, this.m[4] = x, this.m[5] = S, this;
}
getMatrix() {
return this.m;
}
decompose() {
const d = this.m[0], v = this.m[1], C = this.m[2], E = this.m[3], p = this.m[4], x = this.m[5], S = d * E - v * C, A = {
x: p,
y: x,
rotation: 0,
scaleX: 0,
scaleY: 0,
skewX: 0,
skewY: 0
};
if (d != 0 || v != 0) {
const I = Math.sqrt(d * d + v * v);
A.rotation = v > 0 ? Math.acos(d / I) : -Math.acos(d / I), A.scaleX = I, A.scaleY = S / I, A.skewX = (d * C + v * E) / S, A.skewY = 0;
} else if (C != 0 || E != 0) {
const I = Math.sqrt(C * C + E * E);
A.rotation = Math.PI / 2 - (E > 0 ? Math.acos(-C / I) : -Math.acos(C / I)), A.scaleX = S / I, A.scaleY = I, A.skewX = 0, A.skewY = (d * C + v * E) / S;
}
return A.rotation = e.Util._getRotation(A.rotation), A;
}
}
e.Transform = i;
const n = "[object Array]", r = "[object Number]", s = "[object String]", a = "[object Boolean]", o = Math.PI / 180, l = 180 / Math.PI, f = "#", c = "", b = "0", T = "Konva warning: ", g = "Konva error: ", u = "rgb(", m = {
aliceblue: [240, 248, 255],
antiquewhite: [250, 235, 215],
aqua: [0, 255, 255],
aquamarine: [127, 255, 212],
azure: [240, 255, 255],
beige: [245, 245, 220],
bisque: [255, 228, 196],
black: [0, 0, 0],
blanchedalmond: [255, 235, 205],
blue: [0, 0, 255],
blueviolet: [138, 43, 226],
brown: [165, 42, 42],
burlywood: [222, 184, 135],
cadetblue: [95, 158, 160],
chartreuse: [127, 255, 0],
chocolate: [210, 105, 30],
coral: [255, 127, 80],
cornflowerblue: [100, 149, 237],
cornsilk: [255, 248, 220],
crimson: [220, 20, 60],
cyan: [0, 255, 255],
darkblue: [0, 0, 139],
darkcyan: [0, 139, 139],
darkgoldenrod: [184, 132, 11],
darkgray: [169, 169, 169],
darkgreen: [0, 100, 0],
darkgrey: [169, 169, 169],
darkkhaki: [189, 183, 107],
darkmagenta: [139, 0, 139],
darkolivegreen: [85, 107, 47],
darkorange: [255, 140, 0],
darkorchid: [153, 50, 204],
darkred: [139, 0, 0],
darksalmon: [233, 150, 122],
darkseagreen: [143, 188, 143],
darkslateblue: [72, 61, 139],
darkslategray: [47, 79, 79],
darkslategrey: [47, 79, 79],
darkturquoise: [0, 206, 209],
darkviolet: [148, 0, 211],
deeppink: [255, 20, 147],
deepskyblue: [0, 191, 255],
dimgray: [105, 105, 105],
dimgrey: [105, 105, 105],
dodgerblue: [30, 144, 255],
firebrick: [178, 34, 34],
floralwhite: [255, 255, 240],
forestgreen: [34, 139, 34],
fuchsia: [255, 0, 255],
gainsboro: [220, 220, 220],
ghostwhite: [248, 248, 255],
gold: [255, 215, 0],
goldenrod: [218, 165, 32],
gray: [128, 128, 128],
green: [0, 128, 0],
greenyellow: [173, 255, 47],
grey: [128, 128, 128],
honeydew: [240, 255, 240],
hotpink: [255, 105, 180],
indianred: [205, 92, 92],
indigo: [75, 0, 130],
ivory: [255, 255, 240],
khaki: [240, 230, 140],
lavender: [230, 230, 250],
lavenderblush: [255, 240, 245],
lawngreen: [124, 252, 0],
lemonchiffon: [255, 250, 205],
lightblue: [173, 216, 230],
lightcoral: [240, 128, 128],
lightcyan: [224, 255, 255],
lightgoldenrodyellow: [250, 250, 210],
lightgray: [211, 211, 211],
lightgreen: [144, 238, 144],
lightgrey: [211, 211, 211],
lightpink: [255, 182, 193],
lightsalmon: [255, 160, 122],
lightseagreen: [32, 178, 170],
lightskyblue: [135, 206, 250],
lightslategray: [119, 136, 153],
lightslategrey: [119, 136, 153],
lightsteelblue: [176, 196, 222],
lightyellow: [255, 255, 224],
lime: [0, 255, 0],
limegreen: [50, 205, 50],
linen: [250, 240, 230],
magenta: [255, 0, 255],
maroon: [128, 0, 0],
mediumaquamarine: [102, 205, 170],
mediumblue: [0, 0, 205],
mediumorchid: [186, 85, 211],
mediumpurple: [147, 112, 219],
mediumseagreen: [60, 179, 113],
mediumslateblue: [123, 104, 238],
mediumspringgreen: [0, 250, 154],
mediumturquoise: [72, 209, 204],
mediumvioletred: [199, 21, 133],
midnightblue: [25, 25, 112],
mintcream: [245, 255, 250],
mistyrose: [255, 228, 225],
moccasin: [255, 228, 181],
navajowhite: [255, 222, 173],
navy: [0, 0, 128],
oldlace: [253, 245, 230],
olive: [128, 128, 0],
olivedrab: [107, 142, 35],
orange: [255, 165, 0],
orangered: [255, 69, 0],
orchid: [218, 112, 214],
palegoldenrod: [238, 232, 170],
palegreen: [152, 251, 152],
paleturquoise: [175, 238, 238],
palevioletred: [219, 112, 147],
papayawhip: [255, 239, 213],
peachpuff: [255, 218, 185],
peru: [205, 133, 63],
pink: [255, 192, 203],
plum: [221, 160, 203],
powderblue: [176, 224, 230],
purple: [128, 0, 128],
rebeccapurple: [102, 51, 153],
red: [255, 0, 0],
rosybrown: [188, 143, 143],
royalblue: [65, 105, 225],
saddlebrown: [139, 69, 19],
salmon: [250, 128, 114],
sandybrown: [244, 164, 96],
seagreen: [46, 139, 87],
seashell: [255, 245, 238],
sienna: [160, 82, 45],
silver: [192, 192, 192],
skyblue: [135, 206, 235],
slateblue: [106, 90, 205],
slategray: [119, 128, 144],
slategrey: [119, 128, 144],
snow: [255, 255, 250],
springgreen: [0, 255, 127],
steelblue: [70, 130, 180],
tan: [210, 180, 140],
teal: [0, 128, 128],
thistle: [216, 191, 216],
transparent: [255, 255, 255, 0],
tomato: [255, 99, 71],
turquoise: [64, 224, 208],
violet: [238, 130, 238],
wheat: [245, 222, 179],
white: [255, 255, 255],
whitesmoke: [245, 245, 245],
yellow: [255, 255, 0],
yellowgreen: [154, 205, 5]
}, y = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;
let w = [];
const P = typeof requestAnimationFrame < "u" && requestAnimationFrame || function(h) {
setTimeout(h, 60);
};
e.Util = {
_isElement(h) {
return !!(h && h.nodeType == 1);
},
_isFunction(h) {
return !!(h && h.constructor && h.call && h.apply);
},
_isPlainObject(h) {
return !!h && h.constructor === Object;
},
_isArray(h) {
return Object.prototype.toString.call(h) === n;
},
_isNumber(h) {
return Object.prototype.toString.call(h) === r && !isNaN(h) && isFinite(h);
},
_isString(h) {
return Object.prototype.toString.call(h) === s;
},
_isBoolean(h) {
return Object.prototype.toString.call(h) === a;
},
isObject(h) {
return h instanceof Object;
},
isValidSelector(h) {
if (typeof h != "string")
return !1;
const d = h[0];
return d === "#" || d === "." || d === d.toUpperCase();
},
_sign(h) {
return h === 0 || h > 0 ? 1 : -1;
},
requestAnimFrame(h) {
w.push(h), w.length === 1 && P(function() {
const d = w;
w = [], d.forEach(function(v) {
v();
});
});
},
createCanvasElement() {
const h = document.createElement("canvas");
try {
h.style = h.style || {};
} catch {
}
return h;
},
createImageElement() {
return document.createElement("img");
},
_isInDocument(h) {
for (; h = h.parentNode; )
if (h == document)
return !0;
return !1;
},
_urlToImage(h, d) {
const v = e.Util.createImageElement();
v.onload = function() {
d(v);
}, v.src = h;
},
_rgbToHex(h, d, v) {
return ((1 << 24) + (h << 16) + (d << 8) + v).toString(16).slice(1);
},
_hexToRgb(h) {
h = h.replace(f, c);
const d = parseInt(h, 16);
return {
r: d >> 16 & 255,
g: d >> 8 & 255,
b: d & 255
};
},
getRandomColor() {
let h = (Math.random() * 16777215 << 0).toString(16);
for (; h.length < 6; )
h = b + h;
return f + h;
},
getRGB(h) {
let d;
return h in m ? (d = m[h], {
r: d[0],
g: d[1],
b: d[2]
}) : h[0] === f ? this._hexToRgb(h.substring(1)) : h.substr(0, 4) === u ? (d = y.exec(h.replace(/ /g, "")), {
r: parseInt(d[1], 10),
g: parseInt(d[2], 10),
b: parseInt(d[3], 10)
}) : {
r: 0,
g: 0,
b: 0
};
},
colorToRGBA(h) {
return h = h || "black", e.Util._namedColorToRBA(h) || e.Util._hex3ColorToRGBA(h) || e.Util._hex4ColorToRGBA(h) || e.Util._hex6ColorToRGBA(h) || e.Util._hex8ColorToRGBA(h) || e.Util._rgbColorToRGBA(h) || e.Util._rgbaColorToRGBA(h) || e.Util._hslColorToRGBA(h);
},
_namedColorToRBA(h) {
const d = m[h.toLowerCase()];
return d ? {
r: d[0],
g: d[1],
b: d[2],
a: 1
} : null;
},
_rgbColorToRGBA(h) {
if (h.indexOf("rgb(") === 0) {
h = h.match(/rgb\(([^)]+)\)/)[1];
const d = h.split(/ *, */).map(Number);
return {
r: d[0],
g: d[1],
b: d[2],
a: 1
};
}
},
_rgbaColorToRGBA(h) {
if (h.indexOf("rgba(") === 0) {
h = h.match(/rgba\(([^)]+)\)/)[1];
const d = h.split(/ *, */).map((v, C) => v.slice(-1) === "%" ? C === 3 ? parseInt(v) / 100 : parseInt(v) / 100 * 255 : Number(v));
return {
r: d[0],
g: d[1],
b: d[2],
a: d[3]
};
}
},
_hex8ColorToRGBA(h) {
if (h[0] === "#" && h.length === 9)
return {
r: parseInt(h.slice(1, 3), 16),
g: parseInt(h.slice(3, 5), 16),
b: parseInt(h.slice(5, 7), 16),
a: parseInt(h.slice(7, 9), 16) / 255
};
},
_hex6ColorToRGBA(h) {
if (h[0] === "#" && h.length === 7)
return {
r: parseInt(h.slice(1, 3), 16),
g: parseInt(h.slice(3, 5), 16),
b: parseInt(h.slice(5, 7), 16),
a: 1
};
},
_hex4ColorToRGBA(h) {
if (h[0] === "#" && h.length === 5)
return {
r: parseInt(h[1] + h[1], 16),
g: parseInt(h[2] + h[2], 16),
b: parseInt(h[3] + h[3], 16),
a: parseInt(h[4] + h[4], 16) / 255
};
},
_hex3ColorToRGBA(h) {
if (h[0] === "#" && h.length === 4)
return {
r: parseInt(h[1] + h[1], 16),
g: parseInt(h[2] + h[2], 16),
b: parseInt(h[3] + h[3], 16),
a: 1
};
},
_hslColorToRGBA(h) {
if (/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(h)) {
const [d, ...v] = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(h), C = Number(v[0]) / 360, E = Number(v[1]) / 100, p = Number(v[2]) / 100;
let x, S, A;
if (E === 0)
return A = p * 255, {
r: Math.round(A),
g: Math.round(A),
b: Math.round(A),
a: 1
};
p < 0.5 ? x = p * (1 + E) : x = p + E - p * E;
const I = 2 * p - x, O = [0, 0, 0];
for (let R = 0; R < 3; R++)
S = C + 1 / 3 * -(R - 1), S < 0 && S++, S > 1 && S--, 6 * S < 1 ? A = I + (x - I) * 6 * S : 2 * S < 1 ? A = x : 3 * S < 2 ? A = I + (x - I) * (2 / 3 - S) * 6 : A = I, O[R] = A * 255;
return {
r: Math.round(O[0]),
g: Math.round(O[1]),
b: Math.round(O[2]),
a: 1
};
}
},
haveIntersection(h, d) {
return !(d.x > h.x + h.width || d.x + d.width < h.x || d.y > h.y + h.height || d.y + d.height < h.y);
},
cloneObject(h) {
const d = {};
for (const v in h)
this._isPlainObject(h[v]) ? d[v] = this.cloneObject(h[v]) : this._isArray(h[v]) ? d[v] = this.cloneArray(h[v]) : d[v] = h[v];
return d;
},
cloneArray(h) {
return h.slice(0);
},
degToRad(h) {
return h * o;
},
radToDeg(h) {
return h * l;
},
_degToRad(h) {
return e.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."), e.Util.degToRad(h);
},
_radToDeg(h) {
return e.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."), e.Util.radToDeg(h);
},
_getRotation(h) {
return t.Konva.angleDeg ? e.Util.radToDeg(h) : h;
},
_capitalize(h) {
return h.charAt(0).toUpperCase() + h.slice(1);
},
throw(h) {
throw new Error(g + h);
},
error(h) {
console.error(g + h);
},
warn(h) {
t.Konva.showWarnings && console.warn(T + h);
},
each(h, d) {
for (const v in h)
d(v, h[v]);
},
_inRange(h, d, v) {
return d <= h && h < v;
},
_getProjectionToSegment(h, d, v, C, E, p) {
let x, S, A;
const I = (h - v) * (h - v) + (d - C) * (d - C);
if (I == 0)
x = h, S = d, A = (E - v) * (E - v) + (p - C) * (p - C);
else {
const O = ((E - h) * (v - h) + (p - d) * (C - d)) / I;
O < 0 ? (x = h, S = d, A = (h - E) * (h - E) + (d - p) * (d - p)) : O > 1 ? (x = v, S = C, A = (v - E) * (v - E) + (C - p) * (C - p)) : (x = h + O * (v - h), S = d + O * (C - d), A = (x - E) * (x - E) + (S - p) * (S - p));
}
return [x, S, A];
},
_getProjectionToLine(h, d, v) {
const C = e.Util.cloneObject(h);
let E = Number.MAX_VALUE;
return d.forEach(function(p, x) {
if (!v && x === d.length - 1)
return;
const S = d[(x + 1) % d.length], A = e.Util._getProjectionToSegment(p.x, p.y, S.x, S.y, h.x, h.y), I = A[0], O = A[1], R = A[2];
R < E && (C.x = I, C.y = O, E = R);
}), C;
},
_prepareArrayForTween(h, d, v) {
const C = [], E = [];
if (h.length > d.length) {
const x = d;
d = h, h = x;
}
for (let x = 0; x < h.length; x += 2)
C.push({
x: h[x],
y: h[x + 1]
});
for (let x = 0; x < d.length; x += 2)
E.push({
x: d[x],
y: d[x + 1]
});
const p = [];
return E.forEach(function(x) {
const S = e.Util._getProjectionToLine(x, C, v);
p.push(S.x), p.push(S.y);
}), p;
},
_prepareToStringify(h) {
let d;
h.visitedByCircularReferenceRemoval = !0;
for (const v in h)
if (h.hasOwnProperty(v) && h[v] && typeof h[v] == "object") {
if (d = Object.getOwnPropertyDescriptor(h, v), h[v].visitedByCircularReferenceRemoval || e.Util._isElement(h[v]))
if (d.configurable)
delete h[v];
else
return null;
else if (e.Util._prepareToStringify(h[v]) === null)
if (d.configurable)
delete h[v];
else
return null;
}
return delete h.visitedByCircularReferenceRemoval, h;
},
_assign(h, d) {
for (const v in d)
h[v] = d[v];
return h;
},
_getFirstPointerId(h) {
return h.touches ? h.changedTouches[0].identifier : h.pointerId || 999;
},
releaseCanvas(...h) {
t.Konva.releaseCanvasOnDestroy && h.forEach((d) => {
d.width = 0, d.height = 0;
});
},
drawRoundedRectPath(h, d, v, C) {
let E = 0, p = 0, x = 0, S = 0;
typeof C == "number" ? E = p = x = S = Math.min(C, d / 2, v / 2) : (E = Math.min(C[0] || 0, d / 2, v / 2), p = Math.min(C[1] || 0, d / 2, v / 2), S = Math.min(C[2] || 0, d / 2, v / 2), x = Math.min(C[3] || 0, d / 2, v / 2)), h.moveTo(E, 0), h.lineTo(d - p, 0), h.arc(d - p, p, p, Math.PI * 3 / 2, 0, !1), h.lineTo(d, v - S), h.arc(d - S, v - S, S, 0, Math.PI / 2, !1), h.lineTo(x, v), h.arc(x, v - x, x, Math.PI / 2, Math.PI, !1), h.lineTo(0, E), h.arc(E, E, E, Math.PI, Math.PI * 3 / 2, !1);
}
};
})(dt);
var Zt = {}, Dt = {}, et = {};
Object.defineProperty(et, "__esModule", { value: !0 });
et.RGBComponent = Nn;
et.alphaComponent = Xn;
et.getNumberValidator = zn;
et.getNumberOrArrayOfNumbersValidator = Yn;
et.getNumberOrAutoValidator = Zn;
et.getStringValidator = Kn;
et.getStringOrGradientValidator = jn;
et.getFunctionValidator = $n;
et.getNumberArrayValidator = qn;
et.getBooleanValidator = Jn;
et.getComponentValidator = Qn;
const Wt = J, q = dt;
function Bt(e) {
return q.Util._isString(e) ? '"' + e + '"' : Object.prototype.toString.call(e) === "[object Number]" || q.Util._isBoolean(e) ? e : Object.prototype.toString.call(e);
}
function Nn(e) {
return e > 255 ? 255 : e < 0 ? 0 : Math.round(e);
}
function Xn(e) {
return e > 1 ? 1 : e < 1e-4 ? 1e-4 : e;
}
function zn() {
if (Wt.Konva.isUnminified)
return function(e, t) {
return q.Util._isNumber(e) || q.Util.warn(Bt(e) + ' is a not valid value for "' + t + '" attribute. The value should be a number.'), e;
};
}
function Yn(e) {
if (Wt.Konva.isUnminified)
return function(t, i) {
let n = q.Util._isNumber(t), r = q.Util._isArray(t) && t.length == e;
return !n && !r && q.Util.warn(Bt(t) + ' is a not valid value for "' + i + '" attribute. The value should be a number or Array<number>(' + e + ")"), t;
};
}
function Zn() {
if (Wt.Konva.isUnminified)
return function(e, t) {
var i = q.Util._isNumber(e), n = e === "auto";
return i || n || q.Util.warn(Bt(e) + ' is a not valid value for "' + t + '" attribute. The value should be a number or "auto".'), e;
};
}
function Kn() {
if (Wt.Konva.isUnminified)
return function(e, t) {
return q.Util._isString(e) || q.Util.warn(Bt(e) + ' is a not valid value for "' + t + '" attribute. The value should be a string.'), e;
};
}
function jn() {
if (Wt.Konva.isUnminified)
return function(e, t) {
const i = q.Util._isString(e), n = Object.prototype.toString.call(e) === "[object CanvasGradient]" || e && e.addColorStop;
return i || n || q.Util.warn(Bt(e) + ' is a not valid value for "' + t + '" attribute. The value should be a string or a native gradient.'), e;
};
}
function $n() {
if (Wt.Konva.isUnminified)
return function(e, t) {
return q.Util._isFunction(e) || q.Util.warn(Bt(e) + ' is a not valid value for "' + t + '" attribute. The value should be a function.'), e;
};
}
function qn() {
if (Wt.Konva.isUnminified)
return function(e, t) {
const i = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
return i && e instanceof i || (q.Util._isArray(e) ? e.forEach(function(n) {
q.Util._isNumber(n) || q.Util.warn('"' + t + '" attribute has non numeric element ' + n + ". Make sure that all elements are numbers.");
}) : q.Util.warn(Bt(e) + ' is a not valid value for "' + t + '" attribute. The value should be a array of numbers.')), e;
};
}
function Jn() {
if (Wt.Konva.isUnminified)
return function(e, t) {
var i = e === !0 || e === !1;
return i || q.Util.warn(Bt(e) + ' is a not valid value for "' + t + '" attribute. The value should be a boolean.'), e;
};
}
function Qn(e) {
if (Wt.Konva.isUnminified)
return function(t, i) {
return t == null || q.Util.isObject(t) || q.Util.warn(Bt(t) + ' is a not valid value for "' + i + '" attribute. The value should be an object with properties ' + e), t;
};
}
(function(e) {
Object.defineProperty(e, "__esModule", { value: !0 }), e.Factory = void 0;
const t = dt, i = et, n = "get", r = "set";
e.Factory = {
addGetterSetter(s, a, o, l, f) {
e.Factory.addGetter(s, a, o), e.Factory.addSetter(s, a, l, f), e.Factory.addOverloadedGetterSetter(s, a);
},
addGetter(s, a, o) {
var l = n + t.Util._capitalize(a);
s.prototype[l] = s.prototype[l] || function() {
const f = this.attrs[a];
return f === void 0 ? o : f;
};
},
addSetter(s, a, o, l) {
var f = r + t.Util._capitalize(a);
s.prototype[f] || e.Factory.overWriteSetter(s, a, o, l);
},
overWriteSetter(s, a, o, l) {
var f = r + t.Util._capitalize(a);
s.prototype[f] = function(c) {
return o && c !== void 0 && c !== null && (c = o.call(this, c, a)), this._setAttr(a, c), l && l.call(this), this;
};
},
addComponentsGetterSetter(s, a, o, l, f) {
const c = o.length, b = t.Util._capitalize, T = n + b(a), g = r + b(a);
s.prototype[T] = function() {
const m = {};
for (let y = 0; y < c; y++) {
const w = o[y];
m[w] = this.getAttr(a + b(w));
}
return m;
};
const u = (0, i.getComponentValidator)(o);
s.prototype[g] = function(m) {
const y = this.attrs[a];
l && (m = l.call(this, m, a)), u && u.call(this, m, a);
for (const w in m)
m.hasOwnProperty(w) && this._setAttr(a + b(w), m[w]);
return m || o.forEach((w) => {
this._setAttr(a + b(w), void 0);
}), this._fireChangeEvent(a, y, m), f && f.call(this), this;
}, e.Factory.addOverloadedGetterSetter(s, a);
},
addOverloadedGetterSetter(s, a) {
var o = t.Util._capitalize(a), l = r + o, f = n + o;
s.prototype[a] = function() {
return arguments.length ? (this[l](arguments[0]), this) : this[f]();
};
},
addDeprecatedGetterSetter(s, a, o, l) {
t.Util.error("Adding deprecated " + a);
const f = n + t.Util._capitalize(a), c = a + " property is deprecated and will be removed soon. Look at Konva change log for more information.";
s.prototype[f] = function() {
t.Util.error(c);
const b = this.attrs[a];
return b === void 0 ? o : b;
}, e.Factory.addSetter(s, a, l, function() {
t.Util.error(c);
}), e.Factory.addOverloadedGetterSetter(s, a);
},
backCompat(s, a) {
t.Util.each(a, function(o, l) {
const f = s.prototype[l], c = n + t.Util._capitalize(o), b = r + t.Util._capitalize(o);
function T() {
f.apply(this, arguments), t.Util.error('"' + o + '" method is deprecated and will be removed soon. Use ""' + l + '" instead.');
}
s.prototype[o] = T, s.prototype[c] = T, s.prototype[b] = T;
});
},
afterSetFilter() {
this._filterUpToDate = !1;
}
};
})(Dt);
var At = {}, Gt = {};
Object.defineProperty(Gt, "__esModule", { value: !0 });
Gt.HitContext = Gt.SceneContext = Gt.Context = void 0;
const nn = dt, tr = J;
function er(e) {
const t = [], i = e.length, n = nn.Util;
for (let r = 0; r < i; r++) {
let s = e[r];
n._isNumber(s) ? s = Math.round(s * 1e3) / 1e3 : n._isString(s) || (s = s + ""), t.push(s);
}
return t;
}
const Li = ",", ir = "(", nr = ")", rr = "([", sr = "])", ar = ";", or = "()", hr = "=", Oi = [
"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"
], lr = [
"fillStyle",
"strokeStyle",
"shadowColor",
"shadowBlur",
"shadowOffsetX",
"shadowOffsetY",
"letterSpacing",
"lineCap",
"lineDashOffset",
"lineJoin",
"lineWidth",
"miterLimit",
"direction",
"font",
"textAlign",
"textBaseline",
"globalAlpha",
"globalCompositeOperation",
"imageSmoothingEnabled"
], dr = 100;
class Ke {
constructor(t) {
this.canvas = t, tr.Konva.enableTrace && (this.traceArr = [], this._enableTrace());
}
fillShape(t) {
t.fillEnabled() && this._fill(t);
}
_fill(t) {
}
strokeShape(t) {
t.hasStroke() && this._stroke(t);
}
_stroke(t) {
}
fillStrokeShape(t) {
t.attrs.fillAfterStrokeEnabled ? (this.strokeShape(t), this.fillShape(t)) : (this.fillShape(t), this.strokeShape(t));
}
getTrace(t, i) {
let n = this.traceArr, r = n.length, s = "", a, o, l, f;
for (a = 0; a < r; a++)
o = n[a], l = o.method, l ? (f = o.args, s += l, t ? s += or : nn.Util._isArray(f[0]) ? s += rr + f.join(Li) + sr : (i && (f = f.map((c) => typeof c == "number" ? Math.floor(c) : c)), s += ir + f.join(Li) + nr)) : (s += o.property, t || (s += hr + o.val)), s += ar;
return s;
}
clearTrace() {
this.traceArr = [];
}
_trace(t) {
let i = this.traceArr, n;
i.push(t), n = i.length, n >= dr && i.shift();
}
reset() {
const t = this.getCanvas().getPixelRatio();
this.setTransform(1 * t, 0, 0, 1 * t, 0, 0);
}
getCanvas() {
return this.canvas;
}
clear(t) {
const i = this.getCanvas();
t ? this.clearRect(t.x || 0, t.y || 0, t.width || 0, t.height || 0) : this.clearRect(0, 0, i.getWidth() / i.pixelRatio, i.getHeight() / i.pixelRatio);
}
_applyLineCap(t) {
const i = t.attrs.lineCap;
i && this.setAttr("lineCap", i);
}
_applyOpacity(t) {
const i = t.getAbsoluteOpacity();
i !== 1 && this.setAttr("globalAlpha", i);
}
_applyLineJoin(t) {
const i = t.attrs.lineJoin;
i && this.setAttr("lineJoin", i);
}
setAttr(t, i) {
this._context[t] = i;
}
arc(t, i, n, r, s, a) {
this._context.arc(t, i, n, r, s, a);
}
arcTo(t, i, n, r, s) {
this._context.arcTo(t, i, n, r, s);
}
beginPath() {
this._context.beginPath();
}
bezierCurveTo(t, i, n, r, s, a) {
this._context.bezierCurveTo(t, i, n, r, s, a);
}
clearRect(t, i, n, r) {
this._context.clearRect(t, i, n, r);
}
clip(...t) {
this._context.clip.apply(this._context, t);
}
closePath() {
this._context.closePath();
}
createImageData(t, i) {
const n = arguments;
if (n.length === 2)
return this._context.createImageData(t, i);
if (n.length === 1)
return this._context.createImageData(t);
}
createLinearGradient(t, i, n, r) {
return this._context.createLinearGradient(t, i, n, r);
}
createPattern(t, i) {
return this._context.createPattern(t, i);
}
createRadialGradient(t, i, n, r, s, a) {
return this._context.createRadialGradient(t, i, n, r, s, a);
}
drawImage(t, i, n, r, s, a, o, l, f) {
const c = arguments, b = this._context;
c.length === 3 ? b.drawImage(t, i, n) : c.length === 5 ? b.drawImage(t, i, n, r, s) : c.length === 9 && b.drawImage(t, i, n, r, s, a, o, l, f);
}
ellipse(t, i, n, r, s, a, o, l) {
this._context.ellipse(t, i, n, r, s, a, o, l);
}
isPointInPath(t, i, n, r) {
return n ? this._context.isPointInPath(n, t, i, r) : this._context.isPointInPath(t, i, r);
}
fill(...t) {
this._context.fill.apply(this._context, t);
}
fillRect(t, i, n, r) {
this._context.fillRect(t, i, n, r);
}
strokeRect(t, i, n, r) {
this._context.strokeRect(t, i, n, r);
}
fillText(t, i, n, r) {
r ? this._context.fillText(t, i, n, r) : this._context.fillText(t, i, n);
}
measureText(t) {
return this._context.measureText(t);
}
getImageData(t, i, n, r) {
return this._context.getImageData(t, i, n, r);
}
lineTo(t, i) {
this._context.lineTo(t, i);
}
moveTo(t, i) {
this._context.moveTo(t, i);
}
rect(t, i, n, r) {
this._context.rect(t, i, n, r);
}
roundRect(t, i, n, r, s) {
this._context.roundRect(t, i, n, r, s);
}
putImageData(t, i, n) {
this._context.putImageData(t, i, n);
}
quadraticCurveTo(t, i, n, r) {
this._context.quadraticCurveTo(t, i, n, r);
}
restore() {
this._context.restore();
}
rotate(t) {
this._context.rotate(t);
}
save() {
this._context.save();
}
scale(t, i) {
this._context.scale(t, i);
}
setLineDash(t) {
this._context.setLineDash ? this._context.setLineDash(t) : "mozDash" in this._context ? this._context.mozDash = t : "webkitLineDash" in this._context && (this._context.webkitLineDash = t);
}
getLineDash() {
return this._context.getLineDash();
}
setTransform(t, i, n, r, s, a) {
this._context.setTransform(t, i, n, r, s, a);
}
stroke(t) {
t ? this._context.stroke(t) : this._context.stroke();
}
strokeText(t, i, n, r) {
this._context.strokeText(t, i, n, r);
}
transform(t, i, n, r, s, a) {
this._context.transform(t, i, n, r, s, a);
}
translate(t, i) {
this._context.translate(t, i);
}
_enableTrace() {
let t = this, i = Oi.length, n = this.setAttr, r, s;
const a = function(o) {
let l = t[o], f;
t[o] = function() {
return s = er(Array.prototype.slice.call(arguments, 0)), f = l.apply(t, arguments), t._trace({
method: o,
args: s
}), f;
};
};
for (r = 0; r < i; r++)
a(Oi[r]);
t.setAttr = function() {
n.apply(t, arguments);
const o = arguments[0];
let l = arguments[1];
(o === "shadowOffsetX" || o === "shadowOffsetY" || o === "shadowBlur") && (l = l / this.canvas.getPixelRatio()), t._trace({
property: o,
val: l
});
};
}
_applyGlobalCompositeOperation(t) {
const i = t.attrs.globalCompositeOperation;
!i || i === "source-over" || this.setAttr("globalCompositeOperation", i);
}
}
Gt.Context = Ke;
lr.forEach(function(e) {
Object.defineProperty(Ke.prototype, e, {
get() {
return this._context[e];
},
set(t) {
this._context[e] = t;
}
});
});
class ur extends Ke {
constructor(t, { willReadFrequently: i = !1 } = {}) {
super(t), this._context = t._canvas.getContext("2d", {
willReadFrequently: i
});
}
_fillColor(t) {
const i = t.fill();
this.setAttr("fillStyle", i), t._fillFunc(this);
}
_fillPattern(t) {
this.setAttr("fillStyle", t._getFillPattern()), t._fillFunc(this);
}
_fillLinearGradient(t) {
const i = t._getLinearGradient();
i && (this.setAttr("fillStyle", i), t._fillFunc(this));
}
_fillRadialGradient(t) {
const i = t._getRadialGradient();
i && (this.setAttr("fillStyle", i), t._fillFunc(this));
}
_fill(t) {
const i = t.fill(), n = t.getFillPriority();
if (i && n === "color") {
this._fillColor(t);
return;
}
const r = t.getFillPatternImage();
if (r && n === "pattern") {
this._fillPattern(t);
return;
}
const s = t.getFillLinearGradientColorStops();
if (s && n === "linear-gradient") {
this._fillLinearGradient(t);
return;
}
const a = t.getFillRadialGradientColorStops();
if (a && n === "radial-gradient") {
this._fillRadialGradient(t);
return;
}
i ? this._fillColor(t) : r ? this._fillPattern(t) : s ? this._fillLinearGradient(t) : a && this._fillRadialGradient(t);
}
_strokeLinearGradient(t) {
const i = t.getStrokeLinearGradientStartPoint(), n = t.getStrokeLinearGradientEndPoint(), r = t.getStrokeLinearGradientColorStops(), s = this.createLinearGradient(i.x, i.y, n.x, n.y);
if (r) {
for (let a = 0; a < r.length; a += 2)
s.addColorStop(r[a], r[a + 1]);
this.setAttr("strokeStyle", s);
}
}
_stroke(t) {
const i = t.dash(), n = t.getStrokeScaleEnabled();
if (t.hasStroke()) {
if (!n) {
this.save();
const s = this.getCanvas().getPixelRatio();
this.setTransform(s, 0, 0, s, 0, 0);
}
this._applyLineCap(t), i && t.dashEnabled() && (this.setLineDash(i), this.setAttr("lineDashOffset", t.dashOffset())), this.setAttr("lineWidth", t.strokeWidth()), t.getShadowForStrokeEnabled() || this.setAttr("shadowColor", "rgba(0,0,0,0)"), t.getStrokeLinearGradientColorStops() ? this._strokeLinearGradient(t) : this.setAttr("strokeStyle", t.stroke()), t._strokeFunc(this), n || this.restore();
}
}
_applyShadow(t) {
var i, n, r;
const s = (i = t.getShadowRGBA()) !== null && i !== void 0 ? i : "black", a = (n = t.getShadowBlur()) !== null && n !== void 0 ? n : 5, o = (r = t.getShadowOffset()) !== null && r !== void 0 ? r : {
x: 0,
y: 0
}, l = t.getAbsoluteScale(), f = this.canvas.getPixelRatio(), c = l.x * f, b = l.y * f;
this.setAttr("shadowColor", s), this.setAttr("shadowBlur", a * Math.min(Math.abs(c), Math.abs(b))), this.setAttr("shadowOffsetX", o.x * c), this.setAttr("shadowOffsetY", o.y * b);
}
}
Gt.SceneContext = ur;
class fr extends Ke {
constructor(t) {
super(t), this._context = t._canvas.getContext("2d", {
willReadFrequently: !0
});
}
_fill(t) {
this.save(), this.setAttr("fillStyle", t.colorKey), t._fillFuncHit(this), this.restore();
}
strokeShape(t) {
t.hasHitStroke() && this._stroke(t);
}
_stroke(t) {
if (t.hasHitStroke()) {
const i = t.getStrokeScaleEnabled();
if (!i) {
this.save();
const s = this.getCanvas().getPixelRatio();
this.setTransform(s, 0, 0, s, 0, 0);
}
this._applyLineCap(t);
const n = t.hitStrokeWidth(), r = n === "auto" ? t.strokeWidth() : n;
this.setAttr("lineWidth", r), this.setAttr("strokeStyle", t.colorKey), t._strokeFuncHit(this), i || this.restore();
}
}
}
Gt.HitContext = fr;
Object.defineProperty(At, "__esModule", { value: !0 });
At.HitCanvas = At.SceneCanvas = At.Canvas = void 0;
const Ne = dt, rn = Gt, sn = J, cr = Dt, gr = et;
let Re;
function _r() {
if (Re)
return Re;
const e = Ne.Util.createCanvasElement(), t = e.getContext("2d");
return Re = function() {
const i = sn.Konva._global.devicePixelRatio || 1, n = t.webkitBackingStorePixelRatio || t.mozBackingStorePixelRatio || t.msBackingStorePixelRatio || t.oBackingStorePixelRatio || t.backingStorePixelRatio || 1;
return i / n;
}(), Ne.Util.releaseCanvas(e), Re;
}
class je {
constructor(t) {
this.pixelRatio = 1, this.width = 0, this.height = 0, this.isCache = !1;
const n = (t || {}).pixelRatio || sn.Konva.pixelRatio || _r();
this.pixelRatio = n, this._canvas = Ne.Util.createCanvasElement(), this._canvas.style.padding = "0", this._canvas.style.margin = "0", this._canvas.style.border = "0", this._canvas.style.background = "transparent", this._canvas.style.position = "absolute", this._canvas.style.top = "0", this._canvas.style.left = "0";
}
getContext() {
return this.context;
}
getPixelRatio() {
return this.pixelRatio;
}
setPixelRatio(t) {
const i = this.pixelRatio;
this.pixelRatio = t, this.setSize(this.getWidth() / i, this.getHeight() / i);
}
setWidth(t) {
this.width = this._canvas.width = t * this.pixelRatio, this._canvas.style.width = t + "px";
const i = this.pixelRatio;
this.getContext()._context.scale(i, i);
}
setHeight(t) {
this.height = this._canvas.height = t * this.pixelRatio, this._canvas.style.height = t + "px";
const i = this.pixelRatio;
this.getContext()._context.scale(i, i);
}
getWidth() {
return this.width;
}
getHeight() {
return this.height;
}
setSize(t, i) {
this.setWidth(t || 0), this.setHeight(i || 0);
}
toDataURL(t, i) {
try {
return this._canvas.toDataURL(t, i);
} catch {
try {
return this._canvas.toDataURL();
} catch (r) {
return Ne.Util.error("Unable to get data URL. " + r.message + " For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."), "";
}
}
}
}
At.Canvas = je;
cr.Factory.addGetterSetter(je, "pixelRatio", void 0, (0, gr.getNumberValidator)());
class pr extends je {
constructor(t = { width: 0, height: 0, willReadFrequently: !1 }) {
super(t), this.context = new rn.SceneContext(this, {
willReadFrequently: t.willReadFrequently
}), this.setSize(t.width, t.height);
}
}
At.SceneCanvas = pr;
class mr extends je {
constructor(t = { width: 0, height: 0 }) {
super(t), this.hitCanvas = !0, this.context = new rn.HitContext(this), this.setSize(t.width, t.height);
}
}
At.HitCanvas = mr;
var $e = {};
(function(e) {
Object.defineProperty(e, "__esModule", { value: !0 }), e.DD = void 0;
const t = J, i = dt;
e.DD = {
get isDragging() {
let n = !1;
return e.DD._dragElements.forEach((r) => {
r.dragStatus === "dragging" && (n = !0);
}), n;
},
justDragged: !1,
get node() {
let n;
return e.DD._dragElements.forEach((r) => {
n = r.node;
}), n;
},
_dragElements: /* @__PURE__ */ new Map(),
_drag(n) {
const r = [];
e.DD._dragElements.forEach((s, a) => {
const { node: o } = s, l = o.getStage();
l.setPointersPositions(n), s.pointerId === void 0 && (s.pointerId = i.Util._getFirstPointerId(n));
const f = l._changedPointerPositions.find((c) => c.id === s.pointerId);
if (f) {
if (s.dragStatus !== "dragging") {
const c = o.dragDistance();
if (Math.max(Math.abs(f.x - s.startPointerPos.x), Math.abs(f.y - s.startPointerPos.y)) < c || (o.startDrag({ evt: n }), !o.isDragging()))
return;
}
o._setDragPosition(n, s), r.push(o);
}
}), r.forEach((s) => {
s.fire("dragmove", {
type: "dragmove",
target: s,
evt: n
}, !0);
});
},
_endDragBefore(n) {
const r = [];
e.DD._dragElements.forEach((s) => {
const { node: a } = s, o = a.getStage();
if (n && o.setPointersPositions(n), !o._changedPointerPositions.find((c) => c.id === s.pointerId))
return;
(s.dragStatus === "dragging" || s.dragStatus === "stopped") && (e.DD.justDragged = !0, t.Konva._mouseListenClick = !1, t.Konva._touchListenClick = !1, t.Konva._pointerListenClick = !1, s.dragStatus = "stopped");
const f = s.node.getLayer() || s.node instanceof t.Konva.Stage && s.node;
f && r.indexOf(f) === -1 && r.push(f);
}), r.forEach((s) => {
s.draw();
});
},
_endDragAfter(n) {
e.DD._dragElements.forEach((r, s) => {
r.dragStatus === "stopped" && r.node.fire("dragend", {
type: "dragend",
target: r.node,
evt: n
}, !0), r.dragStatus !== "dragging" && e.DD._dragElements.delete(s);
});
}
}, t.Konva.isBrowser && (window.addEventListener("mouseup", e.DD._endDragBefore, !0), window.addEventListener("touchend", e.DD._endDragBefore, !0), window.addEventListener("touchcancel", e.DD._endDragBefore, !0), window.addEventListener("mousemove", e.DD._drag), window.addEventListener("touchmove", e.DD._drag), window.addEventListener("mouseup", e.DD._endDragAfter, !1), window.addEventListener("touchend", e.DD._endDragAfter, !1), window.addEventListener("touchcancel", e.DD._endDragAfter, !1));
})($e);
Object.defineProperty(Zt, "__esModule", { value: !0 });
Zt.Node = void 0;
const B = dt, xe = Dt, we = At, Nt = J, Tt = $e, it = et, He = "absoluteOpacity", Ge = "allEventListeners", Rt = "absoluteTransform", Fi = "absoluteScale", Qt = "canvas", vr = "Change", yr = "children", wr = "konva", yi = "listening", Ri = "mouseenter", Gi = "mouseleave", Wi = "set", Bi = "Shape", Ve = " ", Hi = "stage", Xt = "transform", br = "Stage", wi = "visible", Sr = [
"xChange.konva",
"yChange.konva",
"scaleXChange.konva",
"scaleYChange.konva",
"skewXChange.konva",
"skewYChange.konva",
"rotationChange.konva",
"offsetXChange.konva",
"offsetYChange.konva",
"transformsEnabledChange.konva"
].join(Ve);
let Cr = 1;
class F {
constructor(t) {
this._id = Cr++, this.eventListeners = {}, this.attrs = {}, this.index = 0, this._allEventListeners = null, this.parent = null, this._cache = /* @__PURE__ */ new Map(), this._attachedDepsListeners = /* @__PURE__ */ new Map(), this._lastPos = null, this._batchingTransformChange = !1, this._needClearTransformCache = !1, this._filterUpToDate = !1, this._isUnderCache = !1, this._dragEventId = null, this._shouldFireChangeEvents = !1, this.setAttrs(t), this._shouldFireChangeEvents = !0;
}
hasChildren() {
return !1;
}
_clearCache(t) {
(t === Xt || t === Rt) && this._cache.get(t) ? this._cache.get(t).dirty = !0 : t ? this._cache.delete(t) : this._cache.clear();
}
_getCache(t, i) {
let n = this._cache.get(t);
return (n === void 0 || (t === Xt || t === Rt) && n.dirty === !0) && (n = i.call(this), this._cache.set(t, n)), n;
}
_calculate(t, i, n) {
if (!this._attachedDepsListeners.get(t)) {
const r = i.map((s) => s + "Change.konva").join(Ve);
this.on(r, () => {
this._clearCache(t);
}), this._attachedDepsListeners.set(t, !0);
}
return this._getCache(t, n);
}
_getCanvasCache() {
return this._cache.get(Qt);
}
_clearSelfAndDescendantCache(t) {
this._clearCache(t), t === Rt && this.fire("absoluteTransformChange");
}
clearCache() {
if (this._cache.has(Qt)) {
const { scene: t, filter: i, hit: n } = this._cache.get(Qt);
B.Util.releaseCanvas(t, i, n), this._cache.delete(Qt);
}
return this._clearSelfAndDescendantCache(), this._requestDraw(), this;
}
cache(t) {
const i = t || {};
let n = {};
(i.x === void 0 || i.y === void 0 || i.width === void 0 || i.height === void 0) && (n = this.getClientRect({
skipTransform: !0,
relativeTo: this.getParent() || void 0
}));
let r = Math.ceil(i.width || n.width), s = Math.ceil(i.height || n.height), a = i.pixelRatio, o = i.x === void 0 ? Math.floor(n.x) : i.x, l = i.y === void 0 ? Math.floor(n.y) : i.y, f = i.offset || 0, c = i.drawBorder || !1, b = i.hitCanvasPixelRatio || 1;
if (!r || !s) {
B.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");
return;
}
const T = Math.abs(Math.round(n.x) - o) > 0.5 ? 1 : 0, g = Math.abs(Math.round(n.y) - l) > 0.5 ? 1 : 0;
r += f * 2 + T, s += f * 2 + g, o -= f, l -= f;
const u = new we.SceneCanvas({
pixelRatio: a,
width: r,
height: s
}), m = new we.SceneCanvas({
pixelRatio: a,
width: 0,
height: 0,
willReadFrequently: !0
}), y = new we.HitCanvas({
pixelRatio: b,
width: r,
height: s
}), w = u.getContext(), P = y.getContext();
return y.isCache = !0, u.isCache = !0, this._cache.delete(Qt), this._filterUpToDate = !1, i.imageSmoothingEnabled === !1 && (u.getContext()._context.imageSmoothingEnabled = !1, m.getContext()._context.imageSmoothingEnabled = !1), w.save(), P.save(), w.translate(-o, -l), P.translate(-o, -l), this._isUnderCache = !0, this._clearSelfAndDescendantCache(He), this._clearSelfAndDescendantCache(Fi), this.drawScene(u, this), this.drawHit(y, this), this._isUnderCache = !1, w.restore(), P.restore(), c && (w.save(), w.beginPath(), w.rect(0, 0, r, s), w.closePath(), w.setAttr("strokeStyle", "red"), w.setAttr("lineWidth", 5), w.stroke(), w.restore()), this._cache.set(Qt, {
scene: u,
filter: m,
hit: y,
x: o,
y: l
}), this._requestDraw(), this;
}
isCached() {
return this._cache.has(Qt);
}
getClientRect(t) {
throw new Error('abstract "getClientRect" method call');
}
_transformedRect(t, i) {
const n = [
{ x: t.x, y: t.y },
{ x: t.x + t.width, y: t.y },
{ x: t.x + t.width, y: t.y + t.height },
{ x: t.x, y: t.y + t.height }
];
let r = 1 / 0, s = 1 / 0, a = -1 / 0, o = -1 / 0;
const l = this.getAbsoluteTransform(i);
return n.forEach(function(f) {
const c = l.point(f);
r === void 0 && (r = a = c.x, s = o = c.y), r = Math.min(r, c.x), s = Math.min(s, c.y), a = Math.max(a, c.x), o = Math.max(o, c.y);
}), {
x: r,
y: s,
width: a - r,
height: o - s
};
}
_drawCachedSceneCanvas(t) {
t.save(), t._applyOpacity(this), t._applyGlobalCompositeOperation(this);
const i = this._getCanvasCache();
t.translate(i.x, i.y);
const n = this._getCachedSceneCanvas(), r = n.pixelRatio;
t.drawImage(n._canvas, 0, 0, n.width / r, n.height / r), t.restore();
}
_drawCachedHitCanvas(t) {
const i = this._getCanvasCache(), n = i.hit;
t.save(), t.translate(i.x, i.y), t.drawImage(n._canvas, 0, 0, n.width / n.pixelRatio, n.height / n.pixelRatio), t.restore();
}
_getCachedSceneCanvas() {
let t = this.filters(), i = this._getCanvasCache(), n = i.scene, r = i.filter, s = r.getContext(), a, o, l, f;
if (t) {
if (!this._filterUpToDate) {
const c = n.pixelRatio;
r.setSize(n.width / n.pixelRatio, n.height / n.pixelRatio);
try {
for (a = t.length, s.clear(), s.drawImage(n._canvas, 0, 0, n.getWidth() / c, n.getHeight() / c), o = s.getImageData(0, 0, r.getWidth(), r.getHeight()), l = 0; l < a; l++) {
if (f = t[l], typeof f != "function") {
B.Util.error("Filter should be type of function, but got " + typeof f + " instead. Please check correct filters");
continue;
}
f.call(this, o), s.putImageData(o, 0, 0);
}
} catch (b) {
B.Util.error("Unable to apply filter. " + b.message + " This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.");
}
this._filterUpToDate = !0;
}
return r;
}
return n;
}
on(t, i) {
if (this._c