@byomakase/omakase-player 0.3.0 → 0.3.2

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.
@@ -1,22 +1,22 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Qe=require("hls.js");var Bl=Math.PI/180;function $l(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}const si=typeof global<"u"?global:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},D={_global:si,version:"8.3.14",isBrowser:$l(),isUnminified:/param/.test(function(i){}.toString()),dblClickWindow:400,getAngle(i){return D.angleDeg?i*Bl:i},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,pixelRatio:typeof window<"u"&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return D.DD.isDragging},isDragReady(){return!!D.DD.node},releaseCanvasOnDestroy:!0,document:si.document,_injectGlobal(i){si.Konva=i}},ge=i=>{D[i.prototype.getClassName()]=i};D._injectGlobal(D);class Ge{constructor(e=[1,0,0,1,0,0]){this.dirty=!1,this.m=e&&e.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new Ge(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){var t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){var t=Math.cos(e),r=Math.sin(e),s=this.m[0]*t+this.m[2]*r,n=this.m[1]*t+this.m[3]*r,a=this.m[0]*-r+this.m[2]*t,o=this.m[1]*-r+this.m[3]*t;return this.m[0]=s,this.m[1]=n,this.m[2]=a,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){var r=this.m[0]+this.m[2]*t,s=this.m[1]+this.m[3]*t,n=this.m[2]+this.m[0]*e,a=this.m[3]+this.m[1]*e;return this.m[0]=r,this.m[1]=s,this.m[2]=n,this.m[3]=a,this}multiply(e){var t=this.m[0]*e.m[0]+this.m[2]*e.m[1],r=this.m[1]*e.m[0]+this.m[3]*e.m[1],s=this.m[0]*e.m[2]+this.m[2]*e.m[3],n=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]=r,this.m[2]=s,this.m[3]=n,this.m[4]=a,this.m[5]=o,this}invert(){var e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,r=-this.m[1]*e,s=-this.m[2]*e,n=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]=r,this.m[2]=s,this.m[3]=n,this.m[4]=a,this.m[5]=o,this}getMatrix(){return this.m}decompose(){var e=this.m[0],t=this.m[1],r=this.m[2],s=this.m[3],n=this.m[4],a=this.m[5],o=e*s-t*r;let h={x:n,y:a,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||t!=0){var l=Math.sqrt(e*e+t*t);h.rotation=t>0?Math.acos(e/l):-Math.acos(e/l),h.scaleX=l,h.scaleY=o/l,h.skewX=(e*r+t*s)/o,h.skewY=0}else if(r!=0||s!=0){var d=Math.sqrt(r*r+s*s);h.rotation=Math.PI/2-(s>0?Math.acos(-r/d):-Math.acos(r/d)),h.scaleX=o/d,h.scaleY=d,h.skewX=0,h.skewY=(e*r+t*s)/o}return h.rotation=y._getRotation(h.rotation),h}}var Vl="[object Array]",zl="[object Number]",Ul="[object String]",Wl="[object Boolean]",Zl=Math.PI/180,jl=180/Math.PI,hs="#",Xl="",ql="0",Yl="Konva warning: ",An="Konva error: ",Kl="rgb(",ds={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]},Jl=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,or=[];const Ql=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(i){setTimeout(i,60)},y={_isElement(i){return!!(i&&i.nodeType==1)},_isFunction(i){return!!(i&&i.constructor&&i.call&&i.apply)},_isPlainObject(i){return!!i&&i.constructor===Object},_isArray(i){return Object.prototype.toString.call(i)===Vl},_isNumber(i){return Object.prototype.toString.call(i)===zl&&!isNaN(i)&&isFinite(i)},_isString(i){return Object.prototype.toString.call(i)===Ul},_isBoolean(i){return Object.prototype.toString.call(i)===Wl},isObject(i){return i instanceof Object},isValidSelector(i){if(typeof i!="string")return!1;var e=i[0];return e==="#"||e==="."||e===e.toUpperCase()},_sign(i){return i===0||i>0?1:-1},requestAnimFrame(i){or.push(i),or.length===1&&Ql(function(){const e=or;or=[],e.forEach(function(t){t()})})},createCanvasElement(){var i=document.createElement("canvas");try{i.style=i.style||{}}catch{}return i},createImageElement(){return document.createElement("img")},_isInDocument(i){for(;i=i.parentNode;)if(i==document)return!0;return!1},_urlToImage(i,e){var t=y.createImageElement();t.onload=function(){e(t)},t.src=i},_rgbToHex(i,e,t){return((1<<24)+(i<<16)+(e<<8)+t).toString(16).slice(1)},_hexToRgb(i){i=i.replace(hs,Xl);var e=parseInt(i,16);return{r:e>>16&255,g:e>>8&255,b:e&255}},getRandomColor(){for(var i=(Math.random()*16777215<<0).toString(16);i.length<6;)i=ql+i;return hs+i},getRGB(i){var e;return i in ds?(e=ds[i],{r:e[0],g:e[1],b:e[2]}):i[0]===hs?this._hexToRgb(i.substring(1)):i.substr(0,4)===Kl?(e=Jl.exec(i.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA(i){return i=i||"black",y._namedColorToRBA(i)||y._hex3ColorToRGBA(i)||y._hex6ColorToRGBA(i)||y._rgbColorToRGBA(i)||y._rgbaColorToRGBA(i)||y._hslColorToRGBA(i)},_namedColorToRBA(i){var e=ds[i.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(i){if(i.indexOf("rgb(")===0){i=i.match(/rgb\(([^)]+)\)/)[1];var e=i.split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(i){if(i.indexOf("rgba(")===0){i=i.match(/rgba\(([^)]+)\)/)[1];var e=i.split(/ *, */).map((t,r)=>t.slice(-1)==="%"?r===3?parseInt(t)/100:parseInt(t)/100*255:Number(t));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex6ColorToRGBA(i){if(i[0]==="#"&&i.length===7)return{r:parseInt(i.slice(1,3),16),g:parseInt(i.slice(3,5),16),b:parseInt(i.slice(5,7),16),a:1}},_hex3ColorToRGBA(i){if(i[0]==="#"&&i.length===4)return{r:parseInt(i[1]+i[1],16),g:parseInt(i[2]+i[2],16),b:parseInt(i[3]+i[3],16),a:1}},_hslColorToRGBA(i){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(i)){const[e,...t]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(i),r=Number(t[0])/360,s=Number(t[1])/100,n=Number(t[2])/100;let a,o,h;if(s===0)return h=n*255,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};n<.5?a=n*(1+s):a=n+s-n*s;const l=2*n-a,d=[0,0,0];for(let u=0;u<3;u++)o=r+1/3*-(u-1),o<0&&o++,o>1&&o--,6*o<1?h=l+(a-l)*6*o:2*o<1?h=a:3*o<2?h=l+(a-l)*(2/3-o)*6:h=l,d[u]=h*255;return{r:Math.round(d[0]),g:Math.round(d[1]),b:Math.round(d[2]),a:1}}},haveIntersection(i,e){return!(e.x>i.x+i.width||e.x+e.width<i.x||e.y>i.y+i.height||e.y+e.height<i.y)},cloneObject(i){var e={};for(var t in i)this._isPlainObject(i[t])?e[t]=this.cloneObject(i[t]):this._isArray(i[t])?e[t]=this.cloneArray(i[t]):e[t]=i[t];return e},cloneArray(i){return i.slice(0)},degToRad(i){return i*Zl},radToDeg(i){return i*jl},_degToRad(i){return y.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),y.degToRad(i)},_radToDeg(i){return y.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),y.radToDeg(i)},_getRotation(i){return D.angleDeg?y.radToDeg(i):i},_capitalize(i){return i.charAt(0).toUpperCase()+i.slice(1)},throw(i){throw new Error(An+i)},error(i){console.error(An+i)},warn(i){D.showWarnings&&console.warn(Yl+i)},each(i,e){for(var t in i)e(t,i[t])},_inRange(i,e,t){return e<=i&&i<t},_getProjectionToSegment(i,e,t,r,s,n){var a,o,h,l=(i-t)*(i-t)+(e-r)*(e-r);if(l==0)a=i,o=e,h=(s-t)*(s-t)+(n-r)*(n-r);else{var d=((s-i)*(t-i)+(n-e)*(r-e))/l;d<0?(a=i,o=e,h=(i-s)*(i-s)+(e-n)*(e-n)):d>1?(a=t,o=r,h=(t-s)*(t-s)+(r-n)*(r-n)):(a=i+d*(t-i),o=e+d*(r-e),h=(a-s)*(a-s)+(o-n)*(o-n))}return[a,o,h]},_getProjectionToLine(i,e,t){var r=y.cloneObject(i),s=Number.MAX_VALUE;return e.forEach(function(n,a){if(!(!t&&a===e.length-1)){var o=e[(a+1)%e.length],h=y._getProjectionToSegment(n.x,n.y,o.x,o.y,i.x,i.y),l=h[0],d=h[1],u=h[2];u<s&&(r.x=l,r.y=d,s=u)}}),r},_prepareArrayForTween(i,e,t){var r,s=[],n=[];if(i.length>e.length){var a=e;e=i,i=a}for(r=0;r<i.length;r+=2)s.push({x:i[r],y:i[r+1]});for(r=0;r<e.length;r+=2)n.push({x:e[r],y:e[r+1]});var o=[];return n.forEach(function(h){var l=y._getProjectionToLine(h,s,t);o.push(l.x),o.push(l.y)}),o},_prepareToStringify(i){var e;i.visitedByCircularReferenceRemoval=!0;for(var t in i)if(i.hasOwnProperty(t)&&i[t]&&typeof i[t]=="object"){if(e=Object.getOwnPropertyDescriptor(i,t),i[t].visitedByCircularReferenceRemoval||y._isElement(i[t]))if(e.configurable)delete i[t];else return null;else if(y._prepareToStringify(i[t])===null)if(e.configurable)delete i[t];else return null}return delete i.visitedByCircularReferenceRemoval,i},_assign(i,e){for(var t in e)i[t]=e[t];return i},_getFirstPointerId(i){return i.touches?i.changedTouches[0].identifier:i.pointerId||999},releaseCanvas(...i){D.releaseCanvasOnDestroy&&i.forEach(e=>{e.width=0,e.height=0})}};function Nt(i){return y._isString(i)?'"'+i+'"':Object.prototype.toString.call(i)==="[object Number]"||y._isBoolean(i)?i:Object.prototype.toString.call(i)}function Na(i){return i>255?255:i<0?0:Math.round(i)}function x(){if(D.isUnminified)return function(i,e){return y._isNumber(i)||y.warn(Nt(i)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),i}}function Ga(i){if(D.isUnminified)return function(e,t){let r=y._isNumber(e),s=y._isArray(e)&&e.length==i;return!r&&!s&&y.warn(Nt(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or Array<number>('+i+")"),e}}function rn(){if(D.isUnminified)return function(i,e){var t=y._isNumber(i),r=i==="auto";return t||r||y.warn(Nt(i)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),i}}function gi(){if(D.isUnminified)return function(i,e){return y._isString(i)||y.warn(Nt(i)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),i}}function Da(){if(D.isUnminified)return function(i,e){const t=y._isString(i),r=Object.prototype.toString.call(i)==="[object CanvasGradient]"||i&&i.addColorStop;return t||r||y.warn(Nt(i)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),i}}function eh(){if(D.isUnminified)return function(i,e){const t=Int8Array?Object.getPrototypeOf(Int8Array):null;return t&&i instanceof t||(y._isArray(i)?i.forEach(function(r){y._isNumber(r)||y.warn('"'+e+'" attribute has non numeric element '+r+". Make sure that all elements are numbers.")}):y.warn(Nt(i)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),i}}function qe(){if(D.isUnminified)return function(i,e){var t=i===!0||i===!1;return t||y.warn(Nt(i)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),i}}function th(i){if(D.isUnminified)return function(e,t){return e==null||y.isObject(e)||y.warn(Nt(e)+' is a not valid value for "'+t+'" attribute. The value should be an object with properties '+i),e}}var Ti="get",Ci="set";const v={addGetterSetter(i,e,t,r,s){v.addGetter(i,e,t),v.addSetter(i,e,r,s),v.addOverloadedGetterSetter(i,e)},addGetter(i,e,t){var r=Ti+y._capitalize(e);i.prototype[r]=i.prototype[r]||function(){var s=this.attrs[e];return s===void 0?t:s}},addSetter(i,e,t,r){var s=Ci+y._capitalize(e);i.prototype[s]||v.overWriteSetter(i,e,t,r)},overWriteSetter(i,e,t,r){var s=Ci+y._capitalize(e);i.prototype[s]=function(n){return t&&n!==void 0&&n!==null&&(n=t.call(this,n,e)),this._setAttr(e,n),r&&r.call(this),this}},addComponentsGetterSetter(i,e,t,r,s){var n=t.length,a=y._capitalize,o=Ti+a(e),h=Ci+a(e),l,d;i.prototype[o]=function(){var c={};for(l=0;l<n;l++)d=t[l],c[d]=this.getAttr(e+a(d));return c};var u=th(t);i.prototype[h]=function(c){var p=this.attrs[e],f;r&&(c=r.call(this,c)),u&&u.call(this,c,e);for(f in c)c.hasOwnProperty(f)&&this._setAttr(e+a(f),c[f]);return c||t.forEach(m=>{this._setAttr(e+a(m),void 0)}),this._fireChangeEvent(e,p,c),s&&s.call(this),this},v.addOverloadedGetterSetter(i,e)},addOverloadedGetterSetter(i,e){var t=y._capitalize(e),r=Ci+t,s=Ti+t;i.prototype[e]=function(){return arguments.length?(this[r](arguments[0]),this):this[s]()}},addDeprecatedGetterSetter(i,e,t,r){y.error("Adding deprecated "+e);var s=Ti+y._capitalize(e),n=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[s]=function(){y.error(n);var a=this.attrs[e];return a===void 0?t:a},v.addSetter(i,e,r,function(){y.error(n)}),v.addOverloadedGetterSetter(i,e)},backCompat(i,e){y.each(e,function(t,r){var s=i.prototype[r],n=Ti+y._capitalize(t),a=Ci+y._capitalize(t);function o(){s.apply(this,arguments),y.error('"'+t+'" method is deprecated and will be removed soon. Use ""'+r+'" instead.')}i.prototype[t]=o,i.prototype[n]=o,i.prototype[a]=o})},afterSetFilter(){this._filterUpToDate=!1}};function ih(i){var e=[],t=i.length,r=y,s,n;for(s=0;s<t;s++)n=i[s],r._isNumber(n)?n=Math.round(n*1e3)/1e3:r._isString(n)||(n=n+""),e.push(n);return e}var Mn=",",rh="(",sh=")",nh="([",ah="])",oh=";",lh="()",hh="=",On=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],dh=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"];const uh=100;class qr{constructor(e){this.canvas=e,D.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){var r=this.traceArr,s=r.length,n="",a,o,h,l;for(a=0;a<s;a++)o=r[a],h=o.method,h?(l=o.args,n+=h,e?n+=lh:y._isArray(l[0])?n+=nh+l.join(Mn)+ah:(t&&(l=l.map(d=>typeof d=="number"?Math.floor(d):d)),n+=rh+l.join(Mn)+sh)):(n+=o.property,e||(n+=hh+o.val)),n+=oh;return n}clearTrace(){this.traceArr=[]}_trace(e){var t=this.traceArr,r;t.push(e),r=t.length,r>=uh&&t.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){var t=e.getLineCap();t&&this.setAttr("lineCap",t)}_applyOpacity(e){var t=e.getAbsoluteOpacity();t!==1&&this.setAttr("globalAlpha",t)}_applyLineJoin(e){var t=e.attrs.lineJoin;t&&this.setAttr("lineJoin",t)}setAttr(e,t){this._context[e]=t}arc(e,t,r,s,n,a){this._context.arc(e,t,r,s,n,a)}arcTo(e,t,r,s,n){this._context.arcTo(e,t,r,s,n)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,r,s,n,a){this._context.bezierCurveTo(e,t,r,s,n,a)}clearRect(e,t,r,s){this._context.clearRect(e,t,r,s)}clip(){this._context.clip()}closePath(){this._context.closePath()}createImageData(e,t){var r=arguments;if(r.length===2)return this._context.createImageData(e,t);if(r.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,r,s){return this._context.createLinearGradient(e,t,r,s)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,r,s,n,a){return this._context.createRadialGradient(e,t,r,s,n,a)}drawImage(e,t,r,s,n,a,o,h,l){var d=arguments,u=this._context;d.length===3?u.drawImage(e,t,r):d.length===5?u.drawImage(e,t,r,s,n):d.length===9&&u.drawImage(e,t,r,s,n,a,o,h,l)}ellipse(e,t,r,s,n,a,o,h){this._context.ellipse(e,t,r,s,n,a,o,h)}isPointInPath(e,t){return this._context.isPointInPath(e,t)}fill(e){e?this._context.fill(e):this._context.fill()}fillRect(e,t,r,s){this._context.fillRect(e,t,r,s)}strokeRect(e,t,r,s){this._context.strokeRect(e,t,r,s)}fillText(e,t,r,s){s?this._context.fillText(e,t,r,s):this._context.fillText(e,t,r)}measureText(e){return this._context.measureText(e)}getImageData(e,t,r,s){return this._context.getImageData(e,t,r,s)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,r,s){this._context.rect(e,t,r,s)}putImageData(e,t,r){this._context.putImageData(e,t,r)}quadraticCurveTo(e,t,r,s){this._context.quadraticCurveTo(e,t,r,s)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,r,s,n,a){this._context.setTransform(e,t,r,s,n,a)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,r,s){this._context.strokeText(e,t,r,s)}transform(e,t,r,s,n,a){this._context.transform(e,t,r,s,n,a)}translate(e,t){this._context.translate(e,t)}_enableTrace(){var e=this,t=On.length,r=this.setAttr,s,n,a=function(o){var h=e[o],l;e[o]=function(){return n=ih(Array.prototype.slice.call(arguments,0)),l=h.apply(e,arguments),e._trace({method:o,args:n}),l}};for(s=0;s<t;s++)a(On[s]);e.setAttr=function(){r.apply(e,arguments);var o=arguments[0],h=arguments[1];(o==="shadowOffsetX"||o==="shadowOffsetY"||o==="shadowBlur")&&(h=h/this.canvas.getPixelRatio()),e._trace({property:o,val:h})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;var r=!t||t==="source-over";r||this.setAttr("globalCompositeOperation",t)}}dh.forEach(function(i){Object.defineProperty(qr.prototype,i,{get(){return this._context[i]},set(e){this._context[i]=e}})});class ch extends qr{constructor(e){super(e),this._context=e._canvas.getContext("2d")}_fillColor(e){var t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var t=e._getLinearGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fillRadialGradient(e){var t=e._getRadialGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fill(e){var t=e.fill(),r=e.getFillPriority();if(t&&r==="color"){this._fillColor(e);return}var s=e.getFillPatternImage();if(s&&r==="pattern"){this._fillPattern(e);return}var n=e.getFillLinearGradientColorStops();if(n&&r==="linear-gradient"){this._fillLinearGradient(e);return}var a=e.getFillRadialGradientColorStops();if(a&&r==="radial-gradient"){this._fillRadialGradient(e);return}t?this._fillColor(e):s?this._fillPattern(e):n?this._fillLinearGradient(e):a&&this._fillRadialGradient(e)}_strokeLinearGradient(e){var t=e.getStrokeLinearGradientStartPoint(),r=e.getStrokeLinearGradientEndPoint(),s=e.getStrokeLinearGradientColorStops(),n=this.createLinearGradient(t.x,t.y,r.x,r.y);if(s){for(var a=0;a<s.length;a+=2)n.addColorStop(s[a],s[a+1]);this.setAttr("strokeStyle",n)}}_stroke(e){var t=e.dash(),r=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!r){this.save();var s=this.getCanvas().getPixelRatio();this.setTransform(s,0,0,s,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");var n=e.getStrokeLinearGradientColorStops();n?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),r||this.restore()}}_applyShadow(e){var t,r,s,n=(t=e.getShadowRGBA())!==null&&t!==void 0?t:"black",a=(r=e.getShadowBlur())!==null&&r!==void 0?r:5,o=(s=e.getShadowOffset())!==null&&s!==void 0?s:{x:0,y:0},h=e.getAbsoluteScale(),l=this.canvas.getPixelRatio(),d=h.x*l,u=h.y*l;this.setAttr("shadowColor",n),this.setAttr("shadowBlur",a*Math.min(Math.abs(d),Math.abs(u))),this.setAttr("shadowOffsetX",o.x*d),this.setAttr("shadowOffsetY",o.y*u)}}class fh extends qr{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){var t=e.getStrokeScaleEnabled();if(!t){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e);var s=e.hitStrokeWidth(),n=s==="auto"?e.strokeWidth():s;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),t||this.restore()}}}var lr;function ph(){if(lr)return lr;var i=y.createCanvasElement(),e=i.getContext("2d");return lr=function(){var t=D._global.devicePixelRatio||1,r=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return t/r}(),y.releaseCanvas(i),lr}class Yr{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var t=e||{},r=t.pixelRatio||D.pixelRatio||ph();this.pixelRatio=r,this._canvas=y.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){var t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var t=this.pixelRatio,r=this.getContext()._context;r.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var t=this.pixelRatio,r=this.getContext()._context;r.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(s){return y.error("Unable to get data URL. "+s.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}v.addGetterSetter(Yr,"pixelRatio",void 0,x());class ni extends Yr{constructor(e={width:0,height:0}){super(e),this.context=new ch(this),this.setSize(e.width,e.height)}}class sn extends Yr{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new fh(this),this.setSize(e.width,e.height)}}const re={get isDragging(){var i=!1;return re._dragElements.forEach(e=>{e.dragStatus==="dragging"&&(i=!0)}),i},justDragged:!1,get node(){var i;return re._dragElements.forEach(e=>{i=e.node}),i},_dragElements:new Map,_drag(i){const e=[];re._dragElements.forEach((t,r)=>{const{node:s}=t,n=s.getStage();n.setPointersPositions(i),t.pointerId===void 0&&(t.pointerId=y._getFirstPointerId(i));const a=n._changedPointerPositions.find(l=>l.id===t.pointerId);if(a){if(t.dragStatus!=="dragging"){var o=s.dragDistance(),h=Math.max(Math.abs(a.x-t.startPointerPos.x),Math.abs(a.y-t.startPointerPos.y));if(h<o||(s.startDrag({evt:i}),!s.isDragging()))return}s._setDragPosition(i,t),e.push(s)}}),e.forEach(t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:i},!0)})},_endDragBefore(i){const e=[];re._dragElements.forEach(t=>{const{node:r}=t,s=r.getStage();if(i&&s.setPointersPositions(i),!s._changedPointerPositions.find(o=>o.id===t.pointerId))return;(t.dragStatus==="dragging"||t.dragStatus==="stopped")&&(re.justDragged=!0,D._mouseListenClick=!1,D._touchListenClick=!1,D._pointerListenClick=!1,t.dragStatus="stopped");const a=t.node.getLayer()||t.node instanceof D.Stage&&t.node;a&&e.indexOf(a)===-1&&e.push(a)}),e.forEach(t=>{t.draw()})},_endDragAfter(i){re._dragElements.forEach((e,t)=>{e.dragStatus==="stopped"&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:i},!0),e.dragStatus!=="dragging"&&re._dragElements.delete(t)})}};D.isBrowser&&(window.addEventListener("mouseup",re._endDragBefore,!0),window.addEventListener("touchend",re._endDragBefore,!0),window.addEventListener("mousemove",re._drag),window.addEventListener("touchmove",re._drag),window.addEventListener("mouseup",re._endDragAfter,!1),window.addEventListener("touchend",re._endDragAfter,!1));var wr="absoluteOpacity",hr="allEventListeners",lt="absoluteTransform",Ln="absoluteScale",Ht="canvas",mh="Change",gh="children",vh="konva",Cs="listening",Rn="mouseenter",In="mouseleave",Nn="set",Gn="Shape",Sr=" ",Dn="stage",kt="transform",yh="Stage",Es="visible",bh=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Sr);let _h=1;class P{constructor(e){this._id=_h++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){(e===kt||e===lt)&&this._cache.get(e)?this._cache.get(e).dirty=!0:e?this._cache.delete(e):this._cache.clear()}_getCache(e,t){var r=this._cache.get(e),s=e===kt||e===lt,n=r===void 0||s&&r.dirty===!0;return n&&(r=t.call(this),this._cache.set(e,r)),r}_calculate(e,t,r){if(!this._attachedDepsListeners.get(e)){const s=t.map(n=>n+"Change.konva").join(Sr);this.on(s,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,r)}_getCanvasCache(){return this._cache.get(Ht)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===lt&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(Ht)){const{scene:e,filter:t,hit:r}=this._cache.get(Ht);y.releaseCanvas(e,t,r),this._cache.delete(Ht)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var t=e||{},r={};(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)&&(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()}));var s=Math.ceil(t.width||r.width),n=Math.ceil(t.height||r.height),a=t.pixelRatio,o=t.x===void 0?Math.floor(r.x):t.x,h=t.y===void 0?Math.floor(r.y):t.y,l=t.offset||0,d=t.drawBorder||!1,u=t.hitCanvasPixelRatio||1;if(!s||!n){y.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}s+=l*2+1,n+=l*2+1,o-=l,h-=l;var c=new ni({pixelRatio:a,width:s,height:n}),p=new ni({pixelRatio:a,width:0,height:0}),f=new sn({pixelRatio:u,width:s,height:n}),m=c.getContext(),g=f.getContext();return f.isCache=!0,c.isCache=!0,this._cache.delete(Ht),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(c.getContext()._context.imageSmoothingEnabled=!1,p.getContext()._context.imageSmoothingEnabled=!1),m.save(),g.save(),m.translate(-o,-h),g.translate(-o,-h),this._isUnderCache=!0,this._clearSelfAndDescendantCache(wr),this._clearSelfAndDescendantCache(Ln),this.drawScene(c,this),this.drawHit(f,this),this._isUnderCache=!1,m.restore(),g.restore(),d&&(m.save(),m.beginPath(),m.rect(0,0,s,n),m.closePath(),m.setAttr("strokeStyle","red"),m.setAttr("lineWidth",5),m.stroke(),m.restore()),this._cache.set(Ht,{scene:c,filter:p,hit:f,x:o,y:h}),this._requestDraw(),this}isCached(){return this._cache.has(Ht)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,t){var r=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],s,n,a,o,h=this.getAbsoluteTransform(t);return r.forEach(function(l){var d=h.point(l);s===void 0&&(s=a=d.x,n=o=d.y),s=Math.min(s,d.x),n=Math.min(n,d.y),a=Math.max(a,d.x),o=Math.max(o,d.y)}),{x:s,y:n,width:a-s,height:o-n}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const t=this._getCanvasCache();e.translate(t.x,t.y);var r=this._getCachedSceneCanvas(),s=r.pixelRatio;e.drawImage(r._canvas,0,0,r.width/s,r.height/s),e.restore()}_drawCachedHitCanvas(e){var t=this._getCanvasCache(),r=t.hit;e.save(),e.translate(t.x,t.y),e.drawImage(r._canvas,0,0,r.width/r.pixelRatio,r.height/r.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e=this.filters(),t=this._getCanvasCache(),r=t.scene,s=t.filter,n=s.getContext(),a,o,h,l;if(e){if(!this._filterUpToDate){var d=r.pixelRatio;s.setSize(r.width/r.pixelRatio,r.height/r.pixelRatio);try{for(a=e.length,n.clear(),n.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),o=n.getImageData(0,0,s.getWidth(),s.getHeight()),h=0;h<a;h++){if(l=e[h],typeof l!="function"){y.error("Filter should be type of function, but got "+typeof l+" instead. Please check correct filters");continue}l.call(this,o),n.putImageData(o,0,0)}}catch(u){y.error("Unable to apply filter. "+u.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return s}return r}on(e,t){if(this._cache&&this._cache.delete(hr),arguments.length===3)return this._delegate.apply(this,arguments);var r=e.split(Sr),s=r.length,n,a,o,h,l;for(n=0;n<s;n++)a=r[n],o=a.split("."),h=o[0],l=o[1]||"",this.eventListeners[h]||(this.eventListeners[h]=[]),this.eventListeners[h].push({name:l,handler:t});return this}off(e,t){var r=(e||"").split(Sr),s=r.length,n,a,o,h,l,d;if(this._cache&&this._cache.delete(hr),!e)for(a in this.eventListeners)this._off(a);for(n=0;n<s;n++)if(o=r[n],h=o.split("."),l=h[0],d=h[1],l)this.eventListeners[l]&&this._off(l,d,t);else for(a in this.eventListeners)this._off(a,d,t);return this}dispatchEvent(e){var t={target:this,type:e.type,evt:e};return this.fire(e.type,t),this}addEventListener(e,t){return this.on(e,function(r){t.call(this,r.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,t,r){var s=this;this.on(e,function(n){for(var a=n.target.findAncestors(t,!0,s),o=0;o<a.length;o++)n=y.cloneObject(n),n.currentTarget=a[o],r.call(a[o],n)})}remove(){return this.isDragging()&&this.stopDrag(),re._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(lt),this._clearSelfAndDescendantCache(wr),this._clearSelfAndDescendantCache(Ln),this._clearSelfAndDescendantCache(Dn),this._clearSelfAndDescendantCache(Es),this._clearSelfAndDescendantCache(Cs)}_remove(){this._clearCaches();var e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){var t="get"+y._capitalize(e);return y._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),t=[];e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{var t,r;if(!e)return this;for(t in e)t!==gh&&(r=Nn+y._capitalize(t),y._isFunction(this[r])?this[r](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(Cs,this._isListening)}_isListening(e){if(!this.listening())return!1;const r=this.getParent();return r&&r!==e&&this!==e?r._isListening(e):!0}isVisible(){return this._getCache(Es,this._isVisible)}_isVisible(e){if(!this.visible())return!1;const r=this.getParent();return r&&r!==e&&this!==e?r._isVisible(e):!0}shouldDrawHit(e,t=!1){if(e)return this._isVisible(e)&&this._isListening(e);var r=this.getLayer(),s=!1;re._dragElements.forEach(a=>{a.dragStatus==="dragging"&&(a.node.nodeType==="Stage"||a.node.getLayer()===r)&&(s=!0)});var n=!t&&!D.hitOnDragEnabled&&s;return this.isListening()&&this.isVisible()&&!n}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var e=this.getDepth(),t=this,r=0,s,n,a,o;function h(l){for(s=[],n=l.length,a=0;a<n;a++)o=l[a],r++,o.nodeType!==Gn&&(s=s.concat(o.getChildren().slice())),o._id===t._id&&(a=n);s.length>0&&s[0].getDepth()<=e&&h(s)}return t.nodeType!==yh&&h(t.getStage().getChildren()),r}getDepth(){for(var e=0,t=this.parent;t;)e++,t=t.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(kt),this._clearSelfAndDescendantCache(lt)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){if(!this.getStage())return null;var e=this.getStage().getPointerPosition();if(!e)return null;var t=this.getAbsoluteTransform().copy();return t.invert(),t.point(e)}getAbsolutePosition(e){let t=!1,r=this.parent;for(;r;){if(r.isCached()){t=!0;break}r=r.parent}t&&!e&&(e=!0);var s=this.getAbsoluteTransform(e).getMatrix(),n=new Ge,a=this.offset();return n.m=s.slice(),n.translate(a.x,a.y),n.getTranslation()}setAbsolutePosition(e){var t=this._clearTransform();this.attrs.x=t.x,this.attrs.y=t.y,delete t.x,delete t.y,this._clearCache(kt);var r=this._getAbsoluteTransform().copy();return r.invert(),r.translate(e.x,e.y),e={x:this.attrs.x+r.getTranslation().x,y:this.attrs.y+r.getTranslation().y},this._setTransform(t),this.setPosition({x:e.x,y:e.y}),this._clearCache(kt),this._clearSelfAndDescendantCache(lt),this}_setTransform(e){var t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){var 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){var t=e.x,r=e.y,s=this.x(),n=this.y();return t!==void 0&&(s+=t),r!==void 0&&(n+=r),this.setPosition({x:s,y:n}),this}_eachAncestorReverse(e,t){var r=[],s=this.getParent(),n,a;if(!(t&&t._id===this._id)){for(r.unshift(this);s&&(!t||s._id!==t._id);)r.unshift(s),s=s.parent;for(n=r.length,a=0;a<n;a++)e(r[a])}}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return y.warn("Node has no parent. moveToTop function is ignored."),!1;var e=this.index,t=this.parent.getChildren().length;return e<t-1?(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return y.warn("Node has no parent. moveUp function is ignored."),!1;var e=this.index,t=this.parent.getChildren().length;return e<t-1?(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return y.warn("Node has no parent. moveDown function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return y.warn("Node has no parent. moveToBottom function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(e){if(!this.parent)return y.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&y.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)+".");var 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(wr,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var 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(){var e={},t=this.getAttrs(),r,s,n,a,o;e.attrs={};for(r in t)s=t[r],o=y.isObject(s)&&!y._isPlainObject(s)&&!y._isArray(s),!o&&(n=typeof this[r]=="function"&&this[r],delete t[r],a=n?n.call(this):null,t[r]=s,a!==s&&(e.attrs[r]=s));return e.className=this.getClassName(),y._prepareToStringify(e)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,r){var s=[];t&&this._isMatch(e)&&s.push(this);for(var n=this.parent;n;){if(n===r)return s;n._isMatch(e)&&s.push(n),n=n.parent}return s}isAncestorOf(e){return!1}findAncestor(e,t,r){return this.findAncestors(e,t,r)[0]}_isMatch(e){if(!e)return!1;if(typeof e=="function")return e(this);var t=e.replace(/ /g,"").split(","),r=t.length,s,n;for(s=0;s<r;s++)if(n=t[s],y.isValidSelector(n)||(y.warn('Selector "'+n+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),y.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),y.warn("Konva is awesome, right?")),n.charAt(0)==="#"){if(this.id()===n.slice(1))return!0}else if(n.charAt(0)==="."){if(this.hasName(n.slice(1)))return!0}else if(this.className===n||this.nodeType===n)return!0;return!1}getLayer(){var e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(Dn,this._getStage)}_getStage(){var e=this.getParent();if(e)return e.getStage()}fire(e,t={},r){return t.target=t.target||this,r?this._fireAndBubble(e,t):this._fire(e,t),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(lt,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var t;if(e)return t=new Ge,this._eachAncestorReverse(function(s){var n=s.transformsEnabled();n==="all"?t.multiply(s.getTransform()):n==="position"&&t.translate(s.x()-s.offsetX(),s.y()-s.offsetY())},e),t;t=this._cache.get(lt)||new Ge,this.parent?this.parent.getAbsoluteTransform().copyInto(t):t.reset();var r=this.transformsEnabled();if(r==="all")t.multiply(this.getTransform());else if(r==="position"){const s=this.attrs.x||0,n=this.attrs.y||0,a=this.attrs.offsetX||0,o=this.attrs.offsetY||0;t.translate(s-a,n-o)}return t.dirty=!1,t}getAbsoluteScale(e){for(var t=this;t;)t._isUnderCache&&(e=t),t=t.getParent();const s=this.getAbsoluteTransform(e).decompose();return{x:s.scaleX,y:s.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(kt,this._getTransform)}_getTransform(){var e,t,r=this._cache.get(kt)||new Ge;r.reset();var s=this.x(),n=this.y(),a=D.getAngle(this.rotation()),o=(e=this.attrs.scaleX)!==null&&e!==void 0?e:1,h=(t=this.attrs.scaleY)!==null&&t!==void 0?t:1,l=this.attrs.skewX||0,d=this.attrs.skewY||0,u=this.attrs.offsetX||0,c=this.attrs.offsetY||0;return(s!==0||n!==0)&&r.translate(s,n),a!==0&&r.rotate(a),(l!==0||d!==0)&&r.skew(l,d),(o!==1||h!==1)&&r.scale(o,h),(u!==0||c!==0)&&r.translate(-1*u,-1*c),r.dirty=!1,r}clone(e){var t=y.cloneObject(this.attrs),r,s,n,a,o;for(r in e)t[r]=e[r];var h=new this.constructor(t);for(r in this.eventListeners)for(s=this.eventListeners[r],n=s.length,a=0;a<n;a++)o=s[a],o.name.indexOf(vh)<0&&(h.eventListeners[r]||(h.eventListeners[r]=[]),h.eventListeners[r].push(o));return h}_toKonvaCanvas(e){e=e||{};var t=this.getClientRect(),r=this.getStage(),s=e.x!==void 0?e.x:Math.floor(t.x),n=e.y!==void 0?e.y:Math.floor(t.y),a=e.pixelRatio||1,o=new ni({width:e.width||Math.ceil(t.width)||(r?r.width():0),height:e.height||Math.ceil(t.height)||(r?r.height():0),pixelRatio:a}),h=o.getContext();return e.imageSmoothingEnabled===!1&&(h._context.imageSmoothingEnabled=!1),h.save(),(s||n)&&h.translate(-1*s,-1*n),this.drawScene(o),h.restore(),o}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e=e||{};var t=e.mimeType||null,r=e.quality||null,s=this._toKonvaCanvas(e).toDataURL(t,r);return e.callback&&e.callback(s),s}toImage(e){return new Promise((t,r)=>{try{const s=e==null?void 0:e.callback;s&&delete e.callback,y._urlToImage(this.toDataURL(e),function(n){t(n),s==null||s(n)})}catch(s){r(s)}})}toBlob(e){return new Promise((t,r)=>{try{const s=e==null?void 0:e.callback;s&&delete e.callback,this.toCanvas(e).toBlob(n=>{t(n),s==null||s(n)})}catch(s){r(s)}})}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.attrs.dragDistance:this.parent?this.parent.getDragDistance():D.dragDistance}_off(e,t,r){var s=this.eventListeners[e],n,a,o;for(n=0;n<s.length;n++)if(a=s[n].name,o=s[n].handler,(a!=="konva"||t==="konva")&&(!t||a===t)&&(!r||r===o)){if(s.splice(n,1),s.length===0){delete this.eventListeners[e];break}n--}}_fireChangeEvent(e,t,r){this._fire(e+mh,{oldVal:t,newVal:r})}addName(e){if(!this.hasName(e)){var t=this.name(),r=t?t+" "+e:e;this.name(r)}return this}hasName(e){if(!e)return!1;const t=this.name();if(!t)return!1;var r=(t||"").split(/\s/g);return r.indexOf(e)!==-1}removeName(e){var t=(this.name()||"").split(/\s/g),r=t.indexOf(e);return r!==-1&&(t.splice(r,1),this.name(t.join(" "))),this}setAttr(e,t){var r=this[Nn+y._capitalize(e)];return y._isFunction(r)?r.call(this,t):this._setAttr(e,t),this}_requestDraw(){if(D.autoDrawEnabled){const e=this.getLayer()||this.getStage();e==null||e.batchDraw()}}_setAttr(e,t){var r=this.attrs[e];r===t&&!y.isObject(t)||(t==null?delete this.attrs[e]:this.attrs[e]=t,this._shouldFireChangeEvents&&this._fireChangeEvent(e,r,t),this._requestDraw())}_setComponentAttr(e,t,r){var s;r!==void 0&&(s=this.attrs[e],s||(this.attrs[e]=this.getAttr(e)),this.attrs[e][t]=r,this._fireChangeEvent(e,s,r))}_fireAndBubble(e,t,r){t&&this.nodeType===Gn&&(t.target=this);var s=(e===Rn||e===In)&&(r&&(this===r||this.isAncestorOf&&this.isAncestorOf(r))||this.nodeType==="Stage"&&!r);if(!s){this._fire(e,t);var n=(e===Rn||e===In)&&r&&r.isAncestorOf&&r.isAncestorOf(this)&&!r.isAncestorOf(this.parent);(t&&!t.cancelBubble||!t)&&this.parent&&this.parent.isListening()&&!n&&(r&&r.parent?this._fireAndBubble.call(this.parent,e,t,r):this._fireAndBubble.call(this.parent,e,t))}}_getProtoListeners(e){let t=this._cache.get(hr);if(!t){t={};let s=Object.getPrototypeOf(this);for(;s;){if(!s.eventListeners){s=Object.getPrototypeOf(s);continue}for(var r in s.eventListeners){const n=s.eventListeners[r],a=t[r]||[];t[r]=n.concat(a)}s=Object.getPrototypeOf(s)}this._cache.set(hr,t)}return t[e]}_fire(e,t){t=t||{},t.currentTarget=this,t.type=e;const r=this._getProtoListeners(e);if(r)for(var s=0;s<r.length;s++)r[s].handler.call(this,t);const n=this.eventListeners[e];if(n)for(var s=0;s<n.length;s++)n[s].handler.call(this,t)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var t=e?e.pointerId:void 0,r=this.getStage(),s=this.getAbsolutePosition(),n=r._getPointerById(t)||r._changedPointerPositions[0]||s;re._dragElements.set(this._id,{node:this,startPointerPos:n,offset:{x:n.x-s.x,y:n.y-s.y},dragStatus:"ready",pointerId:t})}startDrag(e,t=!0){re._dragElements.has(this._id)||this._createDragElement(e);const r=re._dragElements.get(this._id);r.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:e&&e.evt},t)}_setDragPosition(e,t){const r=this.getStage()._getPointerById(t.pointerId);if(r){var s={x:r.x-t.offset.x,y:r.y-t.offset.y},n=this.dragBoundFunc();if(n!==void 0){const a=n.call(this,s,e);a?s=a:y.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==s.x||this._lastPos.y!==s.y)&&(this.setAbsolutePosition(s),this._requestDraw()),this._lastPos=s}}stopDrag(e){const t=re._dragElements.get(this._id);t&&(t.dragStatus="stopped"),re._endDragBefore(e),re._endDragAfter(e)}setDraggable(e){this._setAttr("draggable",e),this._dragChange()}isDragging(){const e=re._dragElements.get(this._id);return e?e.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(e){var t=e.evt.button!==void 0,r=!t||D.dragButtons.indexOf(e.evt.button)>=0;if(r&&!this.isDragging()){var s=!1;re._dragElements.forEach(n=>{this.isAncestorOf(n.node)&&(s=!0)}),s||this._createDragElement(e)}})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();var e=this.getStage();if(!e)return;const t=re._dragElements.get(this._id),r=t&&t.dragStatus==="dragging",s=t&&t.dragStatus==="ready";r?this.stopDrag():s&&re._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const t=this.getStage();if(!t)return!1;const r={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return y.haveIntersection(r,this.getClientRect())}static create(e,t){return y._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(e,t){var r=P.prototype.getClassName.call(e),s=e.children,n,a,o;t&&(e.attrs.container=t),D[r]||(y.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const h=D[r];if(n=new h(e.attrs),s)for(a=s.length,o=0;o<a;o++)n.add(P._createNode(s[o]));return n}}P.prototype.nodeType="Node";P.prototype._attrsAffectingSize=[];P.prototype.eventListeners={};P.prototype.on.call(P.prototype,bh,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(kt),this._clearSelfAndDescendantCache(lt)});P.prototype.on.call(P.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(Es)});P.prototype.on.call(P.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(Cs)});P.prototype.on.call(P.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(wr)});const ce=v.addGetterSetter;ce(P,"zIndex");ce(P,"absolutePosition");ce(P,"position");ce(P,"x",0,x());ce(P,"y",0,x());ce(P,"globalCompositeOperation","source-over",gi());ce(P,"opacity",1,x());ce(P,"name","",gi());ce(P,"id","",gi());ce(P,"rotation",0,x());v.addComponentsGetterSetter(P,"scale",["x","y"]);ce(P,"scaleX",1,x());ce(P,"scaleY",1,x());v.addComponentsGetterSetter(P,"skew",["x","y"]);ce(P,"skewX",0,x());ce(P,"skewY",0,x());v.addComponentsGetterSetter(P,"offset",["x","y"]);ce(P,"offsetX",0,x());ce(P,"offsetY",0,x());ce(P,"dragDistance",null,x());ce(P,"width",0,x());ce(P,"height",0,x());ce(P,"listening",!0,qe());ce(P,"preventDefault",!0,qe());ce(P,"filters",null,function(i){return this._filterUpToDate=!1,i});ce(P,"visible",!0,qe());ce(P,"transformsEnabled","all",gi());ce(P,"size");ce(P,"dragBoundFunc");ce(P,"draggable",!1,qe());v.backCompat(P,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class De extends P{constructor(){super(...arguments),this.children=[]}getChildren(e){if(!e)return this.children||[];const t=this.children||[];var r=[];return t.forEach(function(s){e(s)&&r.push(s)}),r}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(arguments.length>1){for(var t=0;t<arguments.length;t++)this.add(arguments[t]);return this}var r=e[0];return r.getParent()?(r.moveTo(this),this):(this._validateAdd(r),r.index=this.getChildren().length,r.parent=this,r._clearCaches(),this.getChildren().push(r),this._fire("add",{child:r}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){var t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){var r=[];return this._descendants(s=>{const n=s._isMatch(e);return n&&r.push(s),!!(n&&t)}),r}_descendants(e){let t=!1;const r=this.getChildren();for(const s of r){if(t=e(s),t)return!0;if(s.hasChildren()&&(t=s._descendants(e),t))return!0}return!1}toObject(){var e=P.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){for(var t=e.getParent();t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){var t=P.prototype.clone.call(this,e);return this.getChildren().forEach(function(r){t.add(r.clone())}),t}getAllIntersections(e){var t=[];return this.find("Shape").forEach(function(r){r.isVisible()&&r.intersects(e)&&t.push(r)}),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),!this.isCached()&&((t=this.children)===null||t===void 0||t.forEach(function(r){r._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(t,r){t.index=r}),this._requestDraw()}drawScene(e,t){var r=this.getLayer(),s=e||r&&r.getCanvas(),n=s&&s.getContext(),a=this._getCanvasCache(),o=a&&a.scene,h=s&&s.isCache;if(!this.isVisible()&&!h)return this;if(o){n.save();var l=this.getAbsoluteTransform(t).getMatrix();n.transform(l[0],l[1],l[2],l[3],l[4],l[5]),this._drawCachedSceneCanvas(n),n.restore()}else this._drawChildren("drawScene",s,t);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;var r=this.getLayer(),s=e||r&&r.hitCanvas,n=s&&s.getContext(),a=this._getCanvasCache(),o=a&&a.hit;if(o){n.save();var h=this.getAbsoluteTransform(t).getMatrix();n.transform(h[0],h[1],h[2],h[3],h[4],h[5]),this._drawCachedHitCanvas(n),n.restore()}else this._drawChildren("drawHit",s,t);return this}_drawChildren(e,t,r){var s,n=t&&t.getContext(),a=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l=a&&o||h;const d=r===this;if(l){n.save();var u=this.getAbsoluteTransform(r),c=u.getMatrix();if(n.transform(c[0],c[1],c[2],c[3],c[4],c[5]),n.beginPath(),h)h.call(this,n,this);else{var p=this.clipX(),f=this.clipY();n.rect(p,f,a,o)}n.clip(),c=u.copy().invert().getMatrix(),n.transform(c[0],c[1],c[2],c[3],c[4],c[5])}var m=!d&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";m&&(n.save(),n._applyGlobalCompositeOperation(this)),(s=this.children)===null||s===void 0||s.forEach(function(g){g[e](t,r)}),m&&n.restore(),l&&n.restore()}getClientRect(e){var t;e=e||{};var r=e.skipTransform,s=e.relativeTo,n,a,o,h,l={x:1/0,y:1/0,width:0,height:0},d=this;(t=this.children)===null||t===void 0||t.forEach(function(m){if(m.visible()){var g=m.getClientRect({relativeTo:d,skipShadow:e.skipShadow,skipStroke:e.skipStroke});g.width===0&&g.height===0||(n===void 0?(n=g.x,a=g.y,o=g.x+g.width,h=g.y+g.height):(n=Math.min(n,g.x),a=Math.min(a,g.y),o=Math.max(o,g.x+g.width),h=Math.max(h,g.y+g.height)))}});for(var u=this.find("Shape"),c=!1,p=0;p<u.length;p++){var f=u[p];if(f._isVisible(this)){c=!0;break}}return c&&n!==void 0?l={x:n,y:a,width:o-n,height:h-a}:l={x:0,y:0,width:0,height:0},r?l:this._transformedRect(l,s)}}v.addComponentsGetterSetter(De,"clip",["x","y","width","height"]);v.addGetterSetter(De,"clipX",void 0,x());v.addGetterSetter(De,"clipY",void 0,x());v.addGetterSetter(De,"clipWidth",void 0,x());v.addGetterSetter(De,"clipHeight",void 0,x());v.addGetterSetter(De,"clipFunc");const Di=new Map,Fa=D._global.PointerEvent!==void 0;function us(i){return Di.get(i)}function nn(i){return{evt:i,pointerId:i.pointerId}}function Ha(i,e){return Di.get(i)===e}function Ba(i,e){Ii(i),e.getStage()&&(Di.set(i,e),Fa&&e._fire("gotpointercapture",nn(new PointerEvent("gotpointercapture"))))}function Ii(i,e){const t=Di.get(i);if(!t)return;const r=t.getStage();r&&r.content,Di.delete(i),Fa&&t._fire("lostpointercapture",nn(new PointerEvent("lostpointercapture")))}var wh="Stage",Sh="string",Fn="px",Th="mouseout",$a="mouseleave",Va="mouseover",za="mouseenter",Ua="mousemove",Wa="mousedown",Za="mouseup",Ai="pointermove",Mi="pointerdown",ei="pointerup",Oi="pointercancel",Ch="lostpointercapture",dr="pointerout",ur="pointerleave",cr="pointerover",fr="pointerenter",ks="contextmenu",ja="touchstart",Xa="touchend",qa="touchmove",Ya="touchcancel",xs="wheel",Eh=5,kh=[[za,"_pointerenter"],[Wa,"_pointerdown"],[Ua,"_pointermove"],[Za,"_pointerup"],[$a,"_pointerleave"],[ja,"_pointerdown"],[qa,"_pointermove"],[Xa,"_pointerup"],[Ya,"_pointercancel"],[Va,"_pointerover"],[xs,"_wheel"],[ks,"_contextmenu"],[Mi,"_pointerdown"],[Ai,"_pointermove"],[ei,"_pointerup"],[Oi,"_pointercancel"],[Ch,"_lostpointercapture"]];const cs={mouse:{[dr]:Th,[ur]:$a,[cr]:Va,[fr]:za,[Ai]:Ua,[Mi]:Wa,[ei]:Za,[Oi]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[dr]:"touchout",[ur]:"touchleave",[cr]:"touchover",[fr]:"touchenter",[Ai]:qa,[Mi]:ja,[ei]:Xa,[Oi]:Ya,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[dr]:dr,[ur]:ur,[cr]:cr,[fr]:fr,[Ai]:Ai,[Mi]:Mi,[ei]:ei,[Oi]:Oi,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},Li=i=>i.indexOf("pointer")>=0?"pointer":i.indexOf("touch")>=0?"touch":"mouse",Kt=i=>{const e=Li(i);if(e==="pointer")return D.pointerEventsEnabled&&cs.pointer;if(e==="touch")return cs.touch;if(e==="mouse")return cs.mouse};function Hn(i={}){return(i.clipFunc||i.clipWidth||i.clipHeight)&&y.warn("Stage does not support clipping. Please use clip for Layers or Groups."),i}const xh="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);",Tr=[];class Kr extends De{constructor(e){super(Hn(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),Tr.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{Hn(this.attrs)}),this._checkVisibility()}_validateAdd(e){const t=e.getType()==="Layer",r=e.getType()==="FastLayer";t||r||y.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if(typeof e===Sh){if(e.charAt(0)==="."){var t=e.slice(1);e=document.getElementsByClassName(t)[0]}else{var r;e.charAt(0)!=="#"?r=e:r=e.slice(1),e=document.getElementById(r)}if(!e)throw"Can not find container in document with id "+r}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var e=this.children,t=e.length,r;for(r=0;r<t;r++)e[r].clear();return this}clone(e){return e||(e={}),e.container=typeof document<"u"&&document.createElement("div"),De.prototype.clone.call(this,e)}destroy(){super.destroy();var e=this.content;e&&y._isInDocument(e)&&this.container().removeChild(e);var t=Tr.indexOf(this);return t>-1&&Tr.splice(t,1),y.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(y.warn(xh),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();var t=new ni({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),r=t.getContext()._context,s=this.children;return(e.x||e.y)&&r.translate(-1*e.x,-1*e.y),s.forEach(function(n){if(n.isVisible()){var a=n._toKonvaCanvas(e);r.drawImage(a._canvas,e.x,e.y,a.getWidth()/a.getPixelRatio(),a.getHeight()/a.getPixelRatio())}}),t}getIntersection(e){if(!e)return null;var t=this.children,r=t.length,s=r-1,n;for(n=s;n>=0;n--){const a=t[n].getIntersection(e);if(a)return a}return null}_resizeDOM(){var e=this.width(),t=this.height();this.content&&(this.content.style.width=e+Fn,this.content.style.height=t+Fn),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach(r=>{r.setSize({width:e,height:t}),r.draw()})}add(e,...t){if(arguments.length>1){for(var r=0;r<arguments.length;r++)this.add(arguments[r]);return this}super.add(e);var s=this.children.length;return s>Eh&&y.warn("The stage has "+s+" 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(),D.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return Ha(e,this)}setPointerCapture(e){Ba(e,this)}releaseCapture(e){Ii(e)}getLayers(){return this.children}_bindContentEvents(){D.isBrowser&&kh.forEach(([e,t])=>{this.content.addEventListener(e,r=>{this[t](r)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=Kt(e.type);this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=Kt(e.type);this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){const t=Kt(e.type),r=Li(e.type);if(t){this.setPointersPositions(e);var s=this._getTargetShape(r),n=!re.isDragging||D.hitOnDragEnabled;s&&n?(s._fireAndBubble(t.pointerout,{evt:e}),s._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[r+"targetShape"]=null):n&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=void 0,this._pointerPositions=[]}}_pointerdown(e){const t=Kt(e.type),r=Li(e.type);if(t){this.setPointersPositions(e);var s=!1;this._changedPointerPositions.forEach(n=>{var a=this.getIntersection(n);if(re.justDragged=!1,D["_"+r+"ListenClick"]=!0,!(a&&a.isListening()))return;D.capturePointerEventsEnabled&&a.setPointerCapture(n.id),this[r+"ClickStartShape"]=a,a._fireAndBubble(t.pointerdown,{evt:e,pointerId:n.id}),s=!0;const h=e.type.indexOf("touch")>=0;a.preventDefault()&&e.cancelable&&h&&e.preventDefault()}),s||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(e){const t=Kt(e.type),r=Li(e.type);if(!t)return;re.isDragging&&re.node.preventDefault()&&e.cancelable&&e.preventDefault(),this.setPointersPositions(e);var s=!re.isDragging||D.hitOnDragEnabled;if(!s)return;var n={};let a=!1;var o=this._getTargetShape(r);this._changedPointerPositions.forEach(h=>{const l=us(h.id)||this.getIntersection(h),d=h.id,u={evt:e,pointerId:d};var c=o!==l;if(c&&o&&(o._fireAndBubble(t.pointerout,Object.assign({},u),l),o._fireAndBubble(t.pointerleave,Object.assign({},u),l)),l){if(n[l._id])return;n[l._id]=!0}l&&l.isListening()?(a=!0,c&&(l._fireAndBubble(t.pointerover,Object.assign({},u),o),l._fireAndBubble(t.pointerenter,Object.assign({},u),o),this[r+"targetShape"]=l),l._fireAndBubble(t.pointermove,Object.assign({},u))):o&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:d}),this[r+"targetShape"]=null)}),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=Kt(e.type),r=Li(e.type);if(!t)return;this.setPointersPositions(e);const s=this[r+"ClickStartShape"],n=this[r+"ClickEndShape"];var a={};let o=!1;this._changedPointerPositions.forEach(h=>{const l=us(h.id)||this.getIntersection(h);if(l){if(l.releaseCapture(h.id),a[l._id])return;a[l._id]=!0}const d=h.id,u={evt:e,pointerId:d};let c=!1;D["_"+r+"InDblClickWindow"]?(c=!0,clearTimeout(this[r+"DblTimeout"])):re.justDragged||(D["_"+r+"InDblClickWindow"]=!0,clearTimeout(this[r+"DblTimeout"])),this[r+"DblTimeout"]=setTimeout(function(){D["_"+r+"InDblClickWindow"]=!1},D.dblClickWindow),l&&l.isListening()?(o=!0,this[r+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,Object.assign({},u)),D["_"+r+"ListenClick"]&&s&&s===l&&(l._fireAndBubble(t.pointerclick,Object.assign({},u)),c&&n&&n===l&&l._fireAndBubble(t.pointerdblclick,Object.assign({},u)))):(this[r+"ClickEndShape"]=null,D["_"+r+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:d}),c&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:d}))}),o||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),D["_"+r+"ListenClick"]=!1,e.cancelable&&r!=="touch"&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(ks,{evt:e}):this._fire(ks,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(xs,{evt:e}):this._fire(xs,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=us(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(ei,nn(e)),Ii(e.pointerId)}_lostpointercapture(e){Ii(e.pointerId)}setPointersPositions(e){var t=this._getContentPosition(),r=null,s=null;e=e||window.event,e.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,n=>{this._pointerPositions.push({id:n.identifier,x:(n.clientX-t.left)/t.scaleX,y:(n.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,n=>{this._changedPointerPositions.push({id:n.identifier,x:(n.clientX-t.left)/t.scaleX,y:(n.clientY-t.top)/t.scaleY})})):(r=(e.clientX-t.left)/t.scaleX,s=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:r,y:s},this._pointerPositions=[{x:r,y:s,id:y._getFirstPointerId(e)}],this._changedPointerPositions=[{x:r,y:s,id:y._getFirstPointerId(e)}])}_setPointerPosition(e){y.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};var e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new ni({width:this.width(),height:this.height()}),this.bufferHitCanvas=new sn({pixelRatio:1,width:this.width(),height:this.height()}),!!D.isBrowser){var e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}}cache(){return y.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}}Kr.prototype.nodeType=wh;ge(Kr);v.addGetterSetter(Kr,"container");var Ka="hasShadow",Ja="shadowRGBA",Qa="patternImage",eo="linearGradient",to="radialGradient";let pr;function fs(){return pr||(pr=y.createCanvasElement().getContext("2d"),pr)}const Ni={};function Ph(i){i.fill()}function Ah(i){i.stroke()}function Mh(i){i.fill()}function Oh(i){i.stroke()}function Lh(){this._clearCache(Ka)}function Rh(){this._clearCache(Ja)}function Ih(){this._clearCache(Qa)}function Nh(){this._clearCache(eo)}function Gh(){this._clearCache(to)}class E extends P{constructor(e){super(e);let t;for(;t=y.getRandomColor(),!(t&&!(t in Ni)););this.colorKey=t,Ni[t]=this}getContext(){return y.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return y.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(Ka,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(Qa,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){var e=fs();const t=e.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const r=new Ge;r.translate(this.fillPatternX(),this.fillPatternY()),r.rotate(D.getAngle(this.fillPatternRotation())),r.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),r.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const s=r.getMatrix(),n=typeof DOMMatrix>"u"?{a:s[0],b:s[1],c:s[2],d:s[3],e:s[4],f:s[5]}:new DOMMatrix(s);t.setTransform(n)}return t}}_getLinearGradient(){return this._getCache(eo,this.__getLinearGradient)}__getLinearGradient(){var e=this.fillLinearGradientColorStops();if(e){for(var t=fs(),r=this.fillLinearGradientStartPoint(),s=this.fillLinearGradientEndPoint(),n=t.createLinearGradient(r.x,r.y,s.x,s.y),a=0;a<e.length;a+=2)n.addColorStop(e[a],e[a+1]);return n}}_getRadialGradient(){return this._getCache(to,this.__getRadialGradient)}__getRadialGradient(){var e=this.fillRadialGradientColorStops();if(e){for(var t=fs(),r=this.fillRadialGradientStartPoint(),s=this.fillRadialGradientEndPoint(),n=t.createRadialGradient(r.x,r.y,this.fillRadialGradientStartRadius(),s.x,s.y,this.fillRadialGradientEndRadius()),a=0;a<e.length;a+=2)n.addColorStop(e[a],e[a+1]);return n}}getShadowRGBA(){return this._getCache(Ja,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var e=y.colorToRGBA(this.shadowColor());if(e)return"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")"}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const e=this.hitStrokeWidth();return e==="auto"?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){var t=this.getStage(),r=t.bufferHitCanvas,s;return r.getContext().clear(),this.drawHit(r,null,!0),s=r.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data,s[3]>0}destroy(){return P.prototype.destroy.call(this),delete Ni[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!this.getStage()||!((t=this.attrs.perfectDrawEnabled)!==null&&t!==void 0?t:!0))return!1;const s=e||this.hasFill(),n=this.hasStroke(),a=this.getAbsoluteOpacity()!==1;if(s&&n&&a)return!0;const o=this.hasShadow(),h=this.shadowForStrokeEnabled();return!!(s&&n&&o&&h)}setStrokeHitEnabled(e){y.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){var e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){const t=e.skipTransform,r=e.relativeTo,s=this.getSelfRect(),a=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=s.width+a,h=s.height+a,l=!e.skipShadow&&this.hasShadow(),d=l?this.shadowOffsetX():0,u=l?this.shadowOffsetY():0,c=o+Math.abs(d),p=h+Math.abs(u),f=l&&this.shadowBlur()||0,m=c+f*2,g=p+f*2,_={width:m,height:g,x:-(a/2+f)+Math.min(d,0)+s.x,y:-(a/2+f)+Math.min(u,0)+s.y};return t?_:this._transformedRect(_,r)}drawScene(e,t){var r=this.getLayer(),s=e||r.getCanvas(),n=s.getContext(),a=this._getCanvasCache(),o=this.getSceneFunc(),h=this.hasShadow(),l,d,u,c=s.isCache,p=t===this;if(!this.isVisible()&&!p)return this;if(a){n.save();var f=this.getAbsoluteTransform(t).getMatrix();return n.transform(f[0],f[1],f[2],f[3],f[4],f[5]),this._drawCachedSceneCanvas(n),n.restore(),this}if(!o)return this;if(n.save(),this._useBufferCanvas()&&!c){l=this.getStage(),d=l.bufferCanvas,u=d.getContext(),u.clear(),u.save(),u._applyLineJoin(this);var m=this.getAbsoluteTransform(t).getMatrix();u.transform(m[0],m[1],m[2],m[3],m[4],m[5]),o.call(this,u,this),u.restore();var g=d.pixelRatio;h&&n._applyShadow(this),n._applyOpacity(this),n._applyGlobalCompositeOperation(this),n.drawImage(d._canvas,0,0,d.width/g,d.height/g)}else{if(n._applyLineJoin(this),!p){var m=this.getAbsoluteTransform(t).getMatrix();n.transform(m[0],m[1],m[2],m[3],m[4],m[5]),n._applyOpacity(this),n._applyGlobalCompositeOperation(this)}h&&n._applyShadow(this),o.call(this,n,this)}return n.restore(),this}drawHit(e,t,r=!1){if(!this.shouldDrawHit(t,r))return this;var s=this.getLayer(),n=e||s.hitCanvas,a=n&&n.getContext(),o=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||y.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){a.save();var d=this.getAbsoluteTransform(t).getMatrix();return a.transform(d[0],d[1],d[2],d[3],d[4],d[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!o)return this;if(a.save(),a._applyLineJoin(this),!(this===t)){var c=this.getAbsoluteTransform(t).getMatrix();a.transform(c[0],c[1],c[2],c[3],c[4],c[5])}return o.call(this,a,this),a.restore(),this}drawHitFromCache(e=0){var t=this._getCanvasCache(),r=this._getCachedSceneCanvas(),s=t.hit,n=s.getContext(),a=s.getWidth(),o=s.getHeight(),h,l,d,u,c,p;n.clear(),n.drawImage(r._canvas,0,0,a,o);try{for(h=n.getImageData(0,0,a,o),l=h.data,d=l.length,u=y._hexToRgb(this.colorKey),c=0;c<d;c+=4)p=l[c+3],p>e?(l[c]=u.r,l[c+1]=u.g,l[c+2]=u.b,l[c+3]=255):l[c+3]=0;n.putImageData(h,0,0)}catch(f){y.error("Unable to draw hit graph from cached scene canvas. "+f.message)}return this}hasPointerCapture(e){return Ha(e,this)}setPointerCapture(e){Ba(e,this)}releaseCapture(e){Ii(e)}}E.prototype._fillFunc=Ph;E.prototype._strokeFunc=Ah;E.prototype._fillFuncHit=Mh;E.prototype._strokeFuncHit=Oh;E.prototype._centroid=!1;E.prototype.nodeType="Shape";ge(E);E.prototype.eventListeners={};E.prototype.on.call(E.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",Lh);E.prototype.on.call(E.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",Rh);E.prototype.on.call(E.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",Ih);E.prototype.on.call(E.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",Nh);E.prototype.on.call(E.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",Gh);v.addGetterSetter(E,"stroke",void 0,Da());v.addGetterSetter(E,"strokeWidth",2,x());v.addGetterSetter(E,"fillAfterStrokeEnabled",!1);v.addGetterSetter(E,"hitStrokeWidth","auto",rn());v.addGetterSetter(E,"strokeHitEnabled",!0,qe());v.addGetterSetter(E,"perfectDrawEnabled",!0,qe());v.addGetterSetter(E,"shadowForStrokeEnabled",!0,qe());v.addGetterSetter(E,"lineJoin");v.addGetterSetter(E,"lineCap");v.addGetterSetter(E,"sceneFunc");v.addGetterSetter(E,"hitFunc");v.addGetterSetter(E,"dash");v.addGetterSetter(E,"dashOffset",0,x());v.addGetterSetter(E,"shadowColor",void 0,gi());v.addGetterSetter(E,"shadowBlur",0,x());v.addGetterSetter(E,"shadowOpacity",1,x());v.addComponentsGetterSetter(E,"shadowOffset",["x","y"]);v.addGetterSetter(E,"shadowOffsetX",0,x());v.addGetterSetter(E,"shadowOffsetY",0,x());v.addGetterSetter(E,"fillPatternImage");v.addGetterSetter(E,"fill",void 0,Da());v.addGetterSetter(E,"fillPatternX",0,x());v.addGetterSetter(E,"fillPatternY",0,x());v.addGetterSetter(E,"fillLinearGradientColorStops");v.addGetterSetter(E,"strokeLinearGradientColorStops");v.addGetterSetter(E,"fillRadialGradientStartRadius",0);v.addGetterSetter(E,"fillRadialGradientEndRadius",0);v.addGetterSetter(E,"fillRadialGradientColorStops");v.addGetterSetter(E,"fillPatternRepeat","repeat");v.addGetterSetter(E,"fillEnabled",!0);v.addGetterSetter(E,"strokeEnabled",!0);v.addGetterSetter(E,"shadowEnabled",!0);v.addGetterSetter(E,"dashEnabled",!0);v.addGetterSetter(E,"strokeScaleEnabled",!0);v.addGetterSetter(E,"fillPriority","color");v.addComponentsGetterSetter(E,"fillPatternOffset",["x","y"]);v.addGetterSetter(E,"fillPatternOffsetX",0,x());v.addGetterSetter(E,"fillPatternOffsetY",0,x());v.addComponentsGetterSetter(E,"fillPatternScale",["x","y"]);v.addGetterSetter(E,"fillPatternScaleX",1,x());v.addGetterSetter(E,"fillPatternScaleY",1,x());v.addComponentsGetterSetter(E,"fillLinearGradientStartPoint",["x","y"]);v.addComponentsGetterSetter(E,"strokeLinearGradientStartPoint",["x","y"]);v.addGetterSetter(E,"fillLinearGradientStartPointX",0);v.addGetterSetter(E,"strokeLinearGradientStartPointX",0);v.addGetterSetter(E,"fillLinearGradientStartPointY",0);v.addGetterSetter(E,"strokeLinearGradientStartPointY",0);v.addComponentsGetterSetter(E,"fillLinearGradientEndPoint",["x","y"]);v.addComponentsGetterSetter(E,"strokeLinearGradientEndPoint",["x","y"]);v.addGetterSetter(E,"fillLinearGradientEndPointX",0);v.addGetterSetter(E,"strokeLinearGradientEndPointX",0);v.addGetterSetter(E,"fillLinearGradientEndPointY",0);v.addGetterSetter(E,"strokeLinearGradientEndPointY",0);v.addComponentsGetterSetter(E,"fillRadialGradientStartPoint",["x","y"]);v.addGetterSetter(E,"fillRadialGradientStartPointX",0);v.addGetterSetter(E,"fillRadialGradientStartPointY",0);v.addComponentsGetterSetter(E,"fillRadialGradientEndPoint",["x","y"]);v.addGetterSetter(E,"fillRadialGradientEndPointX",0);v.addGetterSetter(E,"fillRadialGradientEndPointY",0);v.addGetterSetter(E,"fillPatternRotation",0);v.backCompat(E,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var Dh="#",Fh="beforeDraw",Hh="draw",io=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],Bh=io.length;class Zt extends De{constructor(e){super(e),this.canvas=new ni,this.hitCanvas=new sn({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);var 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(){P.prototype.moveToTop.call(this);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){var e=P.prototype.moveUp.call(this);if(!e)return!1;var t=this.getStage();return!t||!t.content?!1:(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(P.prototype.moveDown.call(this)){var e=this.getStage();if(e){var 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(P.prototype.moveToBottom.call(this)){var e=this.getStage();if(e){var 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=this.getNativeCanvasElement();return P.prototype.remove.call(this),e&&e.parentNode&&y._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){var t=e.getType();t!=="Group"&&t!=="Shape"&&y.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?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),P.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(){y.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){y.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,y.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;for(var t=1,r=!1;;){for(let s=0;s<Bh;s++){const n=io[s],a=this._getIntersection({x:e.x+n.x*t,y:e.y+n.y*t}),o=a.shape;if(o)return o;if(r=!!a.antialiased,!a.antialiased)break}if(r)t+=1;else return null}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,r=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,s=r[3];if(s===255){const n=y._rgbToHex(r[0],r[1],r[2]),a=Ni[Dh+n];return a?{shape:a}:{antialiased:!0}}else if(s>0)return{antialiased:!0};return{}}drawScene(e,t){var r=this.getLayer(),s=e||r&&r.getCanvas();return this._fire(Fh,{node:this}),this.clearBeforeDraw()&&s.getContext().clear(),De.prototype.drawScene.call(this,s,t),this._fire(Hh,{node:this}),this}drawHit(e,t){var r=this.getLayer(),s=e||r&&r.hitCanvas;return r&&r.clearBeforeDraw()&&r.getHitCanvas().getContext().clear(),De.prototype.drawHit.call(this,s,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){y.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return y.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!(!this.parent||!this.parent.content)){var e=this.parent,t=!!this.hitCanvas._canvas.parentNode;t?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}}destroy(){return y.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}Zt.prototype.nodeType="Layer";ge(Zt);v.addGetterSetter(Zt,"imageSmoothingEnabled",!0);v.addGetterSetter(Zt,"clearBeforeDraw",!0);v.addGetterSetter(Zt,"hitGraphEnabled",!0,qe());class an extends Zt{constructor(e){super(e),this.listening(!1),y.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}an.prototype.nodeType="FastLayer";ge(an);class hi extends De{_validateAdd(e){var t=e.getType();t!=="Group"&&t!=="Shape"&&y.throw("You may only add groups and shapes to groups.")}}hi.prototype.nodeType="Group";ge(hi);var ps=function(){return si.performance&&si.performance.now?function(){return si.performance.now()}:function(){return new Date().getTime()}}();class Be{constructor(e,t){this.id=Be.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:ps(),frameRate:0},this.func=e,this.setLayers(t)}setLayers(e){var t=[];return e?e.length>0?t=e:t=[e]:t=[],this.layers=t,this}getLayers(){return this.layers}addLayer(e){var t=this.layers,r=t.length,s;for(s=0;s<r;s++)if(t[s]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){var e=Be,t=e.animations,r=t.length,s;for(s=0;s<r;s++)if(t[s].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=ps(),Be._addAnimation(this),this}stop(){return Be._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){var t=e.id,r=this.animations,s=r.length,n;for(n=0;n<s;n++)if(r[n].id===t){this.animations.splice(n,1);break}}static _runFrames(){var e={},t=this.animations,r,s,n,a,o,h,l,d,u;for(a=0;a<t.length;a++)if(r=t[a],s=r.layers,n=r.func,r._updateFrameObject(ps()),h=s.length,n?u=n.call(r,r.frame)!==!1:u=!0,!!u)for(o=0;o<h;o++)l=s[o],l._id!==void 0&&(e[l._id]=l);for(d in e)e.hasOwnProperty(d)&&e[d].batchDraw()}static _animationLoop(){var e=Be;e.animations.length?(e._runFrames(),y.requestAnimFrame(e._animationLoop)):e.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,y.requestAnimFrame(this._animationLoop))}}Be.animations=[];Be.animIdCounter=0;Be.animRunning=!1;var $h={node:1,duration:1,easing:1,onFinish:1,yoyo:1},Vh=1,Bn=2,$n=3,zh=0,Vn=["fill","stroke","shadowColor"];class Uh{constructor(e,t,r,s,n,a,o){this.prop=e,this.propFunc=t,this.begin=s,this._pos=s,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=r,this._change=n-this.begin,this.pause()}fire(e){var 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=Bn,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=$n,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var e=this.getTimer()-this._startTime;this.state===Bn?this.setTime(e):this.state===$n&&this.setTime(this.duration-e)}pause(){this.state=Vh,this.fire("onPause")}getTimer(){return new Date().getTime()}}class ye{constructor(e){var t=this,r=e.node,s=r._id,n,a=e.easing||Gi.Linear,o=!!e.yoyo,h;typeof e.duration>"u"?n=.3:e.duration===0?n=.001:n=e.duration,this.node=r,this._id=zh++;var l=r.getLayer()||(r instanceof D.Stage?r.getLayers():null);l||y.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Be(function(){t.tween.onEnterFrame()},l),this.tween=new Uh(h,function(d){t._tweenFunc(d)},a,0,1,n*1e3,o),this._addListeners(),ye.attrs[s]||(ye.attrs[s]={}),ye.attrs[s][this._id]||(ye.attrs[s][this._id]={}),ye.tweens[s]||(ye.tweens[s]={});for(h in e)$h[h]===void 0&&this._addAttr(h,e[h]);this.reset(),this.onFinish=e.onFinish,this.onReset=e.onReset,this.onUpdate=e.onUpdate}_addAttr(e,t){var r=this.node,s=r._id,n,a,o,h,l,d,u,c;if(o=ye.tweens[s][e],o&&delete ye.attrs[s][o][e],n=r.getAttr(e),y._isArray(t))if(a=[],l=Math.max(t.length,n.length),e==="points"&&t.length!==n.length&&(t.length>n.length?(u=n,n=y._prepareArrayForTween(n,t,r.closed())):(d=t,t=y._prepareArrayForTween(t,n,r.closed()))),e.indexOf("fill")===0)for(h=0;h<l;h++)if(h%2===0)a.push(t[h]-n[h]);else{var p=y.colorToRGBA(n[h]);c=y.colorToRGBA(t[h]),n[h]=p,a.push({r:c.r-p.r,g:c.g-p.g,b:c.b-p.b,a:c.a-p.a})}else for(h=0;h<l;h++)a.push(t[h]-n[h]);else Vn.indexOf(e)!==-1?(n=y.colorToRGBA(n),c=y.colorToRGBA(t),a={r:c.r-n.r,g:c.g-n.g,b:c.b-n.b,a:c.a-n.a}):a=t-n;ye.attrs[s][this._id][e]={start:n,diff:a,end:t,trueEnd:d,trueStart:u},ye.tweens[s][e]=this._id}_tweenFunc(e){var t=this.node,r=ye.attrs[t._id][this._id],s,n,a,o,h,l,d,u;for(s in r){if(n=r[s],a=n.start,o=n.diff,u=n.end,y._isArray(a))if(h=[],d=Math.max(a.length,u.length),s.indexOf("fill")===0)for(l=0;l<d;l++)l%2===0?h.push((a[l]||0)+o[l]*e):h.push("rgba("+Math.round(a[l].r+o[l].r*e)+","+Math.round(a[l].g+o[l].g*e)+","+Math.round(a[l].b+o[l].b*e)+","+(a[l].a+o[l].a*e)+")");else for(l=0;l<d;l++)h.push((a[l]||0)+o[l]*e);else Vn.indexOf(s)!==-1?h="rgba("+Math.round(a.r+o.r*e)+","+Math.round(a.g+o.g*e)+","+Math.round(a.b+o.b*e)+","+(a.a+o.a*e)+")":h=a+o*e;t.setAttr(s,h)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var e=this.node,t=ye.attrs[e._id][this._id];t.points&&t.points.trueEnd&&e.setAttr("points",t.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var e=this.node,t=ye.attrs[e._id][this._id];t.points&&t.points.trueStart&&e.points(t.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(e*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var e=this.node._id,t=this._id,r=ye.tweens[e],s;this.pause();for(s in r)delete ye.tweens[e][s];delete ye.attrs[e][t]}}ye.attrs={};ye.tweens={};P.prototype.to=function(i){var e=i.onFinish;i.node=this,i.onFinish=function(){this.destroy(),e&&e()};var t=new ye(i);t.play()};const Gi={BackEaseIn(i,e,t,r){var s=1.70158;return t*(i/=r)*i*((s+1)*i-s)+e},BackEaseOut(i,e,t,r){var s=1.70158;return t*((i=i/r-1)*i*((s+1)*i+s)+1)+e},BackEaseInOut(i,e,t,r){var s=1.70158;return(i/=r/2)<1?t/2*(i*i*(((s*=1.525)+1)*i-s))+e:t/2*((i-=2)*i*(((s*=1.525)+1)*i+s)+2)+e},ElasticEaseIn(i,e,t,r,s,n){var a=0;return i===0?e:(i/=r)===1?e+t:(n||(n=r*.3),!s||s<Math.abs(t)?(s=t,a=n/4):a=n/(2*Math.PI)*Math.asin(t/s),-(s*Math.pow(2,10*(i-=1))*Math.sin((i*r-a)*(2*Math.PI)/n))+e)},ElasticEaseOut(i,e,t,r,s,n){var a=0;return i===0?e:(i/=r)===1?e+t:(n||(n=r*.3),!s||s<Math.abs(t)?(s=t,a=n/4):a=n/(2*Math.PI)*Math.asin(t/s),s*Math.pow(2,-10*i)*Math.sin((i*r-a)*(2*Math.PI)/n)+t+e)},ElasticEaseInOut(i,e,t,r,s,n){var a=0;return i===0?e:(i/=r/2)===2?e+t:(n||(n=r*(.3*1.5)),!s||s<Math.abs(t)?(s=t,a=n/4):a=n/(2*Math.PI)*Math.asin(t/s),i<1?-.5*(s*Math.pow(2,10*(i-=1))*Math.sin((i*r-a)*(2*Math.PI)/n))+e:s*Math.pow(2,-10*(i-=1))*Math.sin((i*r-a)*(2*Math.PI)/n)*.5+t+e)},BounceEaseOut(i,e,t,r){return(i/=r)<1/2.75?t*(7.5625*i*i)+e:i<2/2.75?t*(7.5625*(i-=1.5/2.75)*i+.75)+e:i<2.5/2.75?t*(7.5625*(i-=2.25/2.75)*i+.9375)+e:t*(7.5625*(i-=2.625/2.75)*i+.984375)+e},BounceEaseIn(i,e,t,r){return t-Gi.BounceEaseOut(r-i,0,t,r)+e},BounceEaseInOut(i,e,t,r){return i<r/2?Gi.BounceEaseIn(i*2,0,t,r)*.5+e:Gi.BounceEaseOut(i*2-r,0,t,r)*.5+t*.5+e},EaseIn(i,e,t,r){return t*(i/=r)*i+e},EaseOut(i,e,t,r){return-t*(i/=r)*(i-2)+e},EaseInOut(i,e,t,r){return(i/=r/2)<1?t/2*i*i+e:-t/2*(--i*(i-2)-1)+e},StrongEaseIn(i,e,t,r){return t*(i/=r)*i*i*i*i+e},StrongEaseOut(i,e,t,r){return t*((i=i/r-1)*i*i*i*i+1)+e},StrongEaseInOut(i,e,t,r){return(i/=r/2)<1?t/2*i*i*i*i*i+e:t/2*((i-=2)*i*i*i*i+2)+e},Linear(i,e,t,r){return t*i/r+e}},zn=y._assign(D,{Util:y,Transform:Ge,Node:P,Container:De,Stage:Kr,stages:Tr,Layer:Zt,FastLayer:an,Group:hi,DD:re,Shape:E,shapes:Ni,Animation:Be,Tween:ye,Easings:Gi,Context:qr,Canvas:Yr});class yt extends E{_sceneFunc(e){var t=D.getAngle(this.angle()),r=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,r),e.arc(0,0,this.innerRadius(),t,0,!r),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),t=this.outerRadius(),r=this.clockwise(),s=D.getAngle(r?360-this.angle():this.angle()),n=Math.cos(Math.min(s,Math.PI)),a=1,o=Math.sin(Math.min(Math.max(Math.PI,s),3*Math.PI/2)),h=Math.sin(Math.min(s,Math.PI/2)),l=n*(n>0?e:t),d=a*t,u=o*(o>0?e:t),c=h*(h>0?t:e);return{x:l,y:r?-1*c:u,width:d-l,height:c-u}}}yt.prototype._centroid=!0;yt.prototype.className="Arc";yt.prototype._attrsAffectingSize=["innerRadius","outerRadius"];ge(yt);v.addGetterSetter(yt,"innerRadius",0,x());v.addGetterSetter(yt,"outerRadius",0,x());v.addGetterSetter(yt,"angle",0,x());v.addGetterSetter(yt,"clockwise",!1,qe());function Ps(i,e,t,r,s,n,a){var o=Math.sqrt(Math.pow(t-i,2)+Math.pow(r-e,2)),h=Math.sqrt(Math.pow(s-t,2)+Math.pow(n-r,2)),l=a*o/(o+h),d=a*h/(o+h),u=t-l*(s-i),c=r-l*(n-e),p=t+d*(s-i),f=r+d*(n-e);return[u,c,p,f]}function Un(i,e){var t=i.length,r=[],s,n;for(s=2;s<t-2;s+=2)n=Ps(i[s-2],i[s-1],i[s],i[s+1],i[s+2],i[s+3],e),!isNaN(n[0])&&(r.push(n[0]),r.push(n[1]),r.push(i[s]),r.push(i[s+1]),r.push(n[2]),r.push(n[3]));return r}class bt extends E{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){var t=this.points(),r=t.length,s=this.tension(),n=this.closed(),a=this.bezier(),o,h,l;if(r){if(e.beginPath(),e.moveTo(t[0],t[1]),s!==0&&r>4){for(o=this.getTensionPoints(),h=o.length,l=n?0:4,n||e.quadraticCurveTo(o[0],o[1],o[2],o[3]);l<h-2;)e.bezierCurveTo(o[l++],o[l++],o[l++],o[l++],o[l++],o[l++]);n||e.quadraticCurveTo(o[h-2],o[h-1],t[r-2],t[r-1])}else if(a)for(l=2;l<r;)e.bezierCurveTo(t[l++],t[l++],t[l++],t[l++],t[l++],t[l++]);else for(l=2;l<r;l+=2)e.lineTo(t[l],t[l+1]);n?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Un(this.points(),this.tension())}_getTensionPointsClosed(){var e=this.points(),t=e.length,r=this.tension(),s=Ps(e[t-2],e[t-1],e[0],e[1],e[2],e[3],r),n=Ps(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],r),a=Un(e,r),o=[s[2],s[3]].concat(a).concat([n[0],n[1],e[t-2],e[t-1],n[2],n[3],s[0],s[1],e[0],e[1]]);return o}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};this.tension()!==0?e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:e=this.points();for(var t=e[0],r=e[0],s=e[1],n=e[1],a,o,h=0;h<e.length/2;h++)a=e[h*2],o=e[h*2+1],t=Math.min(t,a),r=Math.max(r,a),s=Math.min(s,o),n=Math.max(n,o);return{x:t,y:s,width:r-t,height:n-s}}}bt.prototype.className="Line";bt.prototype._attrsAffectingSize=["points","bezier","tension"];ge(bt);v.addGetterSetter(bt,"closed",!1);v.addGetterSetter(bt,"bezier",!1);v.addGetterSetter(bt,"tension",0,x());v.addGetterSetter(bt,"points",[],eh());class he extends E{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this.dataArray=he.parsePathData(this.data()),this.pathLength=0;for(var t=0;t<this.dataArray.length;++t)this.pathLength+=this.dataArray[t].pathLength;this.on("dataChange.konva",function(){this.dataArray=he.parsePathData(this.data()),this.pathLength=0;for(var r=0;r<this.dataArray.length;++r)this.pathLength+=this.dataArray[r].pathLength})}_sceneFunc(e){var t=this.dataArray;e.beginPath();for(var r=!1,s=0;s<t.length;s++){var n=t[s].command,a=t[s].points;switch(n){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":var o=a[0],h=a[1],l=a[2],d=a[3],u=a[4],c=a[5],p=a[6],f=a[7],m=l>d?l:d,g=l>d?1:l/d,_=l>d?d/l:1;e.translate(o,h),e.rotate(p),e.scale(g,_),e.arc(0,0,m,u,u+c,1-f),e.scale(1/g,1/_),e.rotate(-p),e.translate(-o,-h);break;case"z":r=!0,e.closePath();break}}!r&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getSelfRect(){var e=[];this.dataArray.forEach(function(l){if(l.command==="A"){var d=l.points[4],u=l.points[5],c=l.points[4]+u,p=Math.PI/180;if(Math.abs(d-c)<p&&(p=Math.abs(d-c)),u<0)for(let f=d-p;f>c;f-=p){const m=he.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],f,0);e.push(m.x,m.y)}else for(let f=d+p;f<c;f+=p){const m=he.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],f,0);e.push(m.x,m.y)}}else if(l.command==="C")for(let f=0;f<=1;f+=.01){const m=he.getPointOnCubicBezier(f,l.start.x,l.start.y,l.points[0],l.points[1],l.points[2],l.points[3],l.points[4],l.points[5]);e.push(m.x,m.y)}else e=e.concat(l.points)});for(var t=e[0],r=e[0],s=e[1],n=e[1],a,o,h=0;h<e.length/2;h++)a=e[h*2],o=e[h*2+1],isNaN(a)||(t=Math.min(t,a),r=Math.max(r,a)),isNaN(o)||(s=Math.min(s,o),n=Math.max(n,o));return{x:t,y:s,width:r-t,height:n-s}}getLength(){return this.pathLength}getPointAtLength(e){var t,r=0,s=this.dataArray.length;if(!s)return null;for(;r<s&&e>this.dataArray[r].pathLength;)e-=this.dataArray[r].pathLength,++r;if(r===s)return t=this.dataArray[r-1].points.slice(-2),{x:t[0],y:t[1]};if(e<.01)return t=this.dataArray[r].points.slice(0,2),{x:t[0],y:t[1]};var n=this.dataArray[r],a=n.points;switch(n.command){case"L":return he.getPointOnLine(e,n.start.x,n.start.y,a[0],a[1]);case"C":return he.getPointOnCubicBezier(e/n.pathLength,n.start.x,n.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return he.getPointOnQuadraticBezier(e/n.pathLength,n.start.x,n.start.y,a[0],a[1],a[2],a[3]);case"A":var o=a[0],h=a[1],l=a[2],d=a[3],u=a[4],c=a[5],p=a[6];return u+=c*e/n.pathLength,he.getPointOnEllipticalArc(o,h,l,d,u,p)}return null}static getLineLength(e,t,r,s){return Math.sqrt((r-e)*(r-e)+(s-t)*(s-t))}static getPointOnLine(e,t,r,s,n,a,o){a===void 0&&(a=t),o===void 0&&(o=r);var h=(n-r)/(s-t+1e-8),l=Math.sqrt(e*e/(1+h*h));s<t&&(l*=-1);var d=h*l,u;if(s===t)u={x:a,y:o+d};else if((o-r)/(a-t+1e-8)===h)u={x:a+l,y:o+d};else{var c,p,f=this.getLineLength(t,r,s,n),m=(a-t)*(s-t)+(o-r)*(n-r);m=m/(f*f),c=t+m*(s-t),p=r+m*(n-r);var g=this.getLineLength(a,o,c,p),_=Math.sqrt(e*e-g*g);l=Math.sqrt(_*_/(1+h*h)),s<t&&(l*=-1),d=h*l,u={x:c+l,y:p+d}}return u}static getPointOnCubicBezier(e,t,r,s,n,a,o,h,l){function d(g){return g*g*g}function u(g){return 3*g*g*(1-g)}function c(g){return 3*g*(1-g)*(1-g)}function p(g){return(1-g)*(1-g)*(1-g)}var f=h*d(e)+a*u(e)+s*c(e)+t*p(e),m=l*d(e)+o*u(e)+n*c(e)+r*p(e);return{x:f,y:m}}static getPointOnQuadraticBezier(e,t,r,s,n,a,o){function h(p){return p*p}function l(p){return 2*p*(1-p)}function d(p){return(1-p)*(1-p)}var u=a*h(e)+s*l(e)+t*d(e),c=o*h(e)+n*l(e)+r*d(e);return{x:u,y:c}}static getPointOnEllipticalArc(e,t,r,s,n,a){var o=Math.cos(a),h=Math.sin(a),l={x:r*Math.cos(n),y:s*Math.sin(n)};return{x:e+(l.x*o-l.y*h),y:t+(l.x*h+l.y*o)}}static parsePathData(e){if(!e)return[];var t=e,r=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];t=t.replace(new RegExp(" ","g"),",");for(var s=0;s<r.length;s++)t=t.replace(new RegExp(r[s],"g"),"|"+r[s]);var n=t.split("|"),a=[],o=[],h=0,l=0,d=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,u;for(s=1;s<n.length;s++){var c=n[s],p=c.charAt(0);for(c=c.slice(1),o.length=0;u=d.exec(c);)o.push(u[0]);for(var f=[],m=0,g=o.length;m<g;m++){if(o[m]==="00"){f.push(0,0);continue}var _=parseFloat(o[m]);isNaN(_)?f.push(0):f.push(_)}for(;f.length>0&&!isNaN(f[0]);){var w=null,b=[],T=h,L=l,A,G,R,H,$,I,K,U,le,ne;switch(p){case"l":h+=f.shift(),l+=f.shift(),w="L",b.push(h,l);break;case"L":h=f.shift(),l=f.shift(),b.push(h,l);break;case"m":var W=f.shift(),we=f.shift();if(h+=W,l+=we,w="M",a.length>2&&a[a.length-1].command==="z"){for(var Re=a.length-2;Re>=0;Re--)if(a[Re].command==="M"){h=a[Re].points[0]+W,l=a[Re].points[1]+we;break}}b.push(h,l),p="l";break;case"M":h=f.shift(),l=f.shift(),w="M",b.push(h,l),p="L";break;case"h":h+=f.shift(),w="L",b.push(h,l);break;case"H":h=f.shift(),w="L",b.push(h,l);break;case"v":l+=f.shift(),w="L",b.push(h,l);break;case"V":l=f.shift(),w="L",b.push(h,l);break;case"C":b.push(f.shift(),f.shift(),f.shift(),f.shift()),h=f.shift(),l=f.shift(),b.push(h,l);break;case"c":b.push(h+f.shift(),l+f.shift(),h+f.shift(),l+f.shift()),h+=f.shift(),l+=f.shift(),w="C",b.push(h,l);break;case"S":G=h,R=l,A=a[a.length-1],A.command==="C"&&(G=h+(h-A.points[2]),R=l+(l-A.points[3])),b.push(G,R,f.shift(),f.shift()),h=f.shift(),l=f.shift(),w="C",b.push(h,l);break;case"s":G=h,R=l,A=a[a.length-1],A.command==="C"&&(G=h+(h-A.points[2]),R=l+(l-A.points[3])),b.push(G,R,h+f.shift(),l+f.shift()),h+=f.shift(),l+=f.shift(),w="C",b.push(h,l);break;case"Q":b.push(f.shift(),f.shift()),h=f.shift(),l=f.shift(),b.push(h,l);break;case"q":b.push(h+f.shift(),l+f.shift()),h+=f.shift(),l+=f.shift(),w="Q",b.push(h,l);break;case"T":G=h,R=l,A=a[a.length-1],A.command==="Q"&&(G=h+(h-A.points[0]),R=l+(l-A.points[1])),h=f.shift(),l=f.shift(),w="Q",b.push(G,R,h,l);break;case"t":G=h,R=l,A=a[a.length-1],A.command==="Q"&&(G=h+(h-A.points[0]),R=l+(l-A.points[1])),h+=f.shift(),l+=f.shift(),w="Q",b.push(G,R,h,l);break;case"A":H=f.shift(),$=f.shift(),I=f.shift(),K=f.shift(),U=f.shift(),le=h,ne=l,h=f.shift(),l=f.shift(),w="A",b=this.convertEndpointToCenterParameterization(le,ne,h,l,K,U,H,$,I);break;case"a":H=f.shift(),$=f.shift(),I=f.shift(),K=f.shift(),U=f.shift(),le=h,ne=l,h+=f.shift(),l+=f.shift(),w="A",b=this.convertEndpointToCenterParameterization(le,ne,h,l,K,U,H,$,I);break}a.push({command:w||p,points:b,start:{x:T,y:L},pathLength:this.calcLength(T,L,w||p,b)})}(p==="z"||p==="Z")&&a.push({command:"z",points:[],start:void 0,pathLength:0})}return a}static calcLength(e,t,r,s){var n,a,o,h,l=he;switch(r){case"L":return l.getLineLength(e,t,s[0],s[1]);case"C":for(n=0,a=l.getPointOnCubicBezier(0,e,t,s[0],s[1],s[2],s[3],s[4],s[5]),h=.01;h<=1;h+=.01)o=l.getPointOnCubicBezier(h,e,t,s[0],s[1],s[2],s[3],s[4],s[5]),n+=l.getLineLength(a.x,a.y,o.x,o.y),a=o;return n;case"Q":for(n=0,a=l.getPointOnQuadraticBezier(0,e,t,s[0],s[1],s[2],s[3]),h=.01;h<=1;h+=.01)o=l.getPointOnQuadraticBezier(h,e,t,s[0],s[1],s[2],s[3]),n+=l.getLineLength(a.x,a.y,o.x,o.y),a=o;return n;case"A":n=0;var d=s[4],u=s[5],c=s[4]+u,p=Math.PI/180;if(Math.abs(d-c)<p&&(p=Math.abs(d-c)),a=l.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],d,0),u<0)for(h=d-p;h>c;h-=p)o=l.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],h,0),n+=l.getLineLength(a.x,a.y,o.x,o.y),a=o;else for(h=d+p;h<c;h+=p)o=l.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],h,0),n+=l.getLineLength(a.x,a.y,o.x,o.y),a=o;return o=l.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],c,0),n+=l.getLineLength(a.x,a.y,o.x,o.y),n}return 0}static convertEndpointToCenterParameterization(e,t,r,s,n,a,o,h,l){var d=l*(Math.PI/180),u=Math.cos(d)*(e-r)/2+Math.sin(d)*(t-s)/2,c=-1*Math.sin(d)*(e-r)/2+Math.cos(d)*(t-s)/2,p=u*u/(o*o)+c*c/(h*h);p>1&&(o*=Math.sqrt(p),h*=Math.sqrt(p));var f=Math.sqrt((o*o*(h*h)-o*o*(c*c)-h*h*(u*u))/(o*o*(c*c)+h*h*(u*u)));n===a&&(f*=-1),isNaN(f)&&(f=0);var m=f*o*c/h,g=f*-h*u/o,_=(e+r)/2+Math.cos(d)*m-Math.sin(d)*g,w=(t+s)/2+Math.sin(d)*m+Math.cos(d)*g,b=function($){return Math.sqrt($[0]*$[0]+$[1]*$[1])},T=function($,I){return($[0]*I[0]+$[1]*I[1])/(b($)*b(I))},L=function($,I){return($[0]*I[1]<$[1]*I[0]?-1:1)*Math.acos(T($,I))},A=L([1,0],[(u-m)/o,(c-g)/h]),G=[(u-m)/o,(c-g)/h],R=[(-1*u-m)/o,(-1*c-g)/h],H=L(G,R);return T(G,R)<=-1&&(H=Math.PI),T(G,R)>=1&&(H=0),a===0&&H>0&&(H=H-2*Math.PI),a===1&&H<0&&(H=H+2*Math.PI),[_,w,o,h,A,H,d,a]}}he.prototype.className="Path";he.prototype._attrsAffectingSize=["data"];ge(he);v.addGetterSetter(he,"data");class jt extends bt{_sceneFunc(e){super._sceneFunc(e);var t=Math.PI*2,r=this.points(),s=r,n=this.tension()!==0&&r.length>4;n&&(s=this.getTensionPoints());var a=this.pointerLength(),o=r.length,h,l;if(n){const c=[s[s.length-4],s[s.length-3],s[s.length-2],s[s.length-1],r[o-2],r[o-1]],p=he.calcLength(s[s.length-4],s[s.length-3],"C",c),f=he.getPointOnQuadraticBezier(Math.min(1,1-a/p),c[0],c[1],c[2],c[3],c[4],c[5]);h=r[o-2]-f.x,l=r[o-1]-f.y}else h=r[o-2]-r[o-4],l=r[o-1]-r[o-3];var d=(Math.atan2(l,h)+t)%t,u=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(r[o-2],r[o-1]),e.rotate(d),e.moveTo(0,0),e.lineTo(-a,u/2),e.lineTo(-a,-u/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(r[0],r[1]),n?(h=(s[0]+s[2])/2-r[0],l=(s[1]+s[3])/2-r[1]):(h=r[2]-r[0],l=r[3]-r[1]),e.rotate((Math.atan2(-l,-h)+t)%t),e.moveTo(0,0),e.lineTo(-a,u/2),e.lineTo(-a,-u/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}}jt.prototype.className="Arrow";ge(jt);v.addGetterSetter(jt,"pointerLength",10,x());v.addGetterSetter(jt,"pointerWidth",10,x());v.addGetterSetter(jt,"pointerAtBeginning",!1);v.addGetterSetter(jt,"pointerAtEnding",!0);class vi extends E{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}}vi.prototype._centroid=!0;vi.prototype.className="Circle";vi.prototype._attrsAffectingSize=["radius"];ge(vi);v.addGetterSetter(vi,"radius",0,x());class Gt extends E{_sceneFunc(e){var t=this.radiusX(),r=this.radiusY();e.beginPath(),e.save(),t!==r&&e.scale(1,r/t),e.arc(0,0,t,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}}Gt.prototype.className="Ellipse";Gt.prototype._centroid=!0;Gt.prototype._attrsAffectingSize=["radiusX","radiusY"];ge(Gt);v.addComponentsGetterSetter(Gt,"radius",["x","y"]);v.addGetterSetter(Gt,"radiusX",0,x());v.addGetterSetter(Gt,"radiusY",0,x());class Ye extends E{constructor(e){super(e),this.on("imageChange.konva",()=>{this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const e=this.image();e&&e.complete||e&&e.readyState===4||e&&e.addEventListener&&e.addEventListener("load",()=>{this._requestDraw()})}_useBufferCanvas(){return super._useBufferCanvas(!0)}_sceneFunc(e){const t=this.getWidth(),r=this.getHeight(),s=this.attrs.image;let n;if(s){const a=this.attrs.cropWidth,o=this.attrs.cropHeight;a&&o?n=[s,this.cropX(),this.cropY(),a,o,0,0,t,r]:n=[s,0,0,t,r]}(this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,t,r),e.closePath(),e.fillStrokeShape(this)),s&&e.drawImage.apply(e,n)}_hitFunc(e){var t=this.width(),r=this.height();e.beginPath(),e.rect(0,0,t,r),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,t;return(e=this.attrs.width)!==null&&e!==void 0?e:(t=this.image())===null||t===void 0?void 0:t.width}getHeight(){var e,t;return(e=this.attrs.height)!==null&&e!==void 0?e:(t=this.image())===null||t===void 0?void 0:t.height}static fromURL(e,t,r=null){var s=y.createImageElement();s.onload=function(){var n=new Ye({image:s});t(n)},s.onerror=r,s.crossOrigin="Anonymous",s.src=e}}Ye.prototype.className="Image";ge(Ye);v.addGetterSetter(Ye,"image");v.addComponentsGetterSetter(Ye,"crop",["x","y","width","height"]);v.addGetterSetter(Ye,"cropX",0,x());v.addGetterSetter(Ye,"cropY",0,x());v.addGetterSetter(Ye,"cropWidth",0,x());v.addGetterSetter(Ye,"cropHeight",0,x());var ro=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Wh="Change.konva",Zh="none",As="up",Ms="right",Os="down",Ls="left",jh=ro.length;class on extends hi{constructor(e){super(e),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var t=this,r,s=function(){t._sync()};for(r=0;r<jh;r++)e.on(ro[r]+Wh,s)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e=this.getText(),t=this.getTag(),r,s,n,a,o,h,l;if(e&&t){switch(r=e.width(),s=e.height(),n=t.pointerDirection(),a=t.pointerWidth(),l=t.pointerHeight(),o=0,h=0,n){case As:o=r/2,h=-1*l;break;case Ms:o=r+a,h=s/2;break;case Os:o=r/2,h=s+l;break;case Ls:o=-1*a,h=s/2;break}t.setAttrs({x:-1*o,y:-1*h,width:r,height:s}),e.setAttrs({x:-1*o,y:-1*h})}}}on.prototype.className="Label";ge(on);class Xt extends E{_sceneFunc(e){var t=this.width(),r=this.height(),s=this.pointerDirection(),n=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius();let h=0,l=0,d=0,u=0;typeof o=="number"?h=l=d=u=Math.min(o,t/2,r/2):(h=Math.min(o[0]||0,t/2,r/2),l=Math.min(o[1]||0,t/2,r/2),u=Math.min(o[2]||0,t/2,r/2),d=Math.min(o[3]||0,t/2,r/2)),e.beginPath(),e.moveTo(h,0),s===As&&(e.lineTo((t-n)/2,0),e.lineTo(t/2,-1*a),e.lineTo((t+n)/2,0)),e.lineTo(t-l,0),e.arc(t-l,l,l,Math.PI*3/2,0,!1),s===Ms&&(e.lineTo(t,(r-a)/2),e.lineTo(t+n,r/2),e.lineTo(t,(r+a)/2)),e.lineTo(t,r-u),e.arc(t-u,r-u,u,0,Math.PI/2,!1),s===Os&&(e.lineTo((t+n)/2,r),e.lineTo(t/2,r+a),e.lineTo((t-n)/2,r)),e.lineTo(d,r),e.arc(d,r-d,d,Math.PI/2,Math.PI,!1),s===Ls&&(e.lineTo(0,(r+a)/2),e.lineTo(-1*n,r/2),e.lineTo(0,(r-a)/2)),e.lineTo(0,h),e.arc(h,h,h,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){var e=0,t=0,r=this.pointerWidth(),s=this.pointerHeight(),n=this.pointerDirection(),a=this.width(),o=this.height();return n===As?(t-=s,o+=s):n===Os?o+=s:n===Ls?(e-=r*1.5,a+=r):n===Ms&&(a+=r*1.5),{x:e,y:t,width:a,height:o}}}Xt.prototype.className="Tag";ge(Xt);v.addGetterSetter(Xt,"pointerDirection",Zh);v.addGetterSetter(Xt,"pointerWidth",0,x());v.addGetterSetter(Xt,"pointerHeight",0,x());v.addGetterSetter(Xt,"cornerRadius",0,Ga(4));class Ji extends E{_sceneFunc(e){var t=this.cornerRadius(),r=this.width(),s=this.height();if(e.beginPath(),!t)e.rect(0,0,r,s);else{let n=0,a=0,o=0,h=0;typeof t=="number"?n=a=o=h=Math.min(t,r/2,s/2):(n=Math.min(t[0]||0,r/2,s/2),a=Math.min(t[1]||0,r/2,s/2),h=Math.min(t[2]||0,r/2,s/2),o=Math.min(t[3]||0,r/2,s/2)),e.moveTo(n,0),e.lineTo(r-a,0),e.arc(r-a,a,a,Math.PI*3/2,0,!1),e.lineTo(r,s-h),e.arc(r-h,s-h,h,0,Math.PI/2,!1),e.lineTo(o,s),e.arc(o,s-o,o,Math.PI/2,Math.PI,!1),e.lineTo(0,n),e.arc(n,n,n,Math.PI,Math.PI*3/2,!1)}e.closePath(),e.fillStrokeShape(this)}}Ji.prototype.className="Rect";ge(Ji);v.addGetterSetter(Ji,"cornerRadius",0,Ga(4));class qt extends E{_sceneFunc(e){const t=this._getPoints();e.beginPath(),e.moveTo(t[0].x,t[0].y);for(var r=1;r<t.length;r++)e.lineTo(t[r].x,t[r].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,r=[];for(var s=0;s<e;s++)r.push({x:t*Math.sin(s*2*Math.PI/e),y:-1*t*Math.cos(s*2*Math.PI/e)});return r}getSelfRect(){const e=this._getPoints();var t=e[0].x,r=e[0].y,s=e[0].x,n=e[0].y;return e.forEach(a=>{t=Math.min(t,a.x),r=Math.max(r,a.x),s=Math.min(s,a.y),n=Math.max(n,a.y)}),{x:t,y:s,width:r-t,height:n-s}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}qt.prototype.className="RegularPolygon";qt.prototype._centroid=!0;qt.prototype._attrsAffectingSize=["radius"];ge(qt);v.addGetterSetter(qt,"radius",0,x());v.addGetterSetter(qt,"sides",0,x());var Wn=Math.PI*2;class Yt extends E{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,Wn,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),Wn,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Yt.prototype.className="Ring";Yt.prototype._centroid=!0;Yt.prototype._attrsAffectingSize=["innerRadius","outerRadius"];ge(Yt);v.addGetterSetter(Yt,"innerRadius",0,x());v.addGetterSetter(Yt,"outerRadius",0,x());class ot extends E{constructor(e){super(e),this._updated=!0,this.anim=new Be(()=>{var t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){var t=this.animation(),r=this.frameIndex(),s=r*4,n=this.animations()[t],a=this.frameOffsets(),o=n[s+0],h=n[s+1],l=n[s+2],d=n[s+3],u=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,l,d),e.closePath(),e.fillStrokeShape(this)),u)if(a){var c=a[t],p=r*2;e.drawImage(u,o,h,l,d,c[p+0],c[p+1],l,d)}else e.drawImage(u,o,h,l,d,0,0,l,d)}_hitFunc(e){var t=this.animation(),r=this.frameIndex(),s=r*4,n=this.animations()[t],a=this.frameOffsets(),o=n[s+2],h=n[s+3];if(e.beginPath(),a){var l=a[t],d=r*2;e.rect(l[d+0],l[d+1],o,h)}else e.rect(0,0,o,h);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(!this.isRunning()){var e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var e=this.frameIndex(),t=this.animation(),r=this.animations(),s=r[t],n=s.length/4;e<n-1?this.frameIndex(e+1):this.frameIndex(0)}}ot.prototype.className="Sprite";ge(ot);v.addGetterSetter(ot,"animation");v.addGetterSetter(ot,"animations");v.addGetterSetter(ot,"frameOffsets");v.addGetterSetter(ot,"image");v.addGetterSetter(ot,"frameIndex",0,x());v.addGetterSetter(ot,"frameRate",17,x());v.backCompat(ot,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class Dt extends E{_sceneFunc(e){var t=this.innerRadius(),r=this.outerRadius(),s=this.numPoints();e.beginPath(),e.moveTo(0,0-r);for(var n=1;n<s*2;n++){var a=n%2===0?r:t,o=a*Math.sin(n*Math.PI/s),h=-1*a*Math.cos(n*Math.PI/s);e.lineTo(o,h)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Dt.prototype.className="Star";Dt.prototype._centroid=!0;Dt.prototype._attrsAffectingSize=["innerRadius","outerRadius"];ge(Dt);v.addGetterSetter(Dt,"numPoints",5,x());v.addGetterSetter(Dt,"innerRadius",0,x());v.addGetterSetter(Dt,"outerRadius",0,x());function so(i){return Array.from(i)}var Jt="auto",Xh="center",Ei="justify",qh="Change.konva",Yh="2d",Zn="-",no="left",Kh="text",Jh="Text",Qh="top",ed="bottom",jn="middle",ao="normal",td="px ",mr=" ",id="right",rd="word",sd="char",Xn="none",ms="…",oo=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],nd=oo.length;function ad(i){return i.split(",").map(e=>{e=e.trim();const t=e.indexOf(" ")>=0,r=e.indexOf('"')>=0||e.indexOf("'")>=0;return t&&!r&&(e=`"${e}"`),e}).join(", ")}var gr;function gs(){return gr||(gr=y.createCanvasElement().getContext(Yh),gr)}function od(i){i.fillText(this._partialText,this._partialTextX,this._partialTextY)}function ld(i){i.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function hd(i){return i=i||{},!i.fillLinearGradientColorStops&&!i.fillRadialGradientColorStops&&!i.fillPatternImage&&(i.fill=i.fill||"black"),i}class me extends E{constructor(e){super(hd(e)),this._partialTextX=0,this._partialTextY=0;for(var t=0;t<nd;t++)this.on(oo[t]+qh,this._setTextData);this._setTextData()}_sceneFunc(e){var t=this.textArr,r=t.length;if(this.text()){var s=this.padding(),n=this.fontSize(),a=this.lineHeight()*n,o=this.verticalAlign(),h=0,l=this.align(),d=this.getWidth(),u=this.letterSpacing(),c=this.fill(),p=this.textDecoration(),f=p.indexOf("underline")!==-1,m=p.indexOf("line-through")!==-1,g,_=0,_=a/2,w=0,b=0;for(e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",jn),e.setAttr("textAlign",no),o===jn?h=(this.getHeight()-r*a-s*2)/2:o===ed&&(h=this.getHeight()-r*a-s*2),e.translate(s,h+s),g=0;g<r;g++){var w=0,b=0,T=t[g],L=T.text,A=T.width,G=T.lastInParagraph,R,H,$;if(e.save(),l===id?w+=d-A-s*2:l===Xh&&(w+=(d-A-s*2)/2),f&&(e.save(),e.beginPath(),e.moveTo(w,_+b+Math.round(n/2)),R=L.split(" ").length-1,H=R===0,$=l===Ei&&G&&!H?d-s*2:A,e.lineTo(w+Math.round($),_+b+Math.round(n/2)),e.lineWidth=n/15,e.strokeStyle=c,e.stroke(),e.restore()),m&&(e.save(),e.beginPath(),e.moveTo(w,_+b),R=L.split(" ").length-1,H=R===0,$=l===Ei&&G&&!H?d-s*2:A,e.lineTo(w+Math.round($),_+b),e.lineWidth=n/15,e.strokeStyle=c,e.stroke(),e.restore()),u!==0||l===Ei){R=L.split(" ").length-1;for(var I=so(L),K=0;K<I.length;K++){var U=I[K];U===" "&&!G&&l===Ei&&(w+=(d-s*2-A)/R),this._partialTextX=w,this._partialTextY=_+b,this._partialText=U,e.fillStrokeShape(this),w+=this.measureSize(U).width+u}}else this._partialTextX=w,this._partialTextY=_+b,this._partialText=L,e.fillStrokeShape(this);e.restore(),r>1&&(_+=a)}}}_hitFunc(e){var t=this.getWidth(),r=this.getHeight();e.beginPath(),e.rect(0,0,t,r),e.closePath(),e.fillStrokeShape(this)}setText(e){var t=y._isString(e)?e:e==null?"":e+"";return this._setAttr(Kh,t),this}getWidth(){var e=this.attrs.width===Jt||this.attrs.width===void 0;return e?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){var e=this.attrs.height===Jt||this.attrs.height===void 0;return e?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return y.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var t=gs(),r=this.fontSize(),s;return t.save(),t.font=this._getContextFont(),s=t.measureText(e),t.restore(),{width:s.width,height:r}}_getContextFont(){return this.fontStyle()+mr+this.fontVariant()+mr+(this.fontSize()+td)+ad(this.fontFamily())}_addTextLine(e){this.align()===Ei&&(e=e.trim());var t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){var t=this.letterSpacing(),r=e.length;return gs().measureText(e).width+(r?t*(r-1):0)}_setTextData(){var e=this.text().split(`
2
- `),t=+this.fontSize(),r=0,s=this.lineHeight()*t,n=this.attrs.width,a=this.attrs.height,o=n!==Jt&&n!==void 0,h=a!==Jt&&a!==void 0,l=this.padding(),d=n-l*2,u=a-l*2,c=0,p=this.wrap(),f=p!==Xn,m=p!==sd&&f,g=this.ellipsis();this.textArr=[],gs().font=this._getContextFont();for(var _=g?this._getTextWidth(ms):0,w=0,b=e.length;w<b;++w){var T=e[w],L=this._getTextWidth(T);if(o&&L>d)for(;T.length>0;){for(var A=0,G=T.length,R="",H=0;A<G;){var $=A+G>>>1,I=T.slice(0,$+1),K=this._getTextWidth(I)+_;K<=d?(A=$+1,R=I,H=K):G=$}if(R){if(m){var U,le=T[R.length],ne=le===mr||le===Zn;ne&&H<=d?U=R.length:U=Math.max(R.lastIndexOf(mr),R.lastIndexOf(Zn))+1,U>0&&(A=U,R=R.slice(0,A),H=this._getTextWidth(R))}R=R.trimRight(),this._addTextLine(R),r=Math.max(r,H),c+=s;var W=this._shouldHandleEllipsis(c);if(W){this._tryToAddEllipsisToLastLine();break}if(T=T.slice(A),T=T.trimLeft(),T.length>0&&(L=this._getTextWidth(T),L<=d)){this._addTextLine(T),c+=s,r=Math.max(r,L);break}}else break}else this._addTextLine(T),c+=s,r=Math.max(r,L),this._shouldHandleEllipsis(c)&&w<b-1&&this._tryToAddEllipsisToLastLine();if(h&&c+s>u)break;this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0)}this.textHeight=t,this.textWidth=r}_shouldHandleEllipsis(e){var t=+this.fontSize(),r=this.lineHeight()*t,s=this.attrs.height,n=s!==Jt&&s!==void 0,a=this.padding(),o=s-a*2,h=this.wrap(),l=h!==Xn;return!l||n&&e+r>o}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,t=e!==Jt&&e!==void 0,r=this.padding(),s=e-r*2,n=this.ellipsis(),a=this.textArr[this.textArr.length-1];if(!(!a||!n)){if(t){var o=this._getTextWidth(a.text+ms)<s;o||(a.text=a.text.slice(0,a.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(a.text+ms)}}getStrokeScaleEnabled(){return!0}}me.prototype._fillFunc=od;me.prototype._strokeFunc=ld;me.prototype.className=Jh;me.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"];ge(me);v.overWriteSetter(me,"width",rn());v.overWriteSetter(me,"height",rn());v.addGetterSetter(me,"fontFamily","Arial");v.addGetterSetter(me,"fontSize",12,x());v.addGetterSetter(me,"fontStyle",ao);v.addGetterSetter(me,"fontVariant",ao);v.addGetterSetter(me,"padding",0,x());v.addGetterSetter(me,"align",no);v.addGetterSetter(me,"verticalAlign",Qh);v.addGetterSetter(me,"lineHeight",1,x());v.addGetterSetter(me,"wrap",rd);v.addGetterSetter(me,"ellipsis",!1,qe());v.addGetterSetter(me,"letterSpacing",0,x());v.addGetterSetter(me,"text","",gi());v.addGetterSetter(me,"textDecoration","");var dd="",lo="normal";function ho(i){i.fillText(this.partialText,0,0)}function uo(i){i.strokeText(this.partialText,0,0)}class Ce extends E{constructor(e){super(e),this.dummyCanvas=y.createCanvasElement(),this.dataArray=[],this.dataArray=he.parsePathData(this.attrs.data),this.on("dataChange.konva",function(){this.dataArray=he.parsePathData(this.attrs.data),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();var t=this.textDecoration(),r=this.fill(),s=this.fontSize(),n=this.glyphInfo;t==="underline"&&e.beginPath();for(var a=0;a<n.length;a++){e.save();var o=n[a].p0;e.translate(o.x,o.y),e.rotate(n[a].rotation),this.partialText=n[a].text,e.fillStrokeShape(this),t==="underline"&&(a===0&&e.moveTo(0,s/2+1),e.lineTo(s,s/2+1)),e.restore()}t==="underline"&&(e.strokeStyle=r,e.lineWidth=s/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var t=this.glyphInfo;if(t.length>=1){var r=t[0].p0;e.moveTo(r.x,r.y)}for(var s=0;s<t.length;s++){var n=t[s].p1;e.lineTo(n.x,n.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return y.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return me.prototype.setText.call(this,e)}_getContextFont(){return me.prototype._getContextFont.call(this)}_getTextSize(e){var t=this.dummyCanvas,r=t.getContext("2d");r.save(),r.font=this._getContextFont();var s=r.measureText(e);return r.restore(),{width:s.width,height:parseInt(this.attrs.fontSize,10)}}_setTextData(){var e=this,t=this._getTextSize(this.attrs.text),r=this.letterSpacing(),s=this.align(),n=this.kerningFunc();this.textWidth=t.width,this.textHeight=t.height;var a=Math.max(this.textWidth+((this.attrs.text||"").length-1)*r,0);this.glyphInfo=[];for(var o=0,h=0;h<e.dataArray.length;h++)e.dataArray[h].pathLength>0&&(o+=e.dataArray[h].pathLength);var l=0;s==="center"&&(l=Math.max(0,o/2-a/2)),s==="right"&&(l=Math.max(0,o-a));for(var d=so(this.text()),u=this.text().split(" ").length-1,c,p,f,m=-1,g=0,_=function(){g=0;for(var K=e.dataArray,U=m+1;U<K.length;U++){if(K[U].pathLength>0)return m=U,K[U];K[U].command==="M"&&(c={x:K[U].points[0],y:K[U].points[1]})}return{}},w=function(K){var U=e._getTextSize(K).width+r;K===" "&&s==="justify"&&(U+=(o-a)/u);var le=0,ne=0;for(p=void 0;Math.abs(U-le)/U>.01&&ne<20;){ne++;for(var W=le;f===void 0;)f=_(),f&&W+f.pathLength<U&&(W+=f.pathLength,f=void 0);if(Object.keys(f).length===0||c===void 0)return;var we=!1;switch(f.command){case"L":he.getLineLength(c.x,c.y,f.points[0],f.points[1])>U?p=he.getPointOnLine(U,c.x,c.y,f.points[0],f.points[1],c.x,c.y):f=void 0;break;case"A":var Re=f.points[4],ze=f.points[5],te=f.points[4]+ze;g===0?g=Re+1e-8:U>le?g+=Math.PI/180*ze/Math.abs(ze):g-=Math.PI/360*ze/Math.abs(ze),(ze<0&&g<te||ze>=0&&g>te)&&(g=te,we=!0),p=he.getPointOnEllipticalArc(f.points[0],f.points[1],f.points[2],f.points[3],g,f.points[6]);break;case"C":g===0?U>f.pathLength?g=1e-8:g=U/f.pathLength:U>le?g+=(U-le)/f.pathLength/2:g=Math.max(g-(le-U)/f.pathLength/2,0),g>1&&(g=1,we=!0),p=he.getPointOnCubicBezier(g,f.start.x,f.start.y,f.points[0],f.points[1],f.points[2],f.points[3],f.points[4],f.points[5]);break;case"Q":g===0?g=U/f.pathLength:U>le?g+=(U-le)/f.pathLength:g-=(le-U)/f.pathLength,g>1&&(g=1,we=!0),p=he.getPointOnQuadraticBezier(g,f.start.x,f.start.y,f.points[0],f.points[1],f.points[2],f.points[3]);break}p!==void 0&&(le=he.getLineLength(c.x,c.y,p.x,p.y)),we&&(we=!1,f=void 0)}},b="C",T=e._getTextSize(b).width+r,L=l/T-1,A=0;A<L&&(w(b),!(c===void 0||p===void 0));A++)c=p;for(var G=0;G<d.length&&(w(d[G]),!(c===void 0||p===void 0));G++){var R=he.getLineLength(c.x,c.y,p.x,p.y),H=0;if(n)try{H=n(d[G-1],d[G])*this.fontSize()}catch{H=0}c.x+=H,p.x+=H,this.textWidth+=H;var $=he.getPointOnLine(H+R/2,c.x,c.y,p.x,p.y),I=Math.atan2(p.y-c.y,p.x-c.x);this.glyphInfo.push({transposeX:$.x,transposeY:$.y,text:d[G],rotation:I,p0:c,p1:p}),c=p}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var e=[];this.glyphInfo.forEach(function(d){e.push(d.p0.x),e.push(d.p0.y),e.push(d.p1.x),e.push(d.p1.y)});for(var t=e[0]||0,r=e[0]||0,s=e[1]||0,n=e[1]||0,a,o,h=0;h<e.length/2;h++)a=e[h*2],o=e[h*2+1],t=Math.min(t,a),r=Math.max(r,a),s=Math.min(s,o),n=Math.max(n,o);var l=this.fontSize();return{x:t-l/2,y:s-l/2,width:r-t+l,height:n-s+l}}destroy(){return y.releaseCanvas(this.dummyCanvas),super.destroy()}}Ce.prototype._fillFunc=ho;Ce.prototype._strokeFunc=uo;Ce.prototype._fillFuncHit=ho;Ce.prototype._strokeFuncHit=uo;Ce.prototype.className="TextPath";Ce.prototype._attrsAffectingSize=["text","fontSize","data"];ge(Ce);v.addGetterSetter(Ce,"data");v.addGetterSetter(Ce,"fontFamily","Arial");v.addGetterSetter(Ce,"fontSize",12,x());v.addGetterSetter(Ce,"fontStyle",lo);v.addGetterSetter(Ce,"align","left");v.addGetterSetter(Ce,"letterSpacing",0,x());v.addGetterSetter(Ce,"textBaseline","middle");v.addGetterSetter(Ce,"fontVariant",lo);v.addGetterSetter(Ce,"text",dd);v.addGetterSetter(Ce,"textDecoration",null);v.addGetterSetter(Ce,"kerningFunc",null);var co="tr-konva",ud=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange"].map(i=>i+`.${co}`).join(" "),qn="nodesRect",cd=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],fd={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const pd="ontouchstart"in D._global;function md(i,e){if(i==="rotater")return"crosshair";e+=y.degToRad(fd[i]||0);var t=(y.radToDeg(e)%360+360)%360;return y._inRange(t,315+22.5,360)||y._inRange(t,0,22.5)?"ns-resize":y._inRange(t,45-22.5,45+22.5)?"nesw-resize":y._inRange(t,90-22.5,90+22.5)?"ew-resize":y._inRange(t,135-22.5,135+22.5)?"nwse-resize":y._inRange(t,180-22.5,180+22.5)?"ns-resize":y._inRange(t,225-22.5,225+22.5)?"nesw-resize":y._inRange(t,270-22.5,270+22.5)?"ew-resize":y._inRange(t,315-22.5,315+22.5)?"nwse-resize":(y.error("Transformer has unknown angle for cursor detection: "+t),"pointer")}var Or=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],Yn=1e8;function gd(i){return{x:i.x+i.width/2*Math.cos(i.rotation)+i.height/2*Math.sin(-i.rotation),y:i.y+i.height/2*Math.cos(i.rotation)+i.width/2*Math.sin(i.rotation)}}function fo(i,e,t){const r=t.x+(i.x-t.x)*Math.cos(e)-(i.y-t.y)*Math.sin(e),s=t.y+(i.x-t.x)*Math.sin(e)+(i.y-t.y)*Math.cos(e);return Object.assign(Object.assign({},i),{rotation:i.rotation+e,x:r,y:s})}function vd(i,e){const t=gd(i);return fo(i,e,t)}function yd(i,e,t){let r=e;for(let s=0;s<i.length;s++){const n=D.getAngle(i[s]),a=Math.abs(n-e)%(Math.PI*2);Math.min(a,Math.PI*2-a)<t&&(r=n)}return r}class oe extends hi{constructor(e){super(e),this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(ud,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return y.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 co+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach(),this._nodes=e,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(r=>{const s=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()},n=r._attrsAffectingSize.map(a=>a+"Change."+this._getEventNamespace()).join(" ");r.on(n,s),r.on(cd.map(a=>a+`.${this._getEventNamespace()}`).join(" "),s),r.on(`absoluteTransformChange.${this._getEventNamespace()}`,s),this._proxyDrag(r)}),this._resetTransformCache();var t=!!this.findOne(".top-left");return t&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,r=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(r,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,r=>{if(!t)return;const s=e.getAbsolutePosition(),n=s.x-t.x,a=s.y-t.y;this.nodes().forEach(o=>{if(o===e||o.isDragging())return;const h=o.getAbsolutePosition();o.setAbsolutePosition({x:h.x+n,y:h.y+a}),o.startDrag(r)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(qn),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(qn,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),r){var s=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=e.getAbsoluteScale(r),a=e.getAbsolutePosition(r),o=s.x*n.x-e.offsetX()*n.x,h=s.y*n.y-e.offsetY()*n.y;const l=(D.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),d={x:a.x+o*Math.cos(l)+h*Math.sin(-l),y:a.y+h*Math.cos(l)+o*Math.sin(l),width:s.width*n.x,height:s.height*n.y,rotation:l};return fo(d,-D.getAngle(t),{x:0,y:0})}__getNodeRect(){var e=this.getNode();if(!e)return{x:-Yn,y:-Yn,width:0,height:0,rotation:0};const t=[];this.nodes().map(l=>{const d=l.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var u=[{x:d.x,y:d.y},{x:d.x+d.width,y:d.y},{x:d.x+d.width,y:d.y+d.height},{x:d.x,y:d.y+d.height}],c=l.getAbsoluteTransform();u.forEach(function(p){var f=c.point(p);t.push(f)})});const r=new Ge;r.rotate(-D.getAngle(this.rotation()));var s,n,a,o;t.forEach(function(l){var d=r.point(l);s===void 0&&(s=a=d.x,n=o=d.y),s=Math.min(s,d.x),n=Math.min(n,d.y),a=Math.max(a,d.x),o=Math.max(o,d.y)}),r.invert();const h=r.point({x:s,y:n});return{x:h.x,y:h.y,width:a-s,height:o-n,rotation:D.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(),Or.forEach(function(e){this._createAnchor(e)}.bind(this)),this._createAnchor("rotater")}_createAnchor(e){var t=new Ji({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:pd?10:"auto"}),r=this;t.on("mousedown touchstart",function(s){r._handleMouseDown(s)}),t.on("dragstart",s=>{t.stopDrag(),s.cancelBubble=!0}),t.on("dragend",s=>{s.cancelBubble=!0}),t.on("mouseenter",()=>{var s=D.getAngle(this.rotation()),n=md(e,s);t.getStage().content&&(t.getStage().content.style.cursor=n),this._cursorChange=!0}),t.on("mouseout",()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(t)}_createBack(){var e=new E({name:"back",width:0,height:0,draggable:!0,sceneFunc(t){var r=this.getParent(),s=r.padding();t.beginPath(),t.rect(-s,-s,this.width()+s*2,this.height()+s*2),t.moveTo(this.width()/2,-s),r.rotateEnabled()&&t.lineTo(this.width()/2,-r.rotateAnchorOffset()*y._sign(this.height())-s),t.fillStrokeShape(this)},hitFunc:(t,r)=>{if(this.shouldOverdrawWholeArea()){var s=this.padding();t.beginPath(),t.rect(-s,-s,r.width()+s*2,r.height()+s*2),t.fillStrokeShape(r)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(e){this._movingAnchorName=e.target.name().split(" ")[0];var t=this._getNodeRect(),r=t.width,s=t.height,n=Math.sqrt(Math.pow(r,2)+Math.pow(s,2));this.sin=Math.abs(s/n),this.cos=Math.abs(r/n),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var a=e.target.getAbsolutePosition(),o=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:o.x-a.x,y:o.y-a.y},this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(h=>{h._fire("transformstart",{evt:e.evt,target:h})})}_handleMouseMove(e){var t,r,s,n=this.findOne("."+this._movingAnchorName),a=n.getStage();a.setPointersPositions(e);const o=a.getPointerPosition();let h={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y};const l=n.getAbsolutePosition();this.anchorDragBoundFunc()&&(h=this.anchorDragBoundFunc()(l,h,e)),n.setAbsolutePosition(h);const d=n.getAbsolutePosition();if(!(l.x===d.x&&l.y===d.y)){if(this._movingAnchorName==="rotater"){var u=this._getNodeRect();t=n.x()-u.width/2,r=-n.y()+u.height/2;let K=Math.atan2(-r,t)+Math.PI/2;u.height<0&&(K-=Math.PI);var c=D.getAngle(this.rotation());const U=c+K,le=D.getAngle(this.rotationSnapTolerance()),W=yd(this.rotationSnaps(),U,le)-u.rotation,we=vd(u,W);this._fitNodesInto(we,e);return}var p=this.keepRatio()||e.shiftKey,w=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(p){var f=w?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};s=Math.sqrt(Math.pow(f.x-n.x(),2)+Math.pow(f.y-n.y(),2));var m=this.findOne(".top-left").x()>f.x?-1:1,g=this.findOne(".top-left").y()>f.y?-1:1;t=s*this.cos*m,r=s*this.sin*g,this.findOne(".top-left").x(f.x-t),this.findOne(".top-left").y(f.y-r)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(n.y());else if(this._movingAnchorName==="top-right"){if(p){var f=w?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};s=Math.sqrt(Math.pow(n.x()-f.x,2)+Math.pow(f.y-n.y(),2));var m=this.findOne(".top-right").x()<f.x?-1:1,g=this.findOne(".top-right").y()>f.y?-1:1;t=s*this.cos*m,r=s*this.sin*g,this.findOne(".top-right").x(f.x+t),this.findOne(".top-right").y(f.y-r)}var _=n.position();this.findOne(".top-left").y(_.y),this.findOne(".bottom-right").x(_.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(n.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(n.x());else if(this._movingAnchorName==="bottom-left"){if(p){var f=w?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};s=Math.sqrt(Math.pow(f.x-n.x(),2)+Math.pow(n.y()-f.y,2));var m=f.x<n.x()?-1:1,g=n.y()<f.y?-1:1;t=s*this.cos*m,r=s*this.sin*g,n.x(f.x-t),n.y(f.y+r)}_=n.position(),this.findOne(".top-left").x(_.x),this.findOne(".bottom-right").y(_.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(n.y());else if(this._movingAnchorName==="bottom-right"){if(p){var f=w?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};s=Math.sqrt(Math.pow(n.x()-f.x,2)+Math.pow(n.y()-f.y,2));var m=this.findOne(".bottom-right").x()<f.x?-1:1,g=this.findOne(".bottom-right").y()<f.y?-1:1;t=s*this.cos*m,r=s*this.sin*g,this.findOne(".bottom-right").x(f.x+t),this.findOne(".bottom-right").y(f.y+r)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));var w=this.centeredScaling()||e.altKey;if(w){var b=this.findOne(".top-left"),T=this.findOne(".bottom-right"),L=b.x(),A=b.y(),G=this.getWidth()-T.x(),R=this.getHeight()-T.y();T.move({x:-L,y:-A}),b.move({x:G,y:R})}var H=this.findOne(".top-left").getAbsolutePosition();t=H.x,r=H.y;var $=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),I=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:r,width:$,height:I,rotation:D.getAngle(this.rotation())},e)}}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var t=this.getNode();this._fire("transformend",{evt:e,target:t}),t&&this._nodes.forEach(r=>{r._fire("transformend",{evt:e,target:r})}),this._movingAnchorName=null}}_fitNodesInto(e,t){var r=this._getNodeRect();const s=1;if(y._inRange(e.width,-this.padding()*2-s,s)){this.update();return}if(y._inRange(e.height,-this.padding()*2-s,s)){this.update();return}const n=this.flipEnabled();var a=new Ge;if(a.rotate(D.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const u=a.point({x:-this.padding()*2,y:0});if(e.x+=u.x,e.y+=u.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,!n){this.update();return}}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const u=a.point({x:this.padding()*2,y:0});if(this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,e.width+=this.padding()*2,!n){this.update();return}}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const u=a.point({x:0,y:-this.padding()*2});if(e.x+=u.x,e.y+=u.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,e.height+=this.padding()*2,!n){this.update();return}}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const u=a.point({x:0,y:this.padding()*2});if(this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,e.height+=this.padding()*2,!n){this.update();return}}if(this.boundBoxFunc()){const u=this.boundBoxFunc()(r,e);u?e=u:y.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,h=new Ge;h.translate(r.x,r.y),h.rotate(r.rotation),h.scale(r.width/o,r.height/o);const l=new Ge;l.translate(e.x,e.y),l.rotate(e.rotation),l.scale(e.width/o,e.height/o);const d=l.multiply(h.invert());this._nodes.forEach(u=>{var c;const p=u.getParent().getAbsoluteTransform(),f=u.getTransform().copy();f.translate(u.offsetX(),u.offsetY());const m=new Ge;m.multiply(p.copy().invert()).multiply(d).multiply(p).multiply(f);const g=m.decompose();u.setAttrs(g),this._fire("transform",{evt:t,target:u}),u._fire("transform",{evt:t,target:u}),(c=u.getLayer())===null||c===void 0||c.batchDraw()}),this.rotation(y._getRotation(e.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e,t=this._getNodeRect();this.rotation(y._getRotation(t.rotation));var r=t.width,s=t.height,n=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),h=this.anchorSize();this.find("._anchor").forEach(l=>{l.setAttrs({width:h,height:h,offsetX:h/2,offsetY:h/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:h/2+o,offsetY:h/2+o,visible:a&&n.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:r/2,y:0,offsetY:h/2+o,visible:a&&n.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:r,y:0,offsetX:h/2-o,offsetY:h/2+o,visible:a&&n.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:s/2,offsetX:h/2+o,visible:a&&n.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:r,y:s/2,offsetX:h/2-o,visible:a&&n.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:s,offsetX:h/2+o,offsetY:h/2-o,visible:a&&n.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:r/2,y:s,offsetY:h/2-o,visible:a&&n.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:r,y:s,offsetX:h/2-o,offsetY:h/2-o,visible:a&&n.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:r/2,y:-this.rotateAnchorOffset()*y._sign(s)-o,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:r,height:s,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),hi.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return P.prototype.toObject.call(this)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}function bd(i){return i instanceof Array||y.warn("enabledAnchors value should be an array"),i instanceof Array&&i.forEach(function(e){Or.indexOf(e)===-1&&y.warn("Unknown anchor name: "+e+". Available names are: "+Or.join(", "))}),i||[]}oe.prototype.className="Transformer";ge(oe);v.addGetterSetter(oe,"enabledAnchors",Or,bd);v.addGetterSetter(oe,"flipEnabled",!0,qe());v.addGetterSetter(oe,"resizeEnabled",!0);v.addGetterSetter(oe,"anchorSize",10,x());v.addGetterSetter(oe,"rotateEnabled",!0);v.addGetterSetter(oe,"rotationSnaps",[]);v.addGetterSetter(oe,"rotateAnchorOffset",50,x());v.addGetterSetter(oe,"rotationSnapTolerance",5,x());v.addGetterSetter(oe,"borderEnabled",!0);v.addGetterSetter(oe,"anchorStroke","rgb(0, 161, 255)");v.addGetterSetter(oe,"anchorStrokeWidth",1,x());v.addGetterSetter(oe,"anchorFill","white");v.addGetterSetter(oe,"anchorCornerRadius",0,x());v.addGetterSetter(oe,"borderStroke","rgb(0, 161, 255)");v.addGetterSetter(oe,"borderStrokeWidth",1,x());v.addGetterSetter(oe,"borderDash");v.addGetterSetter(oe,"keepRatio",!0);v.addGetterSetter(oe,"centeredScaling",!1);v.addGetterSetter(oe,"ignoreStroke",!1);v.addGetterSetter(oe,"padding",0,x());v.addGetterSetter(oe,"node");v.addGetterSetter(oe,"nodes");v.addGetterSetter(oe,"boundBoxFunc");v.addGetterSetter(oe,"anchorDragBoundFunc");v.addGetterSetter(oe,"shouldOverdrawWholeArea",!1);v.addGetterSetter(oe,"useSingleNodeRotation",!0);v.backCompat(oe,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class _t extends E{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,D.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}_t.prototype.className="Wedge";_t.prototype._centroid=!0;_t.prototype._attrsAffectingSize=["radius"];ge(_t);v.addGetterSetter(_t,"radius",0,x());v.addGetterSetter(_t,"angle",0,x());v.addGetterSetter(_t,"clockwise",!1);v.backCompat(_t,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function Kn(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var _d=[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],wd=[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 Sd(i,e){var t=i.data,r=i.width,s=i.height,n,a,o,h,l,d,u,c,p,f,m,g,_,w,b,T,L,A,G,R,H,$,I,K,U=e+e+1,le=r-1,ne=s-1,W=e+1,we=W*(W+1)/2,Re=new Kn,ze=null,te=Re,ve=null,Ie=null,Tt=_d[e],Ct=wd[e];for(o=1;o<U;o++)te=te.next=new Kn,o===W&&(ze=te);for(te.next=Re,u=d=0,a=0;a<s;a++){for(T=L=A=G=c=p=f=m=0,g=W*(R=t[d]),_=W*(H=t[d+1]),w=W*($=t[d+2]),b=W*(I=t[d+3]),c+=we*R,p+=we*H,f+=we*$,m+=we*I,te=Re,o=0;o<W;o++)te.r=R,te.g=H,te.b=$,te.a=I,te=te.next;for(o=1;o<W;o++)h=d+((le<o?le:o)<<2),c+=(te.r=R=t[h])*(K=W-o),p+=(te.g=H=t[h+1])*K,f+=(te.b=$=t[h+2])*K,m+=(te.a=I=t[h+3])*K,T+=R,L+=H,A+=$,G+=I,te=te.next;for(ve=Re,Ie=ze,n=0;n<r;n++)t[d+3]=I=m*Tt>>Ct,I!==0?(I=255/I,t[d]=(c*Tt>>Ct)*I,t[d+1]=(p*Tt>>Ct)*I,t[d+2]=(f*Tt>>Ct)*I):t[d]=t[d+1]=t[d+2]=0,c-=g,p-=_,f-=w,m-=b,g-=ve.r,_-=ve.g,w-=ve.b,b-=ve.a,h=u+((h=n+e+1)<le?h:le)<<2,T+=ve.r=t[h],L+=ve.g=t[h+1],A+=ve.b=t[h+2],G+=ve.a=t[h+3],c+=T,p+=L,f+=A,m+=G,ve=ve.next,g+=R=Ie.r,_+=H=Ie.g,w+=$=Ie.b,b+=I=Ie.a,T-=R,L-=H,A-=$,G-=I,Ie=Ie.next,d+=4;u+=r}for(n=0;n<r;n++){for(L=A=G=T=p=f=m=c=0,d=n<<2,g=W*(R=t[d]),_=W*(H=t[d+1]),w=W*($=t[d+2]),b=W*(I=t[d+3]),c+=we*R,p+=we*H,f+=we*$,m+=we*I,te=Re,o=0;o<W;o++)te.r=R,te.g=H,te.b=$,te.a=I,te=te.next;for(l=r,o=1;o<=e;o++)d=l+n<<2,c+=(te.r=R=t[d])*(K=W-o),p+=(te.g=H=t[d+1])*K,f+=(te.b=$=t[d+2])*K,m+=(te.a=I=t[d+3])*K,T+=R,L+=H,A+=$,G+=I,te=te.next,o<ne&&(l+=r);for(d=n,ve=Re,Ie=ze,a=0;a<s;a++)h=d<<2,t[h+3]=I=m*Tt>>Ct,I>0?(I=255/I,t[h]=(c*Tt>>Ct)*I,t[h+1]=(p*Tt>>Ct)*I,t[h+2]=(f*Tt>>Ct)*I):t[h]=t[h+1]=t[h+2]=0,c-=g,p-=_,f-=w,m-=b,g-=ve.r,_-=ve.g,w-=ve.b,b-=ve.a,h=n+((h=a+W)<ne?h:ne)*r<<2,c+=T+=ve.r=t[h],p+=L+=ve.g=t[h+1],f+=A+=ve.b=t[h+2],m+=G+=ve.a=t[h+3],ve=ve.next,g+=R=Ie.r,_+=H=Ie.g,w+=$=Ie.b,b+=I=Ie.a,T-=R,L-=H,A-=$,G-=I,Ie=Ie.next,d+=r}}const Td=function(e){var t=Math.round(this.blurRadius());t>0&&Sd(e,t)};v.addGetterSetter(P,"blurRadius",0,x(),v.afterSetFilter);const Cd=function(i){var e=this.brightness()*255,t=i.data,r=t.length,s;for(s=0;s<r;s+=4)t[s]+=e,t[s+1]+=e,t[s+2]+=e};v.addGetterSetter(P,"brightness",0,x(),v.afterSetFilter);const Ed=function(i){var e=Math.pow((this.contrast()+100)/100,2),t=i.data,r=t.length,s=150,n=150,a=150,o;for(o=0;o<r;o+=4)s=t[o],n=t[o+1],a=t[o+2],s/=255,s-=.5,s*=e,s+=.5,s*=255,n/=255,n-=.5,n*=e,n+=.5,n*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,s=s<0?0:s>255?255:s,n=n<0?0:n>255?255:n,a=a<0?0:a>255?255:a,t[o]=s,t[o+1]=n,t[o+2]=a};v.addGetterSetter(P,"contrast",0,x(),v.afterSetFilter);const kd=function(i){var e=this.embossStrength()*10,t=this.embossWhiteLevel()*255,r=this.embossDirection(),s=this.embossBlend(),n=0,a=0,o=i.data,h=i.width,l=i.height,d=h*4,u=l;switch(r){case"top-left":n=-1,a=-1;break;case"top":n=-1,a=0;break;case"top-right":n=-1,a=1;break;case"right":n=0,a=1;break;case"bottom-right":n=1,a=1;break;case"bottom":n=1,a=0;break;case"bottom-left":n=1,a=-1;break;case"left":n=0,a=-1;break;default:y.error("Unknown emboss direction: "+r)}do{var c=(u-1)*d,p=n;u+p<1&&(p=0),u+p>l&&(p=0);var f=(u-1+p)*h*4,m=h;do{var g=c+(m-1)*4,_=a;m+_<1&&(_=0),m+_>h&&(_=0);var w=f+(m-1+_)*4,b=o[g]-o[w],T=o[g+1]-o[w+1],L=o[g+2]-o[w+2],A=b,G=A>0?A:-A,R=T>0?T:-T,H=L>0?L:-L;if(R>G&&(A=T),H>G&&(A=L),A*=e,s){var $=o[g]+A,I=o[g+1]+A,K=o[g+2]+A;o[g]=$>255?255:$<0?0:$,o[g+1]=I>255?255:I<0?0:I,o[g+2]=K>255?255:K<0?0:K}else{var U=t-A;U<0?U=0:U>255&&(U=255),o[g]=o[g+1]=o[g+2]=U}}while(--m)}while(--u)};v.addGetterSetter(P,"embossStrength",.5,x(),v.afterSetFilter);v.addGetterSetter(P,"embossWhiteLevel",.5,x(),v.afterSetFilter);v.addGetterSetter(P,"embossDirection","top-left",null,v.afterSetFilter);v.addGetterSetter(P,"embossBlend",!1,null,v.afterSetFilter);function vs(i,e,t,r,s){var n=t-e,a=s-r,o;return n===0?r+a/2:a===0?r:(o=(i-e)/n,o=a*o+r,o)}const xd=function(i){var e=i.data,t=e.length,r=e[0],s=r,n,a=e[1],o=a,h,l=e[2],d=l,u,c,p=this.enhance();if(p!==0){for(c=0;c<t;c+=4)n=e[c+0],n<r?r=n:n>s&&(s=n),h=e[c+1],h<a?a=h:h>o&&(o=h),u=e[c+2],u<l?l=u:u>d&&(d=u);s===r&&(s=255,r=0),o===a&&(o=255,a=0),d===l&&(d=255,l=0);var f,m,g,_,w,b,T,L,A;for(p>0?(m=s+p*(255-s),g=r-p*(r-0),w=o+p*(255-o),b=a-p*(a-0),L=d+p*(255-d),A=l-p*(l-0)):(f=(s+r)*.5,m=s+p*(s-f),g=r+p*(r-f),_=(o+a)*.5,w=o+p*(o-_),b=a+p*(a-_),T=(d+l)*.5,L=d+p*(d-T),A=l+p*(l-T)),c=0;c<t;c+=4)e[c+0]=vs(e[c+0],r,s,g,m),e[c+1]=vs(e[c+1],a,o,b,w),e[c+2]=vs(e[c+2],l,d,A,L)}};v.addGetterSetter(P,"enhance",0,x(),v.afterSetFilter);const Pd=function(i){var e=i.data,t=e.length,r,s;for(r=0;r<t;r+=4)s=.34*e[r]+.5*e[r+1]+.16*e[r+2],e[r]=s,e[r+1]=s,e[r+2]=s};v.addGetterSetter(P,"hue",0,x(),v.afterSetFilter);v.addGetterSetter(P,"saturation",0,x(),v.afterSetFilter);v.addGetterSetter(P,"luminance",0,x(),v.afterSetFilter);const Ad=function(i){var e=i.data,t=e.length,r=1,s=Math.pow(2,this.saturation()),n=Math.abs(this.hue()+360)%360,a=this.luminance()*127,o,h=r*s*Math.cos(n*Math.PI/180),l=r*s*Math.sin(n*Math.PI/180),d=.299*r+.701*h+.167*l,u=.587*r-.587*h+.33*l,c=.114*r-.114*h-.497*l,p=.299*r-.299*h-.328*l,f=.587*r+.413*h+.035*l,m=.114*r-.114*h+.293*l,g=.299*r-.3*h+1.25*l,_=.587*r-.586*h-1.05*l,w=.114*r+.886*h-.2*l,b,T,L,A;for(o=0;o<t;o+=4)b=e[o+0],T=e[o+1],L=e[o+2],A=e[o+3],e[o+0]=d*b+u*T+c*L+a,e[o+1]=p*b+f*T+m*L+a,e[o+2]=g*b+_*T+w*L+a,e[o+3]=A},Md=function(i){var e=i.data,t=e.length,r=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),n=Math.abs(this.hue()+360)%360,a,o=r*s*Math.cos(n*Math.PI/180),h=r*s*Math.sin(n*Math.PI/180),l=.299*r+.701*o+.167*h,d=.587*r-.587*o+.33*h,u=.114*r-.114*o-.497*h,c=.299*r-.299*o-.328*h,p=.587*r+.413*o+.035*h,f=.114*r-.114*o+.293*h,m=.299*r-.3*o+1.25*h,g=.587*r-.586*o-1.05*h,_=.114*r+.886*o-.2*h,w,b,T,L;for(a=0;a<t;a+=4)w=e[a+0],b=e[a+1],T=e[a+2],L=e[a+3],e[a+0]=l*w+d*b+u*T,e[a+1]=c*w+p*b+f*T,e[a+2]=m*w+g*b+_*T,e[a+3]=L};v.addGetterSetter(P,"hue",0,x(),v.afterSetFilter);v.addGetterSetter(P,"saturation",0,x(),v.afterSetFilter);v.addGetterSetter(P,"value",0,x(),v.afterSetFilter);const Od=function(i){var e=i.data,t=e.length,r;for(r=0;r<t;r+=4)e[r]=255-e[r],e[r+1]=255-e[r+1],e[r+2]=255-e[r+2]};var Ld=function(i,e,t){var r=i.data,s=e.data,n=i.width,a=i.height,o=t.polarCenterX||n/2,h=t.polarCenterY||a/2,l,d,u,c=0,p=0,f=0,m=0,g,_=Math.sqrt(o*o+h*h);d=n-o,u=a-h,g=Math.sqrt(d*d+u*u),_=g>_?g:_;var w=a,b=n,T,L,A=360/b*Math.PI/180,G,R;for(L=0;L<b;L+=1)for(G=Math.sin(L*A),R=Math.cos(L*A),T=0;T<w;T+=1)d=Math.floor(o+_*T/w*R),u=Math.floor(h+_*T/w*G),l=(u*n+d)*4,c=r[l+0],p=r[l+1],f=r[l+2],m=r[l+3],l=(L+T*n)*4,s[l+0]=c,s[l+1]=p,s[l+2]=f,s[l+3]=m},Rd=function(i,e,t){var r=i.data,s=e.data,n=i.width,a=i.height,o=t.polarCenterX||n/2,h=t.polarCenterY||a/2,l,d,u,c,p,f=0,m=0,g=0,_=0,w,b=Math.sqrt(o*o+h*h);d=n-o,u=a-h,w=Math.sqrt(d*d+u*u),b=w>b?w:b;var T=a,L=n,A,G,R=t.polarRotation||0,H,$;for(d=0;d<n;d+=1)for(u=0;u<a;u+=1)c=d-o,p=u-h,A=Math.sqrt(c*c+p*p)*T/b,G=(Math.atan2(p,c)*180/Math.PI+360+R)%360,G=G*L/360,H=Math.floor(G),$=Math.floor(A),l=($*n+H)*4,f=r[l+0],m=r[l+1],g=r[l+2],_=r[l+3],l=(u*n+d)*4,s[l+0]=f,s[l+1]=m,s[l+2]=g,s[l+3]=_};const Id=function(i){var e=i.width,t=i.height,r,s,n,a,o,h,l,d,u,c,p=Math.round(this.kaleidoscopePower()),f=Math.round(this.kaleidoscopeAngle()),m=Math.floor(e*(f%360)/360);if(!(p<1)){var g=y.createCanvasElement();g.width=e,g.height=t;var _=g.getContext("2d").getImageData(0,0,e,t);y.releaseCanvas(g),Ld(i,_,{polarCenterX:e/2,polarCenterY:t/2});for(var w=e/Math.pow(2,p);w<=8;)w=w*2,p-=1;w=Math.ceil(w);var b=w,T=0,L=b,A=1;for(m+w>e&&(T=b,L=0,A=-1),s=0;s<t;s+=1)for(r=T;r!==L;r+=A)n=Math.round(r+m)%e,u=(e*s+n)*4,o=_.data[u+0],h=_.data[u+1],l=_.data[u+2],d=_.data[u+3],c=(e*s+r)*4,_.data[c+0]=o,_.data[c+1]=h,_.data[c+2]=l,_.data[c+3]=d;for(s=0;s<t;s+=1)for(b=Math.floor(w),a=0;a<p;a+=1){for(r=0;r<b+1;r+=1)u=(e*s+r)*4,o=_.data[u+0],h=_.data[u+1],l=_.data[u+2],d=_.data[u+3],c=(e*s+b*2-r-1)*4,_.data[c+0]=o,_.data[c+1]=h,_.data[c+2]=l,_.data[c+3]=d;b*=2}Rd(_,i,{polarRotation:0})}};v.addGetterSetter(P,"kaleidoscopePower",2,x(),v.afterSetFilter);v.addGetterSetter(P,"kaleidoscopeAngle",0,x(),v.afterSetFilter);function vr(i,e,t){var r=(t*i.width+e)*4,s=[];return s.push(i.data[r++],i.data[r++],i.data[r++],i.data[r++]),s}function ki(i,e){return Math.sqrt(Math.pow(i[0]-e[0],2)+Math.pow(i[1]-e[1],2)+Math.pow(i[2]-e[2],2))}function Nd(i){for(var e=[0,0,0],t=0;t<i.length;t++)e[0]+=i[t][0],e[1]+=i[t][1],e[2]+=i[t][2];return e[0]/=i.length,e[1]/=i.length,e[2]/=i.length,e}function Gd(i,e){var t=vr(i,0,0),r=vr(i,i.width-1,0),s=vr(i,0,i.height-1),n=vr(i,i.width-1,i.height-1),a=e||10;if(ki(t,r)<a&&ki(r,n)<a&&ki(n,s)<a&&ki(s,t)<a){for(var o=Nd([r,t,n,s]),h=[],l=0;l<i.width*i.height;l++){var d=ki(o,[i.data[l*4],i.data[l*4+1],i.data[l*4+2]]);h[l]=d<a?0:255}return h}}function Dd(i,e){for(var t=0;t<i.width*i.height;t++)i.data[4*t+3]=e[t]}function Fd(i,e,t){for(var r=[1,1,1,1,0,1,1,1,1],s=Math.round(Math.sqrt(r.length)),n=Math.floor(s/2),a=[],o=0;o<t;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,u=0;u<s;u++)for(var c=0;c<s;c++){var p=o+u-n,f=h+c-n;if(p>=0&&p<t&&f>=0&&f<e){var m=p*e+f,g=r[u*s+c];d+=i[m]*g}}a[l]=d===255*8?255:0}return a}function Hd(i,e,t){for(var r=[1,1,1,1,1,1,1,1,1],s=Math.round(Math.sqrt(r.length)),n=Math.floor(s/2),a=[],o=0;o<t;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,u=0;u<s;u++)for(var c=0;c<s;c++){var p=o+u-n,f=h+c-n;if(p>=0&&p<t&&f>=0&&f<e){var m=p*e+f,g=r[u*s+c];d+=i[m]*g}}a[l]=d>=255*4?255:0}return a}function Bd(i,e,t){for(var r=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],s=Math.round(Math.sqrt(r.length)),n=Math.floor(s/2),a=[],o=0;o<t;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,u=0;u<s;u++)for(var c=0;c<s;c++){var p=o+u-n,f=h+c-n;if(p>=0&&p<t&&f>=0&&f<e){var m=p*e+f,g=r[u*s+c];d+=i[m]*g}}a[l]=d}return a}const $d=function(i){var e=this.threshold(),t=Gd(i,e);return t&&(t=Fd(t,i.width,i.height),t=Hd(t,i.width,i.height),t=Bd(t,i.width,i.height),Dd(i,t)),i};v.addGetterSetter(P,"threshold",0,x(),v.afterSetFilter);const Vd=function(i){var e=this.noise()*255,t=i.data,r=t.length,s=e/2,n;for(n=0;n<r;n+=4)t[n+0]+=s-2*s*Math.random(),t[n+1]+=s-2*s*Math.random(),t[n+2]+=s-2*s*Math.random()};v.addGetterSetter(P,"noise",.2,x(),v.afterSetFilter);const zd=function(i){var e=Math.ceil(this.pixelSize()),t=i.width,r=i.height,s,n,a,o,h,l,d,u=Math.ceil(t/e),c=Math.ceil(r/e),p,f,m,g,_,w,b,T=i.data;if(e<=0){y.error("pixelSize value can not be <= 0");return}for(_=0;_<u;_+=1)for(w=0;w<c;w+=1){for(o=0,h=0,l=0,d=0,p=_*e,f=p+e,m=w*e,g=m+e,b=0,s=p;s<f;s+=1)if(!(s>=t))for(n=m;n<g;n+=1)n>=r||(a=(t*n+s)*4,o+=T[a+0],h+=T[a+1],l+=T[a+2],d+=T[a+3],b+=1);for(o=o/b,h=h/b,l=l/b,d=d/b,s=p;s<f;s+=1)if(!(s>=t))for(n=m;n<g;n+=1)n>=r||(a=(t*n+s)*4,T[a+0]=o,T[a+1]=h,T[a+2]=l,T[a+3]=d)}};v.addGetterSetter(P,"pixelSize",8,x(),v.afterSetFilter);const Ud=function(i){var e=Math.round(this.levels()*254)+1,t=i.data,r=t.length,s=255/e,n;for(n=0;n<r;n+=1)t[n]=Math.floor(t[n]/s)*s};v.addGetterSetter(P,"levels",.5,x(),v.afterSetFilter);const Wd=function(i){var e=i.data,t=e.length,r=this.red(),s=this.green(),n=this.blue(),a,o;for(a=0;a<t;a+=4)o=(.34*e[a]+.5*e[a+1]+.16*e[a+2])/255,e[a]=o*r,e[a+1]=o*s,e[a+2]=o*n,e[a+3]=e[a+3]};v.addGetterSetter(P,"red",0,function(i){return this._filterUpToDate=!1,i>255?255:i<0?0:Math.round(i)});v.addGetterSetter(P,"green",0,function(i){return this._filterUpToDate=!1,i>255?255:i<0?0:Math.round(i)});v.addGetterSetter(P,"blue",0,Na,v.afterSetFilter);const Zd=function(i){var e=i.data,t=e.length,r=this.red(),s=this.green(),n=this.blue(),a=this.alpha(),o,h;for(o=0;o<t;o+=4)h=1-a,e[o]=r*a+e[o]*h,e[o+1]=s*a+e[o+1]*h,e[o+2]=n*a+e[o+2]*h};v.addGetterSetter(P,"red",0,function(i){return this._filterUpToDate=!1,i>255?255:i<0?0:Math.round(i)});v.addGetterSetter(P,"green",0,function(i){return this._filterUpToDate=!1,i>255?255:i<0?0:Math.round(i)});v.addGetterSetter(P,"blue",0,Na,v.afterSetFilter);v.addGetterSetter(P,"alpha",1,function(i){return this._filterUpToDate=!1,i>1?1:i<0?0:i});const jd=function(i){var e=i.data,t=e.length,r,s,n,a;for(r=0;r<t;r+=4)s=e[r+0],n=e[r+1],a=e[r+2],e[r+0]=Math.min(255,s*.393+n*.769+a*.189),e[r+1]=Math.min(255,s*.349+n*.686+a*.168),e[r+2]=Math.min(255,s*.272+n*.534+a*.131)},Xd=function(i){var e=i.data,t=i.width,r=i.height,s=t*4,n=r;do{var a=(n-1)*s,o=t;do{var h=a+(o-1)*4,l=e[h],d=e[h+1],u=e[h+2];l>127&&(l=255-l),d>127&&(d=255-d),u>127&&(u=255-u),e[h]=l,e[h+1]=d,e[h+2]=u}while(--o)}while(--n)},qd=function(i){var e=this.threshold()*255,t=i.data,r=t.length,s;for(s=0;s<r;s+=1)t[s]=t[s]<e?0:255};v.addGetterSetter(P,"threshold",.5,x(),v.afterSetFilter);const M=zn.Util._assign(zn,{Arc:yt,Arrow:jt,Circle:vi,Ellipse:Gt,Image:Ye,Label:on,Tag:Xt,Line:bt,Path:he,Rect:Ji,RegularPolygon:qt,Ring:Yt,Sprite:ot,Star:Dt,Text:me,TextPath:Ce,Transformer:oe,Wedge:_t,Filters:{Blur:Td,Brighten:Cd,Contrast:Ed,Emboss:kd,Enhance:xd,Grayscale:Pd,HSL:Ad,HSV:Md,Invert:Od,Kaleidoscope:Id,Mask:$d,Noise:Vd,Pixelate:zd,Posterize:Ud,RGB:Wd,RGBA:Zd,Sepia:jd,Solarize:Xd,Threshold:qd}});var Rs=function(i,e){return Rs=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])},Rs(i,e)};function wt(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Rs(i,e);function t(){this.constructor=i}i.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Yd(i,e,t,r){function s(n){return n instanceof t?n:new t(function(a){a(n)})}return new(t||(t=Promise))(function(n,a){function o(d){try{l(r.next(d))}catch(u){a(u)}}function h(d){try{l(r.throw(d))}catch(u){a(u)}}function l(d){d.done?n(d.value):s(d.value).then(o,h)}l((r=r.apply(i,e||[])).next())})}function po(i,e){var t={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},r,s,n,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(d){return h([l,d])}}function h(l){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(t=0)),t;)try{if(r=1,s&&(n=l[0]&2?s.return:l[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,l[1])).done)return n;switch(s=0,n&&(l=[l[0]&2,n.value]),l[0]){case 0:case 1:n=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,s=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(n=t.trys,!(n=n.length>0&&n[n.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]<n[3])){t.label=l[1];break}if(l[0]===6&&t.label<n[1]){t.label=n[1],n=l;break}if(n&&t.label<n[2]){t.label=n[2],t.ops.push(l);break}n[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(i,t)}catch(d){l=[6,d],s=0}finally{r=n=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function di(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],r=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&r>=i.length&&(i=void 0),{value:i&&i[r++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Mt(i,e){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var r=t.call(i),s,n=[],a;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)n.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(a)throw a.error}}return n}function $t(i,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,n;r<s;r++)(n||!(r in e))&&(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return i.concat(n||Array.prototype.slice.call(e))}function ai(i){return this instanceof ai?(this.v=i,this):new ai(i)}function Kd(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(i,e||[]),s,n=[];return s={},a("next"),a("throw"),a("return"),s[Symbol.asyncIterator]=function(){return this},s;function a(c){r[c]&&(s[c]=function(p){return new Promise(function(f,m){n.push([c,p,f,m])>1||o(c,p)})})}function o(c,p){try{h(r[c](p))}catch(f){u(n[0][3],f)}}function h(c){c.value instanceof ai?Promise.resolve(c.value.v).then(l,d):u(n[0][2],c)}function l(c){o("next",c)}function d(c){o("throw",c)}function u(c,p){c(p),n.shift(),n.length&&o(n[0][0],n[0][1])}}function Jd(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=i[Symbol.asyncIterator],t;return e?e.call(i):(i=typeof di=="function"?di(i):i[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=i[n]&&function(a){return new Promise(function(o,h){a=i[n](a),s(o,h,a.done,a.value)})}}function s(n,a,o,h){Promise.resolve(h).then(function(l){n({value:l,done:o})},a)}}function de(i){return typeof i=="function"}function ln(i){var e=function(r){Error.call(r),r.stack=new Error().stack},t=i(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var ys=ln(function(i){return function(t){i(this),this.message=t?t.length+` errors occurred during unsubscription:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ze=require("hls.js");var Bl=Math.PI/180;function $l(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}const si=typeof global<"u"?global:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},G={_global:si,version:"8.3.14",isBrowser:$l(),isUnminified:/param/.test(function(i){}.toString()),dblClickWindow:400,getAngle(i){return G.angleDeg?i*Bl:i},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,pixelRatio:typeof window<"u"&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return G.DD.isDragging},isDragReady(){return!!G.DD.node},releaseCanvasOnDestroy:!0,document:si.document,_injectGlobal(i){si.Konva=i}},ge=i=>{G[i.prototype.getClassName()]=i};G._injectGlobal(G);class De{constructor(e=[1,0,0,1,0,0]){this.dirty=!1,this.m=e&&e.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new De(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){var t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){var t=Math.cos(e),r=Math.sin(e),s=this.m[0]*t+this.m[2]*r,n=this.m[1]*t+this.m[3]*r,a=this.m[0]*-r+this.m[2]*t,o=this.m[1]*-r+this.m[3]*t;return this.m[0]=s,this.m[1]=n,this.m[2]=a,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){var r=this.m[0]+this.m[2]*t,s=this.m[1]+this.m[3]*t,n=this.m[2]+this.m[0]*e,a=this.m[3]+this.m[1]*e;return this.m[0]=r,this.m[1]=s,this.m[2]=n,this.m[3]=a,this}multiply(e){var t=this.m[0]*e.m[0]+this.m[2]*e.m[1],r=this.m[1]*e.m[0]+this.m[3]*e.m[1],s=this.m[0]*e.m[2]+this.m[2]*e.m[3],n=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]=r,this.m[2]=s,this.m[3]=n,this.m[4]=a,this.m[5]=o,this}invert(){var e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,r=-this.m[1]*e,s=-this.m[2]*e,n=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]=r,this.m[2]=s,this.m[3]=n,this.m[4]=a,this.m[5]=o,this}getMatrix(){return this.m}decompose(){var e=this.m[0],t=this.m[1],r=this.m[2],s=this.m[3],n=this.m[4],a=this.m[5],o=e*s-t*r;let h={x:n,y:a,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||t!=0){var l=Math.sqrt(e*e+t*t);h.rotation=t>0?Math.acos(e/l):-Math.acos(e/l),h.scaleX=l,h.scaleY=o/l,h.skewX=(e*r+t*s)/o,h.skewY=0}else if(r!=0||s!=0){var d=Math.sqrt(r*r+s*s);h.rotation=Math.PI/2-(s>0?Math.acos(-r/d):-Math.acos(r/d)),h.scaleX=o/d,h.scaleY=d,h.skewX=0,h.skewY=(e*r+t*s)/o}return h.rotation=y._getRotation(h.rotation),h}}var Vl="[object Array]",zl="[object Number]",Wl="[object String]",Ul="[object Boolean]",Zl=Math.PI/180,jl=180/Math.PI,hs="#",Xl="",ql="0",Yl="Konva warning: ",An="Konva error: ",Kl="rgb(",ds={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]},Jl=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,or=[];const Ql=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(i){setTimeout(i,60)},y={_isElement(i){return!!(i&&i.nodeType==1)},_isFunction(i){return!!(i&&i.constructor&&i.call&&i.apply)},_isPlainObject(i){return!!i&&i.constructor===Object},_isArray(i){return Object.prototype.toString.call(i)===Vl},_isNumber(i){return Object.prototype.toString.call(i)===zl&&!isNaN(i)&&isFinite(i)},_isString(i){return Object.prototype.toString.call(i)===Wl},_isBoolean(i){return Object.prototype.toString.call(i)===Ul},isObject(i){return i instanceof Object},isValidSelector(i){if(typeof i!="string")return!1;var e=i[0];return e==="#"||e==="."||e===e.toUpperCase()},_sign(i){return i===0||i>0?1:-1},requestAnimFrame(i){or.push(i),or.length===1&&Ql(function(){const e=or;or=[],e.forEach(function(t){t()})})},createCanvasElement(){var i=document.createElement("canvas");try{i.style=i.style||{}}catch{}return i},createImageElement(){return document.createElement("img")},_isInDocument(i){for(;i=i.parentNode;)if(i==document)return!0;return!1},_urlToImage(i,e){var t=y.createImageElement();t.onload=function(){e(t)},t.src=i},_rgbToHex(i,e,t){return((1<<24)+(i<<16)+(e<<8)+t).toString(16).slice(1)},_hexToRgb(i){i=i.replace(hs,Xl);var e=parseInt(i,16);return{r:e>>16&255,g:e>>8&255,b:e&255}},getRandomColor(){for(var i=(Math.random()*16777215<<0).toString(16);i.length<6;)i=ql+i;return hs+i},getRGB(i){var e;return i in ds?(e=ds[i],{r:e[0],g:e[1],b:e[2]}):i[0]===hs?this._hexToRgb(i.substring(1)):i.substr(0,4)===Kl?(e=Jl.exec(i.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA(i){return i=i||"black",y._namedColorToRBA(i)||y._hex3ColorToRGBA(i)||y._hex6ColorToRGBA(i)||y._rgbColorToRGBA(i)||y._rgbaColorToRGBA(i)||y._hslColorToRGBA(i)},_namedColorToRBA(i){var e=ds[i.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(i){if(i.indexOf("rgb(")===0){i=i.match(/rgb\(([^)]+)\)/)[1];var e=i.split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(i){if(i.indexOf("rgba(")===0){i=i.match(/rgba\(([^)]+)\)/)[1];var e=i.split(/ *, */).map((t,r)=>t.slice(-1)==="%"?r===3?parseInt(t)/100:parseInt(t)/100*255:Number(t));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex6ColorToRGBA(i){if(i[0]==="#"&&i.length===7)return{r:parseInt(i.slice(1,3),16),g:parseInt(i.slice(3,5),16),b:parseInt(i.slice(5,7),16),a:1}},_hex3ColorToRGBA(i){if(i[0]==="#"&&i.length===4)return{r:parseInt(i[1]+i[1],16),g:parseInt(i[2]+i[2],16),b:parseInt(i[3]+i[3],16),a:1}},_hslColorToRGBA(i){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(i)){const[e,...t]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(i),r=Number(t[0])/360,s=Number(t[1])/100,n=Number(t[2])/100;let a,o,h;if(s===0)return h=n*255,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};n<.5?a=n*(1+s):a=n+s-n*s;const l=2*n-a,d=[0,0,0];for(let u=0;u<3;u++)o=r+1/3*-(u-1),o<0&&o++,o>1&&o--,6*o<1?h=l+(a-l)*6*o:2*o<1?h=a:3*o<2?h=l+(a-l)*(2/3-o)*6:h=l,d[u]=h*255;return{r:Math.round(d[0]),g:Math.round(d[1]),b:Math.round(d[2]),a:1}}},haveIntersection(i,e){return!(e.x>i.x+i.width||e.x+e.width<i.x||e.y>i.y+i.height||e.y+e.height<i.y)},cloneObject(i){var e={};for(var t in i)this._isPlainObject(i[t])?e[t]=this.cloneObject(i[t]):this._isArray(i[t])?e[t]=this.cloneArray(i[t]):e[t]=i[t];return e},cloneArray(i){return i.slice(0)},degToRad(i){return i*Zl},radToDeg(i){return i*jl},_degToRad(i){return y.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),y.degToRad(i)},_radToDeg(i){return y.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),y.radToDeg(i)},_getRotation(i){return G.angleDeg?y.radToDeg(i):i},_capitalize(i){return i.charAt(0).toUpperCase()+i.slice(1)},throw(i){throw new Error(An+i)},error(i){console.error(An+i)},warn(i){G.showWarnings&&console.warn(Yl+i)},each(i,e){for(var t in i)e(t,i[t])},_inRange(i,e,t){return e<=i&&i<t},_getProjectionToSegment(i,e,t,r,s,n){var a,o,h,l=(i-t)*(i-t)+(e-r)*(e-r);if(l==0)a=i,o=e,h=(s-t)*(s-t)+(n-r)*(n-r);else{var d=((s-i)*(t-i)+(n-e)*(r-e))/l;d<0?(a=i,o=e,h=(i-s)*(i-s)+(e-n)*(e-n)):d>1?(a=t,o=r,h=(t-s)*(t-s)+(r-n)*(r-n)):(a=i+d*(t-i),o=e+d*(r-e),h=(a-s)*(a-s)+(o-n)*(o-n))}return[a,o,h]},_getProjectionToLine(i,e,t){var r=y.cloneObject(i),s=Number.MAX_VALUE;return e.forEach(function(n,a){if(!(!t&&a===e.length-1)){var o=e[(a+1)%e.length],h=y._getProjectionToSegment(n.x,n.y,o.x,o.y,i.x,i.y),l=h[0],d=h[1],u=h[2];u<s&&(r.x=l,r.y=d,s=u)}}),r},_prepareArrayForTween(i,e,t){var r,s=[],n=[];if(i.length>e.length){var a=e;e=i,i=a}for(r=0;r<i.length;r+=2)s.push({x:i[r],y:i[r+1]});for(r=0;r<e.length;r+=2)n.push({x:e[r],y:e[r+1]});var o=[];return n.forEach(function(h){var l=y._getProjectionToLine(h,s,t);o.push(l.x),o.push(l.y)}),o},_prepareToStringify(i){var e;i.visitedByCircularReferenceRemoval=!0;for(var t in i)if(i.hasOwnProperty(t)&&i[t]&&typeof i[t]=="object"){if(e=Object.getOwnPropertyDescriptor(i,t),i[t].visitedByCircularReferenceRemoval||y._isElement(i[t]))if(e.configurable)delete i[t];else return null;else if(y._prepareToStringify(i[t])===null)if(e.configurable)delete i[t];else return null}return delete i.visitedByCircularReferenceRemoval,i},_assign(i,e){for(var t in e)i[t]=e[t];return i},_getFirstPointerId(i){return i.touches?i.changedTouches[0].identifier:i.pointerId||999},releaseCanvas(...i){G.releaseCanvasOnDestroy&&i.forEach(e=>{e.width=0,e.height=0})}};function Nt(i){return y._isString(i)?'"'+i+'"':Object.prototype.toString.call(i)==="[object Number]"||y._isBoolean(i)?i:Object.prototype.toString.call(i)}function Na(i){return i>255?255:i<0?0:Math.round(i)}function x(){if(G.isUnminified)return function(i,e){return y._isNumber(i)||y.warn(Nt(i)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),i}}function Da(i){if(G.isUnminified)return function(e,t){let r=y._isNumber(e),s=y._isArray(e)&&e.length==i;return!r&&!s&&y.warn(Nt(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or Array<number>('+i+")"),e}}function rn(){if(G.isUnminified)return function(i,e){var t=y._isNumber(i),r=i==="auto";return t||r||y.warn(Nt(i)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),i}}function gi(){if(G.isUnminified)return function(i,e){return y._isString(i)||y.warn(Nt(i)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),i}}function Ga(){if(G.isUnminified)return function(i,e){const t=y._isString(i),r=Object.prototype.toString.call(i)==="[object CanvasGradient]"||i&&i.addColorStop;return t||r||y.warn(Nt(i)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),i}}function eh(){if(G.isUnminified)return function(i,e){const t=Int8Array?Object.getPrototypeOf(Int8Array):null;return t&&i instanceof t||(y._isArray(i)?i.forEach(function(r){y._isNumber(r)||y.warn('"'+e+'" attribute has non numeric element '+r+". Make sure that all elements are numbers.")}):y.warn(Nt(i)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),i}}function Ke(){if(G.isUnminified)return function(i,e){var t=i===!0||i===!1;return t||y.warn(Nt(i)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),i}}function th(i){if(G.isUnminified)return function(e,t){return e==null||y.isObject(e)||y.warn(Nt(e)+' is a not valid value for "'+t+'" attribute. The value should be an object with properties '+i),e}}var Ti="get",Ci="set";const v={addGetterSetter(i,e,t,r,s){v.addGetter(i,e,t),v.addSetter(i,e,r,s),v.addOverloadedGetterSetter(i,e)},addGetter(i,e,t){var r=Ti+y._capitalize(e);i.prototype[r]=i.prototype[r]||function(){var s=this.attrs[e];return s===void 0?t:s}},addSetter(i,e,t,r){var s=Ci+y._capitalize(e);i.prototype[s]||v.overWriteSetter(i,e,t,r)},overWriteSetter(i,e,t,r){var s=Ci+y._capitalize(e);i.prototype[s]=function(n){return t&&n!==void 0&&n!==null&&(n=t.call(this,n,e)),this._setAttr(e,n),r&&r.call(this),this}},addComponentsGetterSetter(i,e,t,r,s){var n=t.length,a=y._capitalize,o=Ti+a(e),h=Ci+a(e),l,d;i.prototype[o]=function(){var c={};for(l=0;l<n;l++)d=t[l],c[d]=this.getAttr(e+a(d));return c};var u=th(t);i.prototype[h]=function(c){var p=this.attrs[e],f;r&&(c=r.call(this,c)),u&&u.call(this,c,e);for(f in c)c.hasOwnProperty(f)&&this._setAttr(e+a(f),c[f]);return c||t.forEach(m=>{this._setAttr(e+a(m),void 0)}),this._fireChangeEvent(e,p,c),s&&s.call(this),this},v.addOverloadedGetterSetter(i,e)},addOverloadedGetterSetter(i,e){var t=y._capitalize(e),r=Ci+t,s=Ti+t;i.prototype[e]=function(){return arguments.length?(this[r](arguments[0]),this):this[s]()}},addDeprecatedGetterSetter(i,e,t,r){y.error("Adding deprecated "+e);var s=Ti+y._capitalize(e),n=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[s]=function(){y.error(n);var a=this.attrs[e];return a===void 0?t:a},v.addSetter(i,e,r,function(){y.error(n)}),v.addOverloadedGetterSetter(i,e)},backCompat(i,e){y.each(e,function(t,r){var s=i.prototype[r],n=Ti+y._capitalize(t),a=Ci+y._capitalize(t);function o(){s.apply(this,arguments),y.error('"'+t+'" method is deprecated and will be removed soon. Use ""'+r+'" instead.')}i.prototype[t]=o,i.prototype[n]=o,i.prototype[a]=o})},afterSetFilter(){this._filterUpToDate=!1}};function ih(i){var e=[],t=i.length,r=y,s,n;for(s=0;s<t;s++)n=i[s],r._isNumber(n)?n=Math.round(n*1e3)/1e3:r._isString(n)||(n=n+""),e.push(n);return e}var Mn=",",rh="(",sh=")",nh="([",ah="])",oh=";",lh="()",hh="=",On=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],dh=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"];const uh=100;class qr{constructor(e){this.canvas=e,G.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){var r=this.traceArr,s=r.length,n="",a,o,h,l;for(a=0;a<s;a++)o=r[a],h=o.method,h?(l=o.args,n+=h,e?n+=lh:y._isArray(l[0])?n+=nh+l.join(Mn)+ah:(t&&(l=l.map(d=>typeof d=="number"?Math.floor(d):d)),n+=rh+l.join(Mn)+sh)):(n+=o.property,e||(n+=hh+o.val)),n+=oh;return n}clearTrace(){this.traceArr=[]}_trace(e){var t=this.traceArr,r;t.push(e),r=t.length,r>=uh&&t.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){var t=e.getLineCap();t&&this.setAttr("lineCap",t)}_applyOpacity(e){var t=e.getAbsoluteOpacity();t!==1&&this.setAttr("globalAlpha",t)}_applyLineJoin(e){var t=e.attrs.lineJoin;t&&this.setAttr("lineJoin",t)}setAttr(e,t){this._context[e]=t}arc(e,t,r,s,n,a){this._context.arc(e,t,r,s,n,a)}arcTo(e,t,r,s,n){this._context.arcTo(e,t,r,s,n)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,r,s,n,a){this._context.bezierCurveTo(e,t,r,s,n,a)}clearRect(e,t,r,s){this._context.clearRect(e,t,r,s)}clip(){this._context.clip()}closePath(){this._context.closePath()}createImageData(e,t){var r=arguments;if(r.length===2)return this._context.createImageData(e,t);if(r.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,r,s){return this._context.createLinearGradient(e,t,r,s)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,r,s,n,a){return this._context.createRadialGradient(e,t,r,s,n,a)}drawImage(e,t,r,s,n,a,o,h,l){var d=arguments,u=this._context;d.length===3?u.drawImage(e,t,r):d.length===5?u.drawImage(e,t,r,s,n):d.length===9&&u.drawImage(e,t,r,s,n,a,o,h,l)}ellipse(e,t,r,s,n,a,o,h){this._context.ellipse(e,t,r,s,n,a,o,h)}isPointInPath(e,t){return this._context.isPointInPath(e,t)}fill(e){e?this._context.fill(e):this._context.fill()}fillRect(e,t,r,s){this._context.fillRect(e,t,r,s)}strokeRect(e,t,r,s){this._context.strokeRect(e,t,r,s)}fillText(e,t,r,s){s?this._context.fillText(e,t,r,s):this._context.fillText(e,t,r)}measureText(e){return this._context.measureText(e)}getImageData(e,t,r,s){return this._context.getImageData(e,t,r,s)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,r,s){this._context.rect(e,t,r,s)}putImageData(e,t,r){this._context.putImageData(e,t,r)}quadraticCurveTo(e,t,r,s){this._context.quadraticCurveTo(e,t,r,s)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,r,s,n,a){this._context.setTransform(e,t,r,s,n,a)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,r,s){this._context.strokeText(e,t,r,s)}transform(e,t,r,s,n,a){this._context.transform(e,t,r,s,n,a)}translate(e,t){this._context.translate(e,t)}_enableTrace(){var e=this,t=On.length,r=this.setAttr,s,n,a=function(o){var h=e[o],l;e[o]=function(){return n=ih(Array.prototype.slice.call(arguments,0)),l=h.apply(e,arguments),e._trace({method:o,args:n}),l}};for(s=0;s<t;s++)a(On[s]);e.setAttr=function(){r.apply(e,arguments);var o=arguments[0],h=arguments[1];(o==="shadowOffsetX"||o==="shadowOffsetY"||o==="shadowBlur")&&(h=h/this.canvas.getPixelRatio()),e._trace({property:o,val:h})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;var r=!t||t==="source-over";r||this.setAttr("globalCompositeOperation",t)}}dh.forEach(function(i){Object.defineProperty(qr.prototype,i,{get(){return this._context[i]},set(e){this._context[i]=e}})});class ch extends qr{constructor(e){super(e),this._context=e._canvas.getContext("2d")}_fillColor(e){var t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var t=e._getLinearGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fillRadialGradient(e){var t=e._getRadialGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fill(e){var t=e.fill(),r=e.getFillPriority();if(t&&r==="color"){this._fillColor(e);return}var s=e.getFillPatternImage();if(s&&r==="pattern"){this._fillPattern(e);return}var n=e.getFillLinearGradientColorStops();if(n&&r==="linear-gradient"){this._fillLinearGradient(e);return}var a=e.getFillRadialGradientColorStops();if(a&&r==="radial-gradient"){this._fillRadialGradient(e);return}t?this._fillColor(e):s?this._fillPattern(e):n?this._fillLinearGradient(e):a&&this._fillRadialGradient(e)}_strokeLinearGradient(e){var t=e.getStrokeLinearGradientStartPoint(),r=e.getStrokeLinearGradientEndPoint(),s=e.getStrokeLinearGradientColorStops(),n=this.createLinearGradient(t.x,t.y,r.x,r.y);if(s){for(var a=0;a<s.length;a+=2)n.addColorStop(s[a],s[a+1]);this.setAttr("strokeStyle",n)}}_stroke(e){var t=e.dash(),r=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!r){this.save();var s=this.getCanvas().getPixelRatio();this.setTransform(s,0,0,s,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");var n=e.getStrokeLinearGradientColorStops();n?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),r||this.restore()}}_applyShadow(e){var t,r,s,n=(t=e.getShadowRGBA())!==null&&t!==void 0?t:"black",a=(r=e.getShadowBlur())!==null&&r!==void 0?r:5,o=(s=e.getShadowOffset())!==null&&s!==void 0?s:{x:0,y:0},h=e.getAbsoluteScale(),l=this.canvas.getPixelRatio(),d=h.x*l,u=h.y*l;this.setAttr("shadowColor",n),this.setAttr("shadowBlur",a*Math.min(Math.abs(d),Math.abs(u))),this.setAttr("shadowOffsetX",o.x*d),this.setAttr("shadowOffsetY",o.y*u)}}class fh extends qr{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){var t=e.getStrokeScaleEnabled();if(!t){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e);var s=e.hitStrokeWidth(),n=s==="auto"?e.strokeWidth():s;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),t||this.restore()}}}var lr;function ph(){if(lr)return lr;var i=y.createCanvasElement(),e=i.getContext("2d");return lr=function(){var t=G._global.devicePixelRatio||1,r=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return t/r}(),y.releaseCanvas(i),lr}class Yr{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var t=e||{},r=t.pixelRatio||G.pixelRatio||ph();this.pixelRatio=r,this._canvas=y.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){var t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var t=this.pixelRatio,r=this.getContext()._context;r.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var t=this.pixelRatio,r=this.getContext()._context;r.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(s){return y.error("Unable to get data URL. "+s.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}v.addGetterSetter(Yr,"pixelRatio",void 0,x());class ni extends Yr{constructor(e={width:0,height:0}){super(e),this.context=new ch(this),this.setSize(e.width,e.height)}}class sn extends Yr{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new fh(this),this.setSize(e.width,e.height)}}const se={get isDragging(){var i=!1;return se._dragElements.forEach(e=>{e.dragStatus==="dragging"&&(i=!0)}),i},justDragged:!1,get node(){var i;return se._dragElements.forEach(e=>{i=e.node}),i},_dragElements:new Map,_drag(i){const e=[];se._dragElements.forEach((t,r)=>{const{node:s}=t,n=s.getStage();n.setPointersPositions(i),t.pointerId===void 0&&(t.pointerId=y._getFirstPointerId(i));const a=n._changedPointerPositions.find(l=>l.id===t.pointerId);if(a){if(t.dragStatus!=="dragging"){var o=s.dragDistance(),h=Math.max(Math.abs(a.x-t.startPointerPos.x),Math.abs(a.y-t.startPointerPos.y));if(h<o||(s.startDrag({evt:i}),!s.isDragging()))return}s._setDragPosition(i,t),e.push(s)}}),e.forEach(t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:i},!0)})},_endDragBefore(i){const e=[];se._dragElements.forEach(t=>{const{node:r}=t,s=r.getStage();if(i&&s.setPointersPositions(i),!s._changedPointerPositions.find(o=>o.id===t.pointerId))return;(t.dragStatus==="dragging"||t.dragStatus==="stopped")&&(se.justDragged=!0,G._mouseListenClick=!1,G._touchListenClick=!1,G._pointerListenClick=!1,t.dragStatus="stopped");const a=t.node.getLayer()||t.node instanceof G.Stage&&t.node;a&&e.indexOf(a)===-1&&e.push(a)}),e.forEach(t=>{t.draw()})},_endDragAfter(i){se._dragElements.forEach((e,t)=>{e.dragStatus==="stopped"&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:i},!0),e.dragStatus!=="dragging"&&se._dragElements.delete(t)})}};G.isBrowser&&(window.addEventListener("mouseup",se._endDragBefore,!0),window.addEventListener("touchend",se._endDragBefore,!0),window.addEventListener("mousemove",se._drag),window.addEventListener("touchmove",se._drag),window.addEventListener("mouseup",se._endDragAfter,!1),window.addEventListener("touchend",se._endDragAfter,!1));var wr="absoluteOpacity",hr="allEventListeners",ht="absoluteTransform",Ln="absoluteScale",Ht="canvas",mh="Change",gh="children",vh="konva",Cs="listening",Rn="mouseenter",In="mouseleave",Nn="set",Dn="Shape",Sr=" ",Gn="stage",kt="transform",yh="Stage",Es="visible",bh=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Sr);let _h=1;class P{constructor(e){this._id=_h++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){(e===kt||e===ht)&&this._cache.get(e)?this._cache.get(e).dirty=!0:e?this._cache.delete(e):this._cache.clear()}_getCache(e,t){var r=this._cache.get(e),s=e===kt||e===ht,n=r===void 0||s&&r.dirty===!0;return n&&(r=t.call(this),this._cache.set(e,r)),r}_calculate(e,t,r){if(!this._attachedDepsListeners.get(e)){const s=t.map(n=>n+"Change.konva").join(Sr);this.on(s,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,r)}_getCanvasCache(){return this._cache.get(Ht)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===ht&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(Ht)){const{scene:e,filter:t,hit:r}=this._cache.get(Ht);y.releaseCanvas(e,t,r),this._cache.delete(Ht)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var t=e||{},r={};(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)&&(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()}));var s=Math.ceil(t.width||r.width),n=Math.ceil(t.height||r.height),a=t.pixelRatio,o=t.x===void 0?Math.floor(r.x):t.x,h=t.y===void 0?Math.floor(r.y):t.y,l=t.offset||0,d=t.drawBorder||!1,u=t.hitCanvasPixelRatio||1;if(!s||!n){y.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}s+=l*2+1,n+=l*2+1,o-=l,h-=l;var c=new ni({pixelRatio:a,width:s,height:n}),p=new ni({pixelRatio:a,width:0,height:0}),f=new sn({pixelRatio:u,width:s,height:n}),m=c.getContext(),g=f.getContext();return f.isCache=!0,c.isCache=!0,this._cache.delete(Ht),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(c.getContext()._context.imageSmoothingEnabled=!1,p.getContext()._context.imageSmoothingEnabled=!1),m.save(),g.save(),m.translate(-o,-h),g.translate(-o,-h),this._isUnderCache=!0,this._clearSelfAndDescendantCache(wr),this._clearSelfAndDescendantCache(Ln),this.drawScene(c,this),this.drawHit(f,this),this._isUnderCache=!1,m.restore(),g.restore(),d&&(m.save(),m.beginPath(),m.rect(0,0,s,n),m.closePath(),m.setAttr("strokeStyle","red"),m.setAttr("lineWidth",5),m.stroke(),m.restore()),this._cache.set(Ht,{scene:c,filter:p,hit:f,x:o,y:h}),this._requestDraw(),this}isCached(){return this._cache.has(Ht)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,t){var r=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],s,n,a,o,h=this.getAbsoluteTransform(t);return r.forEach(function(l){var d=h.point(l);s===void 0&&(s=a=d.x,n=o=d.y),s=Math.min(s,d.x),n=Math.min(n,d.y),a=Math.max(a,d.x),o=Math.max(o,d.y)}),{x:s,y:n,width:a-s,height:o-n}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const t=this._getCanvasCache();e.translate(t.x,t.y);var r=this._getCachedSceneCanvas(),s=r.pixelRatio;e.drawImage(r._canvas,0,0,r.width/s,r.height/s),e.restore()}_drawCachedHitCanvas(e){var t=this._getCanvasCache(),r=t.hit;e.save(),e.translate(t.x,t.y),e.drawImage(r._canvas,0,0,r.width/r.pixelRatio,r.height/r.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e=this.filters(),t=this._getCanvasCache(),r=t.scene,s=t.filter,n=s.getContext(),a,o,h,l;if(e){if(!this._filterUpToDate){var d=r.pixelRatio;s.setSize(r.width/r.pixelRatio,r.height/r.pixelRatio);try{for(a=e.length,n.clear(),n.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),o=n.getImageData(0,0,s.getWidth(),s.getHeight()),h=0;h<a;h++){if(l=e[h],typeof l!="function"){y.error("Filter should be type of function, but got "+typeof l+" instead. Please check correct filters");continue}l.call(this,o),n.putImageData(o,0,0)}}catch(u){y.error("Unable to apply filter. "+u.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return s}return r}on(e,t){if(this._cache&&this._cache.delete(hr),arguments.length===3)return this._delegate.apply(this,arguments);var r=e.split(Sr),s=r.length,n,a,o,h,l;for(n=0;n<s;n++)a=r[n],o=a.split("."),h=o[0],l=o[1]||"",this.eventListeners[h]||(this.eventListeners[h]=[]),this.eventListeners[h].push({name:l,handler:t});return this}off(e,t){var r=(e||"").split(Sr),s=r.length,n,a,o,h,l,d;if(this._cache&&this._cache.delete(hr),!e)for(a in this.eventListeners)this._off(a);for(n=0;n<s;n++)if(o=r[n],h=o.split("."),l=h[0],d=h[1],l)this.eventListeners[l]&&this._off(l,d,t);else for(a in this.eventListeners)this._off(a,d,t);return this}dispatchEvent(e){var t={target:this,type:e.type,evt:e};return this.fire(e.type,t),this}addEventListener(e,t){return this.on(e,function(r){t.call(this,r.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,t,r){var s=this;this.on(e,function(n){for(var a=n.target.findAncestors(t,!0,s),o=0;o<a.length;o++)n=y.cloneObject(n),n.currentTarget=a[o],r.call(a[o],n)})}remove(){return this.isDragging()&&this.stopDrag(),se._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(ht),this._clearSelfAndDescendantCache(wr),this._clearSelfAndDescendantCache(Ln),this._clearSelfAndDescendantCache(Gn),this._clearSelfAndDescendantCache(Es),this._clearSelfAndDescendantCache(Cs)}_remove(){this._clearCaches();var e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){var t="get"+y._capitalize(e);return y._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),t=[];e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{var t,r;if(!e)return this;for(t in e)t!==gh&&(r=Nn+y._capitalize(t),y._isFunction(this[r])?this[r](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(Cs,this._isListening)}_isListening(e){if(!this.listening())return!1;const r=this.getParent();return r&&r!==e&&this!==e?r._isListening(e):!0}isVisible(){return this._getCache(Es,this._isVisible)}_isVisible(e){if(!this.visible())return!1;const r=this.getParent();return r&&r!==e&&this!==e?r._isVisible(e):!0}shouldDrawHit(e,t=!1){if(e)return this._isVisible(e)&&this._isListening(e);var r=this.getLayer(),s=!1;se._dragElements.forEach(a=>{a.dragStatus==="dragging"&&(a.node.nodeType==="Stage"||a.node.getLayer()===r)&&(s=!0)});var n=!t&&!G.hitOnDragEnabled&&s;return this.isListening()&&this.isVisible()&&!n}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var e=this.getDepth(),t=this,r=0,s,n,a,o;function h(l){for(s=[],n=l.length,a=0;a<n;a++)o=l[a],r++,o.nodeType!==Dn&&(s=s.concat(o.getChildren().slice())),o._id===t._id&&(a=n);s.length>0&&s[0].getDepth()<=e&&h(s)}return t.nodeType!==yh&&h(t.getStage().getChildren()),r}getDepth(){for(var e=0,t=this.parent;t;)e++,t=t.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(kt),this._clearSelfAndDescendantCache(ht)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){if(!this.getStage())return null;var e=this.getStage().getPointerPosition();if(!e)return null;var t=this.getAbsoluteTransform().copy();return t.invert(),t.point(e)}getAbsolutePosition(e){let t=!1,r=this.parent;for(;r;){if(r.isCached()){t=!0;break}r=r.parent}t&&!e&&(e=!0);var s=this.getAbsoluteTransform(e).getMatrix(),n=new De,a=this.offset();return n.m=s.slice(),n.translate(a.x,a.y),n.getTranslation()}setAbsolutePosition(e){var t=this._clearTransform();this.attrs.x=t.x,this.attrs.y=t.y,delete t.x,delete t.y,this._clearCache(kt);var r=this._getAbsoluteTransform().copy();return r.invert(),r.translate(e.x,e.y),e={x:this.attrs.x+r.getTranslation().x,y:this.attrs.y+r.getTranslation().y},this._setTransform(t),this.setPosition({x:e.x,y:e.y}),this._clearCache(kt),this._clearSelfAndDescendantCache(ht),this}_setTransform(e){var t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){var 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){var t=e.x,r=e.y,s=this.x(),n=this.y();return t!==void 0&&(s+=t),r!==void 0&&(n+=r),this.setPosition({x:s,y:n}),this}_eachAncestorReverse(e,t){var r=[],s=this.getParent(),n,a;if(!(t&&t._id===this._id)){for(r.unshift(this);s&&(!t||s._id!==t._id);)r.unshift(s),s=s.parent;for(n=r.length,a=0;a<n;a++)e(r[a])}}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return y.warn("Node has no parent. moveToTop function is ignored."),!1;var e=this.index,t=this.parent.getChildren().length;return e<t-1?(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return y.warn("Node has no parent. moveUp function is ignored."),!1;var e=this.index,t=this.parent.getChildren().length;return e<t-1?(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return y.warn("Node has no parent. moveDown function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return y.warn("Node has no parent. moveToBottom function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(e){if(!this.parent)return y.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&y.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)+".");var 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(wr,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var 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(){var e={},t=this.getAttrs(),r,s,n,a,o;e.attrs={};for(r in t)s=t[r],o=y.isObject(s)&&!y._isPlainObject(s)&&!y._isArray(s),!o&&(n=typeof this[r]=="function"&&this[r],delete t[r],a=n?n.call(this):null,t[r]=s,a!==s&&(e.attrs[r]=s));return e.className=this.getClassName(),y._prepareToStringify(e)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,r){var s=[];t&&this._isMatch(e)&&s.push(this);for(var n=this.parent;n;){if(n===r)return s;n._isMatch(e)&&s.push(n),n=n.parent}return s}isAncestorOf(e){return!1}findAncestor(e,t,r){return this.findAncestors(e,t,r)[0]}_isMatch(e){if(!e)return!1;if(typeof e=="function")return e(this);var t=e.replace(/ /g,"").split(","),r=t.length,s,n;for(s=0;s<r;s++)if(n=t[s],y.isValidSelector(n)||(y.warn('Selector "'+n+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),y.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),y.warn("Konva is awesome, right?")),n.charAt(0)==="#"){if(this.id()===n.slice(1))return!0}else if(n.charAt(0)==="."){if(this.hasName(n.slice(1)))return!0}else if(this.className===n||this.nodeType===n)return!0;return!1}getLayer(){var e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(Gn,this._getStage)}_getStage(){var e=this.getParent();if(e)return e.getStage()}fire(e,t={},r){return t.target=t.target||this,r?this._fireAndBubble(e,t):this._fire(e,t),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(ht,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var t;if(e)return t=new De,this._eachAncestorReverse(function(s){var n=s.transformsEnabled();n==="all"?t.multiply(s.getTransform()):n==="position"&&t.translate(s.x()-s.offsetX(),s.y()-s.offsetY())},e),t;t=this._cache.get(ht)||new De,this.parent?this.parent.getAbsoluteTransform().copyInto(t):t.reset();var r=this.transformsEnabled();if(r==="all")t.multiply(this.getTransform());else if(r==="position"){const s=this.attrs.x||0,n=this.attrs.y||0,a=this.attrs.offsetX||0,o=this.attrs.offsetY||0;t.translate(s-a,n-o)}return t.dirty=!1,t}getAbsoluteScale(e){for(var t=this;t;)t._isUnderCache&&(e=t),t=t.getParent();const s=this.getAbsoluteTransform(e).decompose();return{x:s.scaleX,y:s.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(kt,this._getTransform)}_getTransform(){var e,t,r=this._cache.get(kt)||new De;r.reset();var s=this.x(),n=this.y(),a=G.getAngle(this.rotation()),o=(e=this.attrs.scaleX)!==null&&e!==void 0?e:1,h=(t=this.attrs.scaleY)!==null&&t!==void 0?t:1,l=this.attrs.skewX||0,d=this.attrs.skewY||0,u=this.attrs.offsetX||0,c=this.attrs.offsetY||0;return(s!==0||n!==0)&&r.translate(s,n),a!==0&&r.rotate(a),(l!==0||d!==0)&&r.skew(l,d),(o!==1||h!==1)&&r.scale(o,h),(u!==0||c!==0)&&r.translate(-1*u,-1*c),r.dirty=!1,r}clone(e){var t=y.cloneObject(this.attrs),r,s,n,a,o;for(r in e)t[r]=e[r];var h=new this.constructor(t);for(r in this.eventListeners)for(s=this.eventListeners[r],n=s.length,a=0;a<n;a++)o=s[a],o.name.indexOf(vh)<0&&(h.eventListeners[r]||(h.eventListeners[r]=[]),h.eventListeners[r].push(o));return h}_toKonvaCanvas(e){e=e||{};var t=this.getClientRect(),r=this.getStage(),s=e.x!==void 0?e.x:Math.floor(t.x),n=e.y!==void 0?e.y:Math.floor(t.y),a=e.pixelRatio||1,o=new ni({width:e.width||Math.ceil(t.width)||(r?r.width():0),height:e.height||Math.ceil(t.height)||(r?r.height():0),pixelRatio:a}),h=o.getContext();return e.imageSmoothingEnabled===!1&&(h._context.imageSmoothingEnabled=!1),h.save(),(s||n)&&h.translate(-1*s,-1*n),this.drawScene(o),h.restore(),o}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e=e||{};var t=e.mimeType||null,r=e.quality||null,s=this._toKonvaCanvas(e).toDataURL(t,r);return e.callback&&e.callback(s),s}toImage(e){return new Promise((t,r)=>{try{const s=e==null?void 0:e.callback;s&&delete e.callback,y._urlToImage(this.toDataURL(e),function(n){t(n),s==null||s(n)})}catch(s){r(s)}})}toBlob(e){return new Promise((t,r)=>{try{const s=e==null?void 0:e.callback;s&&delete e.callback,this.toCanvas(e).toBlob(n=>{t(n),s==null||s(n)})}catch(s){r(s)}})}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.attrs.dragDistance:this.parent?this.parent.getDragDistance():G.dragDistance}_off(e,t,r){var s=this.eventListeners[e],n,a,o;for(n=0;n<s.length;n++)if(a=s[n].name,o=s[n].handler,(a!=="konva"||t==="konva")&&(!t||a===t)&&(!r||r===o)){if(s.splice(n,1),s.length===0){delete this.eventListeners[e];break}n--}}_fireChangeEvent(e,t,r){this._fire(e+mh,{oldVal:t,newVal:r})}addName(e){if(!this.hasName(e)){var t=this.name(),r=t?t+" "+e:e;this.name(r)}return this}hasName(e){if(!e)return!1;const t=this.name();if(!t)return!1;var r=(t||"").split(/\s/g);return r.indexOf(e)!==-1}removeName(e){var t=(this.name()||"").split(/\s/g),r=t.indexOf(e);return r!==-1&&(t.splice(r,1),this.name(t.join(" "))),this}setAttr(e,t){var r=this[Nn+y._capitalize(e)];return y._isFunction(r)?r.call(this,t):this._setAttr(e,t),this}_requestDraw(){if(G.autoDrawEnabled){const e=this.getLayer()||this.getStage();e==null||e.batchDraw()}}_setAttr(e,t){var r=this.attrs[e];r===t&&!y.isObject(t)||(t==null?delete this.attrs[e]:this.attrs[e]=t,this._shouldFireChangeEvents&&this._fireChangeEvent(e,r,t),this._requestDraw())}_setComponentAttr(e,t,r){var s;r!==void 0&&(s=this.attrs[e],s||(this.attrs[e]=this.getAttr(e)),this.attrs[e][t]=r,this._fireChangeEvent(e,s,r))}_fireAndBubble(e,t,r){t&&this.nodeType===Dn&&(t.target=this);var s=(e===Rn||e===In)&&(r&&(this===r||this.isAncestorOf&&this.isAncestorOf(r))||this.nodeType==="Stage"&&!r);if(!s){this._fire(e,t);var n=(e===Rn||e===In)&&r&&r.isAncestorOf&&r.isAncestorOf(this)&&!r.isAncestorOf(this.parent);(t&&!t.cancelBubble||!t)&&this.parent&&this.parent.isListening()&&!n&&(r&&r.parent?this._fireAndBubble.call(this.parent,e,t,r):this._fireAndBubble.call(this.parent,e,t))}}_getProtoListeners(e){let t=this._cache.get(hr);if(!t){t={};let s=Object.getPrototypeOf(this);for(;s;){if(!s.eventListeners){s=Object.getPrototypeOf(s);continue}for(var r in s.eventListeners){const n=s.eventListeners[r],a=t[r]||[];t[r]=n.concat(a)}s=Object.getPrototypeOf(s)}this._cache.set(hr,t)}return t[e]}_fire(e,t){t=t||{},t.currentTarget=this,t.type=e;const r=this._getProtoListeners(e);if(r)for(var s=0;s<r.length;s++)r[s].handler.call(this,t);const n=this.eventListeners[e];if(n)for(var s=0;s<n.length;s++)n[s].handler.call(this,t)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var t=e?e.pointerId:void 0,r=this.getStage(),s=this.getAbsolutePosition(),n=r._getPointerById(t)||r._changedPointerPositions[0]||s;se._dragElements.set(this._id,{node:this,startPointerPos:n,offset:{x:n.x-s.x,y:n.y-s.y},dragStatus:"ready",pointerId:t})}startDrag(e,t=!0){se._dragElements.has(this._id)||this._createDragElement(e);const r=se._dragElements.get(this._id);r.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:e&&e.evt},t)}_setDragPosition(e,t){const r=this.getStage()._getPointerById(t.pointerId);if(r){var s={x:r.x-t.offset.x,y:r.y-t.offset.y},n=this.dragBoundFunc();if(n!==void 0){const a=n.call(this,s,e);a?s=a:y.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==s.x||this._lastPos.y!==s.y)&&(this.setAbsolutePosition(s),this._requestDraw()),this._lastPos=s}}stopDrag(e){const t=se._dragElements.get(this._id);t&&(t.dragStatus="stopped"),se._endDragBefore(e),se._endDragAfter(e)}setDraggable(e){this._setAttr("draggable",e),this._dragChange()}isDragging(){const e=se._dragElements.get(this._id);return e?e.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(e){var t=e.evt.button!==void 0,r=!t||G.dragButtons.indexOf(e.evt.button)>=0;if(r&&!this.isDragging()){var s=!1;se._dragElements.forEach(n=>{this.isAncestorOf(n.node)&&(s=!0)}),s||this._createDragElement(e)}})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();var e=this.getStage();if(!e)return;const t=se._dragElements.get(this._id),r=t&&t.dragStatus==="dragging",s=t&&t.dragStatus==="ready";r?this.stopDrag():s&&se._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const t=this.getStage();if(!t)return!1;const r={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return y.haveIntersection(r,this.getClientRect())}static create(e,t){return y._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(e,t){var r=P.prototype.getClassName.call(e),s=e.children,n,a,o;t&&(e.attrs.container=t),G[r]||(y.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const h=G[r];if(n=new h(e.attrs),s)for(a=s.length,o=0;o<a;o++)n.add(P._createNode(s[o]));return n}}P.prototype.nodeType="Node";P.prototype._attrsAffectingSize=[];P.prototype.eventListeners={};P.prototype.on.call(P.prototype,bh,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(kt),this._clearSelfAndDescendantCache(ht)});P.prototype.on.call(P.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(Es)});P.prototype.on.call(P.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(Cs)});P.prototype.on.call(P.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(wr)});const ce=v.addGetterSetter;ce(P,"zIndex");ce(P,"absolutePosition");ce(P,"position");ce(P,"x",0,x());ce(P,"y",0,x());ce(P,"globalCompositeOperation","source-over",gi());ce(P,"opacity",1,x());ce(P,"name","",gi());ce(P,"id","",gi());ce(P,"rotation",0,x());v.addComponentsGetterSetter(P,"scale",["x","y"]);ce(P,"scaleX",1,x());ce(P,"scaleY",1,x());v.addComponentsGetterSetter(P,"skew",["x","y"]);ce(P,"skewX",0,x());ce(P,"skewY",0,x());v.addComponentsGetterSetter(P,"offset",["x","y"]);ce(P,"offsetX",0,x());ce(P,"offsetY",0,x());ce(P,"dragDistance",null,x());ce(P,"width",0,x());ce(P,"height",0,x());ce(P,"listening",!0,Ke());ce(P,"preventDefault",!0,Ke());ce(P,"filters",null,function(i){return this._filterUpToDate=!1,i});ce(P,"visible",!0,Ke());ce(P,"transformsEnabled","all",gi());ce(P,"size");ce(P,"dragBoundFunc");ce(P,"draggable",!1,Ke());v.backCompat(P,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class Fe extends P{constructor(){super(...arguments),this.children=[]}getChildren(e){if(!e)return this.children||[];const t=this.children||[];var r=[];return t.forEach(function(s){e(s)&&r.push(s)}),r}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(arguments.length>1){for(var t=0;t<arguments.length;t++)this.add(arguments[t]);return this}var r=e[0];return r.getParent()?(r.moveTo(this),this):(this._validateAdd(r),r.index=this.getChildren().length,r.parent=this,r._clearCaches(),this.getChildren().push(r),this._fire("add",{child:r}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){var t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){var r=[];return this._descendants(s=>{const n=s._isMatch(e);return n&&r.push(s),!!(n&&t)}),r}_descendants(e){let t=!1;const r=this.getChildren();for(const s of r){if(t=e(s),t)return!0;if(s.hasChildren()&&(t=s._descendants(e),t))return!0}return!1}toObject(){var e=P.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){for(var t=e.getParent();t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){var t=P.prototype.clone.call(this,e);return this.getChildren().forEach(function(r){t.add(r.clone())}),t}getAllIntersections(e){var t=[];return this.find("Shape").forEach(function(r){r.isVisible()&&r.intersects(e)&&t.push(r)}),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),!this.isCached()&&((t=this.children)===null||t===void 0||t.forEach(function(r){r._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(t,r){t.index=r}),this._requestDraw()}drawScene(e,t){var r=this.getLayer(),s=e||r&&r.getCanvas(),n=s&&s.getContext(),a=this._getCanvasCache(),o=a&&a.scene,h=s&&s.isCache;if(!this.isVisible()&&!h)return this;if(o){n.save();var l=this.getAbsoluteTransform(t).getMatrix();n.transform(l[0],l[1],l[2],l[3],l[4],l[5]),this._drawCachedSceneCanvas(n),n.restore()}else this._drawChildren("drawScene",s,t);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;var r=this.getLayer(),s=e||r&&r.hitCanvas,n=s&&s.getContext(),a=this._getCanvasCache(),o=a&&a.hit;if(o){n.save();var h=this.getAbsoluteTransform(t).getMatrix();n.transform(h[0],h[1],h[2],h[3],h[4],h[5]),this._drawCachedHitCanvas(n),n.restore()}else this._drawChildren("drawHit",s,t);return this}_drawChildren(e,t,r){var s,n=t&&t.getContext(),a=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l=a&&o||h;const d=r===this;if(l){n.save();var u=this.getAbsoluteTransform(r),c=u.getMatrix();if(n.transform(c[0],c[1],c[2],c[3],c[4],c[5]),n.beginPath(),h)h.call(this,n,this);else{var p=this.clipX(),f=this.clipY();n.rect(p,f,a,o)}n.clip(),c=u.copy().invert().getMatrix(),n.transform(c[0],c[1],c[2],c[3],c[4],c[5])}var m=!d&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";m&&(n.save(),n._applyGlobalCompositeOperation(this)),(s=this.children)===null||s===void 0||s.forEach(function(g){g[e](t,r)}),m&&n.restore(),l&&n.restore()}getClientRect(e){var t;e=e||{};var r=e.skipTransform,s=e.relativeTo,n,a,o,h,l={x:1/0,y:1/0,width:0,height:0},d=this;(t=this.children)===null||t===void 0||t.forEach(function(m){if(m.visible()){var g=m.getClientRect({relativeTo:d,skipShadow:e.skipShadow,skipStroke:e.skipStroke});g.width===0&&g.height===0||(n===void 0?(n=g.x,a=g.y,o=g.x+g.width,h=g.y+g.height):(n=Math.min(n,g.x),a=Math.min(a,g.y),o=Math.max(o,g.x+g.width),h=Math.max(h,g.y+g.height)))}});for(var u=this.find("Shape"),c=!1,p=0;p<u.length;p++){var f=u[p];if(f._isVisible(this)){c=!0;break}}return c&&n!==void 0?l={x:n,y:a,width:o-n,height:h-a}:l={x:0,y:0,width:0,height:0},r?l:this._transformedRect(l,s)}}v.addComponentsGetterSetter(Fe,"clip",["x","y","width","height"]);v.addGetterSetter(Fe,"clipX",void 0,x());v.addGetterSetter(Fe,"clipY",void 0,x());v.addGetterSetter(Fe,"clipWidth",void 0,x());v.addGetterSetter(Fe,"clipHeight",void 0,x());v.addGetterSetter(Fe,"clipFunc");const Gi=new Map,Fa=G._global.PointerEvent!==void 0;function us(i){return Gi.get(i)}function nn(i){return{evt:i,pointerId:i.pointerId}}function Ha(i,e){return Gi.get(i)===e}function Ba(i,e){Ii(i),e.getStage()&&(Gi.set(i,e),Fa&&e._fire("gotpointercapture",nn(new PointerEvent("gotpointercapture"))))}function Ii(i,e){const t=Gi.get(i);if(!t)return;const r=t.getStage();r&&r.content,Gi.delete(i),Fa&&t._fire("lostpointercapture",nn(new PointerEvent("lostpointercapture")))}var wh="Stage",Sh="string",Fn="px",Th="mouseout",$a="mouseleave",Va="mouseover",za="mouseenter",Wa="mousemove",Ua="mousedown",Za="mouseup",Ai="pointermove",Mi="pointerdown",ei="pointerup",Oi="pointercancel",Ch="lostpointercapture",dr="pointerout",ur="pointerleave",cr="pointerover",fr="pointerenter",ks="contextmenu",ja="touchstart",Xa="touchend",qa="touchmove",Ya="touchcancel",xs="wheel",Eh=5,kh=[[za,"_pointerenter"],[Ua,"_pointerdown"],[Wa,"_pointermove"],[Za,"_pointerup"],[$a,"_pointerleave"],[ja,"_pointerdown"],[qa,"_pointermove"],[Xa,"_pointerup"],[Ya,"_pointercancel"],[Va,"_pointerover"],[xs,"_wheel"],[ks,"_contextmenu"],[Mi,"_pointerdown"],[Ai,"_pointermove"],[ei,"_pointerup"],[Oi,"_pointercancel"],[Ch,"_lostpointercapture"]];const cs={mouse:{[dr]:Th,[ur]:$a,[cr]:Va,[fr]:za,[Ai]:Wa,[Mi]:Ua,[ei]:Za,[Oi]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[dr]:"touchout",[ur]:"touchleave",[cr]:"touchover",[fr]:"touchenter",[Ai]:qa,[Mi]:ja,[ei]:Xa,[Oi]:Ya,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[dr]:dr,[ur]:ur,[cr]:cr,[fr]:fr,[Ai]:Ai,[Mi]:Mi,[ei]:ei,[Oi]:Oi,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},Li=i=>i.indexOf("pointer")>=0?"pointer":i.indexOf("touch")>=0?"touch":"mouse",Kt=i=>{const e=Li(i);if(e==="pointer")return G.pointerEventsEnabled&&cs.pointer;if(e==="touch")return cs.touch;if(e==="mouse")return cs.mouse};function Hn(i={}){return(i.clipFunc||i.clipWidth||i.clipHeight)&&y.warn("Stage does not support clipping. Please use clip for Layers or Groups."),i}const xh="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);",Tr=[];class Kr extends Fe{constructor(e){super(Hn(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),Tr.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{Hn(this.attrs)}),this._checkVisibility()}_validateAdd(e){const t=e.getType()==="Layer",r=e.getType()==="FastLayer";t||r||y.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if(typeof e===Sh){if(e.charAt(0)==="."){var t=e.slice(1);e=document.getElementsByClassName(t)[0]}else{var r;e.charAt(0)!=="#"?r=e:r=e.slice(1),e=document.getElementById(r)}if(!e)throw"Can not find container in document with id "+r}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var e=this.children,t=e.length,r;for(r=0;r<t;r++)e[r].clear();return this}clone(e){return e||(e={}),e.container=typeof document<"u"&&document.createElement("div"),Fe.prototype.clone.call(this,e)}destroy(){super.destroy();var e=this.content;e&&y._isInDocument(e)&&this.container().removeChild(e);var t=Tr.indexOf(this);return t>-1&&Tr.splice(t,1),y.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(y.warn(xh),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();var t=new ni({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),r=t.getContext()._context,s=this.children;return(e.x||e.y)&&r.translate(-1*e.x,-1*e.y),s.forEach(function(n){if(n.isVisible()){var a=n._toKonvaCanvas(e);r.drawImage(a._canvas,e.x,e.y,a.getWidth()/a.getPixelRatio(),a.getHeight()/a.getPixelRatio())}}),t}getIntersection(e){if(!e)return null;var t=this.children,r=t.length,s=r-1,n;for(n=s;n>=0;n--){const a=t[n].getIntersection(e);if(a)return a}return null}_resizeDOM(){var e=this.width(),t=this.height();this.content&&(this.content.style.width=e+Fn,this.content.style.height=t+Fn),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach(r=>{r.setSize({width:e,height:t}),r.draw()})}add(e,...t){if(arguments.length>1){for(var r=0;r<arguments.length;r++)this.add(arguments[r]);return this}super.add(e);var s=this.children.length;return s>Eh&&y.warn("The stage has "+s+" 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(),G.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return Ha(e,this)}setPointerCapture(e){Ba(e,this)}releaseCapture(e){Ii(e)}getLayers(){return this.children}_bindContentEvents(){G.isBrowser&&kh.forEach(([e,t])=>{this.content.addEventListener(e,r=>{this[t](r)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=Kt(e.type);this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=Kt(e.type);this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){const t=Kt(e.type),r=Li(e.type);if(t){this.setPointersPositions(e);var s=this._getTargetShape(r),n=!se.isDragging||G.hitOnDragEnabled;s&&n?(s._fireAndBubble(t.pointerout,{evt:e}),s._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[r+"targetShape"]=null):n&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=void 0,this._pointerPositions=[]}}_pointerdown(e){const t=Kt(e.type),r=Li(e.type);if(t){this.setPointersPositions(e);var s=!1;this._changedPointerPositions.forEach(n=>{var a=this.getIntersection(n);if(se.justDragged=!1,G["_"+r+"ListenClick"]=!0,!(a&&a.isListening()))return;G.capturePointerEventsEnabled&&a.setPointerCapture(n.id),this[r+"ClickStartShape"]=a,a._fireAndBubble(t.pointerdown,{evt:e,pointerId:n.id}),s=!0;const h=e.type.indexOf("touch")>=0;a.preventDefault()&&e.cancelable&&h&&e.preventDefault()}),s||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(e){const t=Kt(e.type),r=Li(e.type);if(!t)return;se.isDragging&&se.node.preventDefault()&&e.cancelable&&e.preventDefault(),this.setPointersPositions(e);var s=!se.isDragging||G.hitOnDragEnabled;if(!s)return;var n={};let a=!1;var o=this._getTargetShape(r);this._changedPointerPositions.forEach(h=>{const l=us(h.id)||this.getIntersection(h),d=h.id,u={evt:e,pointerId:d};var c=o!==l;if(c&&o&&(o._fireAndBubble(t.pointerout,Object.assign({},u),l),o._fireAndBubble(t.pointerleave,Object.assign({},u),l)),l){if(n[l._id])return;n[l._id]=!0}l&&l.isListening()?(a=!0,c&&(l._fireAndBubble(t.pointerover,Object.assign({},u),o),l._fireAndBubble(t.pointerenter,Object.assign({},u),o),this[r+"targetShape"]=l),l._fireAndBubble(t.pointermove,Object.assign({},u))):o&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:d}),this[r+"targetShape"]=null)}),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=Kt(e.type),r=Li(e.type);if(!t)return;this.setPointersPositions(e);const s=this[r+"ClickStartShape"],n=this[r+"ClickEndShape"];var a={};let o=!1;this._changedPointerPositions.forEach(h=>{const l=us(h.id)||this.getIntersection(h);if(l){if(l.releaseCapture(h.id),a[l._id])return;a[l._id]=!0}const d=h.id,u={evt:e,pointerId:d};let c=!1;G["_"+r+"InDblClickWindow"]?(c=!0,clearTimeout(this[r+"DblTimeout"])):se.justDragged||(G["_"+r+"InDblClickWindow"]=!0,clearTimeout(this[r+"DblTimeout"])),this[r+"DblTimeout"]=setTimeout(function(){G["_"+r+"InDblClickWindow"]=!1},G.dblClickWindow),l&&l.isListening()?(o=!0,this[r+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,Object.assign({},u)),G["_"+r+"ListenClick"]&&s&&s===l&&(l._fireAndBubble(t.pointerclick,Object.assign({},u)),c&&n&&n===l&&l._fireAndBubble(t.pointerdblclick,Object.assign({},u)))):(this[r+"ClickEndShape"]=null,G["_"+r+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:d}),c&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:d}))}),o||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),G["_"+r+"ListenClick"]=!1,e.cancelable&&r!=="touch"&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(ks,{evt:e}):this._fire(ks,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(xs,{evt:e}):this._fire(xs,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=us(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(ei,nn(e)),Ii(e.pointerId)}_lostpointercapture(e){Ii(e.pointerId)}setPointersPositions(e){var t=this._getContentPosition(),r=null,s=null;e=e||window.event,e.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,n=>{this._pointerPositions.push({id:n.identifier,x:(n.clientX-t.left)/t.scaleX,y:(n.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,n=>{this._changedPointerPositions.push({id:n.identifier,x:(n.clientX-t.left)/t.scaleX,y:(n.clientY-t.top)/t.scaleY})})):(r=(e.clientX-t.left)/t.scaleX,s=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:r,y:s},this._pointerPositions=[{x:r,y:s,id:y._getFirstPointerId(e)}],this._changedPointerPositions=[{x:r,y:s,id:y._getFirstPointerId(e)}])}_setPointerPosition(e){y.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};var e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new ni({width:this.width(),height:this.height()}),this.bufferHitCanvas=new sn({pixelRatio:1,width:this.width(),height:this.height()}),!!G.isBrowser){var e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}}cache(){return y.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}}Kr.prototype.nodeType=wh;ge(Kr);v.addGetterSetter(Kr,"container");var Ka="hasShadow",Ja="shadowRGBA",Qa="patternImage",eo="linearGradient",to="radialGradient";let pr;function fs(){return pr||(pr=y.createCanvasElement().getContext("2d"),pr)}const Ni={};function Ph(i){i.fill()}function Ah(i){i.stroke()}function Mh(i){i.fill()}function Oh(i){i.stroke()}function Lh(){this._clearCache(Ka)}function Rh(){this._clearCache(Ja)}function Ih(){this._clearCache(Qa)}function Nh(){this._clearCache(eo)}function Dh(){this._clearCache(to)}class E extends P{constructor(e){super(e);let t;for(;t=y.getRandomColor(),!(t&&!(t in Ni)););this.colorKey=t,Ni[t]=this}getContext(){return y.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return y.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(Ka,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(Qa,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){var e=fs();const t=e.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const r=new De;r.translate(this.fillPatternX(),this.fillPatternY()),r.rotate(G.getAngle(this.fillPatternRotation())),r.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),r.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const s=r.getMatrix(),n=typeof DOMMatrix>"u"?{a:s[0],b:s[1],c:s[2],d:s[3],e:s[4],f:s[5]}:new DOMMatrix(s);t.setTransform(n)}return t}}_getLinearGradient(){return this._getCache(eo,this.__getLinearGradient)}__getLinearGradient(){var e=this.fillLinearGradientColorStops();if(e){for(var t=fs(),r=this.fillLinearGradientStartPoint(),s=this.fillLinearGradientEndPoint(),n=t.createLinearGradient(r.x,r.y,s.x,s.y),a=0;a<e.length;a+=2)n.addColorStop(e[a],e[a+1]);return n}}_getRadialGradient(){return this._getCache(to,this.__getRadialGradient)}__getRadialGradient(){var e=this.fillRadialGradientColorStops();if(e){for(var t=fs(),r=this.fillRadialGradientStartPoint(),s=this.fillRadialGradientEndPoint(),n=t.createRadialGradient(r.x,r.y,this.fillRadialGradientStartRadius(),s.x,s.y,this.fillRadialGradientEndRadius()),a=0;a<e.length;a+=2)n.addColorStop(e[a],e[a+1]);return n}}getShadowRGBA(){return this._getCache(Ja,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var e=y.colorToRGBA(this.shadowColor());if(e)return"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")"}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const e=this.hitStrokeWidth();return e==="auto"?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){var t=this.getStage(),r=t.bufferHitCanvas,s;return r.getContext().clear(),this.drawHit(r,null,!0),s=r.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data,s[3]>0}destroy(){return P.prototype.destroy.call(this),delete Ni[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!this.getStage()||!((t=this.attrs.perfectDrawEnabled)!==null&&t!==void 0?t:!0))return!1;const s=e||this.hasFill(),n=this.hasStroke(),a=this.getAbsoluteOpacity()!==1;if(s&&n&&a)return!0;const o=this.hasShadow(),h=this.shadowForStrokeEnabled();return!!(s&&n&&o&&h)}setStrokeHitEnabled(e){y.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){var e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){const t=e.skipTransform,r=e.relativeTo,s=this.getSelfRect(),a=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=s.width+a,h=s.height+a,l=!e.skipShadow&&this.hasShadow(),d=l?this.shadowOffsetX():0,u=l?this.shadowOffsetY():0,c=o+Math.abs(d),p=h+Math.abs(u),f=l&&this.shadowBlur()||0,m=c+f*2,g=p+f*2,_={width:m,height:g,x:-(a/2+f)+Math.min(d,0)+s.x,y:-(a/2+f)+Math.min(u,0)+s.y};return t?_:this._transformedRect(_,r)}drawScene(e,t){var r=this.getLayer(),s=e||r.getCanvas(),n=s.getContext(),a=this._getCanvasCache(),o=this.getSceneFunc(),h=this.hasShadow(),l,d,u,c=s.isCache,p=t===this;if(!this.isVisible()&&!p)return this;if(a){n.save();var f=this.getAbsoluteTransform(t).getMatrix();return n.transform(f[0],f[1],f[2],f[3],f[4],f[5]),this._drawCachedSceneCanvas(n),n.restore(),this}if(!o)return this;if(n.save(),this._useBufferCanvas()&&!c){l=this.getStage(),d=l.bufferCanvas,u=d.getContext(),u.clear(),u.save(),u._applyLineJoin(this);var m=this.getAbsoluteTransform(t).getMatrix();u.transform(m[0],m[1],m[2],m[3],m[4],m[5]),o.call(this,u,this),u.restore();var g=d.pixelRatio;h&&n._applyShadow(this),n._applyOpacity(this),n._applyGlobalCompositeOperation(this),n.drawImage(d._canvas,0,0,d.width/g,d.height/g)}else{if(n._applyLineJoin(this),!p){var m=this.getAbsoluteTransform(t).getMatrix();n.transform(m[0],m[1],m[2],m[3],m[4],m[5]),n._applyOpacity(this),n._applyGlobalCompositeOperation(this)}h&&n._applyShadow(this),o.call(this,n,this)}return n.restore(),this}drawHit(e,t,r=!1){if(!this.shouldDrawHit(t,r))return this;var s=this.getLayer(),n=e||s.hitCanvas,a=n&&n.getContext(),o=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||y.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){a.save();var d=this.getAbsoluteTransform(t).getMatrix();return a.transform(d[0],d[1],d[2],d[3],d[4],d[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!o)return this;if(a.save(),a._applyLineJoin(this),!(this===t)){var c=this.getAbsoluteTransform(t).getMatrix();a.transform(c[0],c[1],c[2],c[3],c[4],c[5])}return o.call(this,a,this),a.restore(),this}drawHitFromCache(e=0){var t=this._getCanvasCache(),r=this._getCachedSceneCanvas(),s=t.hit,n=s.getContext(),a=s.getWidth(),o=s.getHeight(),h,l,d,u,c,p;n.clear(),n.drawImage(r._canvas,0,0,a,o);try{for(h=n.getImageData(0,0,a,o),l=h.data,d=l.length,u=y._hexToRgb(this.colorKey),c=0;c<d;c+=4)p=l[c+3],p>e?(l[c]=u.r,l[c+1]=u.g,l[c+2]=u.b,l[c+3]=255):l[c+3]=0;n.putImageData(h,0,0)}catch(f){y.error("Unable to draw hit graph from cached scene canvas. "+f.message)}return this}hasPointerCapture(e){return Ha(e,this)}setPointerCapture(e){Ba(e,this)}releaseCapture(e){Ii(e)}}E.prototype._fillFunc=Ph;E.prototype._strokeFunc=Ah;E.prototype._fillFuncHit=Mh;E.prototype._strokeFuncHit=Oh;E.prototype._centroid=!1;E.prototype.nodeType="Shape";ge(E);E.prototype.eventListeners={};E.prototype.on.call(E.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",Lh);E.prototype.on.call(E.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",Rh);E.prototype.on.call(E.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",Ih);E.prototype.on.call(E.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",Nh);E.prototype.on.call(E.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",Dh);v.addGetterSetter(E,"stroke",void 0,Ga());v.addGetterSetter(E,"strokeWidth",2,x());v.addGetterSetter(E,"fillAfterStrokeEnabled",!1);v.addGetterSetter(E,"hitStrokeWidth","auto",rn());v.addGetterSetter(E,"strokeHitEnabled",!0,Ke());v.addGetterSetter(E,"perfectDrawEnabled",!0,Ke());v.addGetterSetter(E,"shadowForStrokeEnabled",!0,Ke());v.addGetterSetter(E,"lineJoin");v.addGetterSetter(E,"lineCap");v.addGetterSetter(E,"sceneFunc");v.addGetterSetter(E,"hitFunc");v.addGetterSetter(E,"dash");v.addGetterSetter(E,"dashOffset",0,x());v.addGetterSetter(E,"shadowColor",void 0,gi());v.addGetterSetter(E,"shadowBlur",0,x());v.addGetterSetter(E,"shadowOpacity",1,x());v.addComponentsGetterSetter(E,"shadowOffset",["x","y"]);v.addGetterSetter(E,"shadowOffsetX",0,x());v.addGetterSetter(E,"shadowOffsetY",0,x());v.addGetterSetter(E,"fillPatternImage");v.addGetterSetter(E,"fill",void 0,Ga());v.addGetterSetter(E,"fillPatternX",0,x());v.addGetterSetter(E,"fillPatternY",0,x());v.addGetterSetter(E,"fillLinearGradientColorStops");v.addGetterSetter(E,"strokeLinearGradientColorStops");v.addGetterSetter(E,"fillRadialGradientStartRadius",0);v.addGetterSetter(E,"fillRadialGradientEndRadius",0);v.addGetterSetter(E,"fillRadialGradientColorStops");v.addGetterSetter(E,"fillPatternRepeat","repeat");v.addGetterSetter(E,"fillEnabled",!0);v.addGetterSetter(E,"strokeEnabled",!0);v.addGetterSetter(E,"shadowEnabled",!0);v.addGetterSetter(E,"dashEnabled",!0);v.addGetterSetter(E,"strokeScaleEnabled",!0);v.addGetterSetter(E,"fillPriority","color");v.addComponentsGetterSetter(E,"fillPatternOffset",["x","y"]);v.addGetterSetter(E,"fillPatternOffsetX",0,x());v.addGetterSetter(E,"fillPatternOffsetY",0,x());v.addComponentsGetterSetter(E,"fillPatternScale",["x","y"]);v.addGetterSetter(E,"fillPatternScaleX",1,x());v.addGetterSetter(E,"fillPatternScaleY",1,x());v.addComponentsGetterSetter(E,"fillLinearGradientStartPoint",["x","y"]);v.addComponentsGetterSetter(E,"strokeLinearGradientStartPoint",["x","y"]);v.addGetterSetter(E,"fillLinearGradientStartPointX",0);v.addGetterSetter(E,"strokeLinearGradientStartPointX",0);v.addGetterSetter(E,"fillLinearGradientStartPointY",0);v.addGetterSetter(E,"strokeLinearGradientStartPointY",0);v.addComponentsGetterSetter(E,"fillLinearGradientEndPoint",["x","y"]);v.addComponentsGetterSetter(E,"strokeLinearGradientEndPoint",["x","y"]);v.addGetterSetter(E,"fillLinearGradientEndPointX",0);v.addGetterSetter(E,"strokeLinearGradientEndPointX",0);v.addGetterSetter(E,"fillLinearGradientEndPointY",0);v.addGetterSetter(E,"strokeLinearGradientEndPointY",0);v.addComponentsGetterSetter(E,"fillRadialGradientStartPoint",["x","y"]);v.addGetterSetter(E,"fillRadialGradientStartPointX",0);v.addGetterSetter(E,"fillRadialGradientStartPointY",0);v.addComponentsGetterSetter(E,"fillRadialGradientEndPoint",["x","y"]);v.addGetterSetter(E,"fillRadialGradientEndPointX",0);v.addGetterSetter(E,"fillRadialGradientEndPointY",0);v.addGetterSetter(E,"fillPatternRotation",0);v.backCompat(E,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var Gh="#",Fh="beforeDraw",Hh="draw",io=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],Bh=io.length;class Zt extends Fe{constructor(e){super(e),this.canvas=new ni,this.hitCanvas=new sn({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);var 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(){P.prototype.moveToTop.call(this);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){var e=P.prototype.moveUp.call(this);if(!e)return!1;var t=this.getStage();return!t||!t.content?!1:(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(P.prototype.moveDown.call(this)){var e=this.getStage();if(e){var 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(P.prototype.moveToBottom.call(this)){var e=this.getStage();if(e){var 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=this.getNativeCanvasElement();return P.prototype.remove.call(this),e&&e.parentNode&&y._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){var t=e.getType();t!=="Group"&&t!=="Shape"&&y.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?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),P.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(){y.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){y.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,y.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;for(var t=1,r=!1;;){for(let s=0;s<Bh;s++){const n=io[s],a=this._getIntersection({x:e.x+n.x*t,y:e.y+n.y*t}),o=a.shape;if(o)return o;if(r=!!a.antialiased,!a.antialiased)break}if(r)t+=1;else return null}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,r=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,s=r[3];if(s===255){const n=y._rgbToHex(r[0],r[1],r[2]),a=Ni[Gh+n];return a?{shape:a}:{antialiased:!0}}else if(s>0)return{antialiased:!0};return{}}drawScene(e,t){var r=this.getLayer(),s=e||r&&r.getCanvas();return this._fire(Fh,{node:this}),this.clearBeforeDraw()&&s.getContext().clear(),Fe.prototype.drawScene.call(this,s,t),this._fire(Hh,{node:this}),this}drawHit(e,t){var r=this.getLayer(),s=e||r&&r.hitCanvas;return r&&r.clearBeforeDraw()&&r.getHitCanvas().getContext().clear(),Fe.prototype.drawHit.call(this,s,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){y.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return y.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!(!this.parent||!this.parent.content)){var e=this.parent,t=!!this.hitCanvas._canvas.parentNode;t?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}}destroy(){return y.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}Zt.prototype.nodeType="Layer";ge(Zt);v.addGetterSetter(Zt,"imageSmoothingEnabled",!0);v.addGetterSetter(Zt,"clearBeforeDraw",!0);v.addGetterSetter(Zt,"hitGraphEnabled",!0,Ke());class an extends Zt{constructor(e){super(e),this.listening(!1),y.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}an.prototype.nodeType="FastLayer";ge(an);class hi extends Fe{_validateAdd(e){var t=e.getType();t!=="Group"&&t!=="Shape"&&y.throw("You may only add groups and shapes to groups.")}}hi.prototype.nodeType="Group";ge(hi);var ps=function(){return si.performance&&si.performance.now?function(){return si.performance.now()}:function(){return new Date().getTime()}}();class ze{constructor(e,t){this.id=ze.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:ps(),frameRate:0},this.func=e,this.setLayers(t)}setLayers(e){var t=[];return e?e.length>0?t=e:t=[e]:t=[],this.layers=t,this}getLayers(){return this.layers}addLayer(e){var t=this.layers,r=t.length,s;for(s=0;s<r;s++)if(t[s]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){var e=ze,t=e.animations,r=t.length,s;for(s=0;s<r;s++)if(t[s].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=ps(),ze._addAnimation(this),this}stop(){return ze._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){var t=e.id,r=this.animations,s=r.length,n;for(n=0;n<s;n++)if(r[n].id===t){this.animations.splice(n,1);break}}static _runFrames(){var e={},t=this.animations,r,s,n,a,o,h,l,d,u;for(a=0;a<t.length;a++)if(r=t[a],s=r.layers,n=r.func,r._updateFrameObject(ps()),h=s.length,n?u=n.call(r,r.frame)!==!1:u=!0,!!u)for(o=0;o<h;o++)l=s[o],l._id!==void 0&&(e[l._id]=l);for(d in e)e.hasOwnProperty(d)&&e[d].batchDraw()}static _animationLoop(){var e=ze;e.animations.length?(e._runFrames(),y.requestAnimFrame(e._animationLoop)):e.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,y.requestAnimFrame(this._animationLoop))}}ze.animations=[];ze.animIdCounter=0;ze.animRunning=!1;var $h={node:1,duration:1,easing:1,onFinish:1,yoyo:1},Vh=1,Bn=2,$n=3,zh=0,Vn=["fill","stroke","shadowColor"];class Wh{constructor(e,t,r,s,n,a,o){this.prop=e,this.propFunc=t,this.begin=s,this._pos=s,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=r,this._change=n-this.begin,this.pause()}fire(e){var 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=Bn,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=$n,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var e=this.getTimer()-this._startTime;this.state===Bn?this.setTime(e):this.state===$n&&this.setTime(this.duration-e)}pause(){this.state=Vh,this.fire("onPause")}getTimer(){return new Date().getTime()}}class ye{constructor(e){var t=this,r=e.node,s=r._id,n,a=e.easing||Di.Linear,o=!!e.yoyo,h;typeof e.duration>"u"?n=.3:e.duration===0?n=.001:n=e.duration,this.node=r,this._id=zh++;var l=r.getLayer()||(r instanceof G.Stage?r.getLayers():null);l||y.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new ze(function(){t.tween.onEnterFrame()},l),this.tween=new Wh(h,function(d){t._tweenFunc(d)},a,0,1,n*1e3,o),this._addListeners(),ye.attrs[s]||(ye.attrs[s]={}),ye.attrs[s][this._id]||(ye.attrs[s][this._id]={}),ye.tweens[s]||(ye.tweens[s]={});for(h in e)$h[h]===void 0&&this._addAttr(h,e[h]);this.reset(),this.onFinish=e.onFinish,this.onReset=e.onReset,this.onUpdate=e.onUpdate}_addAttr(e,t){var r=this.node,s=r._id,n,a,o,h,l,d,u,c;if(o=ye.tweens[s][e],o&&delete ye.attrs[s][o][e],n=r.getAttr(e),y._isArray(t))if(a=[],l=Math.max(t.length,n.length),e==="points"&&t.length!==n.length&&(t.length>n.length?(u=n,n=y._prepareArrayForTween(n,t,r.closed())):(d=t,t=y._prepareArrayForTween(t,n,r.closed()))),e.indexOf("fill")===0)for(h=0;h<l;h++)if(h%2===0)a.push(t[h]-n[h]);else{var p=y.colorToRGBA(n[h]);c=y.colorToRGBA(t[h]),n[h]=p,a.push({r:c.r-p.r,g:c.g-p.g,b:c.b-p.b,a:c.a-p.a})}else for(h=0;h<l;h++)a.push(t[h]-n[h]);else Vn.indexOf(e)!==-1?(n=y.colorToRGBA(n),c=y.colorToRGBA(t),a={r:c.r-n.r,g:c.g-n.g,b:c.b-n.b,a:c.a-n.a}):a=t-n;ye.attrs[s][this._id][e]={start:n,diff:a,end:t,trueEnd:d,trueStart:u},ye.tweens[s][e]=this._id}_tweenFunc(e){var t=this.node,r=ye.attrs[t._id][this._id],s,n,a,o,h,l,d,u;for(s in r){if(n=r[s],a=n.start,o=n.diff,u=n.end,y._isArray(a))if(h=[],d=Math.max(a.length,u.length),s.indexOf("fill")===0)for(l=0;l<d;l++)l%2===0?h.push((a[l]||0)+o[l]*e):h.push("rgba("+Math.round(a[l].r+o[l].r*e)+","+Math.round(a[l].g+o[l].g*e)+","+Math.round(a[l].b+o[l].b*e)+","+(a[l].a+o[l].a*e)+")");else for(l=0;l<d;l++)h.push((a[l]||0)+o[l]*e);else Vn.indexOf(s)!==-1?h="rgba("+Math.round(a.r+o.r*e)+","+Math.round(a.g+o.g*e)+","+Math.round(a.b+o.b*e)+","+(a.a+o.a*e)+")":h=a+o*e;t.setAttr(s,h)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var e=this.node,t=ye.attrs[e._id][this._id];t.points&&t.points.trueEnd&&e.setAttr("points",t.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var e=this.node,t=ye.attrs[e._id][this._id];t.points&&t.points.trueStart&&e.points(t.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(e*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var e=this.node._id,t=this._id,r=ye.tweens[e],s;this.pause();for(s in r)delete ye.tweens[e][s];delete ye.attrs[e][t]}}ye.attrs={};ye.tweens={};P.prototype.to=function(i){var e=i.onFinish;i.node=this,i.onFinish=function(){this.destroy(),e&&e()};var t=new ye(i);t.play()};const Di={BackEaseIn(i,e,t,r){var s=1.70158;return t*(i/=r)*i*((s+1)*i-s)+e},BackEaseOut(i,e,t,r){var s=1.70158;return t*((i=i/r-1)*i*((s+1)*i+s)+1)+e},BackEaseInOut(i,e,t,r){var s=1.70158;return(i/=r/2)<1?t/2*(i*i*(((s*=1.525)+1)*i-s))+e:t/2*((i-=2)*i*(((s*=1.525)+1)*i+s)+2)+e},ElasticEaseIn(i,e,t,r,s,n){var a=0;return i===0?e:(i/=r)===1?e+t:(n||(n=r*.3),!s||s<Math.abs(t)?(s=t,a=n/4):a=n/(2*Math.PI)*Math.asin(t/s),-(s*Math.pow(2,10*(i-=1))*Math.sin((i*r-a)*(2*Math.PI)/n))+e)},ElasticEaseOut(i,e,t,r,s,n){var a=0;return i===0?e:(i/=r)===1?e+t:(n||(n=r*.3),!s||s<Math.abs(t)?(s=t,a=n/4):a=n/(2*Math.PI)*Math.asin(t/s),s*Math.pow(2,-10*i)*Math.sin((i*r-a)*(2*Math.PI)/n)+t+e)},ElasticEaseInOut(i,e,t,r,s,n){var a=0;return i===0?e:(i/=r/2)===2?e+t:(n||(n=r*(.3*1.5)),!s||s<Math.abs(t)?(s=t,a=n/4):a=n/(2*Math.PI)*Math.asin(t/s),i<1?-.5*(s*Math.pow(2,10*(i-=1))*Math.sin((i*r-a)*(2*Math.PI)/n))+e:s*Math.pow(2,-10*(i-=1))*Math.sin((i*r-a)*(2*Math.PI)/n)*.5+t+e)},BounceEaseOut(i,e,t,r){return(i/=r)<1/2.75?t*(7.5625*i*i)+e:i<2/2.75?t*(7.5625*(i-=1.5/2.75)*i+.75)+e:i<2.5/2.75?t*(7.5625*(i-=2.25/2.75)*i+.9375)+e:t*(7.5625*(i-=2.625/2.75)*i+.984375)+e},BounceEaseIn(i,e,t,r){return t-Di.BounceEaseOut(r-i,0,t,r)+e},BounceEaseInOut(i,e,t,r){return i<r/2?Di.BounceEaseIn(i*2,0,t,r)*.5+e:Di.BounceEaseOut(i*2-r,0,t,r)*.5+t*.5+e},EaseIn(i,e,t,r){return t*(i/=r)*i+e},EaseOut(i,e,t,r){return-t*(i/=r)*(i-2)+e},EaseInOut(i,e,t,r){return(i/=r/2)<1?t/2*i*i+e:-t/2*(--i*(i-2)-1)+e},StrongEaseIn(i,e,t,r){return t*(i/=r)*i*i*i*i+e},StrongEaseOut(i,e,t,r){return t*((i=i/r-1)*i*i*i*i+1)+e},StrongEaseInOut(i,e,t,r){return(i/=r/2)<1?t/2*i*i*i*i*i+e:t/2*((i-=2)*i*i*i*i+2)+e},Linear(i,e,t,r){return t*i/r+e}},zn=y._assign(G,{Util:y,Transform:De,Node:P,Container:Fe,Stage:Kr,stages:Tr,Layer:Zt,FastLayer:an,Group:hi,DD:se,Shape:E,shapes:Ni,Animation:ze,Tween:ye,Easings:Di,Context:qr,Canvas:Yr});class yt extends E{_sceneFunc(e){var t=G.getAngle(this.angle()),r=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,r),e.arc(0,0,this.innerRadius(),t,0,!r),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),t=this.outerRadius(),r=this.clockwise(),s=G.getAngle(r?360-this.angle():this.angle()),n=Math.cos(Math.min(s,Math.PI)),a=1,o=Math.sin(Math.min(Math.max(Math.PI,s),3*Math.PI/2)),h=Math.sin(Math.min(s,Math.PI/2)),l=n*(n>0?e:t),d=a*t,u=o*(o>0?e:t),c=h*(h>0?t:e);return{x:l,y:r?-1*c:u,width:d-l,height:c-u}}}yt.prototype._centroid=!0;yt.prototype.className="Arc";yt.prototype._attrsAffectingSize=["innerRadius","outerRadius"];ge(yt);v.addGetterSetter(yt,"innerRadius",0,x());v.addGetterSetter(yt,"outerRadius",0,x());v.addGetterSetter(yt,"angle",0,x());v.addGetterSetter(yt,"clockwise",!1,Ke());function Ps(i,e,t,r,s,n,a){var o=Math.sqrt(Math.pow(t-i,2)+Math.pow(r-e,2)),h=Math.sqrt(Math.pow(s-t,2)+Math.pow(n-r,2)),l=a*o/(o+h),d=a*h/(o+h),u=t-l*(s-i),c=r-l*(n-e),p=t+d*(s-i),f=r+d*(n-e);return[u,c,p,f]}function Wn(i,e){var t=i.length,r=[],s,n;for(s=2;s<t-2;s+=2)n=Ps(i[s-2],i[s-1],i[s],i[s+1],i[s+2],i[s+3],e),!isNaN(n[0])&&(r.push(n[0]),r.push(n[1]),r.push(i[s]),r.push(i[s+1]),r.push(n[2]),r.push(n[3]));return r}class bt extends E{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){var t=this.points(),r=t.length,s=this.tension(),n=this.closed(),a=this.bezier(),o,h,l;if(r){if(e.beginPath(),e.moveTo(t[0],t[1]),s!==0&&r>4){for(o=this.getTensionPoints(),h=o.length,l=n?0:4,n||e.quadraticCurveTo(o[0],o[1],o[2],o[3]);l<h-2;)e.bezierCurveTo(o[l++],o[l++],o[l++],o[l++],o[l++],o[l++]);n||e.quadraticCurveTo(o[h-2],o[h-1],t[r-2],t[r-1])}else if(a)for(l=2;l<r;)e.bezierCurveTo(t[l++],t[l++],t[l++],t[l++],t[l++],t[l++]);else for(l=2;l<r;l+=2)e.lineTo(t[l],t[l+1]);n?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Wn(this.points(),this.tension())}_getTensionPointsClosed(){var e=this.points(),t=e.length,r=this.tension(),s=Ps(e[t-2],e[t-1],e[0],e[1],e[2],e[3],r),n=Ps(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],r),a=Wn(e,r),o=[s[2],s[3]].concat(a).concat([n[0],n[1],e[t-2],e[t-1],n[2],n[3],s[0],s[1],e[0],e[1]]);return o}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};this.tension()!==0?e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:e=this.points();for(var t=e[0],r=e[0],s=e[1],n=e[1],a,o,h=0;h<e.length/2;h++)a=e[h*2],o=e[h*2+1],t=Math.min(t,a),r=Math.max(r,a),s=Math.min(s,o),n=Math.max(n,o);return{x:t,y:s,width:r-t,height:n-s}}}bt.prototype.className="Line";bt.prototype._attrsAffectingSize=["points","bezier","tension"];ge(bt);v.addGetterSetter(bt,"closed",!1);v.addGetterSetter(bt,"bezier",!1);v.addGetterSetter(bt,"tension",0,x());v.addGetterSetter(bt,"points",[],eh());class he extends E{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this.dataArray=he.parsePathData(this.data()),this.pathLength=0;for(var t=0;t<this.dataArray.length;++t)this.pathLength+=this.dataArray[t].pathLength;this.on("dataChange.konva",function(){this.dataArray=he.parsePathData(this.data()),this.pathLength=0;for(var r=0;r<this.dataArray.length;++r)this.pathLength+=this.dataArray[r].pathLength})}_sceneFunc(e){var t=this.dataArray;e.beginPath();for(var r=!1,s=0;s<t.length;s++){var n=t[s].command,a=t[s].points;switch(n){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":var o=a[0],h=a[1],l=a[2],d=a[3],u=a[4],c=a[5],p=a[6],f=a[7],m=l>d?l:d,g=l>d?1:l/d,_=l>d?d/l:1;e.translate(o,h),e.rotate(p),e.scale(g,_),e.arc(0,0,m,u,u+c,1-f),e.scale(1/g,1/_),e.rotate(-p),e.translate(-o,-h);break;case"z":r=!0,e.closePath();break}}!r&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getSelfRect(){var e=[];this.dataArray.forEach(function(l){if(l.command==="A"){var d=l.points[4],u=l.points[5],c=l.points[4]+u,p=Math.PI/180;if(Math.abs(d-c)<p&&(p=Math.abs(d-c)),u<0)for(let f=d-p;f>c;f-=p){const m=he.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],f,0);e.push(m.x,m.y)}else for(let f=d+p;f<c;f+=p){const m=he.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],f,0);e.push(m.x,m.y)}}else if(l.command==="C")for(let f=0;f<=1;f+=.01){const m=he.getPointOnCubicBezier(f,l.start.x,l.start.y,l.points[0],l.points[1],l.points[2],l.points[3],l.points[4],l.points[5]);e.push(m.x,m.y)}else e=e.concat(l.points)});for(var t=e[0],r=e[0],s=e[1],n=e[1],a,o,h=0;h<e.length/2;h++)a=e[h*2],o=e[h*2+1],isNaN(a)||(t=Math.min(t,a),r=Math.max(r,a)),isNaN(o)||(s=Math.min(s,o),n=Math.max(n,o));return{x:t,y:s,width:r-t,height:n-s}}getLength(){return this.pathLength}getPointAtLength(e){var t,r=0,s=this.dataArray.length;if(!s)return null;for(;r<s&&e>this.dataArray[r].pathLength;)e-=this.dataArray[r].pathLength,++r;if(r===s)return t=this.dataArray[r-1].points.slice(-2),{x:t[0],y:t[1]};if(e<.01)return t=this.dataArray[r].points.slice(0,2),{x:t[0],y:t[1]};var n=this.dataArray[r],a=n.points;switch(n.command){case"L":return he.getPointOnLine(e,n.start.x,n.start.y,a[0],a[1]);case"C":return he.getPointOnCubicBezier(e/n.pathLength,n.start.x,n.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return he.getPointOnQuadraticBezier(e/n.pathLength,n.start.x,n.start.y,a[0],a[1],a[2],a[3]);case"A":var o=a[0],h=a[1],l=a[2],d=a[3],u=a[4],c=a[5],p=a[6];return u+=c*e/n.pathLength,he.getPointOnEllipticalArc(o,h,l,d,u,p)}return null}static getLineLength(e,t,r,s){return Math.sqrt((r-e)*(r-e)+(s-t)*(s-t))}static getPointOnLine(e,t,r,s,n,a,o){a===void 0&&(a=t),o===void 0&&(o=r);var h=(n-r)/(s-t+1e-8),l=Math.sqrt(e*e/(1+h*h));s<t&&(l*=-1);var d=h*l,u;if(s===t)u={x:a,y:o+d};else if((o-r)/(a-t+1e-8)===h)u={x:a+l,y:o+d};else{var c,p,f=this.getLineLength(t,r,s,n),m=(a-t)*(s-t)+(o-r)*(n-r);m=m/(f*f),c=t+m*(s-t),p=r+m*(n-r);var g=this.getLineLength(a,o,c,p),_=Math.sqrt(e*e-g*g);l=Math.sqrt(_*_/(1+h*h)),s<t&&(l*=-1),d=h*l,u={x:c+l,y:p+d}}return u}static getPointOnCubicBezier(e,t,r,s,n,a,o,h,l){function d(g){return g*g*g}function u(g){return 3*g*g*(1-g)}function c(g){return 3*g*(1-g)*(1-g)}function p(g){return(1-g)*(1-g)*(1-g)}var f=h*d(e)+a*u(e)+s*c(e)+t*p(e),m=l*d(e)+o*u(e)+n*c(e)+r*p(e);return{x:f,y:m}}static getPointOnQuadraticBezier(e,t,r,s,n,a,o){function h(p){return p*p}function l(p){return 2*p*(1-p)}function d(p){return(1-p)*(1-p)}var u=a*h(e)+s*l(e)+t*d(e),c=o*h(e)+n*l(e)+r*d(e);return{x:u,y:c}}static getPointOnEllipticalArc(e,t,r,s,n,a){var o=Math.cos(a),h=Math.sin(a),l={x:r*Math.cos(n),y:s*Math.sin(n)};return{x:e+(l.x*o-l.y*h),y:t+(l.x*h+l.y*o)}}static parsePathData(e){if(!e)return[];var t=e,r=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];t=t.replace(new RegExp(" ","g"),",");for(var s=0;s<r.length;s++)t=t.replace(new RegExp(r[s],"g"),"|"+r[s]);var n=t.split("|"),a=[],o=[],h=0,l=0,d=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,u;for(s=1;s<n.length;s++){var c=n[s],p=c.charAt(0);for(c=c.slice(1),o.length=0;u=d.exec(c);)o.push(u[0]);for(var f=[],m=0,g=o.length;m<g;m++){if(o[m]==="00"){f.push(0,0);continue}var _=parseFloat(o[m]);isNaN(_)?f.push(0):f.push(_)}for(;f.length>0&&!isNaN(f[0]);){var w=null,b=[],T=h,L=l,A,D,R,H,$,I,K,W,le,ne;switch(p){case"l":h+=f.shift(),l+=f.shift(),w="L",b.push(h,l);break;case"L":h=f.shift(),l=f.shift(),b.push(h,l);break;case"m":var U=f.shift(),we=f.shift();if(h+=U,l+=we,w="M",a.length>2&&a[a.length-1].command==="z"){for(var Re=a.length-2;Re>=0;Re--)if(a[Re].command==="M"){h=a[Re].points[0]+U,l=a[Re].points[1]+we;break}}b.push(h,l),p="l";break;case"M":h=f.shift(),l=f.shift(),w="M",b.push(h,l),p="L";break;case"h":h+=f.shift(),w="L",b.push(h,l);break;case"H":h=f.shift(),w="L",b.push(h,l);break;case"v":l+=f.shift(),w="L",b.push(h,l);break;case"V":l=f.shift(),w="L",b.push(h,l);break;case"C":b.push(f.shift(),f.shift(),f.shift(),f.shift()),h=f.shift(),l=f.shift(),b.push(h,l);break;case"c":b.push(h+f.shift(),l+f.shift(),h+f.shift(),l+f.shift()),h+=f.shift(),l+=f.shift(),w="C",b.push(h,l);break;case"S":D=h,R=l,A=a[a.length-1],A.command==="C"&&(D=h+(h-A.points[2]),R=l+(l-A.points[3])),b.push(D,R,f.shift(),f.shift()),h=f.shift(),l=f.shift(),w="C",b.push(h,l);break;case"s":D=h,R=l,A=a[a.length-1],A.command==="C"&&(D=h+(h-A.points[2]),R=l+(l-A.points[3])),b.push(D,R,h+f.shift(),l+f.shift()),h+=f.shift(),l+=f.shift(),w="C",b.push(h,l);break;case"Q":b.push(f.shift(),f.shift()),h=f.shift(),l=f.shift(),b.push(h,l);break;case"q":b.push(h+f.shift(),l+f.shift()),h+=f.shift(),l+=f.shift(),w="Q",b.push(h,l);break;case"T":D=h,R=l,A=a[a.length-1],A.command==="Q"&&(D=h+(h-A.points[0]),R=l+(l-A.points[1])),h=f.shift(),l=f.shift(),w="Q",b.push(D,R,h,l);break;case"t":D=h,R=l,A=a[a.length-1],A.command==="Q"&&(D=h+(h-A.points[0]),R=l+(l-A.points[1])),h+=f.shift(),l+=f.shift(),w="Q",b.push(D,R,h,l);break;case"A":H=f.shift(),$=f.shift(),I=f.shift(),K=f.shift(),W=f.shift(),le=h,ne=l,h=f.shift(),l=f.shift(),w="A",b=this.convertEndpointToCenterParameterization(le,ne,h,l,K,W,H,$,I);break;case"a":H=f.shift(),$=f.shift(),I=f.shift(),K=f.shift(),W=f.shift(),le=h,ne=l,h+=f.shift(),l+=f.shift(),w="A",b=this.convertEndpointToCenterParameterization(le,ne,h,l,K,W,H,$,I);break}a.push({command:w||p,points:b,start:{x:T,y:L},pathLength:this.calcLength(T,L,w||p,b)})}(p==="z"||p==="Z")&&a.push({command:"z",points:[],start:void 0,pathLength:0})}return a}static calcLength(e,t,r,s){var n,a,o,h,l=he;switch(r){case"L":return l.getLineLength(e,t,s[0],s[1]);case"C":for(n=0,a=l.getPointOnCubicBezier(0,e,t,s[0],s[1],s[2],s[3],s[4],s[5]),h=.01;h<=1;h+=.01)o=l.getPointOnCubicBezier(h,e,t,s[0],s[1],s[2],s[3],s[4],s[5]),n+=l.getLineLength(a.x,a.y,o.x,o.y),a=o;return n;case"Q":for(n=0,a=l.getPointOnQuadraticBezier(0,e,t,s[0],s[1],s[2],s[3]),h=.01;h<=1;h+=.01)o=l.getPointOnQuadraticBezier(h,e,t,s[0],s[1],s[2],s[3]),n+=l.getLineLength(a.x,a.y,o.x,o.y),a=o;return n;case"A":n=0;var d=s[4],u=s[5],c=s[4]+u,p=Math.PI/180;if(Math.abs(d-c)<p&&(p=Math.abs(d-c)),a=l.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],d,0),u<0)for(h=d-p;h>c;h-=p)o=l.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],h,0),n+=l.getLineLength(a.x,a.y,o.x,o.y),a=o;else for(h=d+p;h<c;h+=p)o=l.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],h,0),n+=l.getLineLength(a.x,a.y,o.x,o.y),a=o;return o=l.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],c,0),n+=l.getLineLength(a.x,a.y,o.x,o.y),n}return 0}static convertEndpointToCenterParameterization(e,t,r,s,n,a,o,h,l){var d=l*(Math.PI/180),u=Math.cos(d)*(e-r)/2+Math.sin(d)*(t-s)/2,c=-1*Math.sin(d)*(e-r)/2+Math.cos(d)*(t-s)/2,p=u*u/(o*o)+c*c/(h*h);p>1&&(o*=Math.sqrt(p),h*=Math.sqrt(p));var f=Math.sqrt((o*o*(h*h)-o*o*(c*c)-h*h*(u*u))/(o*o*(c*c)+h*h*(u*u)));n===a&&(f*=-1),isNaN(f)&&(f=0);var m=f*o*c/h,g=f*-h*u/o,_=(e+r)/2+Math.cos(d)*m-Math.sin(d)*g,w=(t+s)/2+Math.sin(d)*m+Math.cos(d)*g,b=function($){return Math.sqrt($[0]*$[0]+$[1]*$[1])},T=function($,I){return($[0]*I[0]+$[1]*I[1])/(b($)*b(I))},L=function($,I){return($[0]*I[1]<$[1]*I[0]?-1:1)*Math.acos(T($,I))},A=L([1,0],[(u-m)/o,(c-g)/h]),D=[(u-m)/o,(c-g)/h],R=[(-1*u-m)/o,(-1*c-g)/h],H=L(D,R);return T(D,R)<=-1&&(H=Math.PI),T(D,R)>=1&&(H=0),a===0&&H>0&&(H=H-2*Math.PI),a===1&&H<0&&(H=H+2*Math.PI),[_,w,o,h,A,H,d,a]}}he.prototype.className="Path";he.prototype._attrsAffectingSize=["data"];ge(he);v.addGetterSetter(he,"data");class jt extends bt{_sceneFunc(e){super._sceneFunc(e);var t=Math.PI*2,r=this.points(),s=r,n=this.tension()!==0&&r.length>4;n&&(s=this.getTensionPoints());var a=this.pointerLength(),o=r.length,h,l;if(n){const c=[s[s.length-4],s[s.length-3],s[s.length-2],s[s.length-1],r[o-2],r[o-1]],p=he.calcLength(s[s.length-4],s[s.length-3],"C",c),f=he.getPointOnQuadraticBezier(Math.min(1,1-a/p),c[0],c[1],c[2],c[3],c[4],c[5]);h=r[o-2]-f.x,l=r[o-1]-f.y}else h=r[o-2]-r[o-4],l=r[o-1]-r[o-3];var d=(Math.atan2(l,h)+t)%t,u=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(r[o-2],r[o-1]),e.rotate(d),e.moveTo(0,0),e.lineTo(-a,u/2),e.lineTo(-a,-u/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(r[0],r[1]),n?(h=(s[0]+s[2])/2-r[0],l=(s[1]+s[3])/2-r[1]):(h=r[2]-r[0],l=r[3]-r[1]),e.rotate((Math.atan2(-l,-h)+t)%t),e.moveTo(0,0),e.lineTo(-a,u/2),e.lineTo(-a,-u/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}}jt.prototype.className="Arrow";ge(jt);v.addGetterSetter(jt,"pointerLength",10,x());v.addGetterSetter(jt,"pointerWidth",10,x());v.addGetterSetter(jt,"pointerAtBeginning",!1);v.addGetterSetter(jt,"pointerAtEnding",!0);class vi extends E{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}}vi.prototype._centroid=!0;vi.prototype.className="Circle";vi.prototype._attrsAffectingSize=["radius"];ge(vi);v.addGetterSetter(vi,"radius",0,x());class Dt extends E{_sceneFunc(e){var t=this.radiusX(),r=this.radiusY();e.beginPath(),e.save(),t!==r&&e.scale(1,r/t),e.arc(0,0,t,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}}Dt.prototype.className="Ellipse";Dt.prototype._centroid=!0;Dt.prototype._attrsAffectingSize=["radiusX","radiusY"];ge(Dt);v.addComponentsGetterSetter(Dt,"radius",["x","y"]);v.addGetterSetter(Dt,"radiusX",0,x());v.addGetterSetter(Dt,"radiusY",0,x());class Je extends E{constructor(e){super(e),this.on("imageChange.konva",()=>{this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const e=this.image();e&&e.complete||e&&e.readyState===4||e&&e.addEventListener&&e.addEventListener("load",()=>{this._requestDraw()})}_useBufferCanvas(){return super._useBufferCanvas(!0)}_sceneFunc(e){const t=this.getWidth(),r=this.getHeight(),s=this.attrs.image;let n;if(s){const a=this.attrs.cropWidth,o=this.attrs.cropHeight;a&&o?n=[s,this.cropX(),this.cropY(),a,o,0,0,t,r]:n=[s,0,0,t,r]}(this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,t,r),e.closePath(),e.fillStrokeShape(this)),s&&e.drawImage.apply(e,n)}_hitFunc(e){var t=this.width(),r=this.height();e.beginPath(),e.rect(0,0,t,r),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,t;return(e=this.attrs.width)!==null&&e!==void 0?e:(t=this.image())===null||t===void 0?void 0:t.width}getHeight(){var e,t;return(e=this.attrs.height)!==null&&e!==void 0?e:(t=this.image())===null||t===void 0?void 0:t.height}static fromURL(e,t,r=null){var s=y.createImageElement();s.onload=function(){var n=new Je({image:s});t(n)},s.onerror=r,s.crossOrigin="Anonymous",s.src=e}}Je.prototype.className="Image";ge(Je);v.addGetterSetter(Je,"image");v.addComponentsGetterSetter(Je,"crop",["x","y","width","height"]);v.addGetterSetter(Je,"cropX",0,x());v.addGetterSetter(Je,"cropY",0,x());v.addGetterSetter(Je,"cropWidth",0,x());v.addGetterSetter(Je,"cropHeight",0,x());var ro=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Uh="Change.konva",Zh="none",As="up",Ms="right",Os="down",Ls="left",jh=ro.length;class on extends hi{constructor(e){super(e),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var t=this,r,s=function(){t._sync()};for(r=0;r<jh;r++)e.on(ro[r]+Uh,s)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e=this.getText(),t=this.getTag(),r,s,n,a,o,h,l;if(e&&t){switch(r=e.width(),s=e.height(),n=t.pointerDirection(),a=t.pointerWidth(),l=t.pointerHeight(),o=0,h=0,n){case As:o=r/2,h=-1*l;break;case Ms:o=r+a,h=s/2;break;case Os:o=r/2,h=s+l;break;case Ls:o=-1*a,h=s/2;break}t.setAttrs({x:-1*o,y:-1*h,width:r,height:s}),e.setAttrs({x:-1*o,y:-1*h})}}}on.prototype.className="Label";ge(on);class Xt extends E{_sceneFunc(e){var t=this.width(),r=this.height(),s=this.pointerDirection(),n=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius();let h=0,l=0,d=0,u=0;typeof o=="number"?h=l=d=u=Math.min(o,t/2,r/2):(h=Math.min(o[0]||0,t/2,r/2),l=Math.min(o[1]||0,t/2,r/2),u=Math.min(o[2]||0,t/2,r/2),d=Math.min(o[3]||0,t/2,r/2)),e.beginPath(),e.moveTo(h,0),s===As&&(e.lineTo((t-n)/2,0),e.lineTo(t/2,-1*a),e.lineTo((t+n)/2,0)),e.lineTo(t-l,0),e.arc(t-l,l,l,Math.PI*3/2,0,!1),s===Ms&&(e.lineTo(t,(r-a)/2),e.lineTo(t+n,r/2),e.lineTo(t,(r+a)/2)),e.lineTo(t,r-u),e.arc(t-u,r-u,u,0,Math.PI/2,!1),s===Os&&(e.lineTo((t+n)/2,r),e.lineTo(t/2,r+a),e.lineTo((t-n)/2,r)),e.lineTo(d,r),e.arc(d,r-d,d,Math.PI/2,Math.PI,!1),s===Ls&&(e.lineTo(0,(r+a)/2),e.lineTo(-1*n,r/2),e.lineTo(0,(r-a)/2)),e.lineTo(0,h),e.arc(h,h,h,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){var e=0,t=0,r=this.pointerWidth(),s=this.pointerHeight(),n=this.pointerDirection(),a=this.width(),o=this.height();return n===As?(t-=s,o+=s):n===Os?o+=s:n===Ls?(e-=r*1.5,a+=r):n===Ms&&(a+=r*1.5),{x:e,y:t,width:a,height:o}}}Xt.prototype.className="Tag";ge(Xt);v.addGetterSetter(Xt,"pointerDirection",Zh);v.addGetterSetter(Xt,"pointerWidth",0,x());v.addGetterSetter(Xt,"pointerHeight",0,x());v.addGetterSetter(Xt,"cornerRadius",0,Da(4));class Ji extends E{_sceneFunc(e){var t=this.cornerRadius(),r=this.width(),s=this.height();if(e.beginPath(),!t)e.rect(0,0,r,s);else{let n=0,a=0,o=0,h=0;typeof t=="number"?n=a=o=h=Math.min(t,r/2,s/2):(n=Math.min(t[0]||0,r/2,s/2),a=Math.min(t[1]||0,r/2,s/2),h=Math.min(t[2]||0,r/2,s/2),o=Math.min(t[3]||0,r/2,s/2)),e.moveTo(n,0),e.lineTo(r-a,0),e.arc(r-a,a,a,Math.PI*3/2,0,!1),e.lineTo(r,s-h),e.arc(r-h,s-h,h,0,Math.PI/2,!1),e.lineTo(o,s),e.arc(o,s-o,o,Math.PI/2,Math.PI,!1),e.lineTo(0,n),e.arc(n,n,n,Math.PI,Math.PI*3/2,!1)}e.closePath(),e.fillStrokeShape(this)}}Ji.prototype.className="Rect";ge(Ji);v.addGetterSetter(Ji,"cornerRadius",0,Da(4));class qt extends E{_sceneFunc(e){const t=this._getPoints();e.beginPath(),e.moveTo(t[0].x,t[0].y);for(var r=1;r<t.length;r++)e.lineTo(t[r].x,t[r].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,r=[];for(var s=0;s<e;s++)r.push({x:t*Math.sin(s*2*Math.PI/e),y:-1*t*Math.cos(s*2*Math.PI/e)});return r}getSelfRect(){const e=this._getPoints();var t=e[0].x,r=e[0].y,s=e[0].x,n=e[0].y;return e.forEach(a=>{t=Math.min(t,a.x),r=Math.max(r,a.x),s=Math.min(s,a.y),n=Math.max(n,a.y)}),{x:t,y:s,width:r-t,height:n-s}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}qt.prototype.className="RegularPolygon";qt.prototype._centroid=!0;qt.prototype._attrsAffectingSize=["radius"];ge(qt);v.addGetterSetter(qt,"radius",0,x());v.addGetterSetter(qt,"sides",0,x());var Un=Math.PI*2;class Yt extends E{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,Un,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),Un,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Yt.prototype.className="Ring";Yt.prototype._centroid=!0;Yt.prototype._attrsAffectingSize=["innerRadius","outerRadius"];ge(Yt);v.addGetterSetter(Yt,"innerRadius",0,x());v.addGetterSetter(Yt,"outerRadius",0,x());class lt extends E{constructor(e){super(e),this._updated=!0,this.anim=new ze(()=>{var t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){var t=this.animation(),r=this.frameIndex(),s=r*4,n=this.animations()[t],a=this.frameOffsets(),o=n[s+0],h=n[s+1],l=n[s+2],d=n[s+3],u=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,l,d),e.closePath(),e.fillStrokeShape(this)),u)if(a){var c=a[t],p=r*2;e.drawImage(u,o,h,l,d,c[p+0],c[p+1],l,d)}else e.drawImage(u,o,h,l,d,0,0,l,d)}_hitFunc(e){var t=this.animation(),r=this.frameIndex(),s=r*4,n=this.animations()[t],a=this.frameOffsets(),o=n[s+2],h=n[s+3];if(e.beginPath(),a){var l=a[t],d=r*2;e.rect(l[d+0],l[d+1],o,h)}else e.rect(0,0,o,h);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(!this.isRunning()){var e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var e=this.frameIndex(),t=this.animation(),r=this.animations(),s=r[t],n=s.length/4;e<n-1?this.frameIndex(e+1):this.frameIndex(0)}}lt.prototype.className="Sprite";ge(lt);v.addGetterSetter(lt,"animation");v.addGetterSetter(lt,"animations");v.addGetterSetter(lt,"frameOffsets");v.addGetterSetter(lt,"image");v.addGetterSetter(lt,"frameIndex",0,x());v.addGetterSetter(lt,"frameRate",17,x());v.backCompat(lt,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class Gt extends E{_sceneFunc(e){var t=this.innerRadius(),r=this.outerRadius(),s=this.numPoints();e.beginPath(),e.moveTo(0,0-r);for(var n=1;n<s*2;n++){var a=n%2===0?r:t,o=a*Math.sin(n*Math.PI/s),h=-1*a*Math.cos(n*Math.PI/s);e.lineTo(o,h)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Gt.prototype.className="Star";Gt.prototype._centroid=!0;Gt.prototype._attrsAffectingSize=["innerRadius","outerRadius"];ge(Gt);v.addGetterSetter(Gt,"numPoints",5,x());v.addGetterSetter(Gt,"innerRadius",0,x());v.addGetterSetter(Gt,"outerRadius",0,x());function so(i){return Array.from(i)}var Jt="auto",Xh="center",Ei="justify",qh="Change.konva",Yh="2d",Zn="-",no="left",Kh="text",Jh="Text",Qh="top",ed="bottom",jn="middle",ao="normal",td="px ",mr=" ",id="right",rd="word",sd="char",Xn="none",ms="…",oo=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],nd=oo.length;function ad(i){return i.split(",").map(e=>{e=e.trim();const t=e.indexOf(" ")>=0,r=e.indexOf('"')>=0||e.indexOf("'")>=0;return t&&!r&&(e=`"${e}"`),e}).join(", ")}var gr;function gs(){return gr||(gr=y.createCanvasElement().getContext(Yh),gr)}function od(i){i.fillText(this._partialText,this._partialTextX,this._partialTextY)}function ld(i){i.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function hd(i){return i=i||{},!i.fillLinearGradientColorStops&&!i.fillRadialGradientColorStops&&!i.fillPatternImage&&(i.fill=i.fill||"black"),i}class me extends E{constructor(e){super(hd(e)),this._partialTextX=0,this._partialTextY=0;for(var t=0;t<nd;t++)this.on(oo[t]+qh,this._setTextData);this._setTextData()}_sceneFunc(e){var t=this.textArr,r=t.length;if(this.text()){var s=this.padding(),n=this.fontSize(),a=this.lineHeight()*n,o=this.verticalAlign(),h=0,l=this.align(),d=this.getWidth(),u=this.letterSpacing(),c=this.fill(),p=this.textDecoration(),f=p.indexOf("underline")!==-1,m=p.indexOf("line-through")!==-1,g,_=0,_=a/2,w=0,b=0;for(e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",jn),e.setAttr("textAlign",no),o===jn?h=(this.getHeight()-r*a-s*2)/2:o===ed&&(h=this.getHeight()-r*a-s*2),e.translate(s,h+s),g=0;g<r;g++){var w=0,b=0,T=t[g],L=T.text,A=T.width,D=T.lastInParagraph,R,H,$;if(e.save(),l===id?w+=d-A-s*2:l===Xh&&(w+=(d-A-s*2)/2),f&&(e.save(),e.beginPath(),e.moveTo(w,_+b+Math.round(n/2)),R=L.split(" ").length-1,H=R===0,$=l===Ei&&D&&!H?d-s*2:A,e.lineTo(w+Math.round($),_+b+Math.round(n/2)),e.lineWidth=n/15,e.strokeStyle=c,e.stroke(),e.restore()),m&&(e.save(),e.beginPath(),e.moveTo(w,_+b),R=L.split(" ").length-1,H=R===0,$=l===Ei&&D&&!H?d-s*2:A,e.lineTo(w+Math.round($),_+b),e.lineWidth=n/15,e.strokeStyle=c,e.stroke(),e.restore()),u!==0||l===Ei){R=L.split(" ").length-1;for(var I=so(L),K=0;K<I.length;K++){var W=I[K];W===" "&&!D&&l===Ei&&(w+=(d-s*2-A)/R),this._partialTextX=w,this._partialTextY=_+b,this._partialText=W,e.fillStrokeShape(this),w+=this.measureSize(W).width+u}}else this._partialTextX=w,this._partialTextY=_+b,this._partialText=L,e.fillStrokeShape(this);e.restore(),r>1&&(_+=a)}}}_hitFunc(e){var t=this.getWidth(),r=this.getHeight();e.beginPath(),e.rect(0,0,t,r),e.closePath(),e.fillStrokeShape(this)}setText(e){var t=y._isString(e)?e:e==null?"":e+"";return this._setAttr(Kh,t),this}getWidth(){var e=this.attrs.width===Jt||this.attrs.width===void 0;return e?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){var e=this.attrs.height===Jt||this.attrs.height===void 0;return e?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return y.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var t=gs(),r=this.fontSize(),s;return t.save(),t.font=this._getContextFont(),s=t.measureText(e),t.restore(),{width:s.width,height:r}}_getContextFont(){return this.fontStyle()+mr+this.fontVariant()+mr+(this.fontSize()+td)+ad(this.fontFamily())}_addTextLine(e){this.align()===Ei&&(e=e.trim());var t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){var t=this.letterSpacing(),r=e.length;return gs().measureText(e).width+(r?t*(r-1):0)}_setTextData(){var e=this.text().split(`
2
+ `),t=+this.fontSize(),r=0,s=this.lineHeight()*t,n=this.attrs.width,a=this.attrs.height,o=n!==Jt&&n!==void 0,h=a!==Jt&&a!==void 0,l=this.padding(),d=n-l*2,u=a-l*2,c=0,p=this.wrap(),f=p!==Xn,m=p!==sd&&f,g=this.ellipsis();this.textArr=[],gs().font=this._getContextFont();for(var _=g?this._getTextWidth(ms):0,w=0,b=e.length;w<b;++w){var T=e[w],L=this._getTextWidth(T);if(o&&L>d)for(;T.length>0;){for(var A=0,D=T.length,R="",H=0;A<D;){var $=A+D>>>1,I=T.slice(0,$+1),K=this._getTextWidth(I)+_;K<=d?(A=$+1,R=I,H=K):D=$}if(R){if(m){var W,le=T[R.length],ne=le===mr||le===Zn;ne&&H<=d?W=R.length:W=Math.max(R.lastIndexOf(mr),R.lastIndexOf(Zn))+1,W>0&&(A=W,R=R.slice(0,A),H=this._getTextWidth(R))}R=R.trimRight(),this._addTextLine(R),r=Math.max(r,H),c+=s;var U=this._shouldHandleEllipsis(c);if(U){this._tryToAddEllipsisToLastLine();break}if(T=T.slice(A),T=T.trimLeft(),T.length>0&&(L=this._getTextWidth(T),L<=d)){this._addTextLine(T),c+=s,r=Math.max(r,L);break}}else break}else this._addTextLine(T),c+=s,r=Math.max(r,L),this._shouldHandleEllipsis(c)&&w<b-1&&this._tryToAddEllipsisToLastLine();if(h&&c+s>u)break;this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0)}this.textHeight=t,this.textWidth=r}_shouldHandleEllipsis(e){var t=+this.fontSize(),r=this.lineHeight()*t,s=this.attrs.height,n=s!==Jt&&s!==void 0,a=this.padding(),o=s-a*2,h=this.wrap(),l=h!==Xn;return!l||n&&e+r>o}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,t=e!==Jt&&e!==void 0,r=this.padding(),s=e-r*2,n=this.ellipsis(),a=this.textArr[this.textArr.length-1];if(!(!a||!n)){if(t){var o=this._getTextWidth(a.text+ms)<s;o||(a.text=a.text.slice(0,a.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(a.text+ms)}}getStrokeScaleEnabled(){return!0}}me.prototype._fillFunc=od;me.prototype._strokeFunc=ld;me.prototype.className=Jh;me.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"];ge(me);v.overWriteSetter(me,"width",rn());v.overWriteSetter(me,"height",rn());v.addGetterSetter(me,"fontFamily","Arial");v.addGetterSetter(me,"fontSize",12,x());v.addGetterSetter(me,"fontStyle",ao);v.addGetterSetter(me,"fontVariant",ao);v.addGetterSetter(me,"padding",0,x());v.addGetterSetter(me,"align",no);v.addGetterSetter(me,"verticalAlign",Qh);v.addGetterSetter(me,"lineHeight",1,x());v.addGetterSetter(me,"wrap",rd);v.addGetterSetter(me,"ellipsis",!1,Ke());v.addGetterSetter(me,"letterSpacing",0,x());v.addGetterSetter(me,"text","",gi());v.addGetterSetter(me,"textDecoration","");var dd="",lo="normal";function ho(i){i.fillText(this.partialText,0,0)}function uo(i){i.strokeText(this.partialText,0,0)}class Ee extends E{constructor(e){super(e),this.dummyCanvas=y.createCanvasElement(),this.dataArray=[],this.dataArray=he.parsePathData(this.attrs.data),this.on("dataChange.konva",function(){this.dataArray=he.parsePathData(this.attrs.data),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();var t=this.textDecoration(),r=this.fill(),s=this.fontSize(),n=this.glyphInfo;t==="underline"&&e.beginPath();for(var a=0;a<n.length;a++){e.save();var o=n[a].p0;e.translate(o.x,o.y),e.rotate(n[a].rotation),this.partialText=n[a].text,e.fillStrokeShape(this),t==="underline"&&(a===0&&e.moveTo(0,s/2+1),e.lineTo(s,s/2+1)),e.restore()}t==="underline"&&(e.strokeStyle=r,e.lineWidth=s/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var t=this.glyphInfo;if(t.length>=1){var r=t[0].p0;e.moveTo(r.x,r.y)}for(var s=0;s<t.length;s++){var n=t[s].p1;e.lineTo(n.x,n.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return y.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return me.prototype.setText.call(this,e)}_getContextFont(){return me.prototype._getContextFont.call(this)}_getTextSize(e){var t=this.dummyCanvas,r=t.getContext("2d");r.save(),r.font=this._getContextFont();var s=r.measureText(e);return r.restore(),{width:s.width,height:parseInt(this.attrs.fontSize,10)}}_setTextData(){var e=this,t=this._getTextSize(this.attrs.text),r=this.letterSpacing(),s=this.align(),n=this.kerningFunc();this.textWidth=t.width,this.textHeight=t.height;var a=Math.max(this.textWidth+((this.attrs.text||"").length-1)*r,0);this.glyphInfo=[];for(var o=0,h=0;h<e.dataArray.length;h++)e.dataArray[h].pathLength>0&&(o+=e.dataArray[h].pathLength);var l=0;s==="center"&&(l=Math.max(0,o/2-a/2)),s==="right"&&(l=Math.max(0,o-a));for(var d=so(this.text()),u=this.text().split(" ").length-1,c,p,f,m=-1,g=0,_=function(){g=0;for(var K=e.dataArray,W=m+1;W<K.length;W++){if(K[W].pathLength>0)return m=W,K[W];K[W].command==="M"&&(c={x:K[W].points[0],y:K[W].points[1]})}return{}},w=function(K){var W=e._getTextSize(K).width+r;K===" "&&s==="justify"&&(W+=(o-a)/u);var le=0,ne=0;for(p=void 0;Math.abs(W-le)/W>.01&&ne<20;){ne++;for(var U=le;f===void 0;)f=_(),f&&U+f.pathLength<W&&(U+=f.pathLength,f=void 0);if(Object.keys(f).length===0||c===void 0)return;var we=!1;switch(f.command){case"L":he.getLineLength(c.x,c.y,f.points[0],f.points[1])>W?p=he.getPointOnLine(W,c.x,c.y,f.points[0],f.points[1],c.x,c.y):f=void 0;break;case"A":var Re=f.points[4],Ue=f.points[5],te=f.points[4]+Ue;g===0?g=Re+1e-8:W>le?g+=Math.PI/180*Ue/Math.abs(Ue):g-=Math.PI/360*Ue/Math.abs(Ue),(Ue<0&&g<te||Ue>=0&&g>te)&&(g=te,we=!0),p=he.getPointOnEllipticalArc(f.points[0],f.points[1],f.points[2],f.points[3],g,f.points[6]);break;case"C":g===0?W>f.pathLength?g=1e-8:g=W/f.pathLength:W>le?g+=(W-le)/f.pathLength/2:g=Math.max(g-(le-W)/f.pathLength/2,0),g>1&&(g=1,we=!0),p=he.getPointOnCubicBezier(g,f.start.x,f.start.y,f.points[0],f.points[1],f.points[2],f.points[3],f.points[4],f.points[5]);break;case"Q":g===0?g=W/f.pathLength:W>le?g+=(W-le)/f.pathLength:g-=(le-W)/f.pathLength,g>1&&(g=1,we=!0),p=he.getPointOnQuadraticBezier(g,f.start.x,f.start.y,f.points[0],f.points[1],f.points[2],f.points[3]);break}p!==void 0&&(le=he.getLineLength(c.x,c.y,p.x,p.y)),we&&(we=!1,f=void 0)}},b="C",T=e._getTextSize(b).width+r,L=l/T-1,A=0;A<L&&(w(b),!(c===void 0||p===void 0));A++)c=p;for(var D=0;D<d.length&&(w(d[D]),!(c===void 0||p===void 0));D++){var R=he.getLineLength(c.x,c.y,p.x,p.y),H=0;if(n)try{H=n(d[D-1],d[D])*this.fontSize()}catch{H=0}c.x+=H,p.x+=H,this.textWidth+=H;var $=he.getPointOnLine(H+R/2,c.x,c.y,p.x,p.y),I=Math.atan2(p.y-c.y,p.x-c.x);this.glyphInfo.push({transposeX:$.x,transposeY:$.y,text:d[D],rotation:I,p0:c,p1:p}),c=p}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var e=[];this.glyphInfo.forEach(function(d){e.push(d.p0.x),e.push(d.p0.y),e.push(d.p1.x),e.push(d.p1.y)});for(var t=e[0]||0,r=e[0]||0,s=e[1]||0,n=e[1]||0,a,o,h=0;h<e.length/2;h++)a=e[h*2],o=e[h*2+1],t=Math.min(t,a),r=Math.max(r,a),s=Math.min(s,o),n=Math.max(n,o);var l=this.fontSize();return{x:t-l/2,y:s-l/2,width:r-t+l,height:n-s+l}}destroy(){return y.releaseCanvas(this.dummyCanvas),super.destroy()}}Ee.prototype._fillFunc=ho;Ee.prototype._strokeFunc=uo;Ee.prototype._fillFuncHit=ho;Ee.prototype._strokeFuncHit=uo;Ee.prototype.className="TextPath";Ee.prototype._attrsAffectingSize=["text","fontSize","data"];ge(Ee);v.addGetterSetter(Ee,"data");v.addGetterSetter(Ee,"fontFamily","Arial");v.addGetterSetter(Ee,"fontSize",12,x());v.addGetterSetter(Ee,"fontStyle",lo);v.addGetterSetter(Ee,"align","left");v.addGetterSetter(Ee,"letterSpacing",0,x());v.addGetterSetter(Ee,"textBaseline","middle");v.addGetterSetter(Ee,"fontVariant",lo);v.addGetterSetter(Ee,"text",dd);v.addGetterSetter(Ee,"textDecoration",null);v.addGetterSetter(Ee,"kerningFunc",null);var co="tr-konva",ud=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange"].map(i=>i+`.${co}`).join(" "),qn="nodesRect",cd=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],fd={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const pd="ontouchstart"in G._global;function md(i,e){if(i==="rotater")return"crosshair";e+=y.degToRad(fd[i]||0);var t=(y.radToDeg(e)%360+360)%360;return y._inRange(t,315+22.5,360)||y._inRange(t,0,22.5)?"ns-resize":y._inRange(t,45-22.5,45+22.5)?"nesw-resize":y._inRange(t,90-22.5,90+22.5)?"ew-resize":y._inRange(t,135-22.5,135+22.5)?"nwse-resize":y._inRange(t,180-22.5,180+22.5)?"ns-resize":y._inRange(t,225-22.5,225+22.5)?"nesw-resize":y._inRange(t,270-22.5,270+22.5)?"ew-resize":y._inRange(t,315-22.5,315+22.5)?"nwse-resize":(y.error("Transformer has unknown angle for cursor detection: "+t),"pointer")}var Or=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],Yn=1e8;function gd(i){return{x:i.x+i.width/2*Math.cos(i.rotation)+i.height/2*Math.sin(-i.rotation),y:i.y+i.height/2*Math.cos(i.rotation)+i.width/2*Math.sin(i.rotation)}}function fo(i,e,t){const r=t.x+(i.x-t.x)*Math.cos(e)-(i.y-t.y)*Math.sin(e),s=t.y+(i.x-t.x)*Math.sin(e)+(i.y-t.y)*Math.cos(e);return Object.assign(Object.assign({},i),{rotation:i.rotation+e,x:r,y:s})}function vd(i,e){const t=gd(i);return fo(i,e,t)}function yd(i,e,t){let r=e;for(let s=0;s<i.length;s++){const n=G.getAngle(i[s]),a=Math.abs(n-e)%(Math.PI*2);Math.min(a,Math.PI*2-a)<t&&(r=n)}return r}class oe extends hi{constructor(e){super(e),this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(ud,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return y.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 co+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach(),this._nodes=e,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(r=>{const s=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()},n=r._attrsAffectingSize.map(a=>a+"Change."+this._getEventNamespace()).join(" ");r.on(n,s),r.on(cd.map(a=>a+`.${this._getEventNamespace()}`).join(" "),s),r.on(`absoluteTransformChange.${this._getEventNamespace()}`,s),this._proxyDrag(r)}),this._resetTransformCache();var t=!!this.findOne(".top-left");return t&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,r=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(r,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,r=>{if(!t)return;const s=e.getAbsolutePosition(),n=s.x-t.x,a=s.y-t.y;this.nodes().forEach(o=>{if(o===e||o.isDragging())return;const h=o.getAbsolutePosition();o.setAbsolutePosition({x:h.x+n,y:h.y+a}),o.startDrag(r)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(qn),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(qn,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),r){var s=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=e.getAbsoluteScale(r),a=e.getAbsolutePosition(r),o=s.x*n.x-e.offsetX()*n.x,h=s.y*n.y-e.offsetY()*n.y;const l=(G.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),d={x:a.x+o*Math.cos(l)+h*Math.sin(-l),y:a.y+h*Math.cos(l)+o*Math.sin(l),width:s.width*n.x,height:s.height*n.y,rotation:l};return fo(d,-G.getAngle(t),{x:0,y:0})}__getNodeRect(){var e=this.getNode();if(!e)return{x:-Yn,y:-Yn,width:0,height:0,rotation:0};const t=[];this.nodes().map(l=>{const d=l.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var u=[{x:d.x,y:d.y},{x:d.x+d.width,y:d.y},{x:d.x+d.width,y:d.y+d.height},{x:d.x,y:d.y+d.height}],c=l.getAbsoluteTransform();u.forEach(function(p){var f=c.point(p);t.push(f)})});const r=new De;r.rotate(-G.getAngle(this.rotation()));var s,n,a,o;t.forEach(function(l){var d=r.point(l);s===void 0&&(s=a=d.x,n=o=d.y),s=Math.min(s,d.x),n=Math.min(n,d.y),a=Math.max(a,d.x),o=Math.max(o,d.y)}),r.invert();const h=r.point({x:s,y:n});return{x:h.x,y:h.y,width:a-s,height:o-n,rotation:G.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(),Or.forEach(function(e){this._createAnchor(e)}.bind(this)),this._createAnchor("rotater")}_createAnchor(e){var t=new Ji({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:pd?10:"auto"}),r=this;t.on("mousedown touchstart",function(s){r._handleMouseDown(s)}),t.on("dragstart",s=>{t.stopDrag(),s.cancelBubble=!0}),t.on("dragend",s=>{s.cancelBubble=!0}),t.on("mouseenter",()=>{var s=G.getAngle(this.rotation()),n=md(e,s);t.getStage().content&&(t.getStage().content.style.cursor=n),this._cursorChange=!0}),t.on("mouseout",()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(t)}_createBack(){var e=new E({name:"back",width:0,height:0,draggable:!0,sceneFunc(t){var r=this.getParent(),s=r.padding();t.beginPath(),t.rect(-s,-s,this.width()+s*2,this.height()+s*2),t.moveTo(this.width()/2,-s),r.rotateEnabled()&&t.lineTo(this.width()/2,-r.rotateAnchorOffset()*y._sign(this.height())-s),t.fillStrokeShape(this)},hitFunc:(t,r)=>{if(this.shouldOverdrawWholeArea()){var s=this.padding();t.beginPath(),t.rect(-s,-s,r.width()+s*2,r.height()+s*2),t.fillStrokeShape(r)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(e){this._movingAnchorName=e.target.name().split(" ")[0];var t=this._getNodeRect(),r=t.width,s=t.height,n=Math.sqrt(Math.pow(r,2)+Math.pow(s,2));this.sin=Math.abs(s/n),this.cos=Math.abs(r/n),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var a=e.target.getAbsolutePosition(),o=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:o.x-a.x,y:o.y-a.y},this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(h=>{h._fire("transformstart",{evt:e.evt,target:h})})}_handleMouseMove(e){var t,r,s,n=this.findOne("."+this._movingAnchorName),a=n.getStage();a.setPointersPositions(e);const o=a.getPointerPosition();let h={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y};const l=n.getAbsolutePosition();this.anchorDragBoundFunc()&&(h=this.anchorDragBoundFunc()(l,h,e)),n.setAbsolutePosition(h);const d=n.getAbsolutePosition();if(!(l.x===d.x&&l.y===d.y)){if(this._movingAnchorName==="rotater"){var u=this._getNodeRect();t=n.x()-u.width/2,r=-n.y()+u.height/2;let K=Math.atan2(-r,t)+Math.PI/2;u.height<0&&(K-=Math.PI);var c=G.getAngle(this.rotation());const W=c+K,le=G.getAngle(this.rotationSnapTolerance()),U=yd(this.rotationSnaps(),W,le)-u.rotation,we=vd(u,U);this._fitNodesInto(we,e);return}var p=this.keepRatio()||e.shiftKey,w=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(p){var f=w?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};s=Math.sqrt(Math.pow(f.x-n.x(),2)+Math.pow(f.y-n.y(),2));var m=this.findOne(".top-left").x()>f.x?-1:1,g=this.findOne(".top-left").y()>f.y?-1:1;t=s*this.cos*m,r=s*this.sin*g,this.findOne(".top-left").x(f.x-t),this.findOne(".top-left").y(f.y-r)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(n.y());else if(this._movingAnchorName==="top-right"){if(p){var f=w?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};s=Math.sqrt(Math.pow(n.x()-f.x,2)+Math.pow(f.y-n.y(),2));var m=this.findOne(".top-right").x()<f.x?-1:1,g=this.findOne(".top-right").y()>f.y?-1:1;t=s*this.cos*m,r=s*this.sin*g,this.findOne(".top-right").x(f.x+t),this.findOne(".top-right").y(f.y-r)}var _=n.position();this.findOne(".top-left").y(_.y),this.findOne(".bottom-right").x(_.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(n.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(n.x());else if(this._movingAnchorName==="bottom-left"){if(p){var f=w?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};s=Math.sqrt(Math.pow(f.x-n.x(),2)+Math.pow(n.y()-f.y,2));var m=f.x<n.x()?-1:1,g=n.y()<f.y?-1:1;t=s*this.cos*m,r=s*this.sin*g,n.x(f.x-t),n.y(f.y+r)}_=n.position(),this.findOne(".top-left").x(_.x),this.findOne(".bottom-right").y(_.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(n.y());else if(this._movingAnchorName==="bottom-right"){if(p){var f=w?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};s=Math.sqrt(Math.pow(n.x()-f.x,2)+Math.pow(n.y()-f.y,2));var m=this.findOne(".bottom-right").x()<f.x?-1:1,g=this.findOne(".bottom-right").y()<f.y?-1:1;t=s*this.cos*m,r=s*this.sin*g,this.findOne(".bottom-right").x(f.x+t),this.findOne(".bottom-right").y(f.y+r)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));var w=this.centeredScaling()||e.altKey;if(w){var b=this.findOne(".top-left"),T=this.findOne(".bottom-right"),L=b.x(),A=b.y(),D=this.getWidth()-T.x(),R=this.getHeight()-T.y();T.move({x:-L,y:-A}),b.move({x:D,y:R})}var H=this.findOne(".top-left").getAbsolutePosition();t=H.x,r=H.y;var $=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),I=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:r,width:$,height:I,rotation:G.getAngle(this.rotation())},e)}}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var t=this.getNode();this._fire("transformend",{evt:e,target:t}),t&&this._nodes.forEach(r=>{r._fire("transformend",{evt:e,target:r})}),this._movingAnchorName=null}}_fitNodesInto(e,t){var r=this._getNodeRect();const s=1;if(y._inRange(e.width,-this.padding()*2-s,s)){this.update();return}if(y._inRange(e.height,-this.padding()*2-s,s)){this.update();return}const n=this.flipEnabled();var a=new De;if(a.rotate(G.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const u=a.point({x:-this.padding()*2,y:0});if(e.x+=u.x,e.y+=u.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,!n){this.update();return}}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const u=a.point({x:this.padding()*2,y:0});if(this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,e.width+=this.padding()*2,!n){this.update();return}}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const u=a.point({x:0,y:-this.padding()*2});if(e.x+=u.x,e.y+=u.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,e.height+=this.padding()*2,!n){this.update();return}}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const u=a.point({x:0,y:this.padding()*2});if(this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,e.height+=this.padding()*2,!n){this.update();return}}if(this.boundBoxFunc()){const u=this.boundBoxFunc()(r,e);u?e=u:y.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,h=new De;h.translate(r.x,r.y),h.rotate(r.rotation),h.scale(r.width/o,r.height/o);const l=new De;l.translate(e.x,e.y),l.rotate(e.rotation),l.scale(e.width/o,e.height/o);const d=l.multiply(h.invert());this._nodes.forEach(u=>{var c;const p=u.getParent().getAbsoluteTransform(),f=u.getTransform().copy();f.translate(u.offsetX(),u.offsetY());const m=new De;m.multiply(p.copy().invert()).multiply(d).multiply(p).multiply(f);const g=m.decompose();u.setAttrs(g),this._fire("transform",{evt:t,target:u}),u._fire("transform",{evt:t,target:u}),(c=u.getLayer())===null||c===void 0||c.batchDraw()}),this.rotation(y._getRotation(e.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e,t=this._getNodeRect();this.rotation(y._getRotation(t.rotation));var r=t.width,s=t.height,n=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),h=this.anchorSize();this.find("._anchor").forEach(l=>{l.setAttrs({width:h,height:h,offsetX:h/2,offsetY:h/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:h/2+o,offsetY:h/2+o,visible:a&&n.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:r/2,y:0,offsetY:h/2+o,visible:a&&n.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:r,y:0,offsetX:h/2-o,offsetY:h/2+o,visible:a&&n.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:s/2,offsetX:h/2+o,visible:a&&n.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:r,y:s/2,offsetX:h/2-o,visible:a&&n.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:s,offsetX:h/2+o,offsetY:h/2-o,visible:a&&n.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:r/2,y:s,offsetY:h/2-o,visible:a&&n.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:r,y:s,offsetX:h/2-o,offsetY:h/2-o,visible:a&&n.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:r/2,y:-this.rotateAnchorOffset()*y._sign(s)-o,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:r,height:s,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),hi.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return P.prototype.toObject.call(this)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}function bd(i){return i instanceof Array||y.warn("enabledAnchors value should be an array"),i instanceof Array&&i.forEach(function(e){Or.indexOf(e)===-1&&y.warn("Unknown anchor name: "+e+". Available names are: "+Or.join(", "))}),i||[]}oe.prototype.className="Transformer";ge(oe);v.addGetterSetter(oe,"enabledAnchors",Or,bd);v.addGetterSetter(oe,"flipEnabled",!0,Ke());v.addGetterSetter(oe,"resizeEnabled",!0);v.addGetterSetter(oe,"anchorSize",10,x());v.addGetterSetter(oe,"rotateEnabled",!0);v.addGetterSetter(oe,"rotationSnaps",[]);v.addGetterSetter(oe,"rotateAnchorOffset",50,x());v.addGetterSetter(oe,"rotationSnapTolerance",5,x());v.addGetterSetter(oe,"borderEnabled",!0);v.addGetterSetter(oe,"anchorStroke","rgb(0, 161, 255)");v.addGetterSetter(oe,"anchorStrokeWidth",1,x());v.addGetterSetter(oe,"anchorFill","white");v.addGetterSetter(oe,"anchorCornerRadius",0,x());v.addGetterSetter(oe,"borderStroke","rgb(0, 161, 255)");v.addGetterSetter(oe,"borderStrokeWidth",1,x());v.addGetterSetter(oe,"borderDash");v.addGetterSetter(oe,"keepRatio",!0);v.addGetterSetter(oe,"centeredScaling",!1);v.addGetterSetter(oe,"ignoreStroke",!1);v.addGetterSetter(oe,"padding",0,x());v.addGetterSetter(oe,"node");v.addGetterSetter(oe,"nodes");v.addGetterSetter(oe,"boundBoxFunc");v.addGetterSetter(oe,"anchorDragBoundFunc");v.addGetterSetter(oe,"shouldOverdrawWholeArea",!1);v.addGetterSetter(oe,"useSingleNodeRotation",!0);v.backCompat(oe,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class _t extends E{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,G.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}_t.prototype.className="Wedge";_t.prototype._centroid=!0;_t.prototype._attrsAffectingSize=["radius"];ge(_t);v.addGetterSetter(_t,"radius",0,x());v.addGetterSetter(_t,"angle",0,x());v.addGetterSetter(_t,"clockwise",!1);v.backCompat(_t,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function Kn(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var _d=[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],wd=[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 Sd(i,e){var t=i.data,r=i.width,s=i.height,n,a,o,h,l,d,u,c,p,f,m,g,_,w,b,T,L,A,D,R,H,$,I,K,W=e+e+1,le=r-1,ne=s-1,U=e+1,we=U*(U+1)/2,Re=new Kn,Ue=null,te=Re,ve=null,Ie=null,Tt=_d[e],Ct=wd[e];for(o=1;o<W;o++)te=te.next=new Kn,o===U&&(Ue=te);for(te.next=Re,u=d=0,a=0;a<s;a++){for(T=L=A=D=c=p=f=m=0,g=U*(R=t[d]),_=U*(H=t[d+1]),w=U*($=t[d+2]),b=U*(I=t[d+3]),c+=we*R,p+=we*H,f+=we*$,m+=we*I,te=Re,o=0;o<U;o++)te.r=R,te.g=H,te.b=$,te.a=I,te=te.next;for(o=1;o<U;o++)h=d+((le<o?le:o)<<2),c+=(te.r=R=t[h])*(K=U-o),p+=(te.g=H=t[h+1])*K,f+=(te.b=$=t[h+2])*K,m+=(te.a=I=t[h+3])*K,T+=R,L+=H,A+=$,D+=I,te=te.next;for(ve=Re,Ie=Ue,n=0;n<r;n++)t[d+3]=I=m*Tt>>Ct,I!==0?(I=255/I,t[d]=(c*Tt>>Ct)*I,t[d+1]=(p*Tt>>Ct)*I,t[d+2]=(f*Tt>>Ct)*I):t[d]=t[d+1]=t[d+2]=0,c-=g,p-=_,f-=w,m-=b,g-=ve.r,_-=ve.g,w-=ve.b,b-=ve.a,h=u+((h=n+e+1)<le?h:le)<<2,T+=ve.r=t[h],L+=ve.g=t[h+1],A+=ve.b=t[h+2],D+=ve.a=t[h+3],c+=T,p+=L,f+=A,m+=D,ve=ve.next,g+=R=Ie.r,_+=H=Ie.g,w+=$=Ie.b,b+=I=Ie.a,T-=R,L-=H,A-=$,D-=I,Ie=Ie.next,d+=4;u+=r}for(n=0;n<r;n++){for(L=A=D=T=p=f=m=c=0,d=n<<2,g=U*(R=t[d]),_=U*(H=t[d+1]),w=U*($=t[d+2]),b=U*(I=t[d+3]),c+=we*R,p+=we*H,f+=we*$,m+=we*I,te=Re,o=0;o<U;o++)te.r=R,te.g=H,te.b=$,te.a=I,te=te.next;for(l=r,o=1;o<=e;o++)d=l+n<<2,c+=(te.r=R=t[d])*(K=U-o),p+=(te.g=H=t[d+1])*K,f+=(te.b=$=t[d+2])*K,m+=(te.a=I=t[d+3])*K,T+=R,L+=H,A+=$,D+=I,te=te.next,o<ne&&(l+=r);for(d=n,ve=Re,Ie=Ue,a=0;a<s;a++)h=d<<2,t[h+3]=I=m*Tt>>Ct,I>0?(I=255/I,t[h]=(c*Tt>>Ct)*I,t[h+1]=(p*Tt>>Ct)*I,t[h+2]=(f*Tt>>Ct)*I):t[h]=t[h+1]=t[h+2]=0,c-=g,p-=_,f-=w,m-=b,g-=ve.r,_-=ve.g,w-=ve.b,b-=ve.a,h=n+((h=a+U)<ne?h:ne)*r<<2,c+=T+=ve.r=t[h],p+=L+=ve.g=t[h+1],f+=A+=ve.b=t[h+2],m+=D+=ve.a=t[h+3],ve=ve.next,g+=R=Ie.r,_+=H=Ie.g,w+=$=Ie.b,b+=I=Ie.a,T-=R,L-=H,A-=$,D-=I,Ie=Ie.next,d+=r}}const Td=function(e){var t=Math.round(this.blurRadius());t>0&&Sd(e,t)};v.addGetterSetter(P,"blurRadius",0,x(),v.afterSetFilter);const Cd=function(i){var e=this.brightness()*255,t=i.data,r=t.length,s;for(s=0;s<r;s+=4)t[s]+=e,t[s+1]+=e,t[s+2]+=e};v.addGetterSetter(P,"brightness",0,x(),v.afterSetFilter);const Ed=function(i){var e=Math.pow((this.contrast()+100)/100,2),t=i.data,r=t.length,s=150,n=150,a=150,o;for(o=0;o<r;o+=4)s=t[o],n=t[o+1],a=t[o+2],s/=255,s-=.5,s*=e,s+=.5,s*=255,n/=255,n-=.5,n*=e,n+=.5,n*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,s=s<0?0:s>255?255:s,n=n<0?0:n>255?255:n,a=a<0?0:a>255?255:a,t[o]=s,t[o+1]=n,t[o+2]=a};v.addGetterSetter(P,"contrast",0,x(),v.afterSetFilter);const kd=function(i){var e=this.embossStrength()*10,t=this.embossWhiteLevel()*255,r=this.embossDirection(),s=this.embossBlend(),n=0,a=0,o=i.data,h=i.width,l=i.height,d=h*4,u=l;switch(r){case"top-left":n=-1,a=-1;break;case"top":n=-1,a=0;break;case"top-right":n=-1,a=1;break;case"right":n=0,a=1;break;case"bottom-right":n=1,a=1;break;case"bottom":n=1,a=0;break;case"bottom-left":n=1,a=-1;break;case"left":n=0,a=-1;break;default:y.error("Unknown emboss direction: "+r)}do{var c=(u-1)*d,p=n;u+p<1&&(p=0),u+p>l&&(p=0);var f=(u-1+p)*h*4,m=h;do{var g=c+(m-1)*4,_=a;m+_<1&&(_=0),m+_>h&&(_=0);var w=f+(m-1+_)*4,b=o[g]-o[w],T=o[g+1]-o[w+1],L=o[g+2]-o[w+2],A=b,D=A>0?A:-A,R=T>0?T:-T,H=L>0?L:-L;if(R>D&&(A=T),H>D&&(A=L),A*=e,s){var $=o[g]+A,I=o[g+1]+A,K=o[g+2]+A;o[g]=$>255?255:$<0?0:$,o[g+1]=I>255?255:I<0?0:I,o[g+2]=K>255?255:K<0?0:K}else{var W=t-A;W<0?W=0:W>255&&(W=255),o[g]=o[g+1]=o[g+2]=W}}while(--m)}while(--u)};v.addGetterSetter(P,"embossStrength",.5,x(),v.afterSetFilter);v.addGetterSetter(P,"embossWhiteLevel",.5,x(),v.afterSetFilter);v.addGetterSetter(P,"embossDirection","top-left",null,v.afterSetFilter);v.addGetterSetter(P,"embossBlend",!1,null,v.afterSetFilter);function vs(i,e,t,r,s){var n=t-e,a=s-r,o;return n===0?r+a/2:a===0?r:(o=(i-e)/n,o=a*o+r,o)}const xd=function(i){var e=i.data,t=e.length,r=e[0],s=r,n,a=e[1],o=a,h,l=e[2],d=l,u,c,p=this.enhance();if(p!==0){for(c=0;c<t;c+=4)n=e[c+0],n<r?r=n:n>s&&(s=n),h=e[c+1],h<a?a=h:h>o&&(o=h),u=e[c+2],u<l?l=u:u>d&&(d=u);s===r&&(s=255,r=0),o===a&&(o=255,a=0),d===l&&(d=255,l=0);var f,m,g,_,w,b,T,L,A;for(p>0?(m=s+p*(255-s),g=r-p*(r-0),w=o+p*(255-o),b=a-p*(a-0),L=d+p*(255-d),A=l-p*(l-0)):(f=(s+r)*.5,m=s+p*(s-f),g=r+p*(r-f),_=(o+a)*.5,w=o+p*(o-_),b=a+p*(a-_),T=(d+l)*.5,L=d+p*(d-T),A=l+p*(l-T)),c=0;c<t;c+=4)e[c+0]=vs(e[c+0],r,s,g,m),e[c+1]=vs(e[c+1],a,o,b,w),e[c+2]=vs(e[c+2],l,d,A,L)}};v.addGetterSetter(P,"enhance",0,x(),v.afterSetFilter);const Pd=function(i){var e=i.data,t=e.length,r,s;for(r=0;r<t;r+=4)s=.34*e[r]+.5*e[r+1]+.16*e[r+2],e[r]=s,e[r+1]=s,e[r+2]=s};v.addGetterSetter(P,"hue",0,x(),v.afterSetFilter);v.addGetterSetter(P,"saturation",0,x(),v.afterSetFilter);v.addGetterSetter(P,"luminance",0,x(),v.afterSetFilter);const Ad=function(i){var e=i.data,t=e.length,r=1,s=Math.pow(2,this.saturation()),n=Math.abs(this.hue()+360)%360,a=this.luminance()*127,o,h=r*s*Math.cos(n*Math.PI/180),l=r*s*Math.sin(n*Math.PI/180),d=.299*r+.701*h+.167*l,u=.587*r-.587*h+.33*l,c=.114*r-.114*h-.497*l,p=.299*r-.299*h-.328*l,f=.587*r+.413*h+.035*l,m=.114*r-.114*h+.293*l,g=.299*r-.3*h+1.25*l,_=.587*r-.586*h-1.05*l,w=.114*r+.886*h-.2*l,b,T,L,A;for(o=0;o<t;o+=4)b=e[o+0],T=e[o+1],L=e[o+2],A=e[o+3],e[o+0]=d*b+u*T+c*L+a,e[o+1]=p*b+f*T+m*L+a,e[o+2]=g*b+_*T+w*L+a,e[o+3]=A},Md=function(i){var e=i.data,t=e.length,r=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),n=Math.abs(this.hue()+360)%360,a,o=r*s*Math.cos(n*Math.PI/180),h=r*s*Math.sin(n*Math.PI/180),l=.299*r+.701*o+.167*h,d=.587*r-.587*o+.33*h,u=.114*r-.114*o-.497*h,c=.299*r-.299*o-.328*h,p=.587*r+.413*o+.035*h,f=.114*r-.114*o+.293*h,m=.299*r-.3*o+1.25*h,g=.587*r-.586*o-1.05*h,_=.114*r+.886*o-.2*h,w,b,T,L;for(a=0;a<t;a+=4)w=e[a+0],b=e[a+1],T=e[a+2],L=e[a+3],e[a+0]=l*w+d*b+u*T,e[a+1]=c*w+p*b+f*T,e[a+2]=m*w+g*b+_*T,e[a+3]=L};v.addGetterSetter(P,"hue",0,x(),v.afterSetFilter);v.addGetterSetter(P,"saturation",0,x(),v.afterSetFilter);v.addGetterSetter(P,"value",0,x(),v.afterSetFilter);const Od=function(i){var e=i.data,t=e.length,r;for(r=0;r<t;r+=4)e[r]=255-e[r],e[r+1]=255-e[r+1],e[r+2]=255-e[r+2]};var Ld=function(i,e,t){var r=i.data,s=e.data,n=i.width,a=i.height,o=t.polarCenterX||n/2,h=t.polarCenterY||a/2,l,d,u,c=0,p=0,f=0,m=0,g,_=Math.sqrt(o*o+h*h);d=n-o,u=a-h,g=Math.sqrt(d*d+u*u),_=g>_?g:_;var w=a,b=n,T,L,A=360/b*Math.PI/180,D,R;for(L=0;L<b;L+=1)for(D=Math.sin(L*A),R=Math.cos(L*A),T=0;T<w;T+=1)d=Math.floor(o+_*T/w*R),u=Math.floor(h+_*T/w*D),l=(u*n+d)*4,c=r[l+0],p=r[l+1],f=r[l+2],m=r[l+3],l=(L+T*n)*4,s[l+0]=c,s[l+1]=p,s[l+2]=f,s[l+3]=m},Rd=function(i,e,t){var r=i.data,s=e.data,n=i.width,a=i.height,o=t.polarCenterX||n/2,h=t.polarCenterY||a/2,l,d,u,c,p,f=0,m=0,g=0,_=0,w,b=Math.sqrt(o*o+h*h);d=n-o,u=a-h,w=Math.sqrt(d*d+u*u),b=w>b?w:b;var T=a,L=n,A,D,R=t.polarRotation||0,H,$;for(d=0;d<n;d+=1)for(u=0;u<a;u+=1)c=d-o,p=u-h,A=Math.sqrt(c*c+p*p)*T/b,D=(Math.atan2(p,c)*180/Math.PI+360+R)%360,D=D*L/360,H=Math.floor(D),$=Math.floor(A),l=($*n+H)*4,f=r[l+0],m=r[l+1],g=r[l+2],_=r[l+3],l=(u*n+d)*4,s[l+0]=f,s[l+1]=m,s[l+2]=g,s[l+3]=_};const Id=function(i){var e=i.width,t=i.height,r,s,n,a,o,h,l,d,u,c,p=Math.round(this.kaleidoscopePower()),f=Math.round(this.kaleidoscopeAngle()),m=Math.floor(e*(f%360)/360);if(!(p<1)){var g=y.createCanvasElement();g.width=e,g.height=t;var _=g.getContext("2d").getImageData(0,0,e,t);y.releaseCanvas(g),Ld(i,_,{polarCenterX:e/2,polarCenterY:t/2});for(var w=e/Math.pow(2,p);w<=8;)w=w*2,p-=1;w=Math.ceil(w);var b=w,T=0,L=b,A=1;for(m+w>e&&(T=b,L=0,A=-1),s=0;s<t;s+=1)for(r=T;r!==L;r+=A)n=Math.round(r+m)%e,u=(e*s+n)*4,o=_.data[u+0],h=_.data[u+1],l=_.data[u+2],d=_.data[u+3],c=(e*s+r)*4,_.data[c+0]=o,_.data[c+1]=h,_.data[c+2]=l,_.data[c+3]=d;for(s=0;s<t;s+=1)for(b=Math.floor(w),a=0;a<p;a+=1){for(r=0;r<b+1;r+=1)u=(e*s+r)*4,o=_.data[u+0],h=_.data[u+1],l=_.data[u+2],d=_.data[u+3],c=(e*s+b*2-r-1)*4,_.data[c+0]=o,_.data[c+1]=h,_.data[c+2]=l,_.data[c+3]=d;b*=2}Rd(_,i,{polarRotation:0})}};v.addGetterSetter(P,"kaleidoscopePower",2,x(),v.afterSetFilter);v.addGetterSetter(P,"kaleidoscopeAngle",0,x(),v.afterSetFilter);function vr(i,e,t){var r=(t*i.width+e)*4,s=[];return s.push(i.data[r++],i.data[r++],i.data[r++],i.data[r++]),s}function ki(i,e){return Math.sqrt(Math.pow(i[0]-e[0],2)+Math.pow(i[1]-e[1],2)+Math.pow(i[2]-e[2],2))}function Nd(i){for(var e=[0,0,0],t=0;t<i.length;t++)e[0]+=i[t][0],e[1]+=i[t][1],e[2]+=i[t][2];return e[0]/=i.length,e[1]/=i.length,e[2]/=i.length,e}function Dd(i,e){var t=vr(i,0,0),r=vr(i,i.width-1,0),s=vr(i,0,i.height-1),n=vr(i,i.width-1,i.height-1),a=e||10;if(ki(t,r)<a&&ki(r,n)<a&&ki(n,s)<a&&ki(s,t)<a){for(var o=Nd([r,t,n,s]),h=[],l=0;l<i.width*i.height;l++){var d=ki(o,[i.data[l*4],i.data[l*4+1],i.data[l*4+2]]);h[l]=d<a?0:255}return h}}function Gd(i,e){for(var t=0;t<i.width*i.height;t++)i.data[4*t+3]=e[t]}function Fd(i,e,t){for(var r=[1,1,1,1,0,1,1,1,1],s=Math.round(Math.sqrt(r.length)),n=Math.floor(s/2),a=[],o=0;o<t;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,u=0;u<s;u++)for(var c=0;c<s;c++){var p=o+u-n,f=h+c-n;if(p>=0&&p<t&&f>=0&&f<e){var m=p*e+f,g=r[u*s+c];d+=i[m]*g}}a[l]=d===255*8?255:0}return a}function Hd(i,e,t){for(var r=[1,1,1,1,1,1,1,1,1],s=Math.round(Math.sqrt(r.length)),n=Math.floor(s/2),a=[],o=0;o<t;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,u=0;u<s;u++)for(var c=0;c<s;c++){var p=o+u-n,f=h+c-n;if(p>=0&&p<t&&f>=0&&f<e){var m=p*e+f,g=r[u*s+c];d+=i[m]*g}}a[l]=d>=255*4?255:0}return a}function Bd(i,e,t){for(var r=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],s=Math.round(Math.sqrt(r.length)),n=Math.floor(s/2),a=[],o=0;o<t;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,u=0;u<s;u++)for(var c=0;c<s;c++){var p=o+u-n,f=h+c-n;if(p>=0&&p<t&&f>=0&&f<e){var m=p*e+f,g=r[u*s+c];d+=i[m]*g}}a[l]=d}return a}const $d=function(i){var e=this.threshold(),t=Dd(i,e);return t&&(t=Fd(t,i.width,i.height),t=Hd(t,i.width,i.height),t=Bd(t,i.width,i.height),Gd(i,t)),i};v.addGetterSetter(P,"threshold",0,x(),v.afterSetFilter);const Vd=function(i){var e=this.noise()*255,t=i.data,r=t.length,s=e/2,n;for(n=0;n<r;n+=4)t[n+0]+=s-2*s*Math.random(),t[n+1]+=s-2*s*Math.random(),t[n+2]+=s-2*s*Math.random()};v.addGetterSetter(P,"noise",.2,x(),v.afterSetFilter);const zd=function(i){var e=Math.ceil(this.pixelSize()),t=i.width,r=i.height,s,n,a,o,h,l,d,u=Math.ceil(t/e),c=Math.ceil(r/e),p,f,m,g,_,w,b,T=i.data;if(e<=0){y.error("pixelSize value can not be <= 0");return}for(_=0;_<u;_+=1)for(w=0;w<c;w+=1){for(o=0,h=0,l=0,d=0,p=_*e,f=p+e,m=w*e,g=m+e,b=0,s=p;s<f;s+=1)if(!(s>=t))for(n=m;n<g;n+=1)n>=r||(a=(t*n+s)*4,o+=T[a+0],h+=T[a+1],l+=T[a+2],d+=T[a+3],b+=1);for(o=o/b,h=h/b,l=l/b,d=d/b,s=p;s<f;s+=1)if(!(s>=t))for(n=m;n<g;n+=1)n>=r||(a=(t*n+s)*4,T[a+0]=o,T[a+1]=h,T[a+2]=l,T[a+3]=d)}};v.addGetterSetter(P,"pixelSize",8,x(),v.afterSetFilter);const Wd=function(i){var e=Math.round(this.levels()*254)+1,t=i.data,r=t.length,s=255/e,n;for(n=0;n<r;n+=1)t[n]=Math.floor(t[n]/s)*s};v.addGetterSetter(P,"levels",.5,x(),v.afterSetFilter);const Ud=function(i){var e=i.data,t=e.length,r=this.red(),s=this.green(),n=this.blue(),a,o;for(a=0;a<t;a+=4)o=(.34*e[a]+.5*e[a+1]+.16*e[a+2])/255,e[a]=o*r,e[a+1]=o*s,e[a+2]=o*n,e[a+3]=e[a+3]};v.addGetterSetter(P,"red",0,function(i){return this._filterUpToDate=!1,i>255?255:i<0?0:Math.round(i)});v.addGetterSetter(P,"green",0,function(i){return this._filterUpToDate=!1,i>255?255:i<0?0:Math.round(i)});v.addGetterSetter(P,"blue",0,Na,v.afterSetFilter);const Zd=function(i){var e=i.data,t=e.length,r=this.red(),s=this.green(),n=this.blue(),a=this.alpha(),o,h;for(o=0;o<t;o+=4)h=1-a,e[o]=r*a+e[o]*h,e[o+1]=s*a+e[o+1]*h,e[o+2]=n*a+e[o+2]*h};v.addGetterSetter(P,"red",0,function(i){return this._filterUpToDate=!1,i>255?255:i<0?0:Math.round(i)});v.addGetterSetter(P,"green",0,function(i){return this._filterUpToDate=!1,i>255?255:i<0?0:Math.round(i)});v.addGetterSetter(P,"blue",0,Na,v.afterSetFilter);v.addGetterSetter(P,"alpha",1,function(i){return this._filterUpToDate=!1,i>1?1:i<0?0:i});const jd=function(i){var e=i.data,t=e.length,r,s,n,a;for(r=0;r<t;r+=4)s=e[r+0],n=e[r+1],a=e[r+2],e[r+0]=Math.min(255,s*.393+n*.769+a*.189),e[r+1]=Math.min(255,s*.349+n*.686+a*.168),e[r+2]=Math.min(255,s*.272+n*.534+a*.131)},Xd=function(i){var e=i.data,t=i.width,r=i.height,s=t*4,n=r;do{var a=(n-1)*s,o=t;do{var h=a+(o-1)*4,l=e[h],d=e[h+1],u=e[h+2];l>127&&(l=255-l),d>127&&(d=255-d),u>127&&(u=255-u),e[h]=l,e[h+1]=d,e[h+2]=u}while(--o)}while(--n)},qd=function(i){var e=this.threshold()*255,t=i.data,r=t.length,s;for(s=0;s<r;s+=1)t[s]=t[s]<e?0:255};v.addGetterSetter(P,"threshold",.5,x(),v.afterSetFilter);const M=zn.Util._assign(zn,{Arc:yt,Arrow:jt,Circle:vi,Ellipse:Dt,Image:Je,Label:on,Tag:Xt,Line:bt,Path:he,Rect:Ji,RegularPolygon:qt,Ring:Yt,Sprite:lt,Star:Gt,Text:me,TextPath:Ee,Transformer:oe,Wedge:_t,Filters:{Blur:Td,Brighten:Cd,Contrast:Ed,Emboss:kd,Enhance:xd,Grayscale:Pd,HSL:Ad,HSV:Md,Invert:Od,Kaleidoscope:Id,Mask:$d,Noise:Vd,Pixelate:zd,Posterize:Wd,RGB:Ud,RGBA:Zd,Sepia:jd,Solarize:Xd,Threshold:qd}});var Rs=function(i,e){return Rs=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])},Rs(i,e)};function wt(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Rs(i,e);function t(){this.constructor=i}i.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Yd(i,e,t,r){function s(n){return n instanceof t?n:new t(function(a){a(n)})}return new(t||(t=Promise))(function(n,a){function o(d){try{l(r.next(d))}catch(u){a(u)}}function h(d){try{l(r.throw(d))}catch(u){a(u)}}function l(d){d.done?n(d.value):s(d.value).then(o,h)}l((r=r.apply(i,e||[])).next())})}function po(i,e){var t={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},r,s,n,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(d){return h([l,d])}}function h(l){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(t=0)),t;)try{if(r=1,s&&(n=l[0]&2?s.return:l[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,l[1])).done)return n;switch(s=0,n&&(l=[l[0]&2,n.value]),l[0]){case 0:case 1:n=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,s=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(n=t.trys,!(n=n.length>0&&n[n.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]<n[3])){t.label=l[1];break}if(l[0]===6&&t.label<n[1]){t.label=n[1],n=l;break}if(n&&t.label<n[2]){t.label=n[2],t.ops.push(l);break}n[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(i,t)}catch(d){l=[6,d],s=0}finally{r=n=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function di(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],r=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&r>=i.length&&(i=void 0),{value:i&&i[r++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Mt(i,e){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var r=t.call(i),s,n=[],a;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)n.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(a)throw a.error}}return n}function $t(i,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,n;r<s;r++)(n||!(r in e))&&(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return i.concat(n||Array.prototype.slice.call(e))}function ai(i){return this instanceof ai?(this.v=i,this):new ai(i)}function Kd(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(i,e||[]),s,n=[];return s={},a("next"),a("throw"),a("return"),s[Symbol.asyncIterator]=function(){return this},s;function a(c){r[c]&&(s[c]=function(p){return new Promise(function(f,m){n.push([c,p,f,m])>1||o(c,p)})})}function o(c,p){try{h(r[c](p))}catch(f){u(n[0][3],f)}}function h(c){c.value instanceof ai?Promise.resolve(c.value.v).then(l,d):u(n[0][2],c)}function l(c){o("next",c)}function d(c){o("throw",c)}function u(c,p){c(p),n.shift(),n.length&&o(n[0][0],n[0][1])}}function Jd(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=i[Symbol.asyncIterator],t;return e?e.call(i):(i=typeof di=="function"?di(i):i[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=i[n]&&function(a){return new Promise(function(o,h){a=i[n](a),s(o,h,a.done,a.value)})}}function s(n,a,o,h){Promise.resolve(h).then(function(l){n({value:l,done:o})},a)}}function de(i){return typeof i=="function"}function ln(i){var e=function(r){Error.call(r),r.stack=new Error().stack},t=i(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var ys=ln(function(i){return function(t){i(this),this.message=t?t.length+` errors occurred during unsubscription:
3
3
  `+t.map(function(r,s){return s+1+") "+r.toString()}).join(`
4
- `):"",this.name="UnsubscriptionError",this.errors=t}});function Lr(i,e){if(i){var t=i.indexOf(e);0<=t&&i.splice(t,1)}}var Qi=function(){function i(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return i.prototype.unsubscribe=function(){var e,t,r,s,n;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var o=di(a),h=o.next();!h.done;h=o.next()){var l=h.value;l.remove(this)}}catch(m){e={error:m}}finally{try{h&&!h.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else a.remove(this);var d=this.initialTeardown;if(de(d))try{d()}catch(m){n=m instanceof ys?m.errors:[m]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var c=di(u),p=c.next();!p.done;p=c.next()){var f=p.value;try{Jn(f)}catch(m){n=n??[],m instanceof ys?n=$t($t([],Mt(n)),Mt(m.errors)):n.push(m)}}}catch(m){r={error:m}}finally{try{p&&!p.done&&(s=c.return)&&s.call(c)}finally{if(r)throw r.error}}}if(n)throw new ys(n)}},i.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)Jn(e);else{if(e instanceof i){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},i.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},i.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},i.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Lr(t,e)},i.prototype.remove=function(e){var t=this._finalizers;t&&Lr(t,e),e instanceof i&&e._removeParent(this)},i.EMPTY=function(){var e=new i;return e.closed=!0,e}(),i}(),mo=Qi.EMPTY;function go(i){return i instanceof Qi||i&&"closed"in i&&de(i.remove)&&de(i.add)&&de(i.unsubscribe)}function Jn(i){de(i)?i():i.unsubscribe()}var vo={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Is={setTimeout:function(i,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];var s=Is.delegate;return s!=null&&s.setTimeout?s.setTimeout.apply(s,$t([i,e],Mt(t))):setTimeout.apply(void 0,$t([i,e],Mt(t)))},clearTimeout:function(i){var e=Is.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(i)},delegate:void 0};function yo(i){Is.setTimeout(function(){throw i})}function Rr(){}function Cr(i){i()}var hn=function(i){wt(e,i);function e(t){var r=i.call(this)||this;return r.isStopped=!1,t?(r.destination=t,go(t)&&t.add(r)):r.destination=iu,r}return e.create=function(t,r,s){return new Ns(t,r,s)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,i.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Qi),Qd=Function.prototype.bind;function bs(i,e){return Qd.call(i,e)}var eu=function(){function i(e){this.partialObserver=e}return i.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(r){yr(r)}},i.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(r){yr(r)}else yr(e)},i.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){yr(t)}},i}(),Ns=function(i){wt(e,i);function e(t,r,s){var n=i.call(this)||this,a;if(de(t)||!t)a={next:t??void 0,error:r??void 0,complete:s??void 0};else{var o;n&&vo.useDeprecatedNextContext?(o=Object.create(t),o.unsubscribe=function(){return n.unsubscribe()},a={next:t.next&&bs(t.next,o),error:t.error&&bs(t.error,o),complete:t.complete&&bs(t.complete,o)}):a=t}return n.destination=new eu(a),n}return e}(hn);function yr(i){yo(i)}function tu(i){throw i}var iu={closed:!0,next:Rr,error:tu,complete:Rr},dn=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function er(i){return i}function ru(i){return i.length===0?er:i.length===1?i[0]:function(t){return i.reduce(function(r,s){return s(r)},t)}}var se=function(){function i(e){e&&(this._subscribe=e)}return i.prototype.lift=function(e){var t=new i;return t.source=this,t.operator=e,t},i.prototype.subscribe=function(e,t,r){var s=this,n=nu(e)?e:new Ns(e,t,r);return Cr(function(){var a=s,o=a.operator,h=a.source;n.add(o?o.call(n,h):h?s._subscribe(n):s._trySubscribe(n))}),n},i.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},i.prototype.forEach=function(e,t){var r=this;return t=Qn(t),new t(function(s,n){var a=new Ns({next:function(o){try{e(o)}catch(h){n(h),a.unsubscribe()}},error:n,complete:s});r.subscribe(a)})},i.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},i.prototype[dn]=function(){return this},i.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ru(e)(this)},i.prototype.toPromise=function(e){var t=this;return e=Qn(e),new e(function(r,s){var n;t.subscribe(function(a){return n=a},function(a){return s(a)},function(){return r(n)})})},i.create=function(e){return new i(e)},i}();function Qn(i){var e;return(e=i??vo.Promise)!==null&&e!==void 0?e:Promise}function su(i){return i&&de(i.next)&&de(i.error)&&de(i.complete)}function nu(i){return i&&i instanceof hn||su(i)&&go(i)}function au(i){return de(i==null?void 0:i.lift)}function Fe(i){return function(e){if(au(e))return e.lift(function(t){try{return i(t,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function Ae(i,e,t,r,s){return new ou(i,e,t,r,s)}var ou=function(i){wt(e,i);function e(t,r,s,n,a,o){var h=i.call(this,t)||this;return h.onFinalize=a,h.shouldUnsubscribe=o,h._next=r?function(l){try{r(l)}catch(d){t.error(d)}}:i.prototype._next,h._error=n?function(l){try{n(l)}catch(d){t.error(d)}finally{this.unsubscribe()}}:i.prototype._error,h._complete=s?function(){try{s()}catch(l){t.error(l)}finally{this.unsubscribe()}}:i.prototype._complete,h}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;i.prototype.unsubscribe.call(this),!r&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(hn),lu=ln(function(i){return function(){i(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),V=function(i){wt(e,i);function e(){var t=i.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var r=new ea(this,this);return r.operator=t,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new lu},e.prototype.next=function(t){var r=this;Cr(function(){var s,n;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var a=di(r.currentObservers),o=a.next();!o.done;o=a.next()){var h=o.value;h.next(t)}}catch(l){s={error:l}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(s)throw s.error}}}})},e.prototype.error=function(t){var r=this;Cr(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=t;for(var s=r.observers;s.length;)s.shift().error(t)}})},e.prototype.complete=function(){var t=this;Cr(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var r=t.observers;r.length;)r.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),i.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var r=this,s=this,n=s.hasError,a=s.isStopped,o=s.observers;return n||a?mo:(this.currentObservers=null,o.push(t),new Qi(function(){r.currentObservers=null,Lr(o,t)}))},e.prototype._checkFinalizedStatuses=function(t){var r=this,s=r.hasError,n=r.thrownError,a=r.isStopped;s?t.error(n):a&&t.complete()},e.prototype.asObservable=function(){var t=new se;return t.source=this,t},e.create=function(t,r){return new ea(t,r)},e}(se),ea=function(i){wt(e,i);function e(t,r){var s=i.call(this)||this;return s.destination=t,s.source=r,s}return e.prototype.next=function(t){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,t)},e.prototype.error=function(t){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.call(r,t)},e.prototype.complete=function(){var t,r;(r=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||r===void 0||r.call(t)},e.prototype._subscribe=function(t){var r,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(t))!==null&&s!==void 0?s:mo},e}(V),ti=function(i){wt(e,i);function e(t){var r=i.call(this)||this;return r._value=t,r}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(t){var r=i.prototype._subscribe.call(this,t);return!r.closed&&t.next(this._value),r},e.prototype.getValue=function(){var t=this,r=t.hasError,s=t.thrownError,n=t._value;if(r)throw s;return this._throwIfClosed(),n},e.prototype.next=function(t){i.prototype.next.call(this,this._value=t)},e}(V),bo={now:function(){return(bo.delegate||Date).now()},delegate:void 0},hu=function(i){wt(e,i);function e(t,r){return i.call(this)||this}return e.prototype.schedule=function(t,r){return this},e}(Qi),Ir={setInterval:function(i,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];var s=Ir.delegate;return s!=null&&s.setInterval?s.setInterval.apply(s,$t([i,e],Mt(t))):setInterval.apply(void 0,$t([i,e],Mt(t)))},clearInterval:function(i){var e=Ir.delegate;return((e==null?void 0:e.clearInterval)||clearInterval)(i)},delegate:void 0},du=function(i){wt(e,i);function e(t,r){var s=i.call(this,t,r)||this;return s.scheduler=t,s.work=r,s.pending=!1,s}return e.prototype.schedule=function(t,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=t;var n=this.id,a=this.scheduler;return n!=null&&(this.id=this.recycleAsyncId(a,n,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(a,this.id,r),this},e.prototype.requestAsyncId=function(t,r,s){return s===void 0&&(s=0),Ir.setInterval(t.flush.bind(t,this),s)},e.prototype.recycleAsyncId=function(t,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&Ir.clearInterval(r)},e.prototype.execute=function(t,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(t,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,r){var s=!1,n;try{this.work(t)}catch(a){s=!0,n=a||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),n},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,r=t.id,s=t.scheduler,n=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Lr(n,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,i.prototype.unsubscribe.call(this)}},e}(hu),ta=function(){function i(e,t){t===void 0&&(t=i.now),this.schedulerActionCtor=e,this.now=t}return i.prototype.schedule=function(e,t,r){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},i.now=bo.now,i}(),uu=function(i){wt(e,i);function e(t,r){r===void 0&&(r=ta.now);var s=i.call(this,t,r)||this;return s.actions=[],s._active=!1,s}return e.prototype.flush=function(t){var r=this.actions;if(this._active){r.push(t);return}var s;this._active=!0;do if(s=t.execute(t.state,t.delay))break;while(t=r.shift());if(this._active=!1,s){for(;t=r.shift();)t.unsubscribe();throw s}},e}(ta),Jr=new uu(du),cu=Jr,fu=new se(function(i){return i.complete()});function _o(i){return i&&de(i.schedule)}function wo(i){return i[i.length-1]}function So(i){return de(wo(i))?i.pop():void 0}function un(i){return _o(wo(i))?i.pop():void 0}var cn=function(i){return i&&typeof i.length=="number"&&typeof i!="function"};function To(i){return de(i==null?void 0:i.then)}function Co(i){return de(i[dn])}function Eo(i){return Symbol.asyncIterator&&de(i==null?void 0:i[Symbol.asyncIterator])}function ko(i){return new TypeError("You provided "+(i!==null&&typeof i=="object"?"an invalid object":"'"+i+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function pu(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var xo=pu();function Po(i){return de(i==null?void 0:i[xo])}function Ao(i){return Kd(this,arguments,function(){var t,r,s,n;return po(this,function(a){switch(a.label){case 0:t=i.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,ai(t.read())];case 3:return r=a.sent(),s=r.value,n=r.done,n?[4,ai(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,ai(s)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Mo(i){return de(i==null?void 0:i.getReader)}function Ke(i){if(i instanceof se)return i;if(i!=null){if(Co(i))return mu(i);if(cn(i))return gu(i);if(To(i))return vu(i);if(Eo(i))return Oo(i);if(Po(i))return yu(i);if(Mo(i))return bu(i)}throw ko(i)}function mu(i){return new se(function(e){var t=i[dn]();if(de(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function gu(i){return new se(function(e){for(var t=0;t<i.length&&!e.closed;t++)e.next(i[t]);e.complete()})}function vu(i){return new se(function(e){i.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,yo)})}function yu(i){return new se(function(e){var t,r;try{for(var s=di(i),n=s.next();!n.done;n=s.next()){var a=n.value;if(e.next(a),e.closed)return}}catch(o){t={error:o}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}e.complete()})}function Oo(i){return new se(function(e){_u(i,e).catch(function(t){return e.error(t)})})}function bu(i){return Oo(Ao(i))}function _u(i,e){var t,r,s,n;return Yd(this,void 0,void 0,function(){var a,o;return po(this,function(h){switch(h.label){case 0:h.trys.push([0,5,6,11]),t=Jd(i),h.label=1;case 1:return[4,t.next()];case 2:if(r=h.sent(),!!r.done)return[3,4];if(a=r.value,e.next(a),e.closed)return[2];h.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return o=h.sent(),s={error:o},[3,11];case 6:return h.trys.push([6,,9,10]),r&&!r.done&&(n=t.return)?[4,n.call(t)]:[3,8];case 7:h.sent(),h.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function ct(i,e,t,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var n=e.schedule(function(){t(),s?i.add(this.schedule(null,r)):this.unsubscribe()},r);if(i.add(n),!s)return n}function Lo(i,e){return e===void 0&&(e=0),Fe(function(t,r){t.subscribe(Ae(r,function(s){return ct(r,i,function(){return r.next(s)},e)},function(){return ct(r,i,function(){return r.complete()},e)},function(s){return ct(r,i,function(){return r.error(s)},e)}))})}function Ro(i,e){return e===void 0&&(e=0),Fe(function(t,r){r.add(i.schedule(function(){return t.subscribe(r)},e))})}function wu(i,e){return Ke(i).pipe(Ro(e),Lo(e))}function Su(i,e){return Ke(i).pipe(Ro(e),Lo(e))}function Tu(i,e){return new se(function(t){var r=0;return e.schedule(function(){r===i.length?t.complete():(t.next(i[r++]),t.closed||this.schedule())})})}function Cu(i,e){return new se(function(t){var r;return ct(t,e,function(){r=i[xo](),ct(t,e,function(){var s,n,a;try{s=r.next(),n=s.value,a=s.done}catch(o){t.error(o);return}a?t.complete():t.next(n)},0,!0)}),function(){return de(r==null?void 0:r.return)&&r.return()}})}function Io(i,e){if(!i)throw new Error("Iterable cannot be null");return new se(function(t){ct(t,e,function(){var r=i[Symbol.asyncIterator]();ct(t,e,function(){r.next().then(function(s){s.done?t.complete():t.next(s.value)})},0,!0)})})}function Eu(i,e){return Io(Ao(i),e)}function ku(i,e){if(i!=null){if(Co(i))return wu(i,e);if(cn(i))return Tu(i,e);if(To(i))return Su(i,e);if(Eo(i))return Io(i,e);if(Po(i))return Cu(i,e);if(Mo(i))return Eu(i,e)}throw ko(i)}function tr(i,e){return e?ku(i,e):Ke(i)}function Ee(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];var t=un(i);return tr(i,t)}function ia(i,e){var t=de(i)?i:function(){return i},r=function(s){return s.error(t())};return new se(e?function(s){return e.schedule(r,0,s)}:r)}var No=ln(function(i){return function(){i(this),this.name="EmptyError",this.message="no elements in sequence"}});function xu(i){return i instanceof Date&&!isNaN(i)}function ke(i,e){return Fe(function(t,r){var s=0;t.subscribe(Ae(r,function(n){r.next(i.call(e,n,s++))}))})}var Pu=Array.isArray;function Au(i,e){return Pu(e)?i.apply(void 0,$t([],Mt(e))):i(e)}function fn(i){return ke(function(e){return Au(i,e)})}var Mu=Array.isArray,Ou=Object.getPrototypeOf,Lu=Object.prototype,Ru=Object.keys;function Go(i){if(i.length===1){var e=i[0];if(Mu(e))return{args:e,keys:null};if(Iu(e)){var t=Ru(e);return{args:t.map(function(r){return e[r]}),keys:t}}}return{args:i,keys:null}}function Iu(i){return i&&typeof i=="object"&&Ou(i)===Lu}function Do(i,e){return i.reduce(function(t,r,s){return t[r]=e[s],t},{})}function Nu(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];var t=un(i),r=So(i),s=Go(i),n=s.args,a=s.keys;if(n.length===0)return tr([],t);var o=new se(Gu(n,t,a?function(h){return Do(a,h)}:er));return r?o.pipe(fn(r)):o}function Gu(i,e,t){return t===void 0&&(t=er),function(r){ra(e,function(){for(var s=i.length,n=new Array(s),a=s,o=s,h=function(d){ra(e,function(){var u=tr(i[d],e),c=!1;u.subscribe(Ae(r,function(p){n[d]=p,c||(c=!0,o--),o||r.next(t(n.slice()))},function(){--a||r.complete()}))},r)},l=0;l<s;l++)h(l)},r)}}function ra(i,e,t){i?ct(t,i,e):e()}function Du(i,e,t,r,s,n,a,o){var h=[],l=0,d=0,u=!1,c=function(){u&&!h.length&&!l&&e.complete()},p=function(m){return l<r?f(m):h.push(m)},f=function(m){n&&e.next(m),l++;var g=!1;Ke(t(m,d++)).subscribe(Ae(e,function(_){s==null||s(_),n?p(_):e.next(_)},function(){g=!0},void 0,function(){if(g)try{l--;for(var _=function(){var w=h.shift();a?ct(e,a,function(){return f(w)}):f(w)};h.length&&l<r;)_();c()}catch(w){e.error(w)}}))};return i.subscribe(Ae(e,p,function(){u=!0,c()})),function(){o==null||o()}}function Qr(i,e,t){return t===void 0&&(t=1/0),de(e)?Qr(function(r,s){return ke(function(n,a){return e(r,n,s,a)})(Ke(i(r,s)))},t):(typeof e=="number"&&(t=e),Fe(function(r,s){return Du(r,s,i,t)}))}function Fu(i){return i===void 0&&(i=1/0),Qr(er,i)}function Hu(){return Fu(1)}function Bu(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];return Hu()(tr(i,un(i)))}function $u(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];var t=So(i),r=Go(i),s=r.args,n=r.keys,a=new se(function(o){var h=s.length;if(!h){o.complete();return}for(var l=new Array(h),d=h,u=h,c=function(f){var m=!1;Ke(s[f]).subscribe(Ae(o,function(g){m||(m=!0,u--),l[f]=g},function(){return d--},void 0,function(){(!d||!m)&&(u||o.next(n?Do(n,l):l),o.complete())}))},p=0;p<h;p++)c(p)});return t?a.pipe(fn(t)):a}var Vu=["addListener","removeListener"],zu=["addEventListener","removeEventListener"],Uu=["on","off"];function be(i,e,t,r){if(de(t)&&(r=t,t=void 0),r)return be(i,e,t).pipe(fn(r));var s=Mt(ju(i)?zu.map(function(o){return function(h){return i[o](e,h,t)}}):Wu(i)?Vu.map(sa(i,e)):Zu(i)?Uu.map(sa(i,e)):[],2),n=s[0],a=s[1];if(!n&&cn(i))return Qr(function(o){return be(o,e,t)})(Ke(i));if(!n)throw new TypeError("Invalid event target");return new se(function(o){var h=function(){for(var l=[],d=0;d<arguments.length;d++)l[d]=arguments[d];return o.next(1<l.length?l:l[0])};return n(h),function(){return a(h)}})}function sa(i,e){return function(t){return function(r){return i[t](e,r)}}}function Wu(i){return de(i.addListener)&&de(i.removeListener)}function Zu(i){return de(i.on)&&de(i.off)}function ju(i){return de(i.addEventListener)&&de(i.removeEventListener)}function Fo(i,e,t){i===void 0&&(i=0),t===void 0&&(t=cu);var r=-1;return e!=null&&(_o(e)?t=e:r=e),new se(function(s){var n=xu(i)?+i-t.now():i;n<0&&(n=0);var a=0;return t.schedule(function(){s.closed||(s.next(a++),0<=r?this.schedule(void 0,r):s.complete())},n)})}function Xu(i,e){return i===void 0&&(i=0),e===void 0&&(e=Jr),i<0&&(i=0),Fo(i,i,e)}function Ve(i,e){return Fe(function(t,r){var s=0;t.subscribe(Ae(r,function(n){return i.call(e,n,s++)&&r.next(n)}))})}function yi(i){return Fe(function(e,t){var r=null,s=!1,n;r=e.subscribe(Ae(t,void 0,void 0,function(a){n=Ke(i(a,yi(i)(e))),r?(r.unsubscribe(),r=null,n.subscribe(t)):s=!0})),s&&(r.unsubscribe(),r=null,n.subscribe(t))})}function Ho(i,e){return e===void 0&&(e=Jr),Fe(function(t,r){var s=null,n=null,a=null,o=function(){if(s){s.unsubscribe(),s=null;var l=n;n=null,r.next(l)}};function h(){var l=a+i,d=e.now();if(d<l){s=this.schedule(void 0,l-d),r.add(s);return}o()}t.subscribe(Ae(r,function(l){n=l,a=e.now(),s||(s=e.schedule(h,i),r.add(s))},function(){o(),r.complete()},void 0,function(){n=s=null}))})}function qu(i){return Fe(function(e,t){var r=!1;e.subscribe(Ae(t,function(s){r=!0,t.next(s)},function(){r||t.next(i),t.complete()}))})}function ft(i){return i<=0?function(){return fu}:Fe(function(e,t){var r=0;e.subscribe(Ae(t,function(s){++r<=i&&(t.next(s),i<=r&&t.complete())}))})}function Yu(){return Fe(function(i,e){i.subscribe(Ae(e,Rr))})}function Ku(i){return ke(function(){return i})}function Bo(i,e){return e?function(t){return Bu(e.pipe(ft(1),Yu()),t.pipe(Bo(i)))}:Qr(function(t,r){return Ke(i(t,r)).pipe(ft(1),Ku(t))})}function Ju(i,e){e===void 0&&(e=Jr);var t=Fo(i,e);return Bo(function(){return t})}function Qu(i){return i===void 0&&(i=ec),Fe(function(e,t){var r=!1;e.subscribe(Ae(t,function(s){r=!0,t.next(s)},function(){return r?t.complete():t.error(i())}))})}function ec(){return new No}function ui(i,e){var t=arguments.length>=2;return function(r){return r.pipe(i?Ve(function(s,n){return i(s,n,r)}):er,ft(1),t?qu(e):Qu(function(){return new No}))}}function tc(i,e){return Fe(function(t,r){var s=null,n=0,a=!1,o=function(){return a&&!s&&r.complete()};t.subscribe(Ae(r,function(h){s==null||s.unsubscribe();var l=0,d=n++;Ke(i(h,d)).subscribe(s=Ae(r,function(u){return r.next(e?e(h,u,d,l++):u)},function(){s=null,o()}))},function(){a=!0,o()}))})}function k(i){return Fe(function(e,t){Ke(i).subscribe(Ae(t,function(){return t.complete()},Rr)),!t.closed&&e.subscribe(t)})}class $o{constructor(e){this.onChange$=new V,this.style=e}get style(){return this._style}set style(e){this._style={...this._style,...e},this.onChange$.next(this._style)}}function $e(i){i&&(i.closed||(i.next(),i.complete()))}function pn(...i){i.forEach(e=>{$e(e)})}function ic(i){i&&(i.closed||i.complete())}function Vt(...i){i.forEach(e=>{ic(e)})}function bi(...i){i.forEach(e=>{rc(e)})}function rc(i){i&&(i.closed||i.unsubscribe())}const _i=(i,e)=>({...e,...i,style:{...e.style,...i.style}});class Je{constructor(e){this.onDestroy$=new V,this.config=e,this.styleAdapter=new $o(e.style)}initCanvasNode(){if(this.isInitialized())throw new Error("Konva node already initalized");return this.canvasNode=this.createCanvasNode(),this.afterCanvasNodeInit(),this.canvasNode}initCanvasNodeAsync(){return this.createCanvasNodeAsync().pipe(ke(e=>(this.canvasNode=e,this.afterCanvasNodeInit(),this.canvasNode)))}createCanvasNodeAsync(){return Ee(this.createCanvasNode())}afterCanvasNodeInit(){}destroy(){this.isInitialized()&&this.getCanvasNode().destroy(),$e(this.onDestroy$),this.config=void 0,this.styleAdapter=void 0,this.canvasNode=void 0}getCanvasNode(){return this.canvasNode}isInitialized(){return!!this.getCanvasNode()}get style(){return this.styleAdapter.style}set style(e){this.styleAdapter.style=e}}class F{}F.POSITION_TOP_LEFT={x:0,y:0};F.DIMENSION_ZERO={width:0,height:0};F.GOLDEN_RATIO=1.61;F.TIMELINE_ZOOM_EASED_DURATION_MS=800;F.TIMELINE_SCROLL_EASED_DURATION_MS=200;F.MIME_TYPE_VND_APPLE_MPEGURL="application/vnd.apple.mpegurl";var ae;(function(i){i.assertEqual=s=>s;function e(s){}i.assertIs=e;function t(s){throw new Error}i.assertNever=t,i.arrayToEnum=s=>{const n={};for(const a of s)n[a]=a;return n},i.getValidEnumValues=s=>{const n=i.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of n)a[o]=s[o];return i.objectValues(a)},i.objectValues=s=>i.objectKeys(s).map(function(n){return s[n]}),i.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const n=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&n.push(a);return n},i.find=(s,n)=>{for(const a of s)if(n(a))return a},i.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,n=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(n)}i.joinValues=r,i.jsonStringifyReplacer=(s,n)=>typeof n=="bigint"?n.toString():n})(ae||(ae={}));const N=ae.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pt=i=>{switch(typeof i){case"undefined":return N.undefined;case"string":return N.string;case"number":return isNaN(i)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":return Array.isArray(i)?N.array:i===null?N.null:i.then&&typeof i.then=="function"&&i.catch&&typeof i.catch=="function"?N.promise:typeof Map<"u"&&i instanceof Map?N.map:typeof Set<"u"&&i instanceof Set?N.set:typeof Date<"u"&&i instanceof Date?N.date:N.object;default:return N.unknown}},O=ae.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),sc=i=>JSON.stringify(i,null,2).replace(/"([^"]+)":/g,"$1:");class rt extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(n){return n.message},r={_errors:[]},s=n=>{for(const a of n.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(t(a));else{let o=r,h=0;for(;h<a.path.length;){const l=a.path[h];h===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(a))):o[l]=o[l]||{_errors:[]},o=o[l],h++}}};return s(this),r}toString(){return this.message}get message(){return JSON.stringify(this.issues,ae.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}rt.create=i=>new rt(i);const Fi=(i,e)=>{let t;switch(i.code){case O.invalid_type:i.received===N.undefined?t="Required":t=`Expected ${i.expected}, received ${i.received}`;break;case O.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(i.expected,ae.jsonStringifyReplacer)}`;break;case O.unrecognized_keys:t=`Unrecognized key(s) in object: ${ae.joinValues(i.keys,", ")}`;break;case O.invalid_union:t="Invalid input";break;case O.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${ae.joinValues(i.options)}`;break;case O.invalid_enum_value:t=`Invalid enum value. Expected ${ae.joinValues(i.options)}, received '${i.received}'`;break;case O.invalid_arguments:t="Invalid function arguments";break;case O.invalid_return_type:t="Invalid function return type";break;case O.invalid_date:t="Invalid date";break;case O.invalid_string:typeof i.validation=="object"?"startsWith"in i.validation?t=`Invalid input: must start with "${i.validation.startsWith}"`:"endsWith"in i.validation?t=`Invalid input: must end with "${i.validation.endsWith}"`:ae.assertNever(i.validation):i.validation!=="regex"?t=`Invalid ${i.validation}`:t="Invalid";break;case O.too_small:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at least":"more than"} ${i.minimum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at least":"over"} ${i.minimum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${i.minimum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${new Date(i.minimum)}`:t="Invalid input";break;case O.too_big:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at most":"less than"} ${i.maximum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at most":"under"} ${i.maximum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly":i.inclusive?"smaller than or equal to":"smaller than"} ${new Date(i.maximum)}`:t="Invalid input";break;case O.custom:t="Invalid input";break;case O.invalid_intersection_types:t="Intersection results could not be merged";break;case O.not_multiple_of:t=`Number must be a multiple of ${i.multipleOf}`;break;case O.not_finite:t="Number must be finite";break;default:t=e.defaultError,ae.assertNever(i)}return{message:t}};let Vo=Fi;function nc(i){Vo=i}function Nr(){return Vo}const Gr=i=>{const{data:e,path:t,errorMaps:r,issueData:s}=i,n=[...t,...s.path||[]],a={...s,path:n};let o="";const h=r.filter(l=>!!l).slice().reverse();for(const l of h)o=l(a,{data:e,defaultError:o}).message;return{...s,path:n,message:s.message||o}},ac=[];function B(i,e){const t=Gr({issueData:e,data:i.data,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,Nr(),Fi].filter(r=>!!r)});i.common.issues.push(t)}class Le{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return Y;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t)r.push({key:await s.key,value:await s.value});return Le.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:n,value:a}=s;if(n.status==="aborted"||a.status==="aborted")return Y;n.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),(typeof a.value<"u"||s.alwaysSet)&&(r[n.value]=a.value)}return{status:e.value,value:r}}}const Y=Object.freeze({status:"aborted"}),zo=i=>({status:"dirty",value:i}),Me=i=>({status:"valid",value:i}),Gs=i=>i.status==="aborted",Ds=i=>i.status==="dirty",Dr=i=>i.status==="valid",Fr=i=>typeof Promise<"u"&&i instanceof Promise;var ee;(function(i){i.errToObj=e=>typeof e=="string"?{message:e}:e||{},i.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ee||(ee={}));class st{constructor(e,t,r,s){this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._path.concat(this._key)}}const na=(i,e)=>{if(Dr(e))return{success:!0,data:e.value};if(!i.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,error:new rt(i.common.issues)}};function J(i){if(!i)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=i;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>a.code!=="invalid_type"?{message:o.defaultError}:typeof o.data>"u"?{message:r??o.defaultError}:{message:t??o.defaultError},description:s}}class Q{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Pt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Le,ctx:{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Fr(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pt(e)},n=this._parseSync({data:e,path:s.path,parent:s});return na(s,n)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pt(e)},s=this._parse({data:e,path:r.path,parent:r}),n=await(Fr(s)?s:Promise.resolve(s));return na(r,n)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,n)=>{const a=e(s),o=()=>n.addIssue({code:O.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(h=>h?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new Xe({schema:this,typeName:X.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return pt.create(this,this._def)}nullable(){return Wt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ze.create(this,this._def)}promise(){return fi.create(this,this._def)}or(e){return zi.create([this,e],this._def)}and(e){return Ui.create(this,e,this._def)}transform(e){return new Xe({...J(this._def),schema:this,typeName:X.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new qi({...J(this._def),innerType:this,defaultValue:t,typeName:X.ZodDefault})}brand(){return new Wo({typeName:X.ZodBranded,type:this,...J(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new zr({...J(this._def),innerType:this,catchValue:t,typeName:X.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ir.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const oc=/^c[^\s-]{8,}$/i,lc=/^[a-z][a-z0-9]*$/,hc=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,dc=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|([^-]([a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}))$/,uc=i=>i.precision?i.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${i.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${i.precision}}Z$`):i.precision===0?i.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):i.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");class gt extends Q{constructor(){super(...arguments),this._regex=(e,t,r)=>this.refinement(s=>e.test(s),{validation:t,code:O.invalid_string,...ee.errToObj(r)}),this.nonempty=e=>this.min(1,ee.errToObj(e)),this.trim=()=>new gt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==N.string){const n=this._getOrReturnCtx(e);return B(n,{code:O.invalid_type,expected:N.string,received:n.parsedType}),Y}const r=new Le;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,o=e.data.length<n.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?B(s,{code:O.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):o&&B(s,{code:O.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if(n.kind==="email")dc.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"email",code:O.invalid_string,message:n.message}),r.dirty());else if(n.kind==="uuid")hc.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"uuid",code:O.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid")oc.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid",code:O.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid2")lc.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid2",code:O.invalid_string,message:n.message}),r.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),B(s,{validation:"url",code:O.invalid_string,message:n.message}),r.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"regex",code:O.invalid_string,message:n.message}),r.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):n.kind==="datetime"?uc(n).test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:"datetime",message:n.message}),r.dirty()):ae.assertNever(n);return{status:r.value,value:e.data}}_addCheck(e){return new gt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ee.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ee.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ee.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ee.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ee.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...ee.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ee.errToObj(t)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ee.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ee.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ee.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ee.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ee.errToObj(t)})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}gt.create=i=>{var e;return new gt({checks:[],typeName:X.ZodString,coerce:(e=i==null?void 0:i.coerce)!==null&&e!==void 0?e:!1,...J(i)})};function cc(i,e){const t=(i.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,n=parseInt(i.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return n%a/Math.pow(10,s)}class Ot extends Q{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==N.number){const n=this._getOrReturnCtx(e);return B(n,{code:O.invalid_type,expected:N.number,received:n.parsedType}),Y}let r;const s=new Le;for(const n of this._def.checks)n.kind==="int"?ae.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),B(r,{code:O.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(r=this._getOrReturnCtx(e,r),B(r,{code:O.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(r=this._getOrReturnCtx(e,r),B(r,{code:O.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?cc(e.data,n.value)!==0&&(r=this._getOrReturnCtx(e,r),B(r,{code:O.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),B(r,{code:O.not_finite,message:n.message}),s.dirty()):ae.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ee.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ee.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ee.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ee.toString(t))}setLimit(e,t,r,s){return new Ot({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:ee.toString(s)}]})}_addCheck(e){return new Ot({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ee.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ee.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ee.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ee.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ee.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ee.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ee.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ae.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Ot.create=i=>new Ot({checks:[],typeName:X.ZodNumber,coerce:(i==null?void 0:i.coerce)||!1,...J(i)});class Hi extends Q{_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==N.bigint){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.bigint,received:r.parsedType}),Y}return Me(e.data)}}Hi.create=i=>{var e;return new Hi({typeName:X.ZodBigInt,coerce:(e=i==null?void 0:i.coerce)!==null&&e!==void 0?e:!1,...J(i)})};class Bi extends Q{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==N.boolean){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.boolean,received:r.parsedType}),Y}return Me(e.data)}}Bi.create=i=>new Bi({typeName:X.ZodBoolean,coerce:(i==null?void 0:i.coerce)||!1,...J(i)});class zt extends Q{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==N.date){const n=this._getOrReturnCtx(e);return B(n,{code:O.invalid_type,expected:N.date,received:n.parsedType}),Y}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return B(n,{code:O.invalid_date}),Y}const r=new Le;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),r.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):ae.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new zt({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ee.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ee.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}zt.create=i=>new zt({checks:[],coerce:(i==null?void 0:i.coerce)||!1,typeName:X.ZodDate,...J(i)});class Hr extends Q{_parse(e){if(this._getType(e)!==N.symbol){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.symbol,received:r.parsedType}),Y}return Me(e.data)}}Hr.create=i=>new Hr({typeName:X.ZodSymbol,...J(i)});class $i extends Q{_parse(e){if(this._getType(e)!==N.undefined){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.undefined,received:r.parsedType}),Y}return Me(e.data)}}$i.create=i=>new $i({typeName:X.ZodUndefined,...J(i)});class Vi extends Q{_parse(e){if(this._getType(e)!==N.null){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.null,received:r.parsedType}),Y}return Me(e.data)}}Vi.create=i=>new Vi({typeName:X.ZodNull,...J(i)});class ci extends Q{constructor(){super(...arguments),this._any=!0}_parse(e){return Me(e.data)}}ci.create=i=>new ci({typeName:X.ZodAny,...J(i)});class Bt extends Q{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Me(e.data)}}Bt.create=i=>new Bt({typeName:X.ZodUnknown,...J(i)});class vt extends Q{_parse(e){const t=this._getOrReturnCtx(e);return B(t,{code:O.invalid_type,expected:N.never,received:t.parsedType}),Y}}vt.create=i=>new vt({typeName:X.ZodNever,...J(i)});class Br extends Q{_parse(e){if(this._getType(e)!==N.undefined){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.void,received:r.parsedType}),Y}return Me(e.data)}}Br.create=i=>new Br({typeName:X.ZodVoid,...J(i)});class Ze extends Q{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==N.array)return B(t,{code:O.invalid_type,expected:N.array,received:t.parsedType}),Y;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(B(t,{code:a?O.too_big:O.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(B(t,{code:O.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(B(t,{code:O.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new st(t,a,t.path,o)))).then(a=>Le.mergeArray(r,a));const n=[...t.data].map((a,o)=>s.type._parseSync(new st(t,a,t.path,o)));return Le.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new Ze({...this._def,minLength:{value:e,message:ee.toString(t)}})}max(e,t){return new Ze({...this._def,maxLength:{value:e,message:ee.toString(t)}})}length(e,t){return new Ze({...this._def,exactLength:{value:e,message:ee.toString(t)}})}nonempty(e){return this.min(1,e)}}Ze.create=(i,e)=>new Ze({type:i,minLength:null,maxLength:null,exactLength:null,typeName:X.ZodArray,...J(e)});var $r;(function(i){i.mergeShapes=(e,t)=>({...e,...t})})($r||($r={}));function Qt(i){if(i instanceof pe){const e={};for(const t in i.shape){const r=i.shape[t];e[t]=pt.create(Qt(r))}return new pe({...i._def,shape:()=>e})}else return i instanceof Ze?Ze.create(Qt(i.element)):i instanceof pt?pt.create(Qt(i.unwrap())):i instanceof Wt?Wt.create(Qt(i.unwrap())):i instanceof nt?nt.create(i.items.map(e=>Qt(e))):i}class pe extends Q{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=ae.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==N.object){const l=this._getOrReturnCtx(e);return B(l,{code:O.invalid_type,expected:N.object,received:l.parsedType}),Y}const{status:r,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof vt&&this._def.unknownKeys==="strip"))for(const l in s.data)a.includes(l)||o.push(l);const h=[];for(const l of a){const d=n[l],u=s.data[l];h.push({key:{status:"valid",value:l},value:d._parse(new st(s,u,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof vt){const l=this._def.unknownKeys;if(l==="passthrough")for(const d of o)h.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(l==="strict")o.length>0&&(B(s,{code:O.unrecognized_keys,keys:o}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const d of o){const u=s.data[d];h.push({key:{status:"valid",value:d},value:l._parse(new st(s,u,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const l=[];for(const d of h){const u=await d.key;l.push({key:u,value:await d.value,alwaysSet:d.alwaysSet})}return l}).then(l=>Le.mergeObjectSync(r,l)):Le.mergeObjectSync(r,h)}get shape(){return this._def.shape()}strict(e){return ee.errToObj,new pe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,n,a,o;const h=(a=(n=(s=this._def).errorMap)===null||n===void 0?void 0:n.call(s,t,r).message)!==null&&a!==void 0?a:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=ee.errToObj(e).message)!==null&&o!==void 0?o:h}:{message:h}}}:{}})}strip(){return new pe({...this._def,unknownKeys:"strip"})}passthrough(){return new pe({...this._def,unknownKeys:"passthrough"})}extend(e){return new pe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new pe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>$r.mergeShapes(this._def.shape(),e._def.shape()),typeName:X.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new pe({...this._def,catchall:e})}pick(e){const t={};return ae.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new pe({...this._def,shape:()=>t})}omit(e){const t={};return ae.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new pe({...this._def,shape:()=>t})}deepPartial(){return Qt(this)}partial(e){const t={};return ae.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new pe({...this._def,shape:()=>t})}required(e){const t={};return ae.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let n=this.shape[r];for(;n instanceof pt;)n=n._def.innerType;t[r]=n}}),new pe({...this._def,shape:()=>t})}keyof(){return Uo(ae.objectKeys(this.shape))}}pe.create=(i,e)=>new pe({shape:()=>i,unknownKeys:"strip",catchall:vt.create(),typeName:X.ZodObject,...J(e)});pe.strictCreate=(i,e)=>new pe({shape:()=>i,unknownKeys:"strict",catchall:vt.create(),typeName:X.ZodObject,...J(e)});pe.lazycreate=(i,e)=>new pe({shape:i,unknownKeys:"strip",catchall:vt.create(),typeName:X.ZodObject,...J(e)});class zi extends Q{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(n){for(const o of n)if(o.result.status==="valid")return o.result;for(const o of n)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=n.map(o=>new rt(o.ctx.common.issues));return B(t,{code:O.invalid_union,unionErrors:a}),Y}if(t.common.async)return Promise.all(r.map(async n=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let n;const a=[];for(const h of r){const l={...t,common:{...t.common,issues:[]},parent:null},d=h._parseSync({data:t.data,path:t.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!n&&(n={result:d,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const o=a.map(h=>new rt(h));return B(t,{code:O.invalid_union,unionErrors:o}),Y}}get options(){return this._def.options}}zi.create=(i,e)=>new zi({options:i,typeName:X.ZodUnion,...J(e)});const Er=i=>i instanceof Zi?Er(i.schema):i instanceof Xe?Er(i.innerType()):i instanceof ji?[i.value]:i instanceof Lt?i.options:i instanceof Xi?Object.keys(i.enum):i instanceof qi?Er(i._def.innerType):i instanceof $i?[void 0]:i instanceof Vi?[null]:null;class es extends Q{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.object)return B(t,{code:O.invalid_type,expected:N.object,received:t.parsedType}),Y;const r=this.discriminator,s=t.data[r],n=this.optionsMap.get(s);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(B(t,{code:O.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const n of t){const a=Er(n.shape[e]);if(!a)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,n)}}return new es({typeName:X.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...J(r)})}}function Fs(i,e){const t=Pt(i),r=Pt(e);if(i===e)return{valid:!0,data:i};if(t===N.object&&r===N.object){const s=ae.objectKeys(e),n=ae.objectKeys(i).filter(o=>s.indexOf(o)!==-1),a={...i,...e};for(const o of n){const h=Fs(i[o],e[o]);if(!h.valid)return{valid:!1};a[o]=h.data}return{valid:!0,data:a}}else if(t===N.array&&r===N.array){if(i.length!==e.length)return{valid:!1};const s=[];for(let n=0;n<i.length;n++){const a=i[n],o=e[n],h=Fs(a,o);if(!h.valid)return{valid:!1};s.push(h.data)}return{valid:!0,data:s}}else return t===N.date&&r===N.date&&+i==+e?{valid:!0,data:i}:{valid:!1}}class Ui extends Q{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(n,a)=>{if(Gs(n)||Gs(a))return Y;const o=Fs(n.value,a.value);return o.valid?((Ds(n)||Ds(a))&&t.dirty(),{status:t.value,value:o.data}):(B(r,{code:O.invalid_intersection_types}),Y)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([n,a])=>s(n,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ui.create=(i,e,t)=>new Ui({left:i,right:e,typeName:X.ZodIntersection,...J(t)});class nt extends Q{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.array)return B(r,{code:O.invalid_type,expected:N.array,received:r.parsedType}),Y;if(r.data.length<this._def.items.length)return B(r,{code:O.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Y;!this._def.rest&&r.data.length>this._def.items.length&&(B(r,{code:O.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...r.data].map((a,o)=>{const h=this._def.items[o]||this._def.rest;return h?h._parse(new st(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(n).then(a=>Le.mergeArray(t,a)):Le.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new nt({...this._def,rest:e})}}nt.create=(i,e)=>{if(!Array.isArray(i))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new nt({items:i,typeName:X.ZodTuple,rest:null,...J(e)})};class Wi extends Q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.object)return B(r,{code:O.invalid_type,expected:N.object,received:r.parsedType}),Y;const s=[],n=this._def.keyType,a=this._def.valueType;for(const o in r.data)s.push({key:n._parse(new st(r,o,r.path,o)),value:a._parse(new st(r,r.data[o],r.path,o))});return r.common.async?Le.mergeObjectAsync(t,s):Le.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof Q?new Wi({keyType:e,valueType:t,typeName:X.ZodRecord,...J(r)}):new Wi({keyType:gt.create(),valueType:e,typeName:X.ZodRecord,...J(t)})}}class Vr extends Q{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.map)return B(r,{code:O.invalid_type,expected:N.map,received:r.parsedType}),Y;const s=this._def.keyType,n=this._def.valueType,a=[...r.data.entries()].map(([o,h],l)=>({key:s._parse(new st(r,o,r.path,[l,"key"])),value:n._parse(new st(r,h,r.path,[l,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const h of a){const l=await h.key,d=await h.value;if(l.status==="aborted"||d.status==="aborted")return Y;(l.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(l.value,d.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const h of a){const l=h.key,d=h.value;if(l.status==="aborted"||d.status==="aborted")return Y;(l.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(l.value,d.value)}return{status:t.value,value:o}}}}Vr.create=(i,e,t)=>new Vr({valueType:e,keyType:i,typeName:X.ZodMap,...J(t)});class Ut extends Q{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.set)return B(r,{code:O.invalid_type,expected:N.set,received:r.parsedType}),Y;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(B(r,{code:O.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(B(r,{code:O.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const n=this._def.valueType;function a(h){const l=new Set;for(const d of h){if(d.status==="aborted")return Y;d.status==="dirty"&&t.dirty(),l.add(d.value)}return{status:t.value,value:l}}const o=[...r.data.values()].map((h,l)=>n._parse(new st(r,h,r.path,l)));return r.common.async?Promise.all(o).then(h=>a(h)):a(o)}min(e,t){return new Ut({...this._def,minSize:{value:e,message:ee.toString(t)}})}max(e,t){return new Ut({...this._def,maxSize:{value:e,message:ee.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ut.create=(i,e)=>new Ut({valueType:i,minSize:null,maxSize:null,typeName:X.ZodSet,...J(e)});class oi extends Q{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.function)return B(t,{code:O.invalid_type,expected:N.function,received:t.parsedType}),Y;function r(o,h){return Gr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Nr(),Fi].filter(l=>!!l),issueData:{code:O.invalid_arguments,argumentsError:h}})}function s(o,h){return Gr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Nr(),Fi].filter(l=>!!l),issueData:{code:O.invalid_return_type,returnTypeError:h}})}const n={errorMap:t.common.contextualErrorMap},a=t.data;return this._def.returns instanceof fi?Me(async(...o)=>{const h=new rt([]),l=await this._def.args.parseAsync(o,n).catch(c=>{throw h.addIssue(r(o,c)),h}),d=await a(...l);return await this._def.returns._def.type.parseAsync(d,n).catch(c=>{throw h.addIssue(s(d,c)),h})}):Me((...o)=>{const h=this._def.args.safeParse(o,n);if(!h.success)throw new rt([r(o,h.error)]);const l=a(...h.data),d=this._def.returns.safeParse(l,n);if(!d.success)throw new rt([s(l,d.error)]);return d.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new oi({...this._def,args:nt.create(e).rest(Bt.create())})}returns(e){return new oi({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new oi({args:e||nt.create([]).rest(Bt.create()),returns:t||Bt.create(),typeName:X.ZodFunction,...J(r)})}}class Zi extends Q{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Zi.create=(i,e)=>new Zi({getter:i,typeName:X.ZodLazy,...J(e)});class ji extends Q{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return B(t,{received:t.data,code:O.invalid_literal,expected:this._def.value}),Y}return{status:"valid",value:e.data}}get value(){return this._def.value}}ji.create=(i,e)=>new ji({value:i,typeName:X.ZodLiteral,...J(e)});function Uo(i,e){return new Lt({values:i,typeName:X.ZodEnum,...J(e)})}class Lt extends Q{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return B(t,{expected:ae.joinValues(r),received:t.parsedType,code:O.invalid_type}),Y}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),r=this._def.values;return B(t,{received:t.data,code:O.invalid_enum_value,options:r}),Y}return Me(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Lt.create(e)}exclude(e){return Lt.create(this.options.filter(t=>!e.includes(t)))}}Lt.create=Uo;class Xi extends Q{_parse(e){const t=ae.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==N.string&&r.parsedType!==N.number){const s=ae.objectValues(t);return B(r,{expected:ae.joinValues(s),received:r.parsedType,code:O.invalid_type}),Y}if(t.indexOf(e.data)===-1){const s=ae.objectValues(t);return B(r,{received:r.data,code:O.invalid_enum_value,options:s}),Y}return Me(e.data)}get enum(){return this._def.values}}Xi.create=(i,e)=>new Xi({values:i,typeName:X.ZodNativeEnum,...J(e)});class fi extends Q{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.promise&&t.common.async===!1)return B(t,{code:O.invalid_type,expected:N.promise,received:t.parsedType}),Y;const r=t.parsedType===N.promise?t.data:Promise.resolve(t.data);return Me(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}fi.create=(i,e)=>new fi({type:i,typeName:X.ZodPromise,...J(e)});class Xe extends Q{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===X.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null;if(s.type==="preprocess"){const a=s.transform(r.data);return r.common.async?Promise.resolve(a).then(o=>this._def.schema._parseAsync({data:o,path:r.path,parent:r})):this._def.schema._parseSync({data:a,path:r.path,parent:r})}const n={addIssue:a=>{B(r,a),a.fatal?t.abort():t.dirty()},get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),s.type==="refinement"){const a=o=>{const h=s.refinement(o,n);if(r.common.async)return Promise.resolve(h);if(h instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Y:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?Y:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Dr(a))return a;const o=s.transform(a.value,n);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>Dr(a)?Promise.resolve(s.transform(a.value,n)).then(o=>({status:t.value,value:o})):a);ae.assertNever(s)}}Xe.create=(i,e,t)=>new Xe({schema:i,typeName:X.ZodEffects,effect:e,...J(t)});Xe.createWithPreprocess=(i,e,t)=>new Xe({schema:e,effect:{type:"preprocess",transform:i},typeName:X.ZodEffects,...J(t)});class pt extends Q{_parse(e){return this._getType(e)===N.undefined?Me(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}pt.create=(i,e)=>new pt({innerType:i,typeName:X.ZodOptional,...J(e)});class Wt extends Q{_parse(e){return this._getType(e)===N.null?Me(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Wt.create=(i,e)=>new Wt({innerType:i,typeName:X.ZodNullable,...J(e)});class qi extends Q{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===N.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}qi.create=(i,e)=>new qi({innerType:i,typeName:X.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...J(e)});class zr extends Q{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t,common:{...t.common,issues:[]}}});return Fr(r)?r.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue()})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue()}}removeCatch(){return this._def.innerType}}zr.create=(i,e)=>new zr({innerType:i,typeName:X.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...J(e)});class Ur extends Q{_parse(e){if(this._getType(e)!==N.nan){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.nan,received:r.parsedType}),Y}return{status:"valid",value:e.data}}}Ur.create=i=>new Ur({typeName:X.ZodNaN,...J(i)});const fc=Symbol("zod_brand");class Wo extends Q{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ir extends Q{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?Y:n.status==="dirty"?(t.dirty(),zo(n.value)):this._def.out._parseAsync({data:n.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Y:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new ir({in:e,out:t,typeName:X.ZodPipeline})}}const Zo=(i,e={},t)=>i?ci.create().superRefine((r,s)=>{if(!i(r)){const n=typeof e=="function"?e(r):e,a=typeof n=="string"?{message:n}:n;s.addIssue({code:"custom",...a,fatal:t})}}):ci.create(),pc={object:pe.lazycreate};var X;(function(i){i.ZodString="ZodString",i.ZodNumber="ZodNumber",i.ZodNaN="ZodNaN",i.ZodBigInt="ZodBigInt",i.ZodBoolean="ZodBoolean",i.ZodDate="ZodDate",i.ZodSymbol="ZodSymbol",i.ZodUndefined="ZodUndefined",i.ZodNull="ZodNull",i.ZodAny="ZodAny",i.ZodUnknown="ZodUnknown",i.ZodNever="ZodNever",i.ZodVoid="ZodVoid",i.ZodArray="ZodArray",i.ZodObject="ZodObject",i.ZodUnion="ZodUnion",i.ZodDiscriminatedUnion="ZodDiscriminatedUnion",i.ZodIntersection="ZodIntersection",i.ZodTuple="ZodTuple",i.ZodRecord="ZodRecord",i.ZodMap="ZodMap",i.ZodSet="ZodSet",i.ZodFunction="ZodFunction",i.ZodLazy="ZodLazy",i.ZodLiteral="ZodLiteral",i.ZodEnum="ZodEnum",i.ZodEffects="ZodEffects",i.ZodNativeEnum="ZodNativeEnum",i.ZodOptional="ZodOptional",i.ZodNullable="ZodNullable",i.ZodDefault="ZodDefault",i.ZodCatch="ZodCatch",i.ZodPromise="ZodPromise",i.ZodBranded="ZodBranded",i.ZodPipeline="ZodPipeline"})(X||(X={}));const mc=(i,e={message:`Input not instance of ${i.name}`})=>Zo(t=>t instanceof i,e,!0),jo=gt.create,Xo=Ot.create,gc=Ur.create,vc=Hi.create,qo=Bi.create,yc=zt.create,bc=Hr.create,_c=$i.create,wc=Vi.create,Sc=ci.create,Tc=Bt.create,Cc=vt.create,Ec=Br.create,kc=Ze.create,xc=pe.create,Pc=pe.strictCreate,Ac=zi.create,Mc=es.create,Oc=Ui.create,Lc=nt.create,Rc=Wi.create,Ic=Vr.create,Nc=Ut.create,Gc=oi.create,Dc=Zi.create,Fc=ji.create,Hc=Lt.create,Bc=Xi.create,$c=fi.create,aa=Xe.create,Vc=pt.create,zc=Wt.create,Uc=Xe.createWithPreprocess,Wc=ir.create,Zc=()=>jo().optional(),jc=()=>Xo().optional(),Xc=()=>qo().optional(),qc={string:i=>gt.create({...i,coerce:!0}),number:i=>Ot.create({...i,coerce:!0}),boolean:i=>Bi.create({...i,coerce:!0}),bigint:i=>Hi.create({...i,coerce:!0}),date:i=>zt.create({...i,coerce:!0})},Yc=Y;var _e=Object.freeze({__proto__:null,defaultErrorMap:Fi,setErrorMap:nc,getErrorMap:Nr,makeIssue:Gr,EMPTY_PATH:ac,addIssueToContext:B,ParseStatus:Le,INVALID:Y,DIRTY:zo,OK:Me,isAborted:Gs,isDirty:Ds,isValid:Dr,isAsync:Fr,get util(){return ae},ZodParsedType:N,getParsedType:Pt,ZodType:Q,ZodString:gt,ZodNumber:Ot,ZodBigInt:Hi,ZodBoolean:Bi,ZodDate:zt,ZodSymbol:Hr,ZodUndefined:$i,ZodNull:Vi,ZodAny:ci,ZodUnknown:Bt,ZodNever:vt,ZodVoid:Br,ZodArray:Ze,get objectUtil(){return $r},ZodObject:pe,ZodUnion:zi,ZodDiscriminatedUnion:es,ZodIntersection:Ui,ZodTuple:nt,ZodRecord:Wi,ZodMap:Vr,ZodSet:Ut,ZodFunction:oi,ZodLazy:Zi,ZodLiteral:ji,ZodEnum:Lt,ZodNativeEnum:Xi,ZodPromise:fi,ZodEffects:Xe,ZodTransformer:Xe,ZodOptional:pt,ZodNullable:Wt,ZodDefault:qi,ZodCatch:zr,ZodNaN:Ur,BRAND:fc,ZodBranded:Wo,ZodPipeline:ir,custom:Zo,Schema:Q,ZodSchema:Q,late:pc,get ZodFirstPartyTypeKind(){return X},coerce:qc,any:Sc,array:kc,bigint:vc,boolean:qo,date:yc,discriminatedUnion:Mc,effect:aa,enum:Hc,function:Gc,instanceof:mc,intersection:Oc,lazy:Dc,literal:Fc,map:Ic,nan:gc,nativeEnum:Bc,never:Cc,null:wc,nullable:zc,number:Xo,object:xc,oboolean:Xc,onumber:jc,optional:Vc,ostring:Zc,pipeline:Wc,preprocess:Uc,promise:$c,record:Rc,set:Nc,strictObject:Pc,string:jo,symbol:bc,transformer:aa,tuple:Lc,undefined:_c,union:Ac,unknown:Tc,void:Ec,NEVER:Yc,ZodIssueCode:O,quotelessJson:sc,ZodError:rt});class li{static id(){return e=>_e.coerce.string().min(1).max(100).parse(e)}static description(){return e=>_e.coerce.string().max(1e3).parse(e)}static boolean(){return e=>_e.coerce.boolean().parse(e)}static url(){return e=>_e.coerce.string().url().parse(e)}}class ht{constructor(){this.onChange$=new ti(void 0)}static instance(){return ht._instance||(ht._instance=new ht),ht._instance}get styles(){return this._styles}set styles(e){this._styles={...this._styles,...e},this.onChange$.next(this._styles)}}const rr={height:80,backgroundFill:"#ffffff",backgroundOpacity:1,descriptionTextFill:"#1c1c1c",descriptionFontSize:15,leftBackgroundFill:"#ffffff",leftBackgroundOpacity:1};class sr extends Je{constructor(e){super(e),this.stylesProvider=ht.instance(),this.id=li.id()(this.config.id),this.description=li.description()(this.config.description)}createCanvasNode(){return this.bodyGroup=new M.Group({...this.timelinePosition,width:this.timeline.getBodyGroupRect().width,height:this.styleAdapter.style.height}),this.bodyBackground=new M.Rect({...F.POSITION_TOP_LEFT,...this.bodyGroup.getSize(),fill:this.styleAdapter.style.backgroundFill,opacity:this.styleAdapter.style.backgroundOpacity,listening:!1}),this.leftGroup=new M.Group({...F.POSITION_TOP_LEFT,width:this.timeline.getLeftPanelRect().width,listening:!1}),this.leftBackground=new M.Rect({...F.POSITION_TOP_LEFT,...this.leftGroup.getSize(),fill:this.styleAdapter.style.leftBackgroundFill,opacity:this.styleAdapter.style.leftBackgroundOpacity,listening:!1}),this.leftPanelText=new M.Text({...F.POSITION_TOP_LEFT,text:this.description,fontSize:this.style.descriptionFontSize,fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily,fill:this.style.descriptionTextFill,width:this.leftGroup.width()-10,height:this.getRect().height,verticalAlign:"middle",align:"right"}),this.leftGroup.add(this.leftBackground),this.leftGroup.add(this.leftPanelText),this.bodyGroup.add(this.bodyBackground),this.bodyGroup.add(this.leftGroup),this.bodyGroup}afterCanvasNodeInit(){this.settleLayout(),this.timeline.onZoom$.pipe(k(this.onDestroy$)).subscribe(e=>{this.settleLayout()}),this.stylesProvider.onChange$.pipe(k(this.onDestroy$),Ve(e=>!!e)).subscribe(e=>{this.onStylesProviderChange()}),this.styleAdapter.onChange$.pipe(k(this.onDestroy$),Ve(e=>!!e)).subscribe(e=>{this.onStyleChange()})}onMeasurementsChange(){this.settleLayout()}onStylesProviderChange(){this.leftPanelText.setAttrs({fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily})}onStyleChange(){this.bodyBackground.setAttrs({fill:this.styleAdapter.style.backgroundFill,opacity:this.styleAdapter.style.backgroundOpacity}),this.leftBackground.setAttrs({fill:this.styleAdapter.style.leftBackgroundFill,opacity:this.styleAdapter.style.leftBackgroundOpacity}),this.leftPanelText.setAttrs({fill:this.styleAdapter.style.leftBackgroundFill,opacity:this.styleAdapter.style.leftBackgroundOpacity})}settleLayout(){this.bodyGroup.setAttrs({...this.timelinePosition,width:this.timeline.getBodyGroupRect().width}),this.bodyBackground.setAttrs({...this.bodyGroup.getSize()}),this.leftGroup.setAttrs({width:this.timeline.getLeftPanelRect().width,height:this.bodyGroup.height(),visible:this.timeline.getLeftPanelVisible()}),this.leftBackground.setAttrs({...this.leftGroup.getSize()})}isTimelineReady(){return this.timeline&&this.timeline.isTimelineReady()}clearContent(){}setTimeline(e){this.timeline=e}setVideoController(e){this.videoController=e}get style(){return super.style}set style(e){super.style=e}getRect(){return{...this.getPosition(),...this.getDimension()}}getPosition(){return{...this.bodyGroup.getPosition()}}getDimension(){return{...this.bodyGroup.getSize()}}getId(){return this.id}getDescription(){return this.description}setTimelinePosition(e){this.timelinePosition=e}getTimelinePosition(){return this.timelinePosition}destroy(){this.clearContent(),super.destroy()}}const Yo={color:"rgba(255,73,145)",renderType:"lane",symbolType:"square"};class Ko extends Je{constructor(e){super(e),this.onChange$=new V,this.onClick$=new V,this.onMouseEnter$=new V,this.onMouseLeave$=new V,this.id=li.id()(this.config.id),this.description=li.description()(this.config.description),this.editable=li.boolean()(this.config.editable),this.observation=this.config.observation}createCanvasNode(){return this.group=new M.Group({...F.POSITION_TOP_LEFT,...this.timeline.getTimecodedGroupDimension()}),this.group}afterCanvasNodeInit(){this.timeline.onZoom$.pipe(k(this.onDestroy$)).subscribe(e=>{this.onMeasurementsChange()}),this.group.on("click",e=>{this.onClick$.next({})}),this.group.on("mouseenter",e=>{this.onMouseEnter$.next({})}),this.group.on("mouseleave",e=>{this.onMouseLeave$.next({})})}onMeasurementsChange(){this.group.setAttrs({...this.timeline.getTimecodedGroupDimension()})}destroy(){super.destroy();let e=[this.onChange$,this.onClick$,this.onMouseEnter$,this.onMouseLeave$];Vt(...e),bi(...e)}setTimeline(e){this.timeline=e}setMarkerLane(e){this.markerLane=e}getId(){return this.id}getDescription(){return this.description}getTimeObservation(){return this.observation}setTimeObservation(e){this.editable&&(this.observation=e,this.onChange())}setEditable(e){this.editable=e}get style(){return this.styleAdapter.style}setStyle(e){this.styleAdapter.style=e}}class tt{static resetCursorStyle(){this.cursor("default")}static cursor(e){document.body.style.cursor=e}}const Jo={color:"#ff6c6c",markerRenderType:"lane",markerSymbolType:"square",lineStrokeWidth:1,lineOpacity:.7};class Qo extends Je{constructor(e,t,r){super(e),this.onDrag=s=>{},this.onDragEnd=s=>{},this.markerLane=t,this.timeline=r,this.x=this.config.x,this.editable=this.config.editable}createCanvasNode(){let e=this.getVerticalMeasurement();return this.group=new M.Group({x:this.x,y:e.y,draggable:this.editable}),this.line=new M.Line({stroke:this.style.color,strokeWidth:this.style.lineStrokeWidth,opacity:this.style.lineOpacity,points:[0,0,0,e.height],listening:!1}),this.handleGroup=new M.Group({x:0,y:this.markerLane.getPosition().y-e.y+this.markerLane.getDimension().height/2}),this.symbol=this.createSymbol(),this.handleGroup.add(this.symbol),this.handleGroup.on("mouseover",t=>{this.editable&&(this.handleGroup.to({scaleX:1.5,scaleY:1.5,duration:.1}),tt.cursor("grab"))}),this.handleGroup.on("mouseleave",()=>{this.editable&&(this.handleGroup.to({scaleX:1,scaleY:1,duration:.1}),tt.cursor("default"))}),this.group.add(this.line),this.group.add(this.handleGroup),this.group}afterCanvasNodeInit(){let e=this.getVerticalMeasurement();this.group.on("dragstart dragmove",t=>{tt.cursor("grabbing");let r=this.timeline.constrainTimelinePosition(this.group.getPosition().x);this.group.setAttrs({x:r,y:e.y}),this.onDrag(this.group)}),this.group.on("dragend",t=>{let r=this.timeline.constrainTimelinePosition(this.group.getPosition().x);this.group.setAttrs({x:r,y:e.y}),this.onDragEnd(this.group),tt.cursor("default")})}onMeasurementsChange(){let e=this.getVerticalMeasurement();this.group.setAttrs({y:e.y}),this.line.setAttrs({points:[0,0,0,e.height]}),this.handleGroup.setAttrs({y:this.markerLane.getPosition().y-e.y+this.markerLane.getDimension().height/2})}getVerticalMeasurement(){switch(this.style.markerRenderType){case"spanning":return{y:0,height:this.timeline.getTimecodedGroupDimension().height};default:return{y:this.markerLane.getTimelinePosition().y,height:this.markerLane.getDimension().height}}}getHandleGroup(){return this.handleGroup}getSymbol(){return this.symbol}getPosition(){return this.group.getPosition()}setPosition(e){this.group.setAttrs({...e}),this.onMeasurementsChange()}setColor(e){this.style.color=e,this.line.setAttrs({stroke:this.style.color}),this.symbol.setAttrs({fill:this.style.color})}setEditable(e){this.editable=e,this.group.draggable(this.editable)}}/*!
4
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function Lr(i,e){if(i){var t=i.indexOf(e);0<=t&&i.splice(t,1)}}var Qi=function(){function i(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return i.prototype.unsubscribe=function(){var e,t,r,s,n;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var o=di(a),h=o.next();!h.done;h=o.next()){var l=h.value;l.remove(this)}}catch(m){e={error:m}}finally{try{h&&!h.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else a.remove(this);var d=this.initialTeardown;if(de(d))try{d()}catch(m){n=m instanceof ys?m.errors:[m]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var c=di(u),p=c.next();!p.done;p=c.next()){var f=p.value;try{Jn(f)}catch(m){n=n??[],m instanceof ys?n=$t($t([],Mt(n)),Mt(m.errors)):n.push(m)}}}catch(m){r={error:m}}finally{try{p&&!p.done&&(s=c.return)&&s.call(c)}finally{if(r)throw r.error}}}if(n)throw new ys(n)}},i.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)Jn(e);else{if(e instanceof i){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},i.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},i.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},i.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Lr(t,e)},i.prototype.remove=function(e){var t=this._finalizers;t&&Lr(t,e),e instanceof i&&e._removeParent(this)},i.EMPTY=function(){var e=new i;return e.closed=!0,e}(),i}(),mo=Qi.EMPTY;function go(i){return i instanceof Qi||i&&"closed"in i&&de(i.remove)&&de(i.add)&&de(i.unsubscribe)}function Jn(i){de(i)?i():i.unsubscribe()}var vo={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Is={setTimeout:function(i,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];var s=Is.delegate;return s!=null&&s.setTimeout?s.setTimeout.apply(s,$t([i,e],Mt(t))):setTimeout.apply(void 0,$t([i,e],Mt(t)))},clearTimeout:function(i){var e=Is.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(i)},delegate:void 0};function yo(i){Is.setTimeout(function(){throw i})}function Rr(){}function Cr(i){i()}var hn=function(i){wt(e,i);function e(t){var r=i.call(this)||this;return r.isStopped=!1,t?(r.destination=t,go(t)&&t.add(r)):r.destination=iu,r}return e.create=function(t,r,s){return new Ns(t,r,s)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,i.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Qi),Qd=Function.prototype.bind;function bs(i,e){return Qd.call(i,e)}var eu=function(){function i(e){this.partialObserver=e}return i.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(r){yr(r)}},i.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(r){yr(r)}else yr(e)},i.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){yr(t)}},i}(),Ns=function(i){wt(e,i);function e(t,r,s){var n=i.call(this)||this,a;if(de(t)||!t)a={next:t??void 0,error:r??void 0,complete:s??void 0};else{var o;n&&vo.useDeprecatedNextContext?(o=Object.create(t),o.unsubscribe=function(){return n.unsubscribe()},a={next:t.next&&bs(t.next,o),error:t.error&&bs(t.error,o),complete:t.complete&&bs(t.complete,o)}):a=t}return n.destination=new eu(a),n}return e}(hn);function yr(i){yo(i)}function tu(i){throw i}var iu={closed:!0,next:Rr,error:tu,complete:Rr},dn=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function er(i){return i}function ru(i){return i.length===0?er:i.length===1?i[0]:function(t){return i.reduce(function(r,s){return s(r)},t)}}var re=function(){function i(e){e&&(this._subscribe=e)}return i.prototype.lift=function(e){var t=new i;return t.source=this,t.operator=e,t},i.prototype.subscribe=function(e,t,r){var s=this,n=nu(e)?e:new Ns(e,t,r);return Cr(function(){var a=s,o=a.operator,h=a.source;n.add(o?o.call(n,h):h?s._subscribe(n):s._trySubscribe(n))}),n},i.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},i.prototype.forEach=function(e,t){var r=this;return t=Qn(t),new t(function(s,n){var a=new Ns({next:function(o){try{e(o)}catch(h){n(h),a.unsubscribe()}},error:n,complete:s});r.subscribe(a)})},i.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},i.prototype[dn]=function(){return this},i.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ru(e)(this)},i.prototype.toPromise=function(e){var t=this;return e=Qn(e),new e(function(r,s){var n;t.subscribe(function(a){return n=a},function(a){return s(a)},function(){return r(n)})})},i.create=function(e){return new i(e)},i}();function Qn(i){var e;return(e=i??vo.Promise)!==null&&e!==void 0?e:Promise}function su(i){return i&&de(i.next)&&de(i.error)&&de(i.complete)}function nu(i){return i&&i instanceof hn||su(i)&&go(i)}function au(i){return de(i==null?void 0:i.lift)}function He(i){return function(e){if(au(e))return e.lift(function(t){try{return i(t,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function Ae(i,e,t,r,s){return new ou(i,e,t,r,s)}var ou=function(i){wt(e,i);function e(t,r,s,n,a,o){var h=i.call(this,t)||this;return h.onFinalize=a,h.shouldUnsubscribe=o,h._next=r?function(l){try{r(l)}catch(d){t.error(d)}}:i.prototype._next,h._error=n?function(l){try{n(l)}catch(d){t.error(d)}finally{this.unsubscribe()}}:i.prototype._error,h._complete=s?function(){try{s()}catch(l){t.error(l)}finally{this.unsubscribe()}}:i.prototype._complete,h}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;i.prototype.unsubscribe.call(this),!r&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(hn),lu=ln(function(i){return function(){i(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),V=function(i){wt(e,i);function e(){var t=i.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var r=new ea(this,this);return r.operator=t,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new lu},e.prototype.next=function(t){var r=this;Cr(function(){var s,n;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var a=di(r.currentObservers),o=a.next();!o.done;o=a.next()){var h=o.value;h.next(t)}}catch(l){s={error:l}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(s)throw s.error}}}})},e.prototype.error=function(t){var r=this;Cr(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=t;for(var s=r.observers;s.length;)s.shift().error(t)}})},e.prototype.complete=function(){var t=this;Cr(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var r=t.observers;r.length;)r.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),i.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var r=this,s=this,n=s.hasError,a=s.isStopped,o=s.observers;return n||a?mo:(this.currentObservers=null,o.push(t),new Qi(function(){r.currentObservers=null,Lr(o,t)}))},e.prototype._checkFinalizedStatuses=function(t){var r=this,s=r.hasError,n=r.thrownError,a=r.isStopped;s?t.error(n):a&&t.complete()},e.prototype.asObservable=function(){var t=new re;return t.source=this,t},e.create=function(t,r){return new ea(t,r)},e}(re),ea=function(i){wt(e,i);function e(t,r){var s=i.call(this)||this;return s.destination=t,s.source=r,s}return e.prototype.next=function(t){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,t)},e.prototype.error=function(t){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.call(r,t)},e.prototype.complete=function(){var t,r;(r=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||r===void 0||r.call(t)},e.prototype._subscribe=function(t){var r,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(t))!==null&&s!==void 0?s:mo},e}(V),ti=function(i){wt(e,i);function e(t){var r=i.call(this)||this;return r._value=t,r}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(t){var r=i.prototype._subscribe.call(this,t);return!r.closed&&t.next(this._value),r},e.prototype.getValue=function(){var t=this,r=t.hasError,s=t.thrownError,n=t._value;if(r)throw s;return this._throwIfClosed(),n},e.prototype.next=function(t){i.prototype.next.call(this,this._value=t)},e}(V),bo={now:function(){return(bo.delegate||Date).now()},delegate:void 0},hu=function(i){wt(e,i);function e(t,r){return i.call(this)||this}return e.prototype.schedule=function(t,r){return this},e}(Qi),Ir={setInterval:function(i,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];var s=Ir.delegate;return s!=null&&s.setInterval?s.setInterval.apply(s,$t([i,e],Mt(t))):setInterval.apply(void 0,$t([i,e],Mt(t)))},clearInterval:function(i){var e=Ir.delegate;return((e==null?void 0:e.clearInterval)||clearInterval)(i)},delegate:void 0},du=function(i){wt(e,i);function e(t,r){var s=i.call(this,t,r)||this;return s.scheduler=t,s.work=r,s.pending=!1,s}return e.prototype.schedule=function(t,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=t;var n=this.id,a=this.scheduler;return n!=null&&(this.id=this.recycleAsyncId(a,n,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(a,this.id,r),this},e.prototype.requestAsyncId=function(t,r,s){return s===void 0&&(s=0),Ir.setInterval(t.flush.bind(t,this),s)},e.prototype.recycleAsyncId=function(t,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&Ir.clearInterval(r)},e.prototype.execute=function(t,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(t,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,r){var s=!1,n;try{this.work(t)}catch(a){s=!0,n=a||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),n},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,r=t.id,s=t.scheduler,n=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Lr(n,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,i.prototype.unsubscribe.call(this)}},e}(hu),ta=function(){function i(e,t){t===void 0&&(t=i.now),this.schedulerActionCtor=e,this.now=t}return i.prototype.schedule=function(e,t,r){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},i.now=bo.now,i}(),uu=function(i){wt(e,i);function e(t,r){r===void 0&&(r=ta.now);var s=i.call(this,t,r)||this;return s.actions=[],s._active=!1,s}return e.prototype.flush=function(t){var r=this.actions;if(this._active){r.push(t);return}var s;this._active=!0;do if(s=t.execute(t.state,t.delay))break;while(t=r.shift());if(this._active=!1,s){for(;t=r.shift();)t.unsubscribe();throw s}},e}(ta),Jr=new uu(du),cu=Jr,fu=new re(function(i){return i.complete()});function _o(i){return i&&de(i.schedule)}function wo(i){return i[i.length-1]}function So(i){return de(wo(i))?i.pop():void 0}function un(i){return _o(wo(i))?i.pop():void 0}var cn=function(i){return i&&typeof i.length=="number"&&typeof i!="function"};function To(i){return de(i==null?void 0:i.then)}function Co(i){return de(i[dn])}function Eo(i){return Symbol.asyncIterator&&de(i==null?void 0:i[Symbol.asyncIterator])}function ko(i){return new TypeError("You provided "+(i!==null&&typeof i=="object"?"an invalid object":"'"+i+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function pu(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var xo=pu();function Po(i){return de(i==null?void 0:i[xo])}function Ao(i){return Kd(this,arguments,function(){var t,r,s,n;return po(this,function(a){switch(a.label){case 0:t=i.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,ai(t.read())];case 3:return r=a.sent(),s=r.value,n=r.done,n?[4,ai(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,ai(s)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Mo(i){return de(i==null?void 0:i.getReader)}function Qe(i){if(i instanceof re)return i;if(i!=null){if(Co(i))return mu(i);if(cn(i))return gu(i);if(To(i))return vu(i);if(Eo(i))return Oo(i);if(Po(i))return yu(i);if(Mo(i))return bu(i)}throw ko(i)}function mu(i){return new re(function(e){var t=i[dn]();if(de(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function gu(i){return new re(function(e){for(var t=0;t<i.length&&!e.closed;t++)e.next(i[t]);e.complete()})}function vu(i){return new re(function(e){i.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,yo)})}function yu(i){return new re(function(e){var t,r;try{for(var s=di(i),n=s.next();!n.done;n=s.next()){var a=n.value;if(e.next(a),e.closed)return}}catch(o){t={error:o}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}e.complete()})}function Oo(i){return new re(function(e){_u(i,e).catch(function(t){return e.error(t)})})}function bu(i){return Oo(Ao(i))}function _u(i,e){var t,r,s,n;return Yd(this,void 0,void 0,function(){var a,o;return po(this,function(h){switch(h.label){case 0:h.trys.push([0,5,6,11]),t=Jd(i),h.label=1;case 1:return[4,t.next()];case 2:if(r=h.sent(),!!r.done)return[3,4];if(a=r.value,e.next(a),e.closed)return[2];h.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return o=h.sent(),s={error:o},[3,11];case 6:return h.trys.push([6,,9,10]),r&&!r.done&&(n=t.return)?[4,n.call(t)]:[3,8];case 7:h.sent(),h.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function ft(i,e,t,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var n=e.schedule(function(){t(),s?i.add(this.schedule(null,r)):this.unsubscribe()},r);if(i.add(n),!s)return n}function Lo(i,e){return e===void 0&&(e=0),He(function(t,r){t.subscribe(Ae(r,function(s){return ft(r,i,function(){return r.next(s)},e)},function(){return ft(r,i,function(){return r.complete()},e)},function(s){return ft(r,i,function(){return r.error(s)},e)}))})}function Ro(i,e){return e===void 0&&(e=0),He(function(t,r){r.add(i.schedule(function(){return t.subscribe(r)},e))})}function wu(i,e){return Qe(i).pipe(Ro(e),Lo(e))}function Su(i,e){return Qe(i).pipe(Ro(e),Lo(e))}function Tu(i,e){return new re(function(t){var r=0;return e.schedule(function(){r===i.length?t.complete():(t.next(i[r++]),t.closed||this.schedule())})})}function Cu(i,e){return new re(function(t){var r;return ft(t,e,function(){r=i[xo](),ft(t,e,function(){var s,n,a;try{s=r.next(),n=s.value,a=s.done}catch(o){t.error(o);return}a?t.complete():t.next(n)},0,!0)}),function(){return de(r==null?void 0:r.return)&&r.return()}})}function Io(i,e){if(!i)throw new Error("Iterable cannot be null");return new re(function(t){ft(t,e,function(){var r=i[Symbol.asyncIterator]();ft(t,e,function(){r.next().then(function(s){s.done?t.complete():t.next(s.value)})},0,!0)})})}function Eu(i,e){return Io(Ao(i),e)}function ku(i,e){if(i!=null){if(Co(i))return wu(i,e);if(cn(i))return Tu(i,e);if(To(i))return Su(i,e);if(Eo(i))return Io(i,e);if(Po(i))return Cu(i,e);if(Mo(i))return Eu(i,e)}throw ko(i)}function tr(i,e){return e?ku(i,e):Qe(i)}function Se(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];var t=un(i);return tr(i,t)}function ia(i,e){var t=de(i)?i:function(){return i},r=function(s){return s.error(t())};return new re(e?function(s){return e.schedule(r,0,s)}:r)}var No=ln(function(i){return function(){i(this),this.name="EmptyError",this.message="no elements in sequence"}});function xu(i){return i instanceof Date&&!isNaN(i)}function ke(i,e){return He(function(t,r){var s=0;t.subscribe(Ae(r,function(n){r.next(i.call(e,n,s++))}))})}var Pu=Array.isArray;function Au(i,e){return Pu(e)?i.apply(void 0,$t([],Mt(e))):i(e)}function fn(i){return ke(function(e){return Au(i,e)})}var Mu=Array.isArray,Ou=Object.getPrototypeOf,Lu=Object.prototype,Ru=Object.keys;function Do(i){if(i.length===1){var e=i[0];if(Mu(e))return{args:e,keys:null};if(Iu(e)){var t=Ru(e);return{args:t.map(function(r){return e[r]}),keys:t}}}return{args:i,keys:null}}function Iu(i){return i&&typeof i=="object"&&Ou(i)===Lu}function Go(i,e){return i.reduce(function(t,r,s){return t[r]=e[s],t},{})}function Nu(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];var t=un(i),r=So(i),s=Do(i),n=s.args,a=s.keys;if(n.length===0)return tr([],t);var o=new re(Du(n,t,a?function(h){return Go(a,h)}:er));return r?o.pipe(fn(r)):o}function Du(i,e,t){return t===void 0&&(t=er),function(r){ra(e,function(){for(var s=i.length,n=new Array(s),a=s,o=s,h=function(d){ra(e,function(){var u=tr(i[d],e),c=!1;u.subscribe(Ae(r,function(p){n[d]=p,c||(c=!0,o--),o||r.next(t(n.slice()))},function(){--a||r.complete()}))},r)},l=0;l<s;l++)h(l)},r)}}function ra(i,e,t){i?ft(t,i,e):e()}function Gu(i,e,t,r,s,n,a,o){var h=[],l=0,d=0,u=!1,c=function(){u&&!h.length&&!l&&e.complete()},p=function(m){return l<r?f(m):h.push(m)},f=function(m){n&&e.next(m),l++;var g=!1;Qe(t(m,d++)).subscribe(Ae(e,function(_){s==null||s(_),n?p(_):e.next(_)},function(){g=!0},void 0,function(){if(g)try{l--;for(var _=function(){var w=h.shift();a?ft(e,a,function(){return f(w)}):f(w)};h.length&&l<r;)_();c()}catch(w){e.error(w)}}))};return i.subscribe(Ae(e,p,function(){u=!0,c()})),function(){o==null||o()}}function Qr(i,e,t){return t===void 0&&(t=1/0),de(e)?Qr(function(r,s){return ke(function(n,a){return e(r,n,s,a)})(Qe(i(r,s)))},t):(typeof e=="number"&&(t=e),He(function(r,s){return Gu(r,s,i,t)}))}function Fu(i){return i===void 0&&(i=1/0),Qr(er,i)}function Hu(){return Fu(1)}function Bu(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];return Hu()(tr(i,un(i)))}function $u(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];var t=So(i),r=Do(i),s=r.args,n=r.keys,a=new re(function(o){var h=s.length;if(!h){o.complete();return}for(var l=new Array(h),d=h,u=h,c=function(f){var m=!1;Qe(s[f]).subscribe(Ae(o,function(g){m||(m=!0,u--),l[f]=g},function(){return d--},void 0,function(){(!d||!m)&&(u||o.next(n?Go(n,l):l),o.complete())}))},p=0;p<h;p++)c(p)});return t?a.pipe(fn(t)):a}var Vu=["addListener","removeListener"],zu=["addEventListener","removeEventListener"],Wu=["on","off"];function be(i,e,t,r){if(de(t)&&(r=t,t=void 0),r)return be(i,e,t).pipe(fn(r));var s=Mt(ju(i)?zu.map(function(o){return function(h){return i[o](e,h,t)}}):Uu(i)?Vu.map(sa(i,e)):Zu(i)?Wu.map(sa(i,e)):[],2),n=s[0],a=s[1];if(!n&&cn(i))return Qr(function(o){return be(o,e,t)})(Qe(i));if(!n)throw new TypeError("Invalid event target");return new re(function(o){var h=function(){for(var l=[],d=0;d<arguments.length;d++)l[d]=arguments[d];return o.next(1<l.length?l:l[0])};return n(h),function(){return a(h)}})}function sa(i,e){return function(t){return function(r){return i[t](e,r)}}}function Uu(i){return de(i.addListener)&&de(i.removeListener)}function Zu(i){return de(i.on)&&de(i.off)}function ju(i){return de(i.addEventListener)&&de(i.removeEventListener)}function Fo(i,e,t){i===void 0&&(i=0),t===void 0&&(t=cu);var r=-1;return e!=null&&(_o(e)?t=e:r=e),new re(function(s){var n=xu(i)?+i-t.now():i;n<0&&(n=0);var a=0;return t.schedule(function(){s.closed||(s.next(a++),0<=r?this.schedule(void 0,r):s.complete())},n)})}function Xu(i,e){return i===void 0&&(i=0),e===void 0&&(e=Jr),i<0&&(i=0),Fo(i,i,e)}function We(i,e){return He(function(t,r){var s=0;t.subscribe(Ae(r,function(n){return i.call(e,n,s++)&&r.next(n)}))})}function yi(i){return He(function(e,t){var r=null,s=!1,n;r=e.subscribe(Ae(t,void 0,void 0,function(a){n=Qe(i(a,yi(i)(e))),r?(r.unsubscribe(),r=null,n.subscribe(t)):s=!0})),s&&(r.unsubscribe(),r=null,n.subscribe(t))})}function Ho(i,e){return e===void 0&&(e=Jr),He(function(t,r){var s=null,n=null,a=null,o=function(){if(s){s.unsubscribe(),s=null;var l=n;n=null,r.next(l)}};function h(){var l=a+i,d=e.now();if(d<l){s=this.schedule(void 0,l-d),r.add(s);return}o()}t.subscribe(Ae(r,function(l){n=l,a=e.now(),s||(s=e.schedule(h,i),r.add(s))},function(){o(),r.complete()},void 0,function(){n=s=null}))})}function qu(i){return He(function(e,t){var r=!1;e.subscribe(Ae(t,function(s){r=!0,t.next(s)},function(){r||t.next(i),t.complete()}))})}function $e(i){return i<=0?function(){return fu}:He(function(e,t){var r=0;e.subscribe(Ae(t,function(s){++r<=i&&(t.next(s),i<=r&&t.complete())}))})}function Yu(){return He(function(i,e){i.subscribe(Ae(e,Rr))})}function Ku(i){return ke(function(){return i})}function Bo(i,e){return e?function(t){return Bu(e.pipe($e(1),Yu()),t.pipe(Bo(i)))}:Qr(function(t,r){return Qe(i(t,r)).pipe($e(1),Ku(t))})}function Ju(i,e){e===void 0&&(e=Jr);var t=Fo(i,e);return Bo(function(){return t})}function Qu(i){return i===void 0&&(i=ec),He(function(e,t){var r=!1;e.subscribe(Ae(t,function(s){r=!0,t.next(s)},function(){return r?t.complete():t.error(i())}))})}function ec(){return new No}function ui(i,e){var t=arguments.length>=2;return function(r){return r.pipe(i?We(function(s,n){return i(s,n,r)}):er,$e(1),t?qu(e):Qu(function(){return new No}))}}function tc(i,e){return He(function(t,r){var s=null,n=0,a=!1,o=function(){return a&&!s&&r.complete()};t.subscribe(Ae(r,function(h){s==null||s.unsubscribe();var l=0,d=n++;Qe(i(h,d)).subscribe(s=Ae(r,function(u){return r.next(e?e(h,u,d,l++):u)},function(){s=null,o()}))},function(){a=!0,o()}))})}function k(i){return He(function(e,t){Qe(i).subscribe(Ae(t,function(){return t.complete()},Rr)),!t.closed&&e.subscribe(t)})}class $o{constructor(e){this.onChange$=new V,this.style=e}get style(){return this._style}set style(e){this._style={...this._style,...e},this.onChange$.next(this._style)}}function Ge(i){i&&(i.closed||(i.next(),i.complete()))}function pn(...i){i.forEach(e=>{Ge(e)})}function ic(i){i&&(i.closed||i.complete())}function Vt(...i){i.forEach(e=>{ic(e)})}function bi(...i){i.forEach(e=>{rc(e)})}function rc(i){i&&(i.closed||i.unsubscribe())}const _i=(i,e)=>({...e,...i,style:{...e.style,...i.style}});class et{constructor(e){this.onDestroy$=new V,this.config=e,this.styleAdapter=new $o(e.style)}initCanvasNode(){if(this.isInitialized())throw new Error("Konva node already initalized");return this.canvasNode=this.createCanvasNode(),this.afterCanvasNodeInit(),this.canvasNode}initCanvasNodeAsync(){return this.createCanvasNodeAsync().pipe(ke(e=>(this.canvasNode=e,this.afterCanvasNodeInit(),this.canvasNode)))}createCanvasNodeAsync(){return Se(this.createCanvasNode())}afterCanvasNodeInit(){}destroy(){this.isInitialized()&&this.getCanvasNode().destroy(),Ge(this.onDestroy$),this.config=void 0,this.styleAdapter=void 0,this.canvasNode=void 0}getCanvasNode(){return this.canvasNode}isInitialized(){return!!this.getCanvasNode()}get style(){return this.styleAdapter.style}set style(e){this.styleAdapter.style=e}}class F{}F.POSITION_TOP_LEFT={x:0,y:0};F.DIMENSION_ZERO={width:0,height:0};F.GOLDEN_RATIO=1.61;F.TIMELINE_ZOOM_EASED_DURATION_MS=800;F.TIMELINE_SCROLL_EASED_DURATION_MS=200;F.MIME_TYPE_VND_APPLE_MPEGURL="application/vnd.apple.mpegurl";var ae;(function(i){i.assertEqual=s=>s;function e(s){}i.assertIs=e;function t(s){throw new Error}i.assertNever=t,i.arrayToEnum=s=>{const n={};for(const a of s)n[a]=a;return n},i.getValidEnumValues=s=>{const n=i.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of n)a[o]=s[o];return i.objectValues(a)},i.objectValues=s=>i.objectKeys(s).map(function(n){return s[n]}),i.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const n=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&n.push(a);return n},i.find=(s,n)=>{for(const a of s)if(n(a))return a},i.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,n=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(n)}i.joinValues=r,i.jsonStringifyReplacer=(s,n)=>typeof n=="bigint"?n.toString():n})(ae||(ae={}));const N=ae.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pt=i=>{switch(typeof i){case"undefined":return N.undefined;case"string":return N.string;case"number":return isNaN(i)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":return Array.isArray(i)?N.array:i===null?N.null:i.then&&typeof i.then=="function"&&i.catch&&typeof i.catch=="function"?N.promise:typeof Map<"u"&&i instanceof Map?N.map:typeof Set<"u"&&i instanceof Set?N.set:typeof Date<"u"&&i instanceof Date?N.date:N.object;default:return N.unknown}},O=ae.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),sc=i=>JSON.stringify(i,null,2).replace(/"([^"]+)":/g,"$1:");class st extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(n){return n.message},r={_errors:[]},s=n=>{for(const a of n.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(t(a));else{let o=r,h=0;for(;h<a.path.length;){const l=a.path[h];h===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(a))):o[l]=o[l]||{_errors:[]},o=o[l],h++}}};return s(this),r}toString(){return this.message}get message(){return JSON.stringify(this.issues,ae.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}st.create=i=>new st(i);const Fi=(i,e)=>{let t;switch(i.code){case O.invalid_type:i.received===N.undefined?t="Required":t=`Expected ${i.expected}, received ${i.received}`;break;case O.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(i.expected,ae.jsonStringifyReplacer)}`;break;case O.unrecognized_keys:t=`Unrecognized key(s) in object: ${ae.joinValues(i.keys,", ")}`;break;case O.invalid_union:t="Invalid input";break;case O.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${ae.joinValues(i.options)}`;break;case O.invalid_enum_value:t=`Invalid enum value. Expected ${ae.joinValues(i.options)}, received '${i.received}'`;break;case O.invalid_arguments:t="Invalid function arguments";break;case O.invalid_return_type:t="Invalid function return type";break;case O.invalid_date:t="Invalid date";break;case O.invalid_string:typeof i.validation=="object"?"startsWith"in i.validation?t=`Invalid input: must start with "${i.validation.startsWith}"`:"endsWith"in i.validation?t=`Invalid input: must end with "${i.validation.endsWith}"`:ae.assertNever(i.validation):i.validation!=="regex"?t=`Invalid ${i.validation}`:t="Invalid";break;case O.too_small:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at least":"more than"} ${i.minimum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at least":"over"} ${i.minimum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${i.minimum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${new Date(i.minimum)}`:t="Invalid input";break;case O.too_big:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at most":"less than"} ${i.maximum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at most":"under"} ${i.maximum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly":i.inclusive?"smaller than or equal to":"smaller than"} ${new Date(i.maximum)}`:t="Invalid input";break;case O.custom:t="Invalid input";break;case O.invalid_intersection_types:t="Intersection results could not be merged";break;case O.not_multiple_of:t=`Number must be a multiple of ${i.multipleOf}`;break;case O.not_finite:t="Number must be finite";break;default:t=e.defaultError,ae.assertNever(i)}return{message:t}};let Vo=Fi;function nc(i){Vo=i}function Nr(){return Vo}const Dr=i=>{const{data:e,path:t,errorMaps:r,issueData:s}=i,n=[...t,...s.path||[]],a={...s,path:n};let o="";const h=r.filter(l=>!!l).slice().reverse();for(const l of h)o=l(a,{data:e,defaultError:o}).message;return{...s,path:n,message:s.message||o}},ac=[];function B(i,e){const t=Dr({issueData:e,data:i.data,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,Nr(),Fi].filter(r=>!!r)});i.common.issues.push(t)}class Le{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return Y;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t)r.push({key:await s.key,value:await s.value});return Le.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:n,value:a}=s;if(n.status==="aborted"||a.status==="aborted")return Y;n.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),(typeof a.value<"u"||s.alwaysSet)&&(r[n.value]=a.value)}return{status:e.value,value:r}}}const Y=Object.freeze({status:"aborted"}),zo=i=>({status:"dirty",value:i}),Me=i=>({status:"valid",value:i}),Ds=i=>i.status==="aborted",Gs=i=>i.status==="dirty",Gr=i=>i.status==="valid",Fr=i=>typeof Promise<"u"&&i instanceof Promise;var ee;(function(i){i.errToObj=e=>typeof e=="string"?{message:e}:e||{},i.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ee||(ee={}));class nt{constructor(e,t,r,s){this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._path.concat(this._key)}}const na=(i,e)=>{if(Gr(e))return{success:!0,data:e.value};if(!i.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,error:new st(i.common.issues)}};function J(i){if(!i)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=i;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>a.code!=="invalid_type"?{message:o.defaultError}:typeof o.data>"u"?{message:r??o.defaultError}:{message:t??o.defaultError},description:s}}class Q{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Pt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Le,ctx:{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Fr(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pt(e)},n=this._parseSync({data:e,path:s.path,parent:s});return na(s,n)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pt(e)},s=this._parse({data:e,path:r.path,parent:r}),n=await(Fr(s)?s:Promise.resolve(s));return na(r,n)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,n)=>{const a=e(s),o=()=>n.addIssue({code:O.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(h=>h?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new Ye({schema:this,typeName:X.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return pt.create(this,this._def)}nullable(){return Ut.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xe.create(this,this._def)}promise(){return fi.create(this,this._def)}or(e){return zi.create([this,e],this._def)}and(e){return Wi.create(this,e,this._def)}transform(e){return new Ye({...J(this._def),schema:this,typeName:X.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new qi({...J(this._def),innerType:this,defaultValue:t,typeName:X.ZodDefault})}brand(){return new Uo({typeName:X.ZodBranded,type:this,...J(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new zr({...J(this._def),innerType:this,catchValue:t,typeName:X.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ir.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const oc=/^c[^\s-]{8,}$/i,lc=/^[a-z][a-z0-9]*$/,hc=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,dc=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|([^-]([a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}))$/,uc=i=>i.precision?i.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${i.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${i.precision}}Z$`):i.precision===0?i.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):i.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");class gt extends Q{constructor(){super(...arguments),this._regex=(e,t,r)=>this.refinement(s=>e.test(s),{validation:t,code:O.invalid_string,...ee.errToObj(r)}),this.nonempty=e=>this.min(1,ee.errToObj(e)),this.trim=()=>new gt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==N.string){const n=this._getOrReturnCtx(e);return B(n,{code:O.invalid_type,expected:N.string,received:n.parsedType}),Y}const r=new Le;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,o=e.data.length<n.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?B(s,{code:O.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):o&&B(s,{code:O.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if(n.kind==="email")dc.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"email",code:O.invalid_string,message:n.message}),r.dirty());else if(n.kind==="uuid")hc.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"uuid",code:O.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid")oc.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid",code:O.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid2")lc.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid2",code:O.invalid_string,message:n.message}),r.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),B(s,{validation:"url",code:O.invalid_string,message:n.message}),r.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"regex",code:O.invalid_string,message:n.message}),r.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):n.kind==="datetime"?uc(n).test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:"datetime",message:n.message}),r.dirty()):ae.assertNever(n);return{status:r.value,value:e.data}}_addCheck(e){return new gt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ee.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ee.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ee.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ee.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ee.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...ee.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ee.errToObj(t)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ee.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ee.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ee.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ee.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ee.errToObj(t)})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}gt.create=i=>{var e;return new gt({checks:[],typeName:X.ZodString,coerce:(e=i==null?void 0:i.coerce)!==null&&e!==void 0?e:!1,...J(i)})};function cc(i,e){const t=(i.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,n=parseInt(i.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return n%a/Math.pow(10,s)}class Ot extends Q{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==N.number){const n=this._getOrReturnCtx(e);return B(n,{code:O.invalid_type,expected:N.number,received:n.parsedType}),Y}let r;const s=new Le;for(const n of this._def.checks)n.kind==="int"?ae.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),B(r,{code:O.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(r=this._getOrReturnCtx(e,r),B(r,{code:O.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(r=this._getOrReturnCtx(e,r),B(r,{code:O.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?cc(e.data,n.value)!==0&&(r=this._getOrReturnCtx(e,r),B(r,{code:O.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),B(r,{code:O.not_finite,message:n.message}),s.dirty()):ae.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ee.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ee.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ee.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ee.toString(t))}setLimit(e,t,r,s){return new Ot({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:ee.toString(s)}]})}_addCheck(e){return new Ot({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ee.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ee.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ee.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ee.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ee.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ee.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ee.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ae.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Ot.create=i=>new Ot({checks:[],typeName:X.ZodNumber,coerce:(i==null?void 0:i.coerce)||!1,...J(i)});class Hi extends Q{_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==N.bigint){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.bigint,received:r.parsedType}),Y}return Me(e.data)}}Hi.create=i=>{var e;return new Hi({typeName:X.ZodBigInt,coerce:(e=i==null?void 0:i.coerce)!==null&&e!==void 0?e:!1,...J(i)})};class Bi extends Q{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==N.boolean){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.boolean,received:r.parsedType}),Y}return Me(e.data)}}Bi.create=i=>new Bi({typeName:X.ZodBoolean,coerce:(i==null?void 0:i.coerce)||!1,...J(i)});class zt extends Q{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==N.date){const n=this._getOrReturnCtx(e);return B(n,{code:O.invalid_type,expected:N.date,received:n.parsedType}),Y}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return B(n,{code:O.invalid_date}),Y}const r=new Le;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),r.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):ae.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new zt({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ee.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ee.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}zt.create=i=>new zt({checks:[],coerce:(i==null?void 0:i.coerce)||!1,typeName:X.ZodDate,...J(i)});class Hr extends Q{_parse(e){if(this._getType(e)!==N.symbol){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.symbol,received:r.parsedType}),Y}return Me(e.data)}}Hr.create=i=>new Hr({typeName:X.ZodSymbol,...J(i)});class $i extends Q{_parse(e){if(this._getType(e)!==N.undefined){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.undefined,received:r.parsedType}),Y}return Me(e.data)}}$i.create=i=>new $i({typeName:X.ZodUndefined,...J(i)});class Vi extends Q{_parse(e){if(this._getType(e)!==N.null){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.null,received:r.parsedType}),Y}return Me(e.data)}}Vi.create=i=>new Vi({typeName:X.ZodNull,...J(i)});class ci extends Q{constructor(){super(...arguments),this._any=!0}_parse(e){return Me(e.data)}}ci.create=i=>new ci({typeName:X.ZodAny,...J(i)});class Bt extends Q{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Me(e.data)}}Bt.create=i=>new Bt({typeName:X.ZodUnknown,...J(i)});class vt extends Q{_parse(e){const t=this._getOrReturnCtx(e);return B(t,{code:O.invalid_type,expected:N.never,received:t.parsedType}),Y}}vt.create=i=>new vt({typeName:X.ZodNever,...J(i)});class Br extends Q{_parse(e){if(this._getType(e)!==N.undefined){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.void,received:r.parsedType}),Y}return Me(e.data)}}Br.create=i=>new Br({typeName:X.ZodVoid,...J(i)});class Xe extends Q{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==N.array)return B(t,{code:O.invalid_type,expected:N.array,received:t.parsedType}),Y;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(B(t,{code:a?O.too_big:O.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(B(t,{code:O.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(B(t,{code:O.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new nt(t,a,t.path,o)))).then(a=>Le.mergeArray(r,a));const n=[...t.data].map((a,o)=>s.type._parseSync(new nt(t,a,t.path,o)));return Le.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new Xe({...this._def,minLength:{value:e,message:ee.toString(t)}})}max(e,t){return new Xe({...this._def,maxLength:{value:e,message:ee.toString(t)}})}length(e,t){return new Xe({...this._def,exactLength:{value:e,message:ee.toString(t)}})}nonempty(e){return this.min(1,e)}}Xe.create=(i,e)=>new Xe({type:i,minLength:null,maxLength:null,exactLength:null,typeName:X.ZodArray,...J(e)});var $r;(function(i){i.mergeShapes=(e,t)=>({...e,...t})})($r||($r={}));function Qt(i){if(i instanceof pe){const e={};for(const t in i.shape){const r=i.shape[t];e[t]=pt.create(Qt(r))}return new pe({...i._def,shape:()=>e})}else return i instanceof Xe?Xe.create(Qt(i.element)):i instanceof pt?pt.create(Qt(i.unwrap())):i instanceof Ut?Ut.create(Qt(i.unwrap())):i instanceof at?at.create(i.items.map(e=>Qt(e))):i}class pe extends Q{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=ae.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==N.object){const l=this._getOrReturnCtx(e);return B(l,{code:O.invalid_type,expected:N.object,received:l.parsedType}),Y}const{status:r,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof vt&&this._def.unknownKeys==="strip"))for(const l in s.data)a.includes(l)||o.push(l);const h=[];for(const l of a){const d=n[l],u=s.data[l];h.push({key:{status:"valid",value:l},value:d._parse(new nt(s,u,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof vt){const l=this._def.unknownKeys;if(l==="passthrough")for(const d of o)h.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(l==="strict")o.length>0&&(B(s,{code:O.unrecognized_keys,keys:o}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const d of o){const u=s.data[d];h.push({key:{status:"valid",value:d},value:l._parse(new nt(s,u,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const l=[];for(const d of h){const u=await d.key;l.push({key:u,value:await d.value,alwaysSet:d.alwaysSet})}return l}).then(l=>Le.mergeObjectSync(r,l)):Le.mergeObjectSync(r,h)}get shape(){return this._def.shape()}strict(e){return ee.errToObj,new pe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,n,a,o;const h=(a=(n=(s=this._def).errorMap)===null||n===void 0?void 0:n.call(s,t,r).message)!==null&&a!==void 0?a:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=ee.errToObj(e).message)!==null&&o!==void 0?o:h}:{message:h}}}:{}})}strip(){return new pe({...this._def,unknownKeys:"strip"})}passthrough(){return new pe({...this._def,unknownKeys:"passthrough"})}extend(e){return new pe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new pe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>$r.mergeShapes(this._def.shape(),e._def.shape()),typeName:X.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new pe({...this._def,catchall:e})}pick(e){const t={};return ae.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new pe({...this._def,shape:()=>t})}omit(e){const t={};return ae.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new pe({...this._def,shape:()=>t})}deepPartial(){return Qt(this)}partial(e){const t={};return ae.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new pe({...this._def,shape:()=>t})}required(e){const t={};return ae.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let n=this.shape[r];for(;n instanceof pt;)n=n._def.innerType;t[r]=n}}),new pe({...this._def,shape:()=>t})}keyof(){return Wo(ae.objectKeys(this.shape))}}pe.create=(i,e)=>new pe({shape:()=>i,unknownKeys:"strip",catchall:vt.create(),typeName:X.ZodObject,...J(e)});pe.strictCreate=(i,e)=>new pe({shape:()=>i,unknownKeys:"strict",catchall:vt.create(),typeName:X.ZodObject,...J(e)});pe.lazycreate=(i,e)=>new pe({shape:i,unknownKeys:"strip",catchall:vt.create(),typeName:X.ZodObject,...J(e)});class zi extends Q{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(n){for(const o of n)if(o.result.status==="valid")return o.result;for(const o of n)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=n.map(o=>new st(o.ctx.common.issues));return B(t,{code:O.invalid_union,unionErrors:a}),Y}if(t.common.async)return Promise.all(r.map(async n=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let n;const a=[];for(const h of r){const l={...t,common:{...t.common,issues:[]},parent:null},d=h._parseSync({data:t.data,path:t.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!n&&(n={result:d,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const o=a.map(h=>new st(h));return B(t,{code:O.invalid_union,unionErrors:o}),Y}}get options(){return this._def.options}}zi.create=(i,e)=>new zi({options:i,typeName:X.ZodUnion,...J(e)});const Er=i=>i instanceof Zi?Er(i.schema):i instanceof Ye?Er(i.innerType()):i instanceof ji?[i.value]:i instanceof Lt?i.options:i instanceof Xi?Object.keys(i.enum):i instanceof qi?Er(i._def.innerType):i instanceof $i?[void 0]:i instanceof Vi?[null]:null;class es extends Q{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.object)return B(t,{code:O.invalid_type,expected:N.object,received:t.parsedType}),Y;const r=this.discriminator,s=t.data[r],n=this.optionsMap.get(s);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(B(t,{code:O.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const n of t){const a=Er(n.shape[e]);if(!a)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,n)}}return new es({typeName:X.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...J(r)})}}function Fs(i,e){const t=Pt(i),r=Pt(e);if(i===e)return{valid:!0,data:i};if(t===N.object&&r===N.object){const s=ae.objectKeys(e),n=ae.objectKeys(i).filter(o=>s.indexOf(o)!==-1),a={...i,...e};for(const o of n){const h=Fs(i[o],e[o]);if(!h.valid)return{valid:!1};a[o]=h.data}return{valid:!0,data:a}}else if(t===N.array&&r===N.array){if(i.length!==e.length)return{valid:!1};const s=[];for(let n=0;n<i.length;n++){const a=i[n],o=e[n],h=Fs(a,o);if(!h.valid)return{valid:!1};s.push(h.data)}return{valid:!0,data:s}}else return t===N.date&&r===N.date&&+i==+e?{valid:!0,data:i}:{valid:!1}}class Wi extends Q{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(n,a)=>{if(Ds(n)||Ds(a))return Y;const o=Fs(n.value,a.value);return o.valid?((Gs(n)||Gs(a))&&t.dirty(),{status:t.value,value:o.data}):(B(r,{code:O.invalid_intersection_types}),Y)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([n,a])=>s(n,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Wi.create=(i,e,t)=>new Wi({left:i,right:e,typeName:X.ZodIntersection,...J(t)});class at extends Q{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.array)return B(r,{code:O.invalid_type,expected:N.array,received:r.parsedType}),Y;if(r.data.length<this._def.items.length)return B(r,{code:O.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Y;!this._def.rest&&r.data.length>this._def.items.length&&(B(r,{code:O.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...r.data].map((a,o)=>{const h=this._def.items[o]||this._def.rest;return h?h._parse(new nt(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(n).then(a=>Le.mergeArray(t,a)):Le.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new at({...this._def,rest:e})}}at.create=(i,e)=>{if(!Array.isArray(i))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new at({items:i,typeName:X.ZodTuple,rest:null,...J(e)})};class Ui extends Q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.object)return B(r,{code:O.invalid_type,expected:N.object,received:r.parsedType}),Y;const s=[],n=this._def.keyType,a=this._def.valueType;for(const o in r.data)s.push({key:n._parse(new nt(r,o,r.path,o)),value:a._parse(new nt(r,r.data[o],r.path,o))});return r.common.async?Le.mergeObjectAsync(t,s):Le.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof Q?new Ui({keyType:e,valueType:t,typeName:X.ZodRecord,...J(r)}):new Ui({keyType:gt.create(),valueType:e,typeName:X.ZodRecord,...J(t)})}}class Vr extends Q{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.map)return B(r,{code:O.invalid_type,expected:N.map,received:r.parsedType}),Y;const s=this._def.keyType,n=this._def.valueType,a=[...r.data.entries()].map(([o,h],l)=>({key:s._parse(new nt(r,o,r.path,[l,"key"])),value:n._parse(new nt(r,h,r.path,[l,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const h of a){const l=await h.key,d=await h.value;if(l.status==="aborted"||d.status==="aborted")return Y;(l.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(l.value,d.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const h of a){const l=h.key,d=h.value;if(l.status==="aborted"||d.status==="aborted")return Y;(l.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(l.value,d.value)}return{status:t.value,value:o}}}}Vr.create=(i,e,t)=>new Vr({valueType:e,keyType:i,typeName:X.ZodMap,...J(t)});class Wt extends Q{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.set)return B(r,{code:O.invalid_type,expected:N.set,received:r.parsedType}),Y;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(B(r,{code:O.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(B(r,{code:O.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const n=this._def.valueType;function a(h){const l=new Set;for(const d of h){if(d.status==="aborted")return Y;d.status==="dirty"&&t.dirty(),l.add(d.value)}return{status:t.value,value:l}}const o=[...r.data.values()].map((h,l)=>n._parse(new nt(r,h,r.path,l)));return r.common.async?Promise.all(o).then(h=>a(h)):a(o)}min(e,t){return new Wt({...this._def,minSize:{value:e,message:ee.toString(t)}})}max(e,t){return new Wt({...this._def,maxSize:{value:e,message:ee.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Wt.create=(i,e)=>new Wt({valueType:i,minSize:null,maxSize:null,typeName:X.ZodSet,...J(e)});class oi extends Q{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.function)return B(t,{code:O.invalid_type,expected:N.function,received:t.parsedType}),Y;function r(o,h){return Dr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Nr(),Fi].filter(l=>!!l),issueData:{code:O.invalid_arguments,argumentsError:h}})}function s(o,h){return Dr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Nr(),Fi].filter(l=>!!l),issueData:{code:O.invalid_return_type,returnTypeError:h}})}const n={errorMap:t.common.contextualErrorMap},a=t.data;return this._def.returns instanceof fi?Me(async(...o)=>{const h=new st([]),l=await this._def.args.parseAsync(o,n).catch(c=>{throw h.addIssue(r(o,c)),h}),d=await a(...l);return await this._def.returns._def.type.parseAsync(d,n).catch(c=>{throw h.addIssue(s(d,c)),h})}):Me((...o)=>{const h=this._def.args.safeParse(o,n);if(!h.success)throw new st([r(o,h.error)]);const l=a(...h.data),d=this._def.returns.safeParse(l,n);if(!d.success)throw new st([s(l,d.error)]);return d.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new oi({...this._def,args:at.create(e).rest(Bt.create())})}returns(e){return new oi({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new oi({args:e||at.create([]).rest(Bt.create()),returns:t||Bt.create(),typeName:X.ZodFunction,...J(r)})}}class Zi extends Q{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Zi.create=(i,e)=>new Zi({getter:i,typeName:X.ZodLazy,...J(e)});class ji extends Q{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return B(t,{received:t.data,code:O.invalid_literal,expected:this._def.value}),Y}return{status:"valid",value:e.data}}get value(){return this._def.value}}ji.create=(i,e)=>new ji({value:i,typeName:X.ZodLiteral,...J(e)});function Wo(i,e){return new Lt({values:i,typeName:X.ZodEnum,...J(e)})}class Lt extends Q{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return B(t,{expected:ae.joinValues(r),received:t.parsedType,code:O.invalid_type}),Y}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),r=this._def.values;return B(t,{received:t.data,code:O.invalid_enum_value,options:r}),Y}return Me(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Lt.create(e)}exclude(e){return Lt.create(this.options.filter(t=>!e.includes(t)))}}Lt.create=Wo;class Xi extends Q{_parse(e){const t=ae.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==N.string&&r.parsedType!==N.number){const s=ae.objectValues(t);return B(r,{expected:ae.joinValues(s),received:r.parsedType,code:O.invalid_type}),Y}if(t.indexOf(e.data)===-1){const s=ae.objectValues(t);return B(r,{received:r.data,code:O.invalid_enum_value,options:s}),Y}return Me(e.data)}get enum(){return this._def.values}}Xi.create=(i,e)=>new Xi({values:i,typeName:X.ZodNativeEnum,...J(e)});class fi extends Q{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.promise&&t.common.async===!1)return B(t,{code:O.invalid_type,expected:N.promise,received:t.parsedType}),Y;const r=t.parsedType===N.promise?t.data:Promise.resolve(t.data);return Me(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}fi.create=(i,e)=>new fi({type:i,typeName:X.ZodPromise,...J(e)});class Ye extends Q{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===X.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null;if(s.type==="preprocess"){const a=s.transform(r.data);return r.common.async?Promise.resolve(a).then(o=>this._def.schema._parseAsync({data:o,path:r.path,parent:r})):this._def.schema._parseSync({data:a,path:r.path,parent:r})}const n={addIssue:a=>{B(r,a),a.fatal?t.abort():t.dirty()},get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),s.type==="refinement"){const a=o=>{const h=s.refinement(o,n);if(r.common.async)return Promise.resolve(h);if(h instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Y:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?Y:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Gr(a))return a;const o=s.transform(a.value,n);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>Gr(a)?Promise.resolve(s.transform(a.value,n)).then(o=>({status:t.value,value:o})):a);ae.assertNever(s)}}Ye.create=(i,e,t)=>new Ye({schema:i,typeName:X.ZodEffects,effect:e,...J(t)});Ye.createWithPreprocess=(i,e,t)=>new Ye({schema:e,effect:{type:"preprocess",transform:i},typeName:X.ZodEffects,...J(t)});class pt extends Q{_parse(e){return this._getType(e)===N.undefined?Me(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}pt.create=(i,e)=>new pt({innerType:i,typeName:X.ZodOptional,...J(e)});class Ut extends Q{_parse(e){return this._getType(e)===N.null?Me(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ut.create=(i,e)=>new Ut({innerType:i,typeName:X.ZodNullable,...J(e)});class qi extends Q{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===N.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}qi.create=(i,e)=>new qi({innerType:i,typeName:X.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...J(e)});class zr extends Q{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t,common:{...t.common,issues:[]}}});return Fr(r)?r.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue()})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue()}}removeCatch(){return this._def.innerType}}zr.create=(i,e)=>new zr({innerType:i,typeName:X.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...J(e)});class Wr extends Q{_parse(e){if(this._getType(e)!==N.nan){const r=this._getOrReturnCtx(e);return B(r,{code:O.invalid_type,expected:N.nan,received:r.parsedType}),Y}return{status:"valid",value:e.data}}}Wr.create=i=>new Wr({typeName:X.ZodNaN,...J(i)});const fc=Symbol("zod_brand");class Uo extends Q{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ir extends Q{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?Y:n.status==="dirty"?(t.dirty(),zo(n.value)):this._def.out._parseAsync({data:n.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Y:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new ir({in:e,out:t,typeName:X.ZodPipeline})}}const Zo=(i,e={},t)=>i?ci.create().superRefine((r,s)=>{if(!i(r)){const n=typeof e=="function"?e(r):e,a=typeof n=="string"?{message:n}:n;s.addIssue({code:"custom",...a,fatal:t})}}):ci.create(),pc={object:pe.lazycreate};var X;(function(i){i.ZodString="ZodString",i.ZodNumber="ZodNumber",i.ZodNaN="ZodNaN",i.ZodBigInt="ZodBigInt",i.ZodBoolean="ZodBoolean",i.ZodDate="ZodDate",i.ZodSymbol="ZodSymbol",i.ZodUndefined="ZodUndefined",i.ZodNull="ZodNull",i.ZodAny="ZodAny",i.ZodUnknown="ZodUnknown",i.ZodNever="ZodNever",i.ZodVoid="ZodVoid",i.ZodArray="ZodArray",i.ZodObject="ZodObject",i.ZodUnion="ZodUnion",i.ZodDiscriminatedUnion="ZodDiscriminatedUnion",i.ZodIntersection="ZodIntersection",i.ZodTuple="ZodTuple",i.ZodRecord="ZodRecord",i.ZodMap="ZodMap",i.ZodSet="ZodSet",i.ZodFunction="ZodFunction",i.ZodLazy="ZodLazy",i.ZodLiteral="ZodLiteral",i.ZodEnum="ZodEnum",i.ZodEffects="ZodEffects",i.ZodNativeEnum="ZodNativeEnum",i.ZodOptional="ZodOptional",i.ZodNullable="ZodNullable",i.ZodDefault="ZodDefault",i.ZodCatch="ZodCatch",i.ZodPromise="ZodPromise",i.ZodBranded="ZodBranded",i.ZodPipeline="ZodPipeline"})(X||(X={}));const mc=(i,e={message:`Input not instance of ${i.name}`})=>Zo(t=>t instanceof i,e,!0),jo=gt.create,Xo=Ot.create,gc=Wr.create,vc=Hi.create,qo=Bi.create,yc=zt.create,bc=Hr.create,_c=$i.create,wc=Vi.create,Sc=ci.create,Tc=Bt.create,Cc=vt.create,Ec=Br.create,kc=Xe.create,xc=pe.create,Pc=pe.strictCreate,Ac=zi.create,Mc=es.create,Oc=Wi.create,Lc=at.create,Rc=Ui.create,Ic=Vr.create,Nc=Wt.create,Dc=oi.create,Gc=Zi.create,Fc=ji.create,Hc=Lt.create,Bc=Xi.create,$c=fi.create,aa=Ye.create,Vc=pt.create,zc=Ut.create,Wc=Ye.createWithPreprocess,Uc=ir.create,Zc=()=>jo().optional(),jc=()=>Xo().optional(),Xc=()=>qo().optional(),qc={string:i=>gt.create({...i,coerce:!0}),number:i=>Ot.create({...i,coerce:!0}),boolean:i=>Bi.create({...i,coerce:!0}),bigint:i=>Hi.create({...i,coerce:!0}),date:i=>zt.create({...i,coerce:!0})},Yc=Y;var _e=Object.freeze({__proto__:null,defaultErrorMap:Fi,setErrorMap:nc,getErrorMap:Nr,makeIssue:Dr,EMPTY_PATH:ac,addIssueToContext:B,ParseStatus:Le,INVALID:Y,DIRTY:zo,OK:Me,isAborted:Ds,isDirty:Gs,isValid:Gr,isAsync:Fr,get util(){return ae},ZodParsedType:N,getParsedType:Pt,ZodType:Q,ZodString:gt,ZodNumber:Ot,ZodBigInt:Hi,ZodBoolean:Bi,ZodDate:zt,ZodSymbol:Hr,ZodUndefined:$i,ZodNull:Vi,ZodAny:ci,ZodUnknown:Bt,ZodNever:vt,ZodVoid:Br,ZodArray:Xe,get objectUtil(){return $r},ZodObject:pe,ZodUnion:zi,ZodDiscriminatedUnion:es,ZodIntersection:Wi,ZodTuple:at,ZodRecord:Ui,ZodMap:Vr,ZodSet:Wt,ZodFunction:oi,ZodLazy:Zi,ZodLiteral:ji,ZodEnum:Lt,ZodNativeEnum:Xi,ZodPromise:fi,ZodEffects:Ye,ZodTransformer:Ye,ZodOptional:pt,ZodNullable:Ut,ZodDefault:qi,ZodCatch:zr,ZodNaN:Wr,BRAND:fc,ZodBranded:Uo,ZodPipeline:ir,custom:Zo,Schema:Q,ZodSchema:Q,late:pc,get ZodFirstPartyTypeKind(){return X},coerce:qc,any:Sc,array:kc,bigint:vc,boolean:qo,date:yc,discriminatedUnion:Mc,effect:aa,enum:Hc,function:Dc,instanceof:mc,intersection:Oc,lazy:Gc,literal:Fc,map:Ic,nan:gc,nativeEnum:Bc,never:Cc,null:wc,nullable:zc,number:Xo,object:xc,oboolean:Xc,onumber:jc,optional:Vc,ostring:Zc,pipeline:Uc,preprocess:Wc,promise:$c,record:Rc,set:Nc,strictObject:Pc,string:jo,symbol:bc,transformer:aa,tuple:Lc,undefined:_c,union:Ac,unknown:Tc,void:Ec,NEVER:Yc,ZodIssueCode:O,quotelessJson:sc,ZodError:st});class li{static id(){return e=>_e.coerce.string().min(1).max(100).parse(e)}static description(){return e=>_e.coerce.string().max(1e3).parse(e)}static boolean(){return e=>_e.coerce.boolean().parse(e)}static url(){return e=>_e.coerce.string().url().parse(e)}}class dt{constructor(){this.onChange$=new ti(void 0)}static instance(){return dt._instance||(dt._instance=new dt),dt._instance}get styles(){return this._styles}set styles(e){this._styles={...this._styles,...e},this.onChange$.next(this._styles)}}const rr={height:80,backgroundFill:"#ffffff",backgroundOpacity:1,descriptionTextFill:"#1c1c1c",descriptionFontSize:15,leftBackgroundFill:"#ffffff",leftBackgroundOpacity:1};class sr extends et{constructor(e){super(e),this.stylesProvider=dt.instance(),this.id=li.id()(this.config.id),this.description=li.description()(this.config.description)}createCanvasNode(){return this.bodyGroup=new M.Group({...this.timelinePosition,width:this.timeline.getBodyGroupRect().width,height:this.styleAdapter.style.height}),this.bodyBackground=new M.Rect({...F.POSITION_TOP_LEFT,...this.bodyGroup.getSize(),fill:this.styleAdapter.style.backgroundFill,opacity:this.styleAdapter.style.backgroundOpacity,listening:!1}),this.leftGroup=new M.Group({...F.POSITION_TOP_LEFT,width:this.timeline.getLeftPanelRect().width,listening:!1}),this.leftBackground=new M.Rect({...F.POSITION_TOP_LEFT,...this.leftGroup.getSize(),fill:this.styleAdapter.style.leftBackgroundFill,opacity:this.styleAdapter.style.leftBackgroundOpacity,listening:!1}),this.leftPanelText=new M.Text({...F.POSITION_TOP_LEFT,text:this.description,fontSize:this.style.descriptionFontSize,fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily,fill:this.style.descriptionTextFill,width:this.leftGroup.width()-10,height:this.getRect().height,verticalAlign:"middle",align:"right"}),this.leftGroup.add(this.leftBackground),this.leftGroup.add(this.leftPanelText),this.bodyGroup.add(this.bodyBackground),this.bodyGroup.add(this.leftGroup),this.bodyGroup}afterCanvasNodeInit(){this.settleLayout(),this.timeline.onZoom$.pipe(k(this.onDestroy$)).subscribe(e=>{this.settleLayout()}),this.stylesProvider.onChange$.pipe(k(this.onDestroy$),We(e=>!!e)).subscribe(e=>{this.onStylesProviderChange()}),this.styleAdapter.onChange$.pipe(k(this.onDestroy$),We(e=>!!e)).subscribe(e=>{this.onStyleChange()})}onMeasurementsChange(){this.settleLayout()}onStylesProviderChange(){this.leftPanelText.setAttrs({fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily})}onStyleChange(){this.bodyBackground.setAttrs({fill:this.styleAdapter.style.backgroundFill,opacity:this.styleAdapter.style.backgroundOpacity}),this.leftBackground.setAttrs({fill:this.styleAdapter.style.leftBackgroundFill,opacity:this.styleAdapter.style.leftBackgroundOpacity}),this.leftPanelText.setAttrs({fill:this.styleAdapter.style.leftBackgroundFill,opacity:this.styleAdapter.style.leftBackgroundOpacity})}settleLayout(){this.bodyGroup.setAttrs({...this.timelinePosition,width:this.timeline.getBodyGroupRect().width}),this.bodyBackground.setAttrs({...this.bodyGroup.getSize()}),this.leftGroup.setAttrs({width:this.timeline.getLeftPanelRect().width,height:this.bodyGroup.height(),visible:this.timeline.getLeftPanelVisible()}),this.leftBackground.setAttrs({...this.leftGroup.getSize()})}isTimelineReady(){return this.timeline&&this.timeline.isTimelineReady()}clearContent(){}setTimeline(e){this.timeline=e}setVideoController(e){this.videoController=e}get style(){return super.style}set style(e){super.style=e}getRect(){return{...this.getPosition(),...this.getDimension()}}getPosition(){return{...this.bodyGroup.getPosition()}}getDimension(){return{...this.bodyGroup.getSize()}}getId(){return this.id}getDescription(){return this.description}setTimelinePosition(e){this.timelinePosition=e}getTimelinePosition(){return this.timelinePosition}destroy(){this.clearContent(),super.destroy()}}const Yo={color:"rgba(255,73,145)",renderType:"lane",symbolType:"square"};class Ko extends et{constructor(e){super(e),this.onChange$=new V,this.onClick$=new V,this.onMouseEnter$=new V,this.onMouseLeave$=new V,this.id=li.id()(this.config.id),this.description=li.description()(this.config.description),this.editable=li.boolean()(this.config.editable),this.observation=this.config.observation}createCanvasNode(){return this.group=new M.Group({...F.POSITION_TOP_LEFT,...this.timeline.getTimecodedGroupDimension()}),this.group}afterCanvasNodeInit(){this.timeline.onZoom$.pipe(k(this.onDestroy$)).subscribe(e=>{this.onMeasurementsChange()}),this.group.on("click",e=>{this.onClick$.next({})}),this.group.on("mouseenter",e=>{this.onMouseEnter$.next({})}),this.group.on("mouseleave",e=>{this.onMouseLeave$.next({})})}onMeasurementsChange(){this.group.setAttrs({...this.timeline.getTimecodedGroupDimension()})}destroy(){super.destroy();let e=[this.onChange$,this.onClick$,this.onMouseEnter$,this.onMouseLeave$];Vt(...e),bi(...e)}setTimeline(e){this.timeline=e}setMarkerLane(e){this.markerLane=e}getId(){return this.id}getDescription(){return this.description}getTimeObservation(){return this.observation}setTimeObservation(e){this.editable&&(this.observation=e,this.onChange())}setEditable(e){this.editable=e}get style(){return this.styleAdapter.style}setStyle(e){this.styleAdapter.style=e}}class it{static resetCursorStyle(){this.cursor("default")}static cursor(e){document.body.style.cursor=e}}const Jo={color:"#ff6c6c",markerRenderType:"lane",markerSymbolType:"square",lineStrokeWidth:1,lineOpacity:.7};class Qo extends et{constructor(e,t,r){super(e),this.onDrag=s=>{},this.onDragEnd=s=>{},this.markerLane=t,this.timeline=r,this.x=this.config.x,this.editable=this.config.editable}createCanvasNode(){let e=this.getVerticalMeasurement();return this.group=new M.Group({x:this.x,y:e.y,draggable:this.editable}),this.line=new M.Line({stroke:this.style.color,strokeWidth:this.style.lineStrokeWidth,opacity:this.style.lineOpacity,points:[0,0,0,e.height],listening:!1}),this.handleGroup=new M.Group({x:0,y:this.markerLane.getPosition().y-e.y+this.markerLane.getDimension().height/2}),this.symbol=this.createSymbol(),this.handleGroup.add(this.symbol),this.handleGroup.on("mouseover",t=>{this.editable&&(this.handleGroup.to({scaleX:1.5,scaleY:1.5,duration:.1}),it.cursor("grab"))}),this.handleGroup.on("mouseleave",()=>{this.editable&&(this.handleGroup.to({scaleX:1,scaleY:1,duration:.1}),it.cursor("default"))}),this.group.add(this.line),this.group.add(this.handleGroup),this.group}afterCanvasNodeInit(){let e=this.getVerticalMeasurement();this.group.on("dragstart dragmove",t=>{it.cursor("grabbing");let r=this.timeline.constrainTimelinePosition(this.group.getPosition().x);this.group.setAttrs({x:r,y:e.y}),this.onDrag(this.group)}),this.group.on("dragend",t=>{let r=this.timeline.constrainTimelinePosition(this.group.getPosition().x);this.group.setAttrs({x:r,y:e.y}),this.onDragEnd(this.group),it.cursor("default")})}onMeasurementsChange(){let e=this.getVerticalMeasurement();this.group.setAttrs({y:e.y}),this.line.setAttrs({points:[0,0,0,e.height]}),this.handleGroup.setAttrs({y:this.markerLane.getPosition().y-e.y+this.markerLane.getDimension().height/2})}getVerticalMeasurement(){switch(this.style.markerRenderType){case"spanning":return{y:0,height:this.timeline.getTimecodedGroupDimension().height};default:return{y:this.markerLane.getTimelinePosition().y,height:this.markerLane.getDimension().height}}}getHandleGroup(){return this.handleGroup}getSymbol(){return this.symbol}getPosition(){return this.group.getPosition()}setPosition(e){this.group.setAttrs({...e}),this.onMeasurementsChange()}setColor(e){this.style.color=e,this.line.setAttrs({stroke:this.style.color}),this.symbol.setAttrs({fill:this.style.color})}setEditable(e){this.editable=e,this.group.draggable(this.editable)}}/*!
5
5
  * decimal.js v10.4.3
6
6
  * An arbitrary-precision Decimal type for JavaScript.
7
7
  * https://github.com/MikeMcl/decimal.js
8
8
  * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
9
9
  * MIT Licence
10
- */var ii=9e15,Ft=1e9,Hs="0123456789abcdef",Wr="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Zr="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Bs={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ii,maxE:ii,crypto:!1},el,dt,q=!0,ts="[DecimalError] ",Rt=ts+"Invalid argument: ",tl=ts+"Precision limit exceeded",il=ts+"crypto unavailable",rl="[object Decimal]",Oe=Math.floor,Se=Math.pow,Kc=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Jc=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Qc=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,sl=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,je=1e7,j=7,ef=9007199254740991,tf=Wr.length-1,$s=Zr.length-1,C={toStringTag:rl};C.absoluteValue=C.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),z(i)};C.ceil=function(){return z(new this.constructor(this),this.e+1,2)};C.clampedTo=C.clamp=function(i,e){var t,r=this,s=r.constructor;if(i=new s(i),e=new s(e),!i.s||!e.s)return new s(NaN);if(i.gt(e))throw Error(Rt+e);return t=r.cmp(i),t<0?i:r.cmp(e)>0?e:new s(r)};C.comparedTo=C.cmp=function(i){var e,t,r,s,n=this,a=n.d,o=(i=new n.constructor(i)).d,h=n.s,l=i.s;if(!a||!o)return!h||!l?NaN:h!==l?h:a===o?0:!a^h<0?1:-1;if(!a[0]||!o[0])return a[0]?h:o[0]?-l:0;if(h!==l)return h;if(n.e!==i.e)return n.e>i.e^h<0?1:-1;for(r=a.length,s=o.length,e=0,t=r<s?r:s;e<t;++e)if(a[e]!==o[e])return a[e]>o[e]^h<0?1:-1;return r===s?0:r>s^h<0?1:-1};C.cosine=C.cos=function(){var i,e,t=this,r=t.constructor;return t.d?t.d[0]?(i=r.precision,e=r.rounding,r.precision=i+Math.max(t.e,t.sd())+j,r.rounding=1,t=rf(r,hl(r,t)),r.precision=i,r.rounding=e,z(dt==2||dt==3?t.neg():t,i,e,!0)):new r(1):new r(NaN)};C.cubeRoot=C.cbrt=function(){var i,e,t,r,s,n,a,o,h,l,d=this,u=d.constructor;if(!d.isFinite()||d.isZero())return new u(d);for(q=!1,n=d.s*Se(d.s*d,1/3),!n||Math.abs(n)==1/0?(t=xe(d.d),i=d.e,(n=(i-t.length+1)%3)&&(t+=n==1||n==-2?"0":"00"),n=Se(t,1/3),i=Oe((i+1)/3)-(i%3==(i<0?-1:2)),n==1/0?t="5e"+i:(t=n.toExponential(),t=t.slice(0,t.indexOf("e")+1)+i),r=new u(t),r.s=d.s):r=new u(n.toString()),a=(i=u.precision)+3;;)if(o=r,h=o.times(o).times(o),l=h.plus(d),r=ue(l.plus(d).times(o),l.plus(h),a+2,1),xe(o.d).slice(0,a)===(t=xe(r.d)).slice(0,a))if(t=t.slice(a-3,a+1),t=="9999"||!s&&t=="4999"){if(!s&&(z(o,i+1,0),o.times(o).times(o).eq(d))){r=o;break}a+=4,s=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(z(r,i+1,1),e=!r.times(r).times(r).eq(d));break}return q=!0,z(r,i,u.rounding,e)};C.decimalPlaces=C.dp=function(){var i,e=this.d,t=NaN;if(e){if(i=e.length-1,t=(i-Oe(this.e/j))*j,i=e[i],i)for(;i%10==0;i/=10)t--;t<0&&(t=0)}return t};C.dividedBy=C.div=function(i){return ue(this,new this.constructor(i))};C.dividedToIntegerBy=C.divToInt=function(i){var e=this,t=e.constructor;return z(ue(e,new t(i),0,1,1),t.precision,t.rounding)};C.equals=C.eq=function(i){return this.cmp(i)===0};C.floor=function(){return z(new this.constructor(this),this.e+1,3)};C.greaterThan=C.gt=function(i){return this.cmp(i)>0};C.greaterThanOrEqualTo=C.gte=function(i){var e=this.cmp(i);return e==1||e===0};C.hyperbolicCosine=C.cosh=function(){var i,e,t,r,s,n=this,a=n.constructor,o=new a(1);if(!n.isFinite())return new a(n.s?1/0:NaN);if(n.isZero())return o;t=a.precision,r=a.rounding,a.precision=t+Math.max(n.e,n.sd())+4,a.rounding=1,s=n.d.length,s<32?(i=Math.ceil(s/3),e=(1/rs(4,i)).toString()):(i=16,e="2.3283064365386962890625e-10"),n=pi(a,1,n.times(e),new a(1),!0);for(var h,l=i,d=new a(8);l--;)h=n.times(n),n=o.minus(h.times(d.minus(h.times(d))));return z(n,a.precision=t,a.rounding=r,!0)};C.hyperbolicSine=C.sinh=function(){var i,e,t,r,s=this,n=s.constructor;if(!s.isFinite()||s.isZero())return new n(s);if(e=n.precision,t=n.rounding,n.precision=e+Math.max(s.e,s.sd())+4,n.rounding=1,r=s.d.length,r<3)s=pi(n,2,s,s,!0);else{i=1.4*Math.sqrt(r),i=i>16?16:i|0,s=s.times(1/rs(5,i)),s=pi(n,2,s,s,!0);for(var a,o=new n(5),h=new n(16),l=new n(20);i--;)a=s.times(s),s=s.times(o.plus(a.times(h.times(a).plus(l))))}return n.precision=e,n.rounding=t,z(s,e,t,!0)};C.hyperbolicTangent=C.tanh=function(){var i,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(i=r.precision,e=r.rounding,r.precision=i+7,r.rounding=1,ue(t.sinh(),t.cosh(),r.precision=i,r.rounding=e)):new r(t.s)};C.inverseCosine=C.acos=function(){var i,e=this,t=e.constructor,r=e.abs().cmp(1),s=t.precision,n=t.rounding;return r!==-1?r===0?e.isNeg()?We(t,s,n):new t(0):new t(NaN):e.isZero()?We(t,s+4,n).times(.5):(t.precision=s+6,t.rounding=1,e=e.asin(),i=We(t,s+4,n).times(.5),t.precision=s,t.rounding=n,i.minus(e))};C.inverseHyperbolicCosine=C.acosh=function(){var i,e,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(i=r.precision,e=r.rounding,r.precision=i+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,q=!1,t=t.times(t).minus(1).sqrt().plus(t),q=!0,r.precision=i,r.rounding=e,t.ln()):new r(t)};C.inverseHyperbolicSine=C.asinh=function(){var i,e,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(i=r.precision,e=r.rounding,r.precision=i+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,q=!1,t=t.times(t).plus(1).sqrt().plus(t),q=!0,r.precision=i,r.rounding=e,t.ln())};C.inverseHyperbolicTangent=C.atanh=function(){var i,e,t,r,s=this,n=s.constructor;return s.isFinite()?s.e>=0?new n(s.abs().eq(1)?s.s/0:s.isZero()?s:NaN):(i=n.precision,e=n.rounding,r=s.sd(),Math.max(r,i)<2*-s.e-1?z(new n(s),i,e,!0):(n.precision=t=r-s.e,s=ue(s.plus(1),new n(1).minus(s),t+i,1),n.precision=i+4,n.rounding=1,s=s.ln(),n.precision=i,n.rounding=e,s.times(.5))):new n(NaN)};C.inverseSine=C.asin=function(){var i,e,t,r,s=this,n=s.constructor;return s.isZero()?new n(s):(e=s.abs().cmp(1),t=n.precision,r=n.rounding,e!==-1?e===0?(i=We(n,t+4,r).times(.5),i.s=s.s,i):new n(NaN):(n.precision=t+6,n.rounding=1,s=s.div(new n(1).minus(s.times(s)).sqrt().plus(1)).atan(),n.precision=t,n.rounding=r,s.times(2)))};C.inverseTangent=C.atan=function(){var i,e,t,r,s,n,a,o,h,l=this,d=l.constructor,u=d.precision,c=d.rounding;if(l.isFinite()){if(l.isZero())return new d(l);if(l.abs().eq(1)&&u+4<=$s)return a=We(d,u+4,c).times(.25),a.s=l.s,a}else{if(!l.s)return new d(NaN);if(u+4<=$s)return a=We(d,u+4,c).times(.5),a.s=l.s,a}for(d.precision=o=u+10,d.rounding=1,t=Math.min(28,o/j+2|0),i=t;i;--i)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(q=!1,e=Math.ceil(o/j),r=1,h=l.times(l),a=new d(l),s=l;i!==-1;)if(s=s.times(h),n=a.minus(s.div(r+=2)),s=s.times(h),a=n.plus(s.div(r+=2)),a.d[e]!==void 0)for(i=e;a.d[i]===n.d[i]&&i--;);return t&&(a=a.times(2<<t-1)),q=!0,z(a,d.precision=u,d.rounding=c,!0)};C.isFinite=function(){return!!this.d};C.isInteger=C.isInt=function(){return!!this.d&&Oe(this.e/j)>this.d.length-2};C.isNaN=function(){return!this.s};C.isNegative=C.isNeg=function(){return this.s<0};C.isPositive=C.isPos=function(){return this.s>0};C.isZero=function(){return!!this.d&&this.d[0]===0};C.lessThan=C.lt=function(i){return this.cmp(i)<0};C.lessThanOrEqualTo=C.lte=function(i){return this.cmp(i)<1};C.logarithm=C.log=function(i){var e,t,r,s,n,a,o,h,l=this,d=l.constructor,u=d.precision,c=d.rounding,p=5;if(i==null)i=new d(10),e=!0;else{if(i=new d(i),t=i.d,i.s<0||!t||!t[0]||i.eq(1))return new d(NaN);e=i.eq(10)}if(t=l.d,l.s<0||!t||!t[0]||l.eq(1))return new d(t&&!t[0]?-1/0:l.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)n=!0;else{for(s=t[0];s%10===0;)s/=10;n=s!==1}if(q=!1,o=u+p,a=At(l,o),r=e?jr(d,o+10):At(i,o),h=ue(a,r,o,1),Yi(h.d,s=u,c))do if(o+=10,a=At(l,o),r=e?jr(d,o+10):At(i,o),h=ue(a,r,o,1),!n){+xe(h.d).slice(s+1,s+15)+1==1e14&&(h=z(h,u+1,0));break}while(Yi(h.d,s+=10,c));return q=!0,z(h,u,c)};C.minus=C.sub=function(i){var e,t,r,s,n,a,o,h,l,d,u,c,p=this,f=p.constructor;if(i=new f(i),!p.d||!i.d)return!p.s||!i.s?i=new f(NaN):p.d?i.s=-i.s:i=new f(i.d||p.s!==i.s?p:NaN),i;if(p.s!=i.s)return i.s=-i.s,p.plus(i);if(l=p.d,c=i.d,o=f.precision,h=f.rounding,!l[0]||!c[0]){if(c[0])i.s=-i.s;else if(l[0])i=new f(p);else return new f(h===3?-0:0);return q?z(i,o,h):i}if(t=Oe(i.e/j),d=Oe(p.e/j),l=l.slice(),n=d-t,n){for(u=n<0,u?(e=l,n=-n,a=c.length):(e=c,t=d,a=l.length),r=Math.max(Math.ceil(o/j),a)+2,n>r&&(n=r,e.length=1),e.reverse(),r=n;r--;)e.push(0);e.reverse()}else{for(r=l.length,a=c.length,u=r<a,u&&(a=r),r=0;r<a;r++)if(l[r]!=c[r]){u=l[r]<c[r];break}n=0}for(u&&(e=l,l=c,c=e,i.s=-i.s),a=l.length,r=c.length-a;r>0;--r)l[a++]=0;for(r=c.length;r>n;){if(l[--r]<c[r]){for(s=r;s&&l[--s]===0;)l[s]=je-1;--l[s],l[r]+=je}l[r]-=c[r]}for(;l[--a]===0;)l.pop();for(;l[0]===0;l.shift())--t;return l[0]?(i.d=l,i.e=is(l,t),q?z(i,o,h):i):new f(h===3?-0:0)};C.modulo=C.mod=function(i){var e,t=this,r=t.constructor;return i=new r(i),!t.d||!i.s||i.d&&!i.d[0]?new r(NaN):!i.d||t.d&&!t.d[0]?z(new r(t),r.precision,r.rounding):(q=!1,r.modulo==9?(e=ue(t,i.abs(),0,3,1),e.s*=i.s):e=ue(t,i,0,r.modulo,1),e=e.times(i),q=!0,t.minus(e))};C.naturalExponential=C.exp=function(){return Vs(this)};C.naturalLogarithm=C.ln=function(){return At(this)};C.negated=C.neg=function(){var i=new this.constructor(this);return i.s=-i.s,z(i)};C.plus=C.add=function(i){var e,t,r,s,n,a,o,h,l,d,u=this,c=u.constructor;if(i=new c(i),!u.d||!i.d)return!u.s||!i.s?i=new c(NaN):u.d||(i=new c(i.d||u.s===i.s?u:NaN)),i;if(u.s!=i.s)return i.s=-i.s,u.minus(i);if(l=u.d,d=i.d,o=c.precision,h=c.rounding,!l[0]||!d[0])return d[0]||(i=new c(u)),q?z(i,o,h):i;if(n=Oe(u.e/j),r=Oe(i.e/j),l=l.slice(),s=n-r,s){for(s<0?(t=l,s=-s,a=d.length):(t=d,r=n,a=l.length),n=Math.ceil(o/j),a=n>a?n+1:a+1,s>a&&(s=a,t.length=1),t.reverse();s--;)t.push(0);t.reverse()}for(a=l.length,s=d.length,a-s<0&&(s=a,t=d,d=l,l=t),e=0;s;)e=(l[--s]=l[s]+d[s]+e)/je|0,l[s]%=je;for(e&&(l.unshift(e),++r),a=l.length;l[--a]==0;)l.pop();return i.d=l,i.e=is(l,r),q?z(i,o,h):i};C.precision=C.sd=function(i){var e,t=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(Rt+i);return t.d?(e=nl(t.d),i&&t.e+1>e&&(e=t.e+1)):e=NaN,e};C.round=function(){var i=this,e=i.constructor;return z(new e(i),i.e+1,e.rounding)};C.sine=C.sin=function(){var i,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(i=r.precision,e=r.rounding,r.precision=i+Math.max(t.e,t.sd())+j,r.rounding=1,t=nf(r,hl(r,t)),r.precision=i,r.rounding=e,z(dt>2?t.neg():t,i,e,!0)):new r(NaN)};C.squareRoot=C.sqrt=function(){var i,e,t,r,s,n,a=this,o=a.d,h=a.e,l=a.s,d=a.constructor;if(l!==1||!o||!o[0])return new d(!l||l<0&&(!o||o[0])?NaN:o?a:1/0);for(q=!1,l=Math.sqrt(+a),l==0||l==1/0?(e=xe(o),(e.length+h)%2==0&&(e+="0"),l=Math.sqrt(e),h=Oe((h+1)/2)-(h<0||h%2),l==1/0?e="5e"+h:(e=l.toExponential(),e=e.slice(0,e.indexOf("e")+1)+h),r=new d(e)):r=new d(l.toString()),t=(h=d.precision)+3;;)if(n=r,r=n.plus(ue(a,n,t+2,1)).times(.5),xe(n.d).slice(0,t)===(e=xe(r.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!s&&e=="4999"){if(!s&&(z(n,h+1,0),n.times(n).eq(a))){r=n;break}t+=4,s=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(z(r,h+1,1),i=!r.times(r).eq(a));break}return q=!0,z(r,h,d.rounding,i)};C.tangent=C.tan=function(){var i,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(i=r.precision,e=r.rounding,r.precision=i+10,r.rounding=1,t=t.sin(),t.s=1,t=ue(t,new r(1).minus(t.times(t)).sqrt(),i+10,0),r.precision=i,r.rounding=e,z(dt==2||dt==4?t.neg():t,i,e,!0)):new r(NaN)};C.times=C.mul=function(i){var e,t,r,s,n,a,o,h,l,d=this,u=d.constructor,c=d.d,p=(i=new u(i)).d;if(i.s*=d.s,!c||!c[0]||!p||!p[0])return new u(!i.s||c&&!c[0]&&!p||p&&!p[0]&&!c?NaN:!c||!p?i.s/0:i.s*0);for(t=Oe(d.e/j)+Oe(i.e/j),h=c.length,l=p.length,h<l&&(n=c,c=p,p=n,a=h,h=l,l=a),n=[],a=h+l,r=a;r--;)n.push(0);for(r=l;--r>=0;){for(e=0,s=h+r;s>r;)o=n[s]+p[r]*c[s-r-1]+e,n[s--]=o%je|0,e=o/je|0;n[s]=(n[s]+e)%je|0}for(;!n[--a];)n.pop();return e?++t:n.shift(),i.d=n,i.e=is(n,t),q?z(i,u.precision,u.rounding):i};C.toBinary=function(i,e){return mn(this,2,i,e)};C.toDecimalPlaces=C.toDP=function(i,e){var t=this,r=t.constructor;return t=new r(t),i===void 0?t:(Ne(i,0,Ft),e===void 0?e=r.rounding:Ne(e,0,8),z(t,i+t.e+1,e))};C.toExponential=function(i,e){var t,r=this,s=r.constructor;return i===void 0?t=at(r,!0):(Ne(i,0,Ft),e===void 0?e=s.rounding:Ne(e,0,8),r=z(new s(r),i+1,e),t=at(r,!0,i+1)),r.isNeg()&&!r.isZero()?"-"+t:t};C.toFixed=function(i,e){var t,r,s=this,n=s.constructor;return i===void 0?t=at(s):(Ne(i,0,Ft),e===void 0?e=n.rounding:Ne(e,0,8),r=z(new n(s),i+s.e+1,e),t=at(r,!1,i+r.e+1)),s.isNeg()&&!s.isZero()?"-"+t:t};C.toFraction=function(i){var e,t,r,s,n,a,o,h,l,d,u,c,p=this,f=p.d,m=p.constructor;if(!f)return new m(p);if(l=t=new m(1),r=h=new m(0),e=new m(r),n=e.e=nl(f)-p.e-1,a=n%j,e.d[0]=Se(10,a<0?j+a:a),i==null)i=n>0?e:l;else{if(o=new m(i),!o.isInt()||o.lt(l))throw Error(Rt+o);i=o.gt(e)?n>0?e:l:o}for(q=!1,o=new m(xe(f)),d=m.precision,m.precision=n=f.length*j*2;u=ue(o,e,0,1,1),s=t.plus(u.times(r)),s.cmp(i)!=1;)t=r,r=s,s=l,l=h.plus(u.times(s)),h=s,s=e,e=o.minus(u.times(s)),o=s;return s=ue(i.minus(t),r,0,1,1),h=h.plus(s.times(l)),t=t.plus(s.times(r)),h.s=l.s=p.s,c=ue(l,r,n,1).minus(p).abs().cmp(ue(h,t,n,1).minus(p).abs())<1?[l,r]:[h,t],m.precision=d,q=!0,c};C.toHexadecimal=C.toHex=function(i,e){return mn(this,16,i,e)};C.toNearest=function(i,e){var t=this,r=t.constructor;if(t=new r(t),i==null){if(!t.d)return t;i=new r(1),e=r.rounding}else{if(i=new r(i),e===void 0?e=r.rounding:Ne(e,0,8),!t.d)return i.s?t:i;if(!i.d)return i.s&&(i.s=t.s),i}return i.d[0]?(q=!1,t=ue(t,i,0,e,1).times(i),q=!0,z(t)):(i.s=t.s,t=i),t};C.toNumber=function(){return+this};C.toOctal=function(i,e){return mn(this,8,i,e)};C.toPower=C.pow=function(i){var e,t,r,s,n,a,o=this,h=o.constructor,l=+(i=new h(i));if(!o.d||!i.d||!o.d[0]||!i.d[0])return new h(Se(+o,l));if(o=new h(o),o.eq(1))return o;if(r=h.precision,n=h.rounding,i.eq(1))return z(o,r,n);if(e=Oe(i.e/j),e>=i.d.length-1&&(t=l<0?-l:l)<=ef)return s=al(h,o,t,r),i.s<0?new h(1).div(s):z(s,r,n);if(a=o.s,a<0){if(e<i.d.length-1)return new h(NaN);if(i.d[e]&1||(a=1),o.e==0&&o.d[0]==1&&o.d.length==1)return o.s=a,o}return t=Se(+o,l),e=t==0||!isFinite(t)?Oe(l*(Math.log("0."+xe(o.d))/Math.LN10+o.e+1)):new h(t+"").e,e>h.maxE+1||e<h.minE-1?new h(e>0?a/0:0):(q=!1,h.rounding=o.s=1,t=Math.min(12,(e+"").length),s=Vs(i.times(At(o,r+t)),r),s.d&&(s=z(s,r+5,1),Yi(s.d,r,n)&&(e=r+10,s=z(Vs(i.times(At(o,e+t)),e),e+5,1),+xe(s.d).slice(r+1,r+15)+1==1e14&&(s=z(s,r+1,0)))),s.s=a,q=!0,h.rounding=n,z(s,r,n))};C.toPrecision=function(i,e){var t,r=this,s=r.constructor;return i===void 0?t=at(r,r.e<=s.toExpNeg||r.e>=s.toExpPos):(Ne(i,1,Ft),e===void 0?e=s.rounding:Ne(e,0,8),r=z(new s(r),i,e),t=at(r,i<=r.e||r.e<=s.toExpNeg,i)),r.isNeg()&&!r.isZero()?"-"+t:t};C.toSignificantDigits=C.toSD=function(i,e){var t=this,r=t.constructor;return i===void 0?(i=r.precision,e=r.rounding):(Ne(i,1,Ft),e===void 0?e=r.rounding:Ne(e,0,8)),z(new r(t),i,e)};C.toString=function(){var i=this,e=i.constructor,t=at(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()&&!i.isZero()?"-"+t:t};C.truncated=C.trunc=function(){return z(new this.constructor(this),this.e+1,1)};C.valueOf=C.toJSON=function(){var i=this,e=i.constructor,t=at(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()?"-"+t:t};function xe(i){var e,t,r,s=i.length-1,n="",a=i[0];if(s>0){for(n+=a,e=1;e<s;e++)r=i[e]+"",t=j-r.length,t&&(n+=xt(t)),n+=r;a=i[e],r=a+"",t=j-r.length,t&&(n+=xt(t))}else if(a===0)return"0";for(;a%10===0;)a/=10;return n+a}function Ne(i,e,t){if(i!==~~i||i<e||i>t)throw Error(Rt+i)}function Yi(i,e,t,r){var s,n,a,o;for(n=i[0];n>=10;n/=10)--e;return--e<0?(e+=j,s=0):(s=Math.ceil((e+1)/j),e%=j),n=Se(10,j-e),o=i[s]%n|0,r==null?e<3?(e==0?o=o/100|0:e==1&&(o=o/10|0),a=t<4&&o==99999||t>3&&o==49999||o==5e4||o==0):a=(t<4&&o+1==n||t>3&&o+1==n/2)&&(i[s+1]/n/100|0)==Se(10,e-2)-1||(o==n/2||o==0)&&(i[s+1]/n/100|0)==0:e<4?(e==0?o=o/1e3|0:e==1?o=o/100|0:e==2&&(o=o/10|0),a=(r||t<4)&&o==9999||!r&&t>3&&o==4999):a=((r||t<4)&&o+1==n||!r&&t>3&&o+1==n/2)&&(i[s+1]/n/1e3|0)==Se(10,e-3)-1,a}function kr(i,e,t){for(var r,s=[0],n,a=0,o=i.length;a<o;){for(n=s.length;n--;)s[n]*=e;for(s[0]+=Hs.indexOf(i.charAt(a++)),r=0;r<s.length;r++)s[r]>t-1&&(s[r+1]===void 0&&(s[r+1]=0),s[r+1]+=s[r]/t|0,s[r]%=t)}return s.reverse()}function rf(i,e){var t,r,s;if(e.isZero())return e;r=e.d.length,r<32?(t=Math.ceil(r/3),s=(1/rs(4,t)).toString()):(t=16,s="2.3283064365386962890625e-10"),i.precision+=t,e=pi(i,1,e.times(s),new i(1));for(var n=t;n--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return i.precision-=t,e}var ue=function(){function i(r,s,n){var a,o=0,h=r.length;for(r=r.slice();h--;)a=r[h]*s+o,r[h]=a%n|0,o=a/n|0;return o&&r.unshift(o),r}function e(r,s,n,a){var o,h;if(n!=a)h=n>a?1:-1;else for(o=h=0;o<n;o++)if(r[o]!=s[o]){h=r[o]>s[o]?1:-1;break}return h}function t(r,s,n,a){for(var o=0;n--;)r[n]-=o,o=r[n]<s[n]?1:0,r[n]=o*a+r[n]-s[n];for(;!r[0]&&r.length>1;)r.shift()}return function(r,s,n,a,o,h){var l,d,u,c,p,f,m,g,_,w,b,T,L,A,G,R,H,$,I,K,U=r.constructor,le=r.s==s.s?1:-1,ne=r.d,W=s.d;if(!ne||!ne[0]||!W||!W[0])return new U(!r.s||!s.s||(ne?W&&ne[0]==W[0]:!W)?NaN:ne&&ne[0]==0||!W?le*0:le/0);for(h?(p=1,d=r.e-s.e):(h=je,p=j,d=Oe(r.e/p)-Oe(s.e/p)),I=W.length,H=ne.length,_=new U(le),w=_.d=[],u=0;W[u]==(ne[u]||0);u++);if(W[u]>(ne[u]||0)&&d--,n==null?(A=n=U.precision,a=U.rounding):o?A=n+(r.e-s.e)+1:A=n,A<0)w.push(1),f=!0;else{if(A=A/p+2|0,u=0,I==1){for(c=0,W=W[0],A++;(u<H||c)&&A--;u++)G=c*h+(ne[u]||0),w[u]=G/W|0,c=G%W|0;f=c||u<H}else{for(c=h/(W[0]+1)|0,c>1&&(W=i(W,c,h),ne=i(ne,c,h),I=W.length,H=ne.length),R=I,b=ne.slice(0,I),T=b.length;T<I;)b[T++]=0;K=W.slice(),K.unshift(0),$=W[0],W[1]>=h/2&&++$;do c=0,l=e(W,b,I,T),l<0?(L=b[0],I!=T&&(L=L*h+(b[1]||0)),c=L/$|0,c>1?(c>=h&&(c=h-1),m=i(W,c,h),g=m.length,T=b.length,l=e(m,b,g,T),l==1&&(c--,t(m,I<g?K:W,g,h))):(c==0&&(l=c=1),m=W.slice()),g=m.length,g<T&&m.unshift(0),t(b,m,T,h),l==-1&&(T=b.length,l=e(W,b,I,T),l<1&&(c++,t(b,I<T?K:W,T,h))),T=b.length):l===0&&(c++,b=[0]),w[u++]=c,l&&b[0]?b[T++]=ne[R]||0:(b=[ne[R]],T=1);while((R++<H||b[0]!==void 0)&&A--);f=b[0]!==void 0}w[0]||w.shift()}if(p==1)_.e=d,el=f;else{for(u=1,c=w[0];c>=10;c/=10)u++;_.e=u+d*p-1,z(_,o?n+_.e+1:n,a,f)}return _}}();function z(i,e,t,r){var s,n,a,o,h,l,d,u,c,p=i.constructor;e:if(e!=null){if(u=i.d,!u)return i;for(s=1,o=u[0];o>=10;o/=10)s++;if(n=e-s,n<0)n+=j,a=e,d=u[c=0],h=d/Se(10,s-a-1)%10|0;else if(c=Math.ceil((n+1)/j),o=u.length,c>=o)if(r){for(;o++<=c;)u.push(0);d=h=0,s=1,n%=j,a=n-j+1}else break e;else{for(d=o=u[c],s=1;o>=10;o/=10)s++;n%=j,a=n-j+s,h=a<0?0:d/Se(10,s-a-1)%10|0}if(r=r||e<0||u[c+1]!==void 0||(a<0?d:d%Se(10,s-a-1)),l=t<4?(h||r)&&(t==0||t==(i.s<0?3:2)):h>5||h==5&&(t==4||r||t==6&&(n>0?a>0?d/Se(10,s-a):0:u[c-1])%10&1||t==(i.s<0?8:7)),e<1||!u[0])return u.length=0,l?(e-=i.e+1,u[0]=Se(10,(j-e%j)%j),i.e=-e||0):u[0]=i.e=0,i;if(n==0?(u.length=c,o=1,c--):(u.length=c+1,o=Se(10,j-n),u[c]=a>0?(d/Se(10,s-a)%Se(10,a)|0)*o:0),l)for(;;)if(c==0){for(n=1,a=u[0];a>=10;a/=10)n++;for(a=u[0]+=o,o=1;a>=10;a/=10)o++;n!=o&&(i.e++,u[0]==je&&(u[0]=1));break}else{if(u[c]+=o,u[c]!=je)break;u[c--]=0,o=1}for(n=u.length;u[--n]===0;)u.pop()}return q&&(i.e>p.maxE?(i.d=null,i.e=NaN):i.e<p.minE&&(i.e=0,i.d=[0])),i}function at(i,e,t){if(!i.isFinite())return ll(i);var r,s=i.e,n=xe(i.d),a=n.length;return e?(t&&(r=t-a)>0?n=n.charAt(0)+"."+n.slice(1)+xt(r):a>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(i.e<0?"e":"e+")+i.e):s<0?(n="0."+xt(-s-1)+n,t&&(r=t-a)>0&&(n+=xt(r))):s>=a?(n+=xt(s+1-a),t&&(r=t-s-1)>0&&(n=n+"."+xt(r))):((r=s+1)<a&&(n=n.slice(0,r)+"."+n.slice(r)),t&&(r=t-a)>0&&(s+1===a&&(n+="."),n+=xt(r))),n}function is(i,e){var t=i[0];for(e*=j;t>=10;t/=10)e++;return e}function jr(i,e,t){if(e>tf)throw q=!0,t&&(i.precision=t),Error(tl);return z(new i(Wr),e,1,!0)}function We(i,e,t){if(e>$s)throw Error(tl);return z(new i(Zr),e,t,!0)}function nl(i){var e=i.length-1,t=e*j+1;if(e=i[e],e){for(;e%10==0;e/=10)t--;for(e=i[0];e>=10;e/=10)t++}return t}function xt(i){for(var e="";i--;)e+="0";return e}function al(i,e,t,r){var s,n=new i(1),a=Math.ceil(r/j+4);for(q=!1;;){if(t%2&&(n=n.times(e),la(n.d,a)&&(s=!0)),t=Oe(t/2),t===0){t=n.d.length-1,s&&n.d[t]===0&&++n.d[t];break}e=e.times(e),la(e.d,a)}return q=!0,n}function oa(i){return i.d[i.d.length-1]&1}function ol(i,e,t){for(var r,s=new i(e[0]),n=0;++n<e.length;)if(r=new i(e[n]),r.s)s[t](r)&&(s=r);else{s=r;break}return s}function Vs(i,e){var t,r,s,n,a,o,h,l=0,d=0,u=0,c=i.constructor,p=c.rounding,f=c.precision;if(!i.d||!i.d[0]||i.e>17)return new c(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:0/0);for(e==null?(q=!1,h=f):h=e,o=new c(.03125);i.e>-2;)i=i.times(o),u+=5;for(r=Math.log(Se(2,u))/Math.LN10*2+5|0,h+=r,t=n=a=new c(1),c.precision=h;;){if(n=z(n.times(i),h,1),t=t.times(++d),o=a.plus(ue(n,t,h,1)),xe(o.d).slice(0,h)===xe(a.d).slice(0,h)){for(s=u;s--;)a=z(a.times(a),h,1);if(e==null)if(l<3&&Yi(a.d,h-r,p,l))c.precision=h+=10,t=n=o=new c(1),d=0,l++;else return z(a,c.precision=f,p,q=!0);else return c.precision=f,a}a=o}}function At(i,e){var t,r,s,n,a,o,h,l,d,u,c,p=1,f=10,m=i,g=m.d,_=m.constructor,w=_.rounding,b=_.precision;if(m.s<0||!g||!g[0]||!m.e&&g[0]==1&&g.length==1)return new _(g&&!g[0]?-1/0:m.s!=1?NaN:g?0:m);if(e==null?(q=!1,d=b):d=e,_.precision=d+=f,t=xe(g),r=t.charAt(0),Math.abs(n=m.e)<15e14){for(;r<7&&r!=1||r==1&&t.charAt(1)>3;)m=m.times(i),t=xe(m.d),r=t.charAt(0),p++;n=m.e,r>1?(m=new _("0."+t),n++):m=new _(r+"."+t.slice(1))}else return l=jr(_,d+2,b).times(n+""),m=At(new _(r+"."+t.slice(1)),d-f).plus(l),_.precision=b,e==null?z(m,b,w,q=!0):m;for(u=m,h=a=m=ue(m.minus(1),m.plus(1),d,1),c=z(m.times(m),d,1),s=3;;){if(a=z(a.times(c),d,1),l=h.plus(ue(a,new _(s),d,1)),xe(l.d).slice(0,d)===xe(h.d).slice(0,d))if(h=h.times(2),n!==0&&(h=h.plus(jr(_,d+2,b).times(n+""))),h=ue(h,new _(p),d,1),e==null)if(Yi(h.d,d-f,w,o))_.precision=d+=f,l=a=m=ue(u.minus(1),u.plus(1),d,1),c=z(m.times(m),d,1),s=o=1;else return z(h,_.precision=b,w,q=!0);else return _.precision=b,h;h=l,s+=2}}function ll(i){return String(i.s*i.s/0)}function zs(i,e){var t,r,s;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),r=0;e.charCodeAt(r)===48;r++);for(s=e.length;e.charCodeAt(s-1)===48;--s);if(e=e.slice(r,s),e){if(s-=r,i.e=t=t-r-1,i.d=[],r=(t+1)%j,t<0&&(r+=j),r<s){for(r&&i.d.push(+e.slice(0,r)),s-=j;r<s;)i.d.push(+e.slice(r,r+=j));e=e.slice(r),r=j-e.length}else r-=s;for(;r--;)e+="0";i.d.push(+e),q&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function sf(i,e){var t,r,s,n,a,o,h,l,d;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),sl.test(e))return zs(i,e)}else if(e==="Infinity"||e==="NaN")return+e||(i.s=NaN),i.e=NaN,i.d=null,i;if(Jc.test(e))t=16,e=e.toLowerCase();else if(Kc.test(e))t=2;else if(Qc.test(e))t=8;else throw Error(Rt+e);for(n=e.search(/p/i),n>0?(h=+e.slice(n+1),e=e.substring(2,n)):e=e.slice(2),n=e.indexOf("."),a=n>=0,r=i.constructor,a&&(e=e.replace(".",""),o=e.length,n=o-n,s=al(r,new r(t),n,n*2)),l=kr(e,t,je),d=l.length-1,n=d;l[n]===0;--n)l.pop();return n<0?new r(i.s*0):(i.e=is(l,d),i.d=l,q=!1,a&&(i=ue(i,s,o*4)),h&&(i=i.times(Math.abs(h)<54?Se(2,h):Z.pow(2,h))),q=!0,i)}function nf(i,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:pi(i,2,e,e);t=1.4*Math.sqrt(r),t=t>16?16:t|0,e=e.times(1/rs(5,t)),e=pi(i,2,e,e);for(var s,n=new i(5),a=new i(16),o=new i(20);t--;)s=e.times(e),e=e.times(n.plus(s.times(a.times(s).minus(o))));return e}function pi(i,e,t,r,s){var n,a,o,h,l=i.precision,d=Math.ceil(l/j);for(q=!1,h=t.times(t),o=new i(r);;){if(a=ue(o.times(h),new i(e++*e++),l,1),o=s?r.plus(a):r.minus(a),r=ue(a.times(h),new i(e++*e++),l,1),a=o.plus(r),a.d[d]!==void 0){for(n=d;a.d[n]===o.d[n]&&n--;);if(n==-1)break}n=o,o=r,r=a,a=n}return q=!0,a.d.length=d+1,a}function rs(i,e){for(var t=i;--e;)t*=i;return t}function hl(i,e){var t,r=e.s<0,s=We(i,i.precision,1),n=s.times(.5);if(e=e.abs(),e.lte(n))return dt=r?4:1,e;if(t=e.divToInt(s),t.isZero())dt=r?3:2;else{if(e=e.minus(t.times(s)),e.lte(n))return dt=oa(t)?r?2:3:r?4:1,e;dt=oa(t)?r?1:4:r?3:2}return e.minus(s).abs()}function mn(i,e,t,r){var s,n,a,o,h,l,d,u,c,p=i.constructor,f=t!==void 0;if(f?(Ne(t,1,Ft),r===void 0?r=p.rounding:Ne(r,0,8)):(t=p.precision,r=p.rounding),!i.isFinite())d=ll(i);else{for(d=at(i),a=d.indexOf("."),f?(s=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):s=e,a>=0&&(d=d.replace(".",""),c=new p(1),c.e=d.length-a,c.d=kr(at(c),10,s),c.e=c.d.length),u=kr(d,10,s),n=h=u.length;u[--h]==0;)u.pop();if(!u[0])d=f?"0p+0":"0";else{if(a<0?n--:(i=new p(i),i.d=u,i.e=n,i=ue(i,c,t,r,0,s),u=i.d,n=i.e,l=el),a=u[t],o=s/2,l=l||u[t+1]!==void 0,l=r<4?(a!==void 0||l)&&(r===0||r===(i.s<0?3:2)):a>o||a===o&&(r===4||l||r===6&&u[t-1]&1||r===(i.s<0?8:7)),u.length=t,l)for(;++u[--t]>s-1;)u[t]=0,t||(++n,u.unshift(1));for(h=u.length;!u[h-1];--h);for(a=0,d="";a<h;a++)d+=Hs.charAt(u[a]);if(f){if(h>1)if(e==16||e==8){for(a=e==16?4:3,--h;h%a;h++)d+="0";for(u=kr(d,s,e),h=u.length;!u[h-1];--h);for(a=1,d="1.";a<h;a++)d+=Hs.charAt(u[a])}else d=d.charAt(0)+"."+d.slice(1);d=d+(n<0?"p":"p+")+n}else if(n<0){for(;++n;)d="0"+d;d="0."+d}else if(++n>h)for(n-=h;n--;)d+="0";else n<h&&(d=d.slice(0,n)+"."+d.slice(n))}d=(e==16?"0x":e==2?"0b":e==8?"0o":"")+d}return i.s<0?"-"+d:d}function la(i,e){if(i.length>e)return i.length=e,!0}function af(i){return new this(i).abs()}function of(i){return new this(i).acos()}function lf(i){return new this(i).acosh()}function hf(i,e){return new this(i).plus(e)}function df(i){return new this(i).asin()}function uf(i){return new this(i).asinh()}function cf(i){return new this(i).atan()}function ff(i){return new this(i).atanh()}function pf(i,e){i=new this(i),e=new this(e);var t,r=this.precision,s=this.rounding,n=r+4;return!i.s||!e.s?t=new this(NaN):!i.d&&!e.d?(t=We(this,n,1).times(e.s>0?.25:.75),t.s=i.s):!e.d||i.isZero()?(t=e.s<0?We(this,r,s):new this(0),t.s=i.s):!i.d||e.isZero()?(t=We(this,n,1).times(.5),t.s=i.s):e.s<0?(this.precision=n,this.rounding=1,t=this.atan(ue(i,e,n,1)),e=We(this,n,1),this.precision=r,this.rounding=s,t=i.s<0?t.minus(e):t.plus(e)):t=this.atan(ue(i,e,n,1)),t}function mf(i){return new this(i).cbrt()}function gf(i){return z(i=new this(i),i.e+1,2)}function vf(i,e,t){return new this(i).clamp(e,t)}function yf(i){if(!i||typeof i!="object")throw Error(ts+"Object expected");var e,t,r,s=i.defaults===!0,n=["precision",1,Ft,"rounding",0,8,"toExpNeg",-ii,0,"toExpPos",0,ii,"maxE",0,ii,"minE",-ii,0,"modulo",0,9];for(e=0;e<n.length;e+=3)if(t=n[e],s&&(this[t]=Bs[t]),(r=i[t])!==void 0)if(Oe(r)===r&&r>=n[e+1]&&r<=n[e+2])this[t]=r;else throw Error(Rt+t+": "+r);if(t="crypto",s&&(this[t]=Bs[t]),(r=i[t])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(il);else this[t]=!1;else throw Error(Rt+t+": "+r);return this}function bf(i){return new this(i).cos()}function _f(i){return new this(i).cosh()}function dl(i){var e,t,r;function s(n){var a,o,h,l=this;if(!(l instanceof s))return new s(n);if(l.constructor=s,ha(n)){l.s=n.s,q?!n.d||n.e>s.maxE?(l.e=NaN,l.d=null):n.e<s.minE?(l.e=0,l.d=[0]):(l.e=n.e,l.d=n.d.slice()):(l.e=n.e,l.d=n.d?n.d.slice():n.d);return}if(h=typeof n,h==="number"){if(n===0){l.s=1/n<0?-1:1,l.e=0,l.d=[0];return}if(n<0?(n=-n,l.s=-1):l.s=1,n===~~n&&n<1e7){for(a=0,o=n;o>=10;o/=10)a++;q?a>s.maxE?(l.e=NaN,l.d=null):a<s.minE?(l.e=0,l.d=[0]):(l.e=a,l.d=[n]):(l.e=a,l.d=[n]);return}else if(n*0!==0){n||(l.s=NaN),l.e=NaN,l.d=null;return}return zs(l,n.toString())}else if(h!=="string")throw Error(Rt+n);return(o=n.charCodeAt(0))===45?(n=n.slice(1),l.s=-1):(o===43&&(n=n.slice(1)),l.s=1),sl.test(n)?zs(l,n):sf(l,n)}if(s.prototype=C,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=yf,s.clone=dl,s.isDecimal=ha,s.abs=af,s.acos=of,s.acosh=lf,s.add=hf,s.asin=df,s.asinh=uf,s.atan=cf,s.atanh=ff,s.atan2=pf,s.cbrt=mf,s.ceil=gf,s.clamp=vf,s.cos=bf,s.cosh=_f,s.div=wf,s.exp=Sf,s.floor=Tf,s.hypot=Cf,s.ln=Ef,s.log=kf,s.log10=Pf,s.log2=xf,s.max=Af,s.min=Mf,s.mod=Of,s.mul=Lf,s.pow=Rf,s.random=If,s.round=Nf,s.sign=Gf,s.sin=Df,s.sinh=Ff,s.sqrt=Hf,s.sub=Bf,s.sum=$f,s.tan=Vf,s.tanh=zf,s.trunc=Uf,i===void 0&&(i={}),i&&i.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<r.length;)i.hasOwnProperty(t=r[e++])||(i[t]=this[t]);return s.config(i),s}function wf(i,e){return new this(i).div(e)}function Sf(i){return new this(i).exp()}function Tf(i){return z(i=new this(i),i.e+1,3)}function Cf(){var i,e,t=new this(0);for(q=!1,i=0;i<arguments.length;)if(e=new this(arguments[i++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return q=!0,new this(1/0);t=e}return q=!0,t.sqrt()}function ha(i){return i instanceof Z||i&&i.toStringTag===rl||!1}function Ef(i){return new this(i).ln()}function kf(i,e){return new this(i).log(e)}function xf(i){return new this(i).log(2)}function Pf(i){return new this(i).log(10)}function Af(){return ol(this,arguments,"lt")}function Mf(){return ol(this,arguments,"gt")}function Of(i,e){return new this(i).mod(e)}function Lf(i,e){return new this(i).mul(e)}function Rf(i,e){return new this(i).pow(e)}function If(i){var e,t,r,s,n=0,a=new this(1),o=[];if(i===void 0?i=this.precision:Ne(i,1,Ft),r=Math.ceil(i/j),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));n<r;)s=e[n],s>=429e7?e[n]=crypto.getRandomValues(new Uint32Array(1))[0]:o[n++]=s%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(r*=4);n<r;)s=e[n]+(e[n+1]<<8)+(e[n+2]<<16)+((e[n+3]&127)<<24),s>=214e7?crypto.randomBytes(4).copy(e,n):(o.push(s%1e7),n+=4);n=r/4}else throw Error(il);else for(;n<r;)o[n++]=Math.random()*1e7|0;for(r=o[--n],i%=j,r&&i&&(s=Se(10,j-i),o[n]=(r/s|0)*s);o[n]===0;n--)o.pop();if(n<0)t=0,o=[0];else{for(t=-1;o[0]===0;t-=j)o.shift();for(r=1,s=o[0];s>=10;s/=10)r++;r<j&&(t-=j-r)}return a.e=t,a.d=o,a}function Nf(i){return z(i=new this(i),i.e+1,this.rounding)}function Gf(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Df(i){return new this(i).sin()}function Ff(i){return new this(i).sinh()}function Hf(i){return new this(i).sqrt()}function Bf(i,e){return new this(i).sub(e)}function $f(){var i=0,e=arguments,t=new this(e[i]);for(q=!1;t.s&&++i<e.length;)t=t.plus(e[i]);return q=!0,z(t,this.precision,this.rounding)}function Vf(i){return new this(i).tan()}function zf(i){return new this(i).tanh()}function Uf(i){return z(i=new this(i),i.e+1,1)}C[Symbol.for("nodejs.util.inspect.custom")]=C.toString;C[Symbol.toStringTag]="Decimal";var Z=C.constructor=dl(Bs);Wr=new Z(Wr);Zr=new Z(Zr);function Ri(i){return i==null}const da={editable:!0,style:{...Jo,markerSymbolSize:20,periodMarkerHandleType:"start"}};class ua extends Qo{constructor(e,t,r){super({...da,...e,style:{...da.style,...e.style}},t,r)}createSymbol(){switch(this.style.markerSymbolType){case"triangle":let t=Z.sqrt(2).mul(this.style.markerSymbolSize).toNumber()/2;return new M.Line({points:this.style.periodMarkerHandleType==="start"?[-t,0,0,0,0,t]:[0,0,t,0,0,t],fill:this.style.color,closed:!0,offsetY:t/2});case"circle":return new M.Arc({fill:this.style.color,innerRadius:0,outerRadius:this.style.markerSymbolSize/2,angle:180,rotation:this.style.periodMarkerHandleType==="start"?90:-90});case"square":return new M.Line({points:[0,0,this.style.markerSymbolSize,0,this.style.markerSymbolSize,this.style.markerSymbolSize],fill:this.style.color,closed:!0,rotation:this.style.periodMarkerHandleType==="start"?225:45,offsetX:this.style.markerSymbolSize/2,offsetY:this.style.markerSymbolSize/2});default:throw Error("Unknown type")}}}const ca={editable:!0,style:{...Yo,selectedAreaOpacity:.2,markerHandleAreaOpacity:.7}};class ul extends Ko{constructor(e){super({...ca,...e,style:{...ca.style,...e.style}}),this.observation.start=_e.coerce.number().min(0).optional().nullable().parse(this.observation.start),this.observation.end=_e.coerce.number().min(0).optional().nullable().parse(this.observation.end),!Ri(this.observation.end)&&!Ri(this.observation.start)&&(this.observation.start=_e.coerce.number().lte(this.observation.end).parse(this.observation.start))}createCanvasNode(){return super.createCanvasNode(),this.initStartMarkerHandle(),this.initEndMarkerHandle(),this.initSelectedAreaRect(),this.group}onChange(){this.settlePosition();let e={timeObservation:this.observation};this.onChange$.next(e)}onMeasurementsChange(){if(super.onMeasurementsChange(),this.hasStart()&&this.hasEnd()){let e=this.startMarkerHandle.getVerticalMeasurement();this.selectedAreaRect.setAttrs({y:e.y,height:e.height});let t={y:this.startMarkerHandle.getHandleGroup().y(),height:this.startMarkerHandle.getHandleGroup().getClientRect().height};this.markerHandleRect.setAttrs({y:e.y+t.y-t.height/2,height:t.height})}this.settlePosition()}initSelectedAreaRect(){if(this.selectedAreaRect&&this.selectedAreaRect.destroy(),this.markerHandleRect&&this.markerHandleRect.destroy(),!this.hasStart()||!this.hasEnd())return;let e=this.startMarkerHandle.getVerticalMeasurement(),t=this.timeline.timeToTimelinePosition(this.observation.start),r=this.timeline.timeToTimelinePosition(this.observation.end);this.selectedAreaRect=new M.Rect({x:t,y:e.y,width:r-t,height:e.height,listening:!1,fill:this.style.color,opacity:this.style.selectedAreaOpacity});let s={y:this.startMarkerHandle.getHandleGroup().y(),height:this.startMarkerHandle.getHandleGroup().getClientRect().height};this.markerHandleRect=new M.Rect({x:t,y:e.y+s.y-s.height/2,width:r-t,height:s.height,listening:!1,fill:this.style.color,opacity:this.style.markerHandleAreaOpacity}),this.group.add(this.selectedAreaRect),this.group.add(this.markerHandleRect)}initStartMarkerHandle(){if(this.startMarkerHandle&&(this.startMarkerHandle.destroy(),this.startMarkerHandle=void 0),!this.hasStart())return;let e=this.timeline.timeToTimelinePosition(this.observation.start);this.startMarkerHandle=new ua({x:e,editable:this.editable,style:{color:this.style.color,markerRenderType:this.style.renderType,markerSymbolType:this.style.symbolType,periodMarkerHandleType:"start"}},this.markerLane,this.timeline),this.startMarkerHandle.onDrag=t=>{this.editable&&(this.hasEnd()&&t.x()>this.endMarkerHandle.getPosition().x&&t.x(this.endMarkerHandle.getPosition().x),this.settleMeasurements(),this.hasStart()&&this.hasEnd()&&this.markerHandleRect.opacity(1))},this.startMarkerHandle.onDragEnd=t=>{if(this.editable){let r=this.timeline.timelinePositionToTime(t.x());this.setTimeObservation({...this.observation,start:r}),this.hasStart()&&this.hasEnd()&&this.markerHandleRect.opacity(this.style.markerHandleAreaOpacity)}},this.group.add(this.startMarkerHandle.initCanvasNode())}initEndMarkerHandle(){if(this.endMarkerHandle&&(this.endMarkerHandle.destroy(),this.endMarkerHandle=void 0),!this.hasEnd())return;let e=this.hasEnd()?this.timeline.timeToTimelinePosition(this.observation.end):void 0;this.endMarkerHandle=new ua({x:e,editable:this.editable,style:{periodMarkerHandleType:"end",color:this.style.color,markerRenderType:this.style.renderType,markerSymbolType:this.style.symbolType}},this.markerLane,this.timeline),this.endMarkerHandle.onDrag=t=>{this.editable&&(this.hasStart()&&t.x()<this.startMarkerHandle.getPosition().x&&t.x(this.startMarkerHandle.getPosition().x),this.settleMeasurements(),this.hasStart()&&this.hasEnd()&&this.markerHandleRect.opacity(1))},this.endMarkerHandle.onDragEnd=t=>{if(this.editable){let r=this.timeline.timelinePositionToTime(t.x());this.setTimeObservation({...this.observation,end:r}),this.hasStart()&&this.hasEnd()&&this.markerHandleRect.opacity(this.style.markerHandleAreaOpacity)}},this.group.add(this.endMarkerHandle.initCanvasNode())}settlePosition(){this.hasStart()&&this.startMarkerHandle.setPosition({...this.startMarkerHandle.getPosition(),x:this.timeline.timeToTimelinePosition(this.observation.start)}),this.hasEnd()&&this.endMarkerHandle.setPosition({...this.endMarkerHandle.getPosition(),x:this.timeline.timeToTimelinePosition(this.observation.end)}),this.settleMeasurements()}settleMeasurements(){this.hasStart()&&this.hasEnd()&&(this.selectedAreaRect.setAttrs({x:this.startMarkerHandle.getPosition().x,width:this.endMarkerHandle.getPosition().x-this.startMarkerHandle.getPosition().x}),this.markerHandleRect.setAttrs({x:this.startMarkerHandle.getPosition().x,width:this.endMarkerHandle.getPosition().x-this.startMarkerHandle.getPosition().x}))}setTimeObservation(e){this.editable&&(this.observation=e,this.initStartMarkerHandle(),this.initEndMarkerHandle(),this.initSelectedAreaRect(),this.onChange())}setEditable(e){super.setEditable(e)}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.styleAdapter.onChange$.pipe(k(this.onDestroy$)).subscribe(e=>{this.hasStart()&&this.initStartMarkerHandle(),this.hasEnd()&&this.initEndMarkerHandle(),this.hasStart()&&this.hasEnd()&&this.initSelectedAreaRect()})}hasStart(){return this.observation&&!Ri(this.observation.start)}hasEnd(){return this.observation&&!Ri(this.observation.end)}}const fa={editable:!0,style:{...Jo,markerSymbolSize:20}};class Wf extends Qo{constructor(e,t,r){super({...fa,...e,style:{...fa.style,...e.style}},t,r)}createSymbol(){switch(this.style.markerSymbolType){case"triangle":let t=Z.sqrt(2).mul(this.style.markerSymbolSize).toNumber()/2;return new M.Line({points:[-t,0,t,0,0,t],fill:this.style.color,closed:!0,offsetY:t/2});case"circle":return new M.Circle({fill:this.style.color,radius:this.style.markerSymbolSize/2});case"square":return new M.Rect({fill:this.style.color,width:this.style.markerSymbolSize,height:this.style.markerSymbolSize,rotation:45,offsetX:this.style.markerSymbolSize/2,offsetY:this.style.markerSymbolSize/2});default:throw Error("Unknown type")}}}const pa={description:"",editable:!0,style:{...Yo}};class cl extends Ko{constructor(e){super({...pa,...e,style:{...pa.style,...e.style}}),this.observation.time=_e.coerce.number().min(0).parse(this.observation.time)}createCanvasNode(){return super.createCanvasNode(),this.initMarkerHandle(),this.group}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.styleAdapter.onChange$.subscribe(e=>{this.initMarkerHandle()})}initMarkerHandle(){this.markerHandle&&(this.markerHandle.destroy(),this.markerHandle=void 0);let e=this.timeline.timeToTimelinePosition(this.observation.time);this.markerHandle=new Wf({x:e,editable:this.editable,style:{color:this.style.color,markerRenderType:this.style.renderType,markerSymbolType:this.style.symbolType}},this.markerLane,this.timeline),this.markerHandle.onDragEnd=t=>{if(this.editable){let r=this.timeline.timelinePositionToTime(t.x());this.setTimeObservation({...this.observation,time:r})}},this.group.add(this.markerHandle.initCanvasNode())}onChange(){this.settlePosition();let e={timeObservation:this.observation};this.onChange$.next(e)}onMeasurementsChange(){super.onMeasurementsChange(),this.markerHandle.onMeasurementsChange(),this.settlePosition()}settlePosition(){this.markerHandle.setPosition({...this.markerHandle.getPosition(),x:this.timeline.timeToTimelinePosition(this.observation.time)})}setEditable(e){super.setEditable(e)}}const Zf={...rr};class Us extends sr{constructor(e){super({...e,style:{...Zf,...e.style}}),this.onMarkerFocus$=new V,this.markers=[],this.markersMap=new Map}createCanvasNode(){return super.createCanvasNode(),this.markersGroup=new M.Group({...F.POSITION_TOP_LEFT,...this.timeline.getTimecodedGroupDimension()}),this.timeline.addToTimecodedMarkersGroup(this.markersGroup),this.bodyGroup}settleLayout(){super.settleLayout();let e=this.timeline.getTimecodedGroupHorizontalMeasurement();[this.markersGroup].forEach(t=>{t.width(e.width)}),this.markers&&this.markers.forEach(t=>{t.onMeasurementsChange()})}destroy(){super.destroy(),this.markersGroup.destroy()}clearContent(){this.removeAllMarkers(),this.markers=[],this.markersMap=new Map,this.markersGroup.destroyChildren()}createMomentMarker(e){return this.addMarker(new cl(e))}createPeriodMarker(e){return this.addMarker(new ul(e))}addMarker(e){if(!this.isInitialized())throw new Error("MarkerLane not initalized. Maybe you forgot to add MarkerLane to Timeline?");if(this.markersMap.has(e.getId()))throw new Error(`Marker with id=${e.getId()} already exists`);return e.setMarkerLane(this),e.setTimeline(this.timeline),e.onClick$.pipe(k(this.onDestroy$)).subscribe(t=>{this.focusMarker(e.getId())}),e.onMouseEnter$.pipe(k(this.onDestroy$)).subscribe(t=>{this.focusMarker(e.getId())}),this.markers.push(e),this.markersMap.set(e.getId(),e),this.markersGroup.add(e.initCanvasNode()),e}removeAllMarkers(){this.markers&&this.markers.forEach(e=>{this.removeMarker(e.getId())})}removeMarker(e){let t=this.getMarker(e);t&&(this.markers.splice(this.markers.findIndex(r=>r.getId()===t.getId()),1),this.markersMap.delete(t.getId()),t.destroy())}getMarker(e){return this.markersMap.get(e)}getMarkers(){return this.markers}focusMarker(e){let t=this.getMarker(e);t&&(this.moveToTop(t),this.markerInFocus=t,this.onMarkerFocus$.next({marker:t}))}getMarkerInFocus(){return this.markerInFocus}moveToTop(e){e&&(this.markersGroup.moveToTop(),e.getCanvasNode().moveToTop())}}class jf{static randomHexColor(){return`#${Math.floor(Math.random()*16777215).toString(16)}`}}class wi{static createGoldenRatioWedge(e){let t=new Z(e.height).div(F.GOLDEN_RATIO+1).toDecimalPlaces(2).toNumber(),r=e.height-t,s=r/2;return new M.Line({points:[e.x-s,e.y,e.x+s,e.y,e.x+s,e.y+r,e.x,e.y+r+t,e.x-s,e.y+r],fill:e.color,stroke:e.color,closed:!0,listening:!1})}static createTriangle(e){let t=e.height/2;return new M.Line({points:[e.x-t,e.y,e.x+t,e.y,e.x,e.y+e.height],fill:e.color,closed:!0,listening:!1})}static createEventCatcher(e={}){return new M.Rect({...F.POSITION_TOP_LEFT,opacity:0,listening:!0,...e})}static createDebugRect(){return new M.Rect({...F.POSITION_TOP_LEFT,width:100,height:100,fill:jf.randomHexColor(),opacity:1})}}function fl(i,e){return function(){return i.apply(e,arguments)}}const{toString:pl}=Object.prototype,{getPrototypeOf:gn}=Object,vn=(i=>e=>{const t=pl.call(e);return i[t]||(i[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),St=i=>(i=i.toLowerCase(),e=>vn(e)===i),ss=i=>e=>typeof e===i,{isArray:Si}=Array,Ki=ss("undefined");function Xf(i){return i!==null&&!Ki(i)&&i.constructor!==null&&!Ki(i.constructor)&&It(i.constructor.isBuffer)&&i.constructor.isBuffer(i)}const ml=St("ArrayBuffer");function qf(i){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(i):e=i&&i.buffer&&ml(i.buffer),e}const Yf=ss("string"),It=ss("function"),gl=ss("number"),yn=i=>i!==null&&typeof i=="object",Kf=i=>i===!0||i===!1,xr=i=>{if(vn(i)!=="object")return!1;const e=gn(i);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in i)&&!(Symbol.iterator in i)},Jf=St("Date"),Qf=St("File"),ep=St("Blob"),tp=St("FileList"),ip=i=>yn(i)&&It(i.pipe),rp=i=>{const e="[object FormData]";return i&&(typeof FormData=="function"&&i instanceof FormData||pl.call(i)===e||It(i.toString)&&i.toString()===e)},sp=St("URLSearchParams"),np=i=>i.trim?i.trim():i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function nr(i,e,{allOwnKeys:t=!1}={}){if(i===null||typeof i>"u")return;let r,s;if(typeof i!="object"&&(i=[i]),Si(i))for(r=0,s=i.length;r<s;r++)e.call(null,i[r],r,i);else{const n=t?Object.getOwnPropertyNames(i):Object.keys(i),a=n.length;let o;for(r=0;r<a;r++)o=n[r],e.call(null,i[o],o,i)}}function vl(i,e){e=e.toLowerCase();const t=Object.keys(i);let r=t.length,s;for(;r-- >0;)if(s=t[r],e===s.toLowerCase())return s;return null}const yl=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),bl=i=>!Ki(i)&&i!==yl;function Ws(){const{caseless:i}=bl(this)&&this||{},e={},t=(r,s)=>{const n=i&&vl(e,s)||s;xr(e[n])&&xr(r)?e[n]=Ws(e[n],r):xr(r)?e[n]=Ws({},r):Si(r)?e[n]=r.slice():e[n]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&nr(arguments[r],t);return e}const ap=(i,e,t,{allOwnKeys:r}={})=>(nr(e,(s,n)=>{t&&It(s)?i[n]=fl(s,t):i[n]=s},{allOwnKeys:r}),i),op=i=>(i.charCodeAt(0)===65279&&(i=i.slice(1)),i),lp=(i,e,t,r)=>{i.prototype=Object.create(e.prototype,r),i.prototype.constructor=i,Object.defineProperty(i,"super",{value:e.prototype}),t&&Object.assign(i.prototype,t)},hp=(i,e,t,r)=>{let s,n,a;const o={};if(e=e||{},i==null)return e;do{for(s=Object.getOwnPropertyNames(i),n=s.length;n-- >0;)a=s[n],(!r||r(a,i,e))&&!o[a]&&(e[a]=i[a],o[a]=!0);i=t!==!1&&gn(i)}while(i&&(!t||t(i,e))&&i!==Object.prototype);return e},dp=(i,e,t)=>{i=String(i),(t===void 0||t>i.length)&&(t=i.length),t-=e.length;const r=i.indexOf(e,t);return r!==-1&&r===t},up=i=>{if(!i)return null;if(Si(i))return i;let e=i.length;if(!gl(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=i[e];return t},cp=(i=>e=>i&&e instanceof i)(typeof Uint8Array<"u"&&gn(Uint8Array)),fp=(i,e)=>{const r=(i&&i[Symbol.iterator]).call(i);let s;for(;(s=r.next())&&!s.done;){const n=s.value;e.call(i,n[0],n[1])}},pp=(i,e)=>{let t;const r=[];for(;(t=i.exec(e))!==null;)r.push(t);return r},mp=St("HTMLFormElement"),gp=i=>i.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,s){return r.toUpperCase()+s}),ma=(({hasOwnProperty:i})=>(e,t)=>i.call(e,t))(Object.prototype),vp=St("RegExp"),_l=(i,e)=>{const t=Object.getOwnPropertyDescriptors(i),r={};nr(t,(s,n)=>{e(s,n,i)!==!1&&(r[n]=s)}),Object.defineProperties(i,r)},yp=i=>{_l(i,(e,t)=>{if(It(i)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const r=i[t];if(It(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},bp=(i,e)=>{const t={},r=s=>{s.forEach(n=>{t[n]=!0})};return Si(i)?r(i):r(String(i).split(e)),t},_p=()=>{},wp=(i,e)=>(i=+i,Number.isFinite(i)?i:e),_s="abcdefghijklmnopqrstuvwxyz",ga="0123456789",wl={DIGIT:ga,ALPHA:_s,ALPHA_DIGIT:_s+_s.toUpperCase()+ga},Sp=(i=16,e=wl.ALPHA_DIGIT)=>{let t="";const{length:r}=e;for(;i--;)t+=e[Math.random()*r|0];return t};function Tp(i){return!!(i&&It(i.append)&&i[Symbol.toStringTag]==="FormData"&&i[Symbol.iterator])}const Cp=i=>{const e=new Array(10),t=(r,s)=>{if(yn(r)){if(e.indexOf(r)>=0)return;if(!("toJSON"in r)){e[s]=r;const n=Si(r)?[]:{};return nr(r,(a,o)=>{const h=t(a,s+1);!Ki(h)&&(n[o]=h)}),e[s]=void 0,n}}return r};return t(i,0)},S={isArray:Si,isArrayBuffer:ml,isBuffer:Xf,isFormData:rp,isArrayBufferView:qf,isString:Yf,isNumber:gl,isBoolean:Kf,isObject:yn,isPlainObject:xr,isUndefined:Ki,isDate:Jf,isFile:Qf,isBlob:ep,isRegExp:vp,isFunction:It,isStream:ip,isURLSearchParams:sp,isTypedArray:cp,isFileList:tp,forEach:nr,merge:Ws,extend:ap,trim:np,stripBOM:op,inherits:lp,toFlatObject:hp,kindOf:vn,kindOfTest:St,endsWith:dp,toArray:up,forEachEntry:fp,matchAll:pp,isHTMLForm:mp,hasOwnProperty:ma,hasOwnProp:ma,reduceDescriptors:_l,freezeMethods:yp,toObjectSet:bp,toCamelCase:gp,noop:_p,toFiniteNumber:wp,findKey:vl,global:yl,isContextDefined:bl,ALPHABET:wl,generateString:Sp,isSpecCompliantForm:Tp,toJSONObject:Cp};function ie(i,e,t,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=i,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),r&&(this.request=r),s&&(this.response=s)}S.inherits(ie,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:S.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Sl=ie.prototype,Tl={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(i=>{Tl[i]={value:i}});Object.defineProperties(ie,Tl);Object.defineProperty(Sl,"isAxiosError",{value:!0});ie.from=(i,e,t,r,s,n)=>{const a=Object.create(Sl);return S.toFlatObject(i,a,function(h){return h!==Error.prototype},o=>o!=="isAxiosError"),ie.call(a,i.message,e,t,r,s),a.cause=i,a.name=i.name,n&&Object.assign(a,n),a};const Ep=null;function Zs(i){return S.isPlainObject(i)||S.isArray(i)}function Cl(i){return S.endsWith(i,"[]")?i.slice(0,-2):i}function va(i,e,t){return i?i.concat(e).map(function(s,n){return s=Cl(s),!t&&n?"["+s+"]":s}).join(t?".":""):e}function kp(i){return S.isArray(i)&&!i.some(Zs)}const xp=S.toFlatObject(S,{},null,function(e){return/^is[A-Z]/.test(e)});function ns(i,e,t){if(!S.isObject(i))throw new TypeError("target must be an object");e=e||new FormData,t=S.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,g){return!S.isUndefined(g[m])});const r=t.metaTokens,s=t.visitor||d,n=t.dots,a=t.indexes,h=(t.Blob||typeof Blob<"u"&&Blob)&&S.isSpecCompliantForm(e);if(!S.isFunction(s))throw new TypeError("visitor must be a function");function l(f){if(f===null)return"";if(S.isDate(f))return f.toISOString();if(!h&&S.isBlob(f))throw new ie("Blob is not supported. Use a Buffer instead.");return S.isArrayBuffer(f)||S.isTypedArray(f)?h&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function d(f,m,g){let _=f;if(f&&!g&&typeof f=="object"){if(S.endsWith(m,"{}"))m=r?m:m.slice(0,-2),f=JSON.stringify(f);else if(S.isArray(f)&&kp(f)||(S.isFileList(f)||S.endsWith(m,"[]"))&&(_=S.toArray(f)))return m=Cl(m),_.forEach(function(b,T){!(S.isUndefined(b)||b===null)&&e.append(a===!0?va([m],T,n):a===null?m:m+"[]",l(b))}),!1}return Zs(f)?!0:(e.append(va(g,m,n),l(f)),!1)}const u=[],c=Object.assign(xp,{defaultVisitor:d,convertValue:l,isVisitable:Zs});function p(f,m){if(!S.isUndefined(f)){if(u.indexOf(f)!==-1)throw Error("Circular reference detected in "+m.join("."));u.push(f),S.forEach(f,function(_,w){(!(S.isUndefined(_)||_===null)&&s.call(e,_,S.isString(w)?w.trim():w,m,c))===!0&&p(_,m?m.concat(w):[w])}),u.pop()}}if(!S.isObject(i))throw new TypeError("data must be an object");return p(i),e}function ya(i){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(i).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function bn(i,e){this._pairs=[],i&&ns(i,this,e)}const El=bn.prototype;El.append=function(e,t){this._pairs.push([e,t])};El.toString=function(e){const t=e?function(r){return e.call(this,r,ya)}:ya;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function Pp(i){return encodeURIComponent(i).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function kl(i,e,t){if(!e)return i;const r=t&&t.encode||Pp,s=t&&t.serialize;let n;if(s?n=s(e,t):n=S.isURLSearchParams(e)?e.toString():new bn(e,t).toString(r),n){const a=i.indexOf("#");a!==-1&&(i=i.slice(0,a)),i+=(i.indexOf("?")===-1?"?":"&")+n}return i}class Ap{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){S.forEach(this.handlers,function(r){r!==null&&e(r)})}}const ba=Ap,xl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Mp=typeof URLSearchParams<"u"?URLSearchParams:bn,Op=typeof FormData<"u"?FormData:null,Lp=(()=>{let i;return typeof navigator<"u"&&((i=navigator.product)==="ReactNative"||i==="NativeScript"||i==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Rp=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),it={isBrowser:!0,classes:{URLSearchParams:Mp,FormData:Op,Blob},isStandardBrowserEnv:Lp,isStandardBrowserWebWorkerEnv:Rp,protocols:["http","https","file","blob","url","data"]};function Ip(i,e){return ns(i,new it.classes.URLSearchParams,Object.assign({visitor:function(t,r,s,n){return it.isNode&&S.isBuffer(t)?(this.append(r,t.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},e))}function Np(i){return S.matchAll(/\w+|\[(\w*)]/g,i).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Gp(i){const e={},t=Object.keys(i);let r;const s=t.length;let n;for(r=0;r<s;r++)n=t[r],e[n]=i[n];return e}function Pl(i){function e(t,r,s,n){let a=t[n++];const o=Number.isFinite(+a),h=n>=t.length;return a=!a&&S.isArray(s)?s.length:a,h?(S.hasOwnProp(s,a)?s[a]=[s[a],r]:s[a]=r,!o):((!s[a]||!S.isObject(s[a]))&&(s[a]=[]),e(t,r,s[a],n)&&S.isArray(s[a])&&(s[a]=Gp(s[a])),!o)}if(S.isFormData(i)&&S.isFunction(i.entries)){const t={};return S.forEachEntry(i,(r,s)=>{e(Np(r),s,t,0)}),t}return null}const Dp={"Content-Type":void 0};function Fp(i,e,t){if(S.isString(i))try{return(e||JSON.parse)(i),S.trim(i)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(i)}const as={transitional:xl,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",s=r.indexOf("application/json")>-1,n=S.isObject(e);if(n&&S.isHTMLForm(e)&&(e=new FormData(e)),S.isFormData(e))return s&&s?JSON.stringify(Pl(e)):e;if(S.isArrayBuffer(e)||S.isBuffer(e)||S.isStream(e)||S.isFile(e)||S.isBlob(e))return e;if(S.isArrayBufferView(e))return e.buffer;if(S.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(n){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Ip(e,this.formSerializer).toString();if((o=S.isFileList(e))||r.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return ns(o?{"files[]":e}:e,h&&new h,this.formSerializer)}}return n||s?(t.setContentType("application/json",!1),Fp(e)):e}],transformResponse:[function(e){const t=this.transitional||as.transitional,r=t&&t.forcedJSONParsing,s=this.responseType==="json";if(e&&S.isString(e)&&(r&&!this.responseType||s)){const a=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e)}catch(o){if(a)throw o.name==="SyntaxError"?ie.from(o,ie.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:it.classes.FormData,Blob:it.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};S.forEach(["delete","get","head"],function(e){as.headers[e]={}});S.forEach(["post","put","patch"],function(e){as.headers[e]=S.merge(Dp)});const _n=as,Hp=S.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Bp=i=>{const e={};let t,r,s;return i&&i.split(`
11
- `).forEach(function(a){s=a.indexOf(":"),t=a.substring(0,s).trim().toLowerCase(),r=a.substring(s+1).trim(),!(!t||e[t]&&Hp[t])&&(t==="set-cookie"?e[t]?e[t].push(r):e[t]=[r]:e[t]=e[t]?e[t]+", "+r:r)}),e},_a=Symbol("internals");function xi(i){return i&&String(i).trim().toLowerCase()}function Pr(i){return i===!1||i==null?i:S.isArray(i)?i.map(Pr):String(i)}function $p(i){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=t.exec(i);)e[r[1]]=r[2];return e}function Vp(i){return/^[-_a-zA-Z]+$/.test(i.trim())}function ws(i,e,t,r,s){if(S.isFunction(r))return r.call(this,e,t);if(s&&(e=t),!!S.isString(e)){if(S.isString(r))return e.indexOf(r)!==-1;if(S.isRegExp(r))return r.test(e)}}function zp(i){return i.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}function Up(i,e){const t=S.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(i,r+t,{value:function(s,n,a){return this[r].call(this,e,s,n,a)},configurable:!0})})}class os{constructor(e){e&&this.set(e)}set(e,t,r){const s=this;function n(o,h,l){const d=xi(h);if(!d)throw new Error("header name must be a non-empty string");const u=S.findKey(s,d);(!u||s[u]===void 0||l===!0||l===void 0&&s[u]!==!1)&&(s[u||h]=Pr(o))}const a=(o,h)=>S.forEach(o,(l,d)=>n(l,d,h));return S.isPlainObject(e)||e instanceof this.constructor?a(e,t):S.isString(e)&&(e=e.trim())&&!Vp(e)?a(Bp(e),t):e!=null&&n(t,e,r),this}get(e,t){if(e=xi(e),e){const r=S.findKey(this,e);if(r){const s=this[r];if(!t)return s;if(t===!0)return $p(s);if(S.isFunction(t))return t.call(this,s,r);if(S.isRegExp(t))return t.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=xi(e),e){const r=S.findKey(this,e);return!!(r&&this[r]!==void 0&&(!t||ws(this,this[r],r,t)))}return!1}delete(e,t){const r=this;let s=!1;function n(a){if(a=xi(a),a){const o=S.findKey(r,a);o&&(!t||ws(r,r[o],o,t))&&(delete r[o],s=!0)}}return S.isArray(e)?e.forEach(n):n(e),s}clear(e){const t=Object.keys(this);let r=t.length,s=!1;for(;r--;){const n=t[r];(!e||ws(this,this[n],n,e,!0))&&(delete this[n],s=!0)}return s}normalize(e){const t=this,r={};return S.forEach(this,(s,n)=>{const a=S.findKey(r,n);if(a){t[a]=Pr(s),delete t[n];return}const o=e?zp(n):String(n).trim();o!==n&&delete t[n],t[o]=Pr(s),r[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return S.forEach(this,(r,s)=>{r!=null&&r!==!1&&(t[s]=e&&S.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
12
- `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[_a]=this[_a]={accessors:{}}).accessors,s=this.prototype;function n(a){const o=xi(a);r[o]||(Up(s,a),r[o]=!0)}return S.isArray(e)?e.forEach(n):n(e),this}}os.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);S.freezeMethods(os.prototype);S.freezeMethods(os);const mt=os;function Ss(i,e){const t=this||_n,r=e||t,s=mt.from(r.headers);let n=r.data;return S.forEach(i,function(o){n=o.call(t,n,s.normalize(),e?e.status:void 0)}),s.normalize(),n}function Al(i){return!!(i&&i.__CANCEL__)}function ar(i,e,t){ie.call(this,i??"canceled",ie.ERR_CANCELED,e,t),this.name="CanceledError"}S.inherits(ar,ie,{__CANCEL__:!0});function Wp(i,e,t){const r=t.config.validateStatus;!t.status||!r||r(t.status)?i(t):e(new ie("Request failed with status code "+t.status,[ie.ERR_BAD_REQUEST,ie.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}const Zp=it.isStandardBrowserEnv?function(){return{write:function(t,r,s,n,a,o){const h=[];h.push(t+"="+encodeURIComponent(r)),S.isNumber(s)&&h.push("expires="+new Date(s).toGMTString()),S.isString(n)&&h.push("path="+n),S.isString(a)&&h.push("domain="+a),o===!0&&h.push("secure"),document.cookie=h.join("; ")},read:function(t){const r=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function jp(i){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(i)}function Xp(i,e){return e?i.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):i}function Ml(i,e){return i&&!jp(e)?Xp(i,e):e}const qp=it.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function s(n){let a=n;return e&&(t.setAttribute("href",a),a=t.href),t.setAttribute("href",a),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=s(window.location.href),function(a){const o=S.isString(a)?s(a):a;return o.protocol===r.protocol&&o.host===r.host}}():function(){return function(){return!0}}();function Yp(i){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(i);return e&&e[1]||""}function Kp(i,e){i=i||10;const t=new Array(i),r=new Array(i);let s=0,n=0,a;return e=e!==void 0?e:1e3,function(h){const l=Date.now(),d=r[n];a||(a=l),t[s]=h,r[s]=l;let u=n,c=0;for(;u!==s;)c+=t[u++],u=u%i;if(s=(s+1)%i,s===n&&(n=(n+1)%i),l-a<e)return;const p=d&&l-d;return p?Math.round(c*1e3/p):void 0}}function wa(i,e){let t=0;const r=Kp(50,250);return s=>{const n=s.loaded,a=s.lengthComputable?s.total:void 0,o=n-t,h=r(o),l=n<=a;t=n;const d={loaded:n,total:a,progress:a?n/a:void 0,bytes:o,rate:h||void 0,estimated:h&&a&&l?(a-n)/h:void 0,event:s};d[e?"download":"upload"]=!0,i(d)}}const Jp=typeof XMLHttpRequest<"u",Qp=Jp&&function(i){return new Promise(function(t,r){let s=i.data;const n=mt.from(i.headers).normalize(),a=i.responseType;let o;function h(){i.cancelToken&&i.cancelToken.unsubscribe(o),i.signal&&i.signal.removeEventListener("abort",o)}S.isFormData(s)&&(it.isStandardBrowserEnv||it.isStandardBrowserWebWorkerEnv)&&n.setContentType(!1);let l=new XMLHttpRequest;if(i.auth){const p=i.auth.username||"",f=i.auth.password?unescape(encodeURIComponent(i.auth.password)):"";n.set("Authorization","Basic "+btoa(p+":"+f))}const d=Ml(i.baseURL,i.url);l.open(i.method.toUpperCase(),kl(d,i.params,i.paramsSerializer),!0),l.timeout=i.timeout;function u(){if(!l)return;const p=mt.from("getAllResponseHeaders"in l&&l.getAllResponseHeaders()),m={data:!a||a==="text"||a==="json"?l.responseText:l.response,status:l.status,statusText:l.statusText,headers:p,config:i,request:l};Wp(function(_){t(_),h()},function(_){r(_),h()},m),l=null}if("onloadend"in l?l.onloadend=u:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(u)},l.onabort=function(){l&&(r(new ie("Request aborted",ie.ECONNABORTED,i,l)),l=null)},l.onerror=function(){r(new ie("Network Error",ie.ERR_NETWORK,i,l)),l=null},l.ontimeout=function(){let f=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const m=i.transitional||xl;i.timeoutErrorMessage&&(f=i.timeoutErrorMessage),r(new ie(f,m.clarifyTimeoutError?ie.ETIMEDOUT:ie.ECONNABORTED,i,l)),l=null},it.isStandardBrowserEnv){const p=(i.withCredentials||qp(d))&&i.xsrfCookieName&&Zp.read(i.xsrfCookieName);p&&n.set(i.xsrfHeaderName,p)}s===void 0&&n.setContentType(null),"setRequestHeader"in l&&S.forEach(n.toJSON(),function(f,m){l.setRequestHeader(m,f)}),S.isUndefined(i.withCredentials)||(l.withCredentials=!!i.withCredentials),a&&a!=="json"&&(l.responseType=i.responseType),typeof i.onDownloadProgress=="function"&&l.addEventListener("progress",wa(i.onDownloadProgress,!0)),typeof i.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",wa(i.onUploadProgress)),(i.cancelToken||i.signal)&&(o=p=>{l&&(r(!p||p.type?new ar(null,i,l):p),l.abort(),l=null)},i.cancelToken&&i.cancelToken.subscribe(o),i.signal&&(i.signal.aborted?o():i.signal.addEventListener("abort",o)));const c=Yp(d);if(c&&it.protocols.indexOf(c)===-1){r(new ie("Unsupported protocol "+c+":",ie.ERR_BAD_REQUEST,i));return}l.send(s||null)})},Ar={http:Ep,xhr:Qp};S.forEach(Ar,(i,e)=>{if(i){try{Object.defineProperty(i,"name",{value:e})}catch{}Object.defineProperty(i,"adapterName",{value:e})}});const em={getAdapter:i=>{i=S.isArray(i)?i:[i];const{length:e}=i;let t,r;for(let s=0;s<e&&(t=i[s],!(r=S.isString(t)?Ar[t.toLowerCase()]:t));s++);if(!r)throw r===!1?new ie(`Adapter ${t} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(S.hasOwnProp(Ar,t)?`Adapter '${t}' is not available in the build`:`Unknown adapter '${t}'`);if(!S.isFunction(r))throw new TypeError("adapter is not a function");return r},adapters:Ar};function Ts(i){if(i.cancelToken&&i.cancelToken.throwIfRequested(),i.signal&&i.signal.aborted)throw new ar(null,i)}function Sa(i){return Ts(i),i.headers=mt.from(i.headers),i.data=Ss.call(i,i.transformRequest),["post","put","patch"].indexOf(i.method)!==-1&&i.headers.setContentType("application/x-www-form-urlencoded",!1),em.getAdapter(i.adapter||_n.adapter)(i).then(function(r){return Ts(i),r.data=Ss.call(i,i.transformResponse,r),r.headers=mt.from(r.headers),r},function(r){return Al(r)||(Ts(i),r&&r.response&&(r.response.data=Ss.call(i,i.transformResponse,r.response),r.response.headers=mt.from(r.response.headers))),Promise.reject(r)})}const Ta=i=>i instanceof mt?i.toJSON():i;function mi(i,e){e=e||{};const t={};function r(l,d,u){return S.isPlainObject(l)&&S.isPlainObject(d)?S.merge.call({caseless:u},l,d):S.isPlainObject(d)?S.merge({},d):S.isArray(d)?d.slice():d}function s(l,d,u){if(S.isUndefined(d)){if(!S.isUndefined(l))return r(void 0,l,u)}else return r(l,d,u)}function n(l,d){if(!S.isUndefined(d))return r(void 0,d)}function a(l,d){if(S.isUndefined(d)){if(!S.isUndefined(l))return r(void 0,l)}else return r(void 0,d)}function o(l,d,u){if(u in e)return r(l,d);if(u in i)return r(void 0,l)}const h={url:n,method:n,data:n,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(l,d)=>s(Ta(l),Ta(d),!0)};return S.forEach(Object.keys(i).concat(Object.keys(e)),function(d){const u=h[d]||s,c=u(i[d],e[d],d);S.isUndefined(c)&&u!==o||(t[d]=c)}),t}const Ol="1.3.3",wn={};["object","boolean","number","function","string","symbol"].forEach((i,e)=>{wn[i]=function(r){return typeof r===i||"a"+(e<1?"n ":" ")+i}});const Ca={};wn.transitional=function(e,t,r){function s(n,a){return"[Axios v"+Ol+"] Transitional option '"+n+"'"+a+(r?". "+r:"")}return(n,a,o)=>{if(e===!1)throw new ie(s(a," has been removed"+(t?" in "+t:"")),ie.ERR_DEPRECATED);return t&&!Ca[a]&&(Ca[a]=!0,console.warn(s(a," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(n,a,o):!0}};function tm(i,e,t){if(typeof i!="object")throw new ie("options must be an object",ie.ERR_BAD_OPTION_VALUE);const r=Object.keys(i);let s=r.length;for(;s-- >0;){const n=r[s],a=e[n];if(a){const o=i[n],h=o===void 0||a(o,n,i);if(h!==!0)throw new ie("option "+n+" must be "+h,ie.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new ie("Unknown option "+n,ie.ERR_BAD_OPTION)}}const js={assertOptions:tm,validators:wn},Et=js.validators;class Xr{constructor(e){this.defaults=e,this.interceptors={request:new ba,response:new ba}}request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=mi(this.defaults,t);const{transitional:r,paramsSerializer:s,headers:n}=t;r!==void 0&&js.assertOptions(r,{silentJSONParsing:Et.transitional(Et.boolean),forcedJSONParsing:Et.transitional(Et.boolean),clarifyTimeoutError:Et.transitional(Et.boolean)},!1),s!==void 0&&js.assertOptions(s,{encode:Et.function,serialize:Et.function},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a;a=n&&S.merge(n.common,n[t.method]),a&&S.forEach(["delete","get","head","post","put","patch","common"],f=>{delete n[f]}),t.headers=mt.concat(a,n);const o=[];let h=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(h=h&&m.synchronous,o.unshift(m.fulfilled,m.rejected))});const l=[];this.interceptors.response.forEach(function(m){l.push(m.fulfilled,m.rejected)});let d,u=0,c;if(!h){const f=[Sa.bind(this),void 0];for(f.unshift.apply(f,o),f.push.apply(f,l),c=f.length,d=Promise.resolve(t);u<c;)d=d.then(f[u++],f[u++]);return d}c=o.length;let p=t;for(u=0;u<c;){const f=o[u++],m=o[u++];try{p=f(p)}catch(g){m.call(this,g);break}}try{d=Sa.call(this,p)}catch(f){return Promise.reject(f)}for(u=0,c=l.length;u<c;)d=d.then(l[u++],l[u++]);return d}getUri(e){e=mi(this.defaults,e);const t=Ml(e.baseURL,e.url);return kl(t,e.params,e.paramsSerializer)}}S.forEach(["delete","get","head","options"],function(e){Xr.prototype[e]=function(t,r){return this.request(mi(r||{},{method:e,url:t,data:(r||{}).data}))}});S.forEach(["post","put","patch"],function(e){function t(r){return function(n,a,o){return this.request(mi(o||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:n,data:a}))}}Xr.prototype[e]=t(),Xr.prototype[e+"Form"]=t(!0)});const Mr=Xr;class Sn{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(n){t=n});const r=this;this.promise.then(s=>{if(!r._listeners)return;let n=r._listeners.length;for(;n-- >0;)r._listeners[n](s);r._listeners=null}),this.promise.then=s=>{let n;const a=new Promise(o=>{r.subscribe(o),n=o}).then(s);return a.cancel=function(){r.unsubscribe(n)},a},e(function(n,a,o){r.reason||(r.reason=new ar(n,a,o),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}static source(){let e;return{token:new Sn(function(s){e=s}),cancel:e}}}const im=Sn;function rm(i){return function(t){return i.apply(null,t)}}function sm(i){return S.isObject(i)&&i.isAxiosError===!0}const Xs={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Xs).forEach(([i,e])=>{Xs[e]=i});const nm=Xs;function Ll(i){const e=new Mr(i),t=fl(Mr.prototype.request,e);return S.extend(t,Mr.prototype,e,{allOwnKeys:!0}),S.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return Ll(mi(i,s))},t}const Te=Ll(_n);Te.Axios=Mr;Te.CanceledError=ar;Te.CancelToken=im;Te.isCancel=Al;Te.VERSION=Ol;Te.toFormData=ns;Te.AxiosError=ie;Te.Cancel=Te.CanceledError;Te.all=function(e){return Promise.all(e)};Te.spread=rm;Te.isAxiosError=sm;Te.mergeConfig=mi;Te.AxiosHeaders=mt;Te.formToJSON=i=>Pl(S.isHTMLForm(i)?new FormData(i):i);Te.HttpStatusCode=nm;Te.default=Te;const Ea=Te;function am(i,e){return Ri(e)?Ea.get(i):Ea.get(i,e)}function He(i,e){this.message=i,this.error=e}He.prototype=Object.create(Error.prototype);const Tn=/([0-9]+)?:?([0-9]{2}):([0-9]{2}\.[0-9]{2,3})/;function om(i,e){e||(e={});const{meta:t=!1,strict:r=!0}=e;if(typeof i!="string")throw new He("Input must be a string");i=i.trim(),i=i.replace(/\r\n/g,`
10
+ */var ii=9e15,Ft=1e9,Hs="0123456789abcdef",Ur="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Zr="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Bs={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ii,maxE:ii,crypto:!1},el,ut,q=!0,ts="[DecimalError] ",Rt=ts+"Invalid argument: ",tl=ts+"Precision limit exceeded",il=ts+"crypto unavailable",rl="[object Decimal]",Oe=Math.floor,Te=Math.pow,Kc=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Jc=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Qc=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,sl=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,qe=1e7,j=7,ef=9007199254740991,tf=Ur.length-1,$s=Zr.length-1,C={toStringTag:rl};C.absoluteValue=C.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),z(i)};C.ceil=function(){return z(new this.constructor(this),this.e+1,2)};C.clampedTo=C.clamp=function(i,e){var t,r=this,s=r.constructor;if(i=new s(i),e=new s(e),!i.s||!e.s)return new s(NaN);if(i.gt(e))throw Error(Rt+e);return t=r.cmp(i),t<0?i:r.cmp(e)>0?e:new s(r)};C.comparedTo=C.cmp=function(i){var e,t,r,s,n=this,a=n.d,o=(i=new n.constructor(i)).d,h=n.s,l=i.s;if(!a||!o)return!h||!l?NaN:h!==l?h:a===o?0:!a^h<0?1:-1;if(!a[0]||!o[0])return a[0]?h:o[0]?-l:0;if(h!==l)return h;if(n.e!==i.e)return n.e>i.e^h<0?1:-1;for(r=a.length,s=o.length,e=0,t=r<s?r:s;e<t;++e)if(a[e]!==o[e])return a[e]>o[e]^h<0?1:-1;return r===s?0:r>s^h<0?1:-1};C.cosine=C.cos=function(){var i,e,t=this,r=t.constructor;return t.d?t.d[0]?(i=r.precision,e=r.rounding,r.precision=i+Math.max(t.e,t.sd())+j,r.rounding=1,t=rf(r,hl(r,t)),r.precision=i,r.rounding=e,z(ut==2||ut==3?t.neg():t,i,e,!0)):new r(1):new r(NaN)};C.cubeRoot=C.cbrt=function(){var i,e,t,r,s,n,a,o,h,l,d=this,u=d.constructor;if(!d.isFinite()||d.isZero())return new u(d);for(q=!1,n=d.s*Te(d.s*d,1/3),!n||Math.abs(n)==1/0?(t=xe(d.d),i=d.e,(n=(i-t.length+1)%3)&&(t+=n==1||n==-2?"0":"00"),n=Te(t,1/3),i=Oe((i+1)/3)-(i%3==(i<0?-1:2)),n==1/0?t="5e"+i:(t=n.toExponential(),t=t.slice(0,t.indexOf("e")+1)+i),r=new u(t),r.s=d.s):r=new u(n.toString()),a=(i=u.precision)+3;;)if(o=r,h=o.times(o).times(o),l=h.plus(d),r=ue(l.plus(d).times(o),l.plus(h),a+2,1),xe(o.d).slice(0,a)===(t=xe(r.d)).slice(0,a))if(t=t.slice(a-3,a+1),t=="9999"||!s&&t=="4999"){if(!s&&(z(o,i+1,0),o.times(o).times(o).eq(d))){r=o;break}a+=4,s=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(z(r,i+1,1),e=!r.times(r).times(r).eq(d));break}return q=!0,z(r,i,u.rounding,e)};C.decimalPlaces=C.dp=function(){var i,e=this.d,t=NaN;if(e){if(i=e.length-1,t=(i-Oe(this.e/j))*j,i=e[i],i)for(;i%10==0;i/=10)t--;t<0&&(t=0)}return t};C.dividedBy=C.div=function(i){return ue(this,new this.constructor(i))};C.dividedToIntegerBy=C.divToInt=function(i){var e=this,t=e.constructor;return z(ue(e,new t(i),0,1,1),t.precision,t.rounding)};C.equals=C.eq=function(i){return this.cmp(i)===0};C.floor=function(){return z(new this.constructor(this),this.e+1,3)};C.greaterThan=C.gt=function(i){return this.cmp(i)>0};C.greaterThanOrEqualTo=C.gte=function(i){var e=this.cmp(i);return e==1||e===0};C.hyperbolicCosine=C.cosh=function(){var i,e,t,r,s,n=this,a=n.constructor,o=new a(1);if(!n.isFinite())return new a(n.s?1/0:NaN);if(n.isZero())return o;t=a.precision,r=a.rounding,a.precision=t+Math.max(n.e,n.sd())+4,a.rounding=1,s=n.d.length,s<32?(i=Math.ceil(s/3),e=(1/rs(4,i)).toString()):(i=16,e="2.3283064365386962890625e-10"),n=pi(a,1,n.times(e),new a(1),!0);for(var h,l=i,d=new a(8);l--;)h=n.times(n),n=o.minus(h.times(d.minus(h.times(d))));return z(n,a.precision=t,a.rounding=r,!0)};C.hyperbolicSine=C.sinh=function(){var i,e,t,r,s=this,n=s.constructor;if(!s.isFinite()||s.isZero())return new n(s);if(e=n.precision,t=n.rounding,n.precision=e+Math.max(s.e,s.sd())+4,n.rounding=1,r=s.d.length,r<3)s=pi(n,2,s,s,!0);else{i=1.4*Math.sqrt(r),i=i>16?16:i|0,s=s.times(1/rs(5,i)),s=pi(n,2,s,s,!0);for(var a,o=new n(5),h=new n(16),l=new n(20);i--;)a=s.times(s),s=s.times(o.plus(a.times(h.times(a).plus(l))))}return n.precision=e,n.rounding=t,z(s,e,t,!0)};C.hyperbolicTangent=C.tanh=function(){var i,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(i=r.precision,e=r.rounding,r.precision=i+7,r.rounding=1,ue(t.sinh(),t.cosh(),r.precision=i,r.rounding=e)):new r(t.s)};C.inverseCosine=C.acos=function(){var i,e=this,t=e.constructor,r=e.abs().cmp(1),s=t.precision,n=t.rounding;return r!==-1?r===0?e.isNeg()?je(t,s,n):new t(0):new t(NaN):e.isZero()?je(t,s+4,n).times(.5):(t.precision=s+6,t.rounding=1,e=e.asin(),i=je(t,s+4,n).times(.5),t.precision=s,t.rounding=n,i.minus(e))};C.inverseHyperbolicCosine=C.acosh=function(){var i,e,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(i=r.precision,e=r.rounding,r.precision=i+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,q=!1,t=t.times(t).minus(1).sqrt().plus(t),q=!0,r.precision=i,r.rounding=e,t.ln()):new r(t)};C.inverseHyperbolicSine=C.asinh=function(){var i,e,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(i=r.precision,e=r.rounding,r.precision=i+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,q=!1,t=t.times(t).plus(1).sqrt().plus(t),q=!0,r.precision=i,r.rounding=e,t.ln())};C.inverseHyperbolicTangent=C.atanh=function(){var i,e,t,r,s=this,n=s.constructor;return s.isFinite()?s.e>=0?new n(s.abs().eq(1)?s.s/0:s.isZero()?s:NaN):(i=n.precision,e=n.rounding,r=s.sd(),Math.max(r,i)<2*-s.e-1?z(new n(s),i,e,!0):(n.precision=t=r-s.e,s=ue(s.plus(1),new n(1).minus(s),t+i,1),n.precision=i+4,n.rounding=1,s=s.ln(),n.precision=i,n.rounding=e,s.times(.5))):new n(NaN)};C.inverseSine=C.asin=function(){var i,e,t,r,s=this,n=s.constructor;return s.isZero()?new n(s):(e=s.abs().cmp(1),t=n.precision,r=n.rounding,e!==-1?e===0?(i=je(n,t+4,r).times(.5),i.s=s.s,i):new n(NaN):(n.precision=t+6,n.rounding=1,s=s.div(new n(1).minus(s.times(s)).sqrt().plus(1)).atan(),n.precision=t,n.rounding=r,s.times(2)))};C.inverseTangent=C.atan=function(){var i,e,t,r,s,n,a,o,h,l=this,d=l.constructor,u=d.precision,c=d.rounding;if(l.isFinite()){if(l.isZero())return new d(l);if(l.abs().eq(1)&&u+4<=$s)return a=je(d,u+4,c).times(.25),a.s=l.s,a}else{if(!l.s)return new d(NaN);if(u+4<=$s)return a=je(d,u+4,c).times(.5),a.s=l.s,a}for(d.precision=o=u+10,d.rounding=1,t=Math.min(28,o/j+2|0),i=t;i;--i)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(q=!1,e=Math.ceil(o/j),r=1,h=l.times(l),a=new d(l),s=l;i!==-1;)if(s=s.times(h),n=a.minus(s.div(r+=2)),s=s.times(h),a=n.plus(s.div(r+=2)),a.d[e]!==void 0)for(i=e;a.d[i]===n.d[i]&&i--;);return t&&(a=a.times(2<<t-1)),q=!0,z(a,d.precision=u,d.rounding=c,!0)};C.isFinite=function(){return!!this.d};C.isInteger=C.isInt=function(){return!!this.d&&Oe(this.e/j)>this.d.length-2};C.isNaN=function(){return!this.s};C.isNegative=C.isNeg=function(){return this.s<0};C.isPositive=C.isPos=function(){return this.s>0};C.isZero=function(){return!!this.d&&this.d[0]===0};C.lessThan=C.lt=function(i){return this.cmp(i)<0};C.lessThanOrEqualTo=C.lte=function(i){return this.cmp(i)<1};C.logarithm=C.log=function(i){var e,t,r,s,n,a,o,h,l=this,d=l.constructor,u=d.precision,c=d.rounding,p=5;if(i==null)i=new d(10),e=!0;else{if(i=new d(i),t=i.d,i.s<0||!t||!t[0]||i.eq(1))return new d(NaN);e=i.eq(10)}if(t=l.d,l.s<0||!t||!t[0]||l.eq(1))return new d(t&&!t[0]?-1/0:l.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)n=!0;else{for(s=t[0];s%10===0;)s/=10;n=s!==1}if(q=!1,o=u+p,a=At(l,o),r=e?jr(d,o+10):At(i,o),h=ue(a,r,o,1),Yi(h.d,s=u,c))do if(o+=10,a=At(l,o),r=e?jr(d,o+10):At(i,o),h=ue(a,r,o,1),!n){+xe(h.d).slice(s+1,s+15)+1==1e14&&(h=z(h,u+1,0));break}while(Yi(h.d,s+=10,c));return q=!0,z(h,u,c)};C.minus=C.sub=function(i){var e,t,r,s,n,a,o,h,l,d,u,c,p=this,f=p.constructor;if(i=new f(i),!p.d||!i.d)return!p.s||!i.s?i=new f(NaN):p.d?i.s=-i.s:i=new f(i.d||p.s!==i.s?p:NaN),i;if(p.s!=i.s)return i.s=-i.s,p.plus(i);if(l=p.d,c=i.d,o=f.precision,h=f.rounding,!l[0]||!c[0]){if(c[0])i.s=-i.s;else if(l[0])i=new f(p);else return new f(h===3?-0:0);return q?z(i,o,h):i}if(t=Oe(i.e/j),d=Oe(p.e/j),l=l.slice(),n=d-t,n){for(u=n<0,u?(e=l,n=-n,a=c.length):(e=c,t=d,a=l.length),r=Math.max(Math.ceil(o/j),a)+2,n>r&&(n=r,e.length=1),e.reverse(),r=n;r--;)e.push(0);e.reverse()}else{for(r=l.length,a=c.length,u=r<a,u&&(a=r),r=0;r<a;r++)if(l[r]!=c[r]){u=l[r]<c[r];break}n=0}for(u&&(e=l,l=c,c=e,i.s=-i.s),a=l.length,r=c.length-a;r>0;--r)l[a++]=0;for(r=c.length;r>n;){if(l[--r]<c[r]){for(s=r;s&&l[--s]===0;)l[s]=qe-1;--l[s],l[r]+=qe}l[r]-=c[r]}for(;l[--a]===0;)l.pop();for(;l[0]===0;l.shift())--t;return l[0]?(i.d=l,i.e=is(l,t),q?z(i,o,h):i):new f(h===3?-0:0)};C.modulo=C.mod=function(i){var e,t=this,r=t.constructor;return i=new r(i),!t.d||!i.s||i.d&&!i.d[0]?new r(NaN):!i.d||t.d&&!t.d[0]?z(new r(t),r.precision,r.rounding):(q=!1,r.modulo==9?(e=ue(t,i.abs(),0,3,1),e.s*=i.s):e=ue(t,i,0,r.modulo,1),e=e.times(i),q=!0,t.minus(e))};C.naturalExponential=C.exp=function(){return Vs(this)};C.naturalLogarithm=C.ln=function(){return At(this)};C.negated=C.neg=function(){var i=new this.constructor(this);return i.s=-i.s,z(i)};C.plus=C.add=function(i){var e,t,r,s,n,a,o,h,l,d,u=this,c=u.constructor;if(i=new c(i),!u.d||!i.d)return!u.s||!i.s?i=new c(NaN):u.d||(i=new c(i.d||u.s===i.s?u:NaN)),i;if(u.s!=i.s)return i.s=-i.s,u.minus(i);if(l=u.d,d=i.d,o=c.precision,h=c.rounding,!l[0]||!d[0])return d[0]||(i=new c(u)),q?z(i,o,h):i;if(n=Oe(u.e/j),r=Oe(i.e/j),l=l.slice(),s=n-r,s){for(s<0?(t=l,s=-s,a=d.length):(t=d,r=n,a=l.length),n=Math.ceil(o/j),a=n>a?n+1:a+1,s>a&&(s=a,t.length=1),t.reverse();s--;)t.push(0);t.reverse()}for(a=l.length,s=d.length,a-s<0&&(s=a,t=d,d=l,l=t),e=0;s;)e=(l[--s]=l[s]+d[s]+e)/qe|0,l[s]%=qe;for(e&&(l.unshift(e),++r),a=l.length;l[--a]==0;)l.pop();return i.d=l,i.e=is(l,r),q?z(i,o,h):i};C.precision=C.sd=function(i){var e,t=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(Rt+i);return t.d?(e=nl(t.d),i&&t.e+1>e&&(e=t.e+1)):e=NaN,e};C.round=function(){var i=this,e=i.constructor;return z(new e(i),i.e+1,e.rounding)};C.sine=C.sin=function(){var i,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(i=r.precision,e=r.rounding,r.precision=i+Math.max(t.e,t.sd())+j,r.rounding=1,t=nf(r,hl(r,t)),r.precision=i,r.rounding=e,z(ut>2?t.neg():t,i,e,!0)):new r(NaN)};C.squareRoot=C.sqrt=function(){var i,e,t,r,s,n,a=this,o=a.d,h=a.e,l=a.s,d=a.constructor;if(l!==1||!o||!o[0])return new d(!l||l<0&&(!o||o[0])?NaN:o?a:1/0);for(q=!1,l=Math.sqrt(+a),l==0||l==1/0?(e=xe(o),(e.length+h)%2==0&&(e+="0"),l=Math.sqrt(e),h=Oe((h+1)/2)-(h<0||h%2),l==1/0?e="5e"+h:(e=l.toExponential(),e=e.slice(0,e.indexOf("e")+1)+h),r=new d(e)):r=new d(l.toString()),t=(h=d.precision)+3;;)if(n=r,r=n.plus(ue(a,n,t+2,1)).times(.5),xe(n.d).slice(0,t)===(e=xe(r.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!s&&e=="4999"){if(!s&&(z(n,h+1,0),n.times(n).eq(a))){r=n;break}t+=4,s=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(z(r,h+1,1),i=!r.times(r).eq(a));break}return q=!0,z(r,h,d.rounding,i)};C.tangent=C.tan=function(){var i,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(i=r.precision,e=r.rounding,r.precision=i+10,r.rounding=1,t=t.sin(),t.s=1,t=ue(t,new r(1).minus(t.times(t)).sqrt(),i+10,0),r.precision=i,r.rounding=e,z(ut==2||ut==4?t.neg():t,i,e,!0)):new r(NaN)};C.times=C.mul=function(i){var e,t,r,s,n,a,o,h,l,d=this,u=d.constructor,c=d.d,p=(i=new u(i)).d;if(i.s*=d.s,!c||!c[0]||!p||!p[0])return new u(!i.s||c&&!c[0]&&!p||p&&!p[0]&&!c?NaN:!c||!p?i.s/0:i.s*0);for(t=Oe(d.e/j)+Oe(i.e/j),h=c.length,l=p.length,h<l&&(n=c,c=p,p=n,a=h,h=l,l=a),n=[],a=h+l,r=a;r--;)n.push(0);for(r=l;--r>=0;){for(e=0,s=h+r;s>r;)o=n[s]+p[r]*c[s-r-1]+e,n[s--]=o%qe|0,e=o/qe|0;n[s]=(n[s]+e)%qe|0}for(;!n[--a];)n.pop();return e?++t:n.shift(),i.d=n,i.e=is(n,t),q?z(i,u.precision,u.rounding):i};C.toBinary=function(i,e){return mn(this,2,i,e)};C.toDecimalPlaces=C.toDP=function(i,e){var t=this,r=t.constructor;return t=new r(t),i===void 0?t:(Ne(i,0,Ft),e===void 0?e=r.rounding:Ne(e,0,8),z(t,i+t.e+1,e))};C.toExponential=function(i,e){var t,r=this,s=r.constructor;return i===void 0?t=ot(r,!0):(Ne(i,0,Ft),e===void 0?e=s.rounding:Ne(e,0,8),r=z(new s(r),i+1,e),t=ot(r,!0,i+1)),r.isNeg()&&!r.isZero()?"-"+t:t};C.toFixed=function(i,e){var t,r,s=this,n=s.constructor;return i===void 0?t=ot(s):(Ne(i,0,Ft),e===void 0?e=n.rounding:Ne(e,0,8),r=z(new n(s),i+s.e+1,e),t=ot(r,!1,i+r.e+1)),s.isNeg()&&!s.isZero()?"-"+t:t};C.toFraction=function(i){var e,t,r,s,n,a,o,h,l,d,u,c,p=this,f=p.d,m=p.constructor;if(!f)return new m(p);if(l=t=new m(1),r=h=new m(0),e=new m(r),n=e.e=nl(f)-p.e-1,a=n%j,e.d[0]=Te(10,a<0?j+a:a),i==null)i=n>0?e:l;else{if(o=new m(i),!o.isInt()||o.lt(l))throw Error(Rt+o);i=o.gt(e)?n>0?e:l:o}for(q=!1,o=new m(xe(f)),d=m.precision,m.precision=n=f.length*j*2;u=ue(o,e,0,1,1),s=t.plus(u.times(r)),s.cmp(i)!=1;)t=r,r=s,s=l,l=h.plus(u.times(s)),h=s,s=e,e=o.minus(u.times(s)),o=s;return s=ue(i.minus(t),r,0,1,1),h=h.plus(s.times(l)),t=t.plus(s.times(r)),h.s=l.s=p.s,c=ue(l,r,n,1).minus(p).abs().cmp(ue(h,t,n,1).minus(p).abs())<1?[l,r]:[h,t],m.precision=d,q=!0,c};C.toHexadecimal=C.toHex=function(i,e){return mn(this,16,i,e)};C.toNearest=function(i,e){var t=this,r=t.constructor;if(t=new r(t),i==null){if(!t.d)return t;i=new r(1),e=r.rounding}else{if(i=new r(i),e===void 0?e=r.rounding:Ne(e,0,8),!t.d)return i.s?t:i;if(!i.d)return i.s&&(i.s=t.s),i}return i.d[0]?(q=!1,t=ue(t,i,0,e,1).times(i),q=!0,z(t)):(i.s=t.s,t=i),t};C.toNumber=function(){return+this};C.toOctal=function(i,e){return mn(this,8,i,e)};C.toPower=C.pow=function(i){var e,t,r,s,n,a,o=this,h=o.constructor,l=+(i=new h(i));if(!o.d||!i.d||!o.d[0]||!i.d[0])return new h(Te(+o,l));if(o=new h(o),o.eq(1))return o;if(r=h.precision,n=h.rounding,i.eq(1))return z(o,r,n);if(e=Oe(i.e/j),e>=i.d.length-1&&(t=l<0?-l:l)<=ef)return s=al(h,o,t,r),i.s<0?new h(1).div(s):z(s,r,n);if(a=o.s,a<0){if(e<i.d.length-1)return new h(NaN);if(i.d[e]&1||(a=1),o.e==0&&o.d[0]==1&&o.d.length==1)return o.s=a,o}return t=Te(+o,l),e=t==0||!isFinite(t)?Oe(l*(Math.log("0."+xe(o.d))/Math.LN10+o.e+1)):new h(t+"").e,e>h.maxE+1||e<h.minE-1?new h(e>0?a/0:0):(q=!1,h.rounding=o.s=1,t=Math.min(12,(e+"").length),s=Vs(i.times(At(o,r+t)),r),s.d&&(s=z(s,r+5,1),Yi(s.d,r,n)&&(e=r+10,s=z(Vs(i.times(At(o,e+t)),e),e+5,1),+xe(s.d).slice(r+1,r+15)+1==1e14&&(s=z(s,r+1,0)))),s.s=a,q=!0,h.rounding=n,z(s,r,n))};C.toPrecision=function(i,e){var t,r=this,s=r.constructor;return i===void 0?t=ot(r,r.e<=s.toExpNeg||r.e>=s.toExpPos):(Ne(i,1,Ft),e===void 0?e=s.rounding:Ne(e,0,8),r=z(new s(r),i,e),t=ot(r,i<=r.e||r.e<=s.toExpNeg,i)),r.isNeg()&&!r.isZero()?"-"+t:t};C.toSignificantDigits=C.toSD=function(i,e){var t=this,r=t.constructor;return i===void 0?(i=r.precision,e=r.rounding):(Ne(i,1,Ft),e===void 0?e=r.rounding:Ne(e,0,8)),z(new r(t),i,e)};C.toString=function(){var i=this,e=i.constructor,t=ot(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()&&!i.isZero()?"-"+t:t};C.truncated=C.trunc=function(){return z(new this.constructor(this),this.e+1,1)};C.valueOf=C.toJSON=function(){var i=this,e=i.constructor,t=ot(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()?"-"+t:t};function xe(i){var e,t,r,s=i.length-1,n="",a=i[0];if(s>0){for(n+=a,e=1;e<s;e++)r=i[e]+"",t=j-r.length,t&&(n+=xt(t)),n+=r;a=i[e],r=a+"",t=j-r.length,t&&(n+=xt(t))}else if(a===0)return"0";for(;a%10===0;)a/=10;return n+a}function Ne(i,e,t){if(i!==~~i||i<e||i>t)throw Error(Rt+i)}function Yi(i,e,t,r){var s,n,a,o;for(n=i[0];n>=10;n/=10)--e;return--e<0?(e+=j,s=0):(s=Math.ceil((e+1)/j),e%=j),n=Te(10,j-e),o=i[s]%n|0,r==null?e<3?(e==0?o=o/100|0:e==1&&(o=o/10|0),a=t<4&&o==99999||t>3&&o==49999||o==5e4||o==0):a=(t<4&&o+1==n||t>3&&o+1==n/2)&&(i[s+1]/n/100|0)==Te(10,e-2)-1||(o==n/2||o==0)&&(i[s+1]/n/100|0)==0:e<4?(e==0?o=o/1e3|0:e==1?o=o/100|0:e==2&&(o=o/10|0),a=(r||t<4)&&o==9999||!r&&t>3&&o==4999):a=((r||t<4)&&o+1==n||!r&&t>3&&o+1==n/2)&&(i[s+1]/n/1e3|0)==Te(10,e-3)-1,a}function kr(i,e,t){for(var r,s=[0],n,a=0,o=i.length;a<o;){for(n=s.length;n--;)s[n]*=e;for(s[0]+=Hs.indexOf(i.charAt(a++)),r=0;r<s.length;r++)s[r]>t-1&&(s[r+1]===void 0&&(s[r+1]=0),s[r+1]+=s[r]/t|0,s[r]%=t)}return s.reverse()}function rf(i,e){var t,r,s;if(e.isZero())return e;r=e.d.length,r<32?(t=Math.ceil(r/3),s=(1/rs(4,t)).toString()):(t=16,s="2.3283064365386962890625e-10"),i.precision+=t,e=pi(i,1,e.times(s),new i(1));for(var n=t;n--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return i.precision-=t,e}var ue=function(){function i(r,s,n){var a,o=0,h=r.length;for(r=r.slice();h--;)a=r[h]*s+o,r[h]=a%n|0,o=a/n|0;return o&&r.unshift(o),r}function e(r,s,n,a){var o,h;if(n!=a)h=n>a?1:-1;else for(o=h=0;o<n;o++)if(r[o]!=s[o]){h=r[o]>s[o]?1:-1;break}return h}function t(r,s,n,a){for(var o=0;n--;)r[n]-=o,o=r[n]<s[n]?1:0,r[n]=o*a+r[n]-s[n];for(;!r[0]&&r.length>1;)r.shift()}return function(r,s,n,a,o,h){var l,d,u,c,p,f,m,g,_,w,b,T,L,A,D,R,H,$,I,K,W=r.constructor,le=r.s==s.s?1:-1,ne=r.d,U=s.d;if(!ne||!ne[0]||!U||!U[0])return new W(!r.s||!s.s||(ne?U&&ne[0]==U[0]:!U)?NaN:ne&&ne[0]==0||!U?le*0:le/0);for(h?(p=1,d=r.e-s.e):(h=qe,p=j,d=Oe(r.e/p)-Oe(s.e/p)),I=U.length,H=ne.length,_=new W(le),w=_.d=[],u=0;U[u]==(ne[u]||0);u++);if(U[u]>(ne[u]||0)&&d--,n==null?(A=n=W.precision,a=W.rounding):o?A=n+(r.e-s.e)+1:A=n,A<0)w.push(1),f=!0;else{if(A=A/p+2|0,u=0,I==1){for(c=0,U=U[0],A++;(u<H||c)&&A--;u++)D=c*h+(ne[u]||0),w[u]=D/U|0,c=D%U|0;f=c||u<H}else{for(c=h/(U[0]+1)|0,c>1&&(U=i(U,c,h),ne=i(ne,c,h),I=U.length,H=ne.length),R=I,b=ne.slice(0,I),T=b.length;T<I;)b[T++]=0;K=U.slice(),K.unshift(0),$=U[0],U[1]>=h/2&&++$;do c=0,l=e(U,b,I,T),l<0?(L=b[0],I!=T&&(L=L*h+(b[1]||0)),c=L/$|0,c>1?(c>=h&&(c=h-1),m=i(U,c,h),g=m.length,T=b.length,l=e(m,b,g,T),l==1&&(c--,t(m,I<g?K:U,g,h))):(c==0&&(l=c=1),m=U.slice()),g=m.length,g<T&&m.unshift(0),t(b,m,T,h),l==-1&&(T=b.length,l=e(U,b,I,T),l<1&&(c++,t(b,I<T?K:U,T,h))),T=b.length):l===0&&(c++,b=[0]),w[u++]=c,l&&b[0]?b[T++]=ne[R]||0:(b=[ne[R]],T=1);while((R++<H||b[0]!==void 0)&&A--);f=b[0]!==void 0}w[0]||w.shift()}if(p==1)_.e=d,el=f;else{for(u=1,c=w[0];c>=10;c/=10)u++;_.e=u+d*p-1,z(_,o?n+_.e+1:n,a,f)}return _}}();function z(i,e,t,r){var s,n,a,o,h,l,d,u,c,p=i.constructor;e:if(e!=null){if(u=i.d,!u)return i;for(s=1,o=u[0];o>=10;o/=10)s++;if(n=e-s,n<0)n+=j,a=e,d=u[c=0],h=d/Te(10,s-a-1)%10|0;else if(c=Math.ceil((n+1)/j),o=u.length,c>=o)if(r){for(;o++<=c;)u.push(0);d=h=0,s=1,n%=j,a=n-j+1}else break e;else{for(d=o=u[c],s=1;o>=10;o/=10)s++;n%=j,a=n-j+s,h=a<0?0:d/Te(10,s-a-1)%10|0}if(r=r||e<0||u[c+1]!==void 0||(a<0?d:d%Te(10,s-a-1)),l=t<4?(h||r)&&(t==0||t==(i.s<0?3:2)):h>5||h==5&&(t==4||r||t==6&&(n>0?a>0?d/Te(10,s-a):0:u[c-1])%10&1||t==(i.s<0?8:7)),e<1||!u[0])return u.length=0,l?(e-=i.e+1,u[0]=Te(10,(j-e%j)%j),i.e=-e||0):u[0]=i.e=0,i;if(n==0?(u.length=c,o=1,c--):(u.length=c+1,o=Te(10,j-n),u[c]=a>0?(d/Te(10,s-a)%Te(10,a)|0)*o:0),l)for(;;)if(c==0){for(n=1,a=u[0];a>=10;a/=10)n++;for(a=u[0]+=o,o=1;a>=10;a/=10)o++;n!=o&&(i.e++,u[0]==qe&&(u[0]=1));break}else{if(u[c]+=o,u[c]!=qe)break;u[c--]=0,o=1}for(n=u.length;u[--n]===0;)u.pop()}return q&&(i.e>p.maxE?(i.d=null,i.e=NaN):i.e<p.minE&&(i.e=0,i.d=[0])),i}function ot(i,e,t){if(!i.isFinite())return ll(i);var r,s=i.e,n=xe(i.d),a=n.length;return e?(t&&(r=t-a)>0?n=n.charAt(0)+"."+n.slice(1)+xt(r):a>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(i.e<0?"e":"e+")+i.e):s<0?(n="0."+xt(-s-1)+n,t&&(r=t-a)>0&&(n+=xt(r))):s>=a?(n+=xt(s+1-a),t&&(r=t-s-1)>0&&(n=n+"."+xt(r))):((r=s+1)<a&&(n=n.slice(0,r)+"."+n.slice(r)),t&&(r=t-a)>0&&(s+1===a&&(n+="."),n+=xt(r))),n}function is(i,e){var t=i[0];for(e*=j;t>=10;t/=10)e++;return e}function jr(i,e,t){if(e>tf)throw q=!0,t&&(i.precision=t),Error(tl);return z(new i(Ur),e,1,!0)}function je(i,e,t){if(e>$s)throw Error(tl);return z(new i(Zr),e,t,!0)}function nl(i){var e=i.length-1,t=e*j+1;if(e=i[e],e){for(;e%10==0;e/=10)t--;for(e=i[0];e>=10;e/=10)t++}return t}function xt(i){for(var e="";i--;)e+="0";return e}function al(i,e,t,r){var s,n=new i(1),a=Math.ceil(r/j+4);for(q=!1;;){if(t%2&&(n=n.times(e),la(n.d,a)&&(s=!0)),t=Oe(t/2),t===0){t=n.d.length-1,s&&n.d[t]===0&&++n.d[t];break}e=e.times(e),la(e.d,a)}return q=!0,n}function oa(i){return i.d[i.d.length-1]&1}function ol(i,e,t){for(var r,s=new i(e[0]),n=0;++n<e.length;)if(r=new i(e[n]),r.s)s[t](r)&&(s=r);else{s=r;break}return s}function Vs(i,e){var t,r,s,n,a,o,h,l=0,d=0,u=0,c=i.constructor,p=c.rounding,f=c.precision;if(!i.d||!i.d[0]||i.e>17)return new c(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:0/0);for(e==null?(q=!1,h=f):h=e,o=new c(.03125);i.e>-2;)i=i.times(o),u+=5;for(r=Math.log(Te(2,u))/Math.LN10*2+5|0,h+=r,t=n=a=new c(1),c.precision=h;;){if(n=z(n.times(i),h,1),t=t.times(++d),o=a.plus(ue(n,t,h,1)),xe(o.d).slice(0,h)===xe(a.d).slice(0,h)){for(s=u;s--;)a=z(a.times(a),h,1);if(e==null)if(l<3&&Yi(a.d,h-r,p,l))c.precision=h+=10,t=n=o=new c(1),d=0,l++;else return z(a,c.precision=f,p,q=!0);else return c.precision=f,a}a=o}}function At(i,e){var t,r,s,n,a,o,h,l,d,u,c,p=1,f=10,m=i,g=m.d,_=m.constructor,w=_.rounding,b=_.precision;if(m.s<0||!g||!g[0]||!m.e&&g[0]==1&&g.length==1)return new _(g&&!g[0]?-1/0:m.s!=1?NaN:g?0:m);if(e==null?(q=!1,d=b):d=e,_.precision=d+=f,t=xe(g),r=t.charAt(0),Math.abs(n=m.e)<15e14){for(;r<7&&r!=1||r==1&&t.charAt(1)>3;)m=m.times(i),t=xe(m.d),r=t.charAt(0),p++;n=m.e,r>1?(m=new _("0."+t),n++):m=new _(r+"."+t.slice(1))}else return l=jr(_,d+2,b).times(n+""),m=At(new _(r+"."+t.slice(1)),d-f).plus(l),_.precision=b,e==null?z(m,b,w,q=!0):m;for(u=m,h=a=m=ue(m.minus(1),m.plus(1),d,1),c=z(m.times(m),d,1),s=3;;){if(a=z(a.times(c),d,1),l=h.plus(ue(a,new _(s),d,1)),xe(l.d).slice(0,d)===xe(h.d).slice(0,d))if(h=h.times(2),n!==0&&(h=h.plus(jr(_,d+2,b).times(n+""))),h=ue(h,new _(p),d,1),e==null)if(Yi(h.d,d-f,w,o))_.precision=d+=f,l=a=m=ue(u.minus(1),u.plus(1),d,1),c=z(m.times(m),d,1),s=o=1;else return z(h,_.precision=b,w,q=!0);else return _.precision=b,h;h=l,s+=2}}function ll(i){return String(i.s*i.s/0)}function zs(i,e){var t,r,s;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),r=0;e.charCodeAt(r)===48;r++);for(s=e.length;e.charCodeAt(s-1)===48;--s);if(e=e.slice(r,s),e){if(s-=r,i.e=t=t-r-1,i.d=[],r=(t+1)%j,t<0&&(r+=j),r<s){for(r&&i.d.push(+e.slice(0,r)),s-=j;r<s;)i.d.push(+e.slice(r,r+=j));e=e.slice(r),r=j-e.length}else r-=s;for(;r--;)e+="0";i.d.push(+e),q&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function sf(i,e){var t,r,s,n,a,o,h,l,d;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),sl.test(e))return zs(i,e)}else if(e==="Infinity"||e==="NaN")return+e||(i.s=NaN),i.e=NaN,i.d=null,i;if(Jc.test(e))t=16,e=e.toLowerCase();else if(Kc.test(e))t=2;else if(Qc.test(e))t=8;else throw Error(Rt+e);for(n=e.search(/p/i),n>0?(h=+e.slice(n+1),e=e.substring(2,n)):e=e.slice(2),n=e.indexOf("."),a=n>=0,r=i.constructor,a&&(e=e.replace(".",""),o=e.length,n=o-n,s=al(r,new r(t),n,n*2)),l=kr(e,t,qe),d=l.length-1,n=d;l[n]===0;--n)l.pop();return n<0?new r(i.s*0):(i.e=is(l,d),i.d=l,q=!1,a&&(i=ue(i,s,o*4)),h&&(i=i.times(Math.abs(h)<54?Te(2,h):Z.pow(2,h))),q=!0,i)}function nf(i,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:pi(i,2,e,e);t=1.4*Math.sqrt(r),t=t>16?16:t|0,e=e.times(1/rs(5,t)),e=pi(i,2,e,e);for(var s,n=new i(5),a=new i(16),o=new i(20);t--;)s=e.times(e),e=e.times(n.plus(s.times(a.times(s).minus(o))));return e}function pi(i,e,t,r,s){var n,a,o,h,l=i.precision,d=Math.ceil(l/j);for(q=!1,h=t.times(t),o=new i(r);;){if(a=ue(o.times(h),new i(e++*e++),l,1),o=s?r.plus(a):r.minus(a),r=ue(a.times(h),new i(e++*e++),l,1),a=o.plus(r),a.d[d]!==void 0){for(n=d;a.d[n]===o.d[n]&&n--;);if(n==-1)break}n=o,o=r,r=a,a=n}return q=!0,a.d.length=d+1,a}function rs(i,e){for(var t=i;--e;)t*=i;return t}function hl(i,e){var t,r=e.s<0,s=je(i,i.precision,1),n=s.times(.5);if(e=e.abs(),e.lte(n))return ut=r?4:1,e;if(t=e.divToInt(s),t.isZero())ut=r?3:2;else{if(e=e.minus(t.times(s)),e.lte(n))return ut=oa(t)?r?2:3:r?4:1,e;ut=oa(t)?r?1:4:r?3:2}return e.minus(s).abs()}function mn(i,e,t,r){var s,n,a,o,h,l,d,u,c,p=i.constructor,f=t!==void 0;if(f?(Ne(t,1,Ft),r===void 0?r=p.rounding:Ne(r,0,8)):(t=p.precision,r=p.rounding),!i.isFinite())d=ll(i);else{for(d=ot(i),a=d.indexOf("."),f?(s=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):s=e,a>=0&&(d=d.replace(".",""),c=new p(1),c.e=d.length-a,c.d=kr(ot(c),10,s),c.e=c.d.length),u=kr(d,10,s),n=h=u.length;u[--h]==0;)u.pop();if(!u[0])d=f?"0p+0":"0";else{if(a<0?n--:(i=new p(i),i.d=u,i.e=n,i=ue(i,c,t,r,0,s),u=i.d,n=i.e,l=el),a=u[t],o=s/2,l=l||u[t+1]!==void 0,l=r<4?(a!==void 0||l)&&(r===0||r===(i.s<0?3:2)):a>o||a===o&&(r===4||l||r===6&&u[t-1]&1||r===(i.s<0?8:7)),u.length=t,l)for(;++u[--t]>s-1;)u[t]=0,t||(++n,u.unshift(1));for(h=u.length;!u[h-1];--h);for(a=0,d="";a<h;a++)d+=Hs.charAt(u[a]);if(f){if(h>1)if(e==16||e==8){for(a=e==16?4:3,--h;h%a;h++)d+="0";for(u=kr(d,s,e),h=u.length;!u[h-1];--h);for(a=1,d="1.";a<h;a++)d+=Hs.charAt(u[a])}else d=d.charAt(0)+"."+d.slice(1);d=d+(n<0?"p":"p+")+n}else if(n<0){for(;++n;)d="0"+d;d="0."+d}else if(++n>h)for(n-=h;n--;)d+="0";else n<h&&(d=d.slice(0,n)+"."+d.slice(n))}d=(e==16?"0x":e==2?"0b":e==8?"0o":"")+d}return i.s<0?"-"+d:d}function la(i,e){if(i.length>e)return i.length=e,!0}function af(i){return new this(i).abs()}function of(i){return new this(i).acos()}function lf(i){return new this(i).acosh()}function hf(i,e){return new this(i).plus(e)}function df(i){return new this(i).asin()}function uf(i){return new this(i).asinh()}function cf(i){return new this(i).atan()}function ff(i){return new this(i).atanh()}function pf(i,e){i=new this(i),e=new this(e);var t,r=this.precision,s=this.rounding,n=r+4;return!i.s||!e.s?t=new this(NaN):!i.d&&!e.d?(t=je(this,n,1).times(e.s>0?.25:.75),t.s=i.s):!e.d||i.isZero()?(t=e.s<0?je(this,r,s):new this(0),t.s=i.s):!i.d||e.isZero()?(t=je(this,n,1).times(.5),t.s=i.s):e.s<0?(this.precision=n,this.rounding=1,t=this.atan(ue(i,e,n,1)),e=je(this,n,1),this.precision=r,this.rounding=s,t=i.s<0?t.minus(e):t.plus(e)):t=this.atan(ue(i,e,n,1)),t}function mf(i){return new this(i).cbrt()}function gf(i){return z(i=new this(i),i.e+1,2)}function vf(i,e,t){return new this(i).clamp(e,t)}function yf(i){if(!i||typeof i!="object")throw Error(ts+"Object expected");var e,t,r,s=i.defaults===!0,n=["precision",1,Ft,"rounding",0,8,"toExpNeg",-ii,0,"toExpPos",0,ii,"maxE",0,ii,"minE",-ii,0,"modulo",0,9];for(e=0;e<n.length;e+=3)if(t=n[e],s&&(this[t]=Bs[t]),(r=i[t])!==void 0)if(Oe(r)===r&&r>=n[e+1]&&r<=n[e+2])this[t]=r;else throw Error(Rt+t+": "+r);if(t="crypto",s&&(this[t]=Bs[t]),(r=i[t])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(il);else this[t]=!1;else throw Error(Rt+t+": "+r);return this}function bf(i){return new this(i).cos()}function _f(i){return new this(i).cosh()}function dl(i){var e,t,r;function s(n){var a,o,h,l=this;if(!(l instanceof s))return new s(n);if(l.constructor=s,ha(n)){l.s=n.s,q?!n.d||n.e>s.maxE?(l.e=NaN,l.d=null):n.e<s.minE?(l.e=0,l.d=[0]):(l.e=n.e,l.d=n.d.slice()):(l.e=n.e,l.d=n.d?n.d.slice():n.d);return}if(h=typeof n,h==="number"){if(n===0){l.s=1/n<0?-1:1,l.e=0,l.d=[0];return}if(n<0?(n=-n,l.s=-1):l.s=1,n===~~n&&n<1e7){for(a=0,o=n;o>=10;o/=10)a++;q?a>s.maxE?(l.e=NaN,l.d=null):a<s.minE?(l.e=0,l.d=[0]):(l.e=a,l.d=[n]):(l.e=a,l.d=[n]);return}else if(n*0!==0){n||(l.s=NaN),l.e=NaN,l.d=null;return}return zs(l,n.toString())}else if(h!=="string")throw Error(Rt+n);return(o=n.charCodeAt(0))===45?(n=n.slice(1),l.s=-1):(o===43&&(n=n.slice(1)),l.s=1),sl.test(n)?zs(l,n):sf(l,n)}if(s.prototype=C,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=yf,s.clone=dl,s.isDecimal=ha,s.abs=af,s.acos=of,s.acosh=lf,s.add=hf,s.asin=df,s.asinh=uf,s.atan=cf,s.atanh=ff,s.atan2=pf,s.cbrt=mf,s.ceil=gf,s.clamp=vf,s.cos=bf,s.cosh=_f,s.div=wf,s.exp=Sf,s.floor=Tf,s.hypot=Cf,s.ln=Ef,s.log=kf,s.log10=Pf,s.log2=xf,s.max=Af,s.min=Mf,s.mod=Of,s.mul=Lf,s.pow=Rf,s.random=If,s.round=Nf,s.sign=Df,s.sin=Gf,s.sinh=Ff,s.sqrt=Hf,s.sub=Bf,s.sum=$f,s.tan=Vf,s.tanh=zf,s.trunc=Wf,i===void 0&&(i={}),i&&i.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<r.length;)i.hasOwnProperty(t=r[e++])||(i[t]=this[t]);return s.config(i),s}function wf(i,e){return new this(i).div(e)}function Sf(i){return new this(i).exp()}function Tf(i){return z(i=new this(i),i.e+1,3)}function Cf(){var i,e,t=new this(0);for(q=!1,i=0;i<arguments.length;)if(e=new this(arguments[i++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return q=!0,new this(1/0);t=e}return q=!0,t.sqrt()}function ha(i){return i instanceof Z||i&&i.toStringTag===rl||!1}function Ef(i){return new this(i).ln()}function kf(i,e){return new this(i).log(e)}function xf(i){return new this(i).log(2)}function Pf(i){return new this(i).log(10)}function Af(){return ol(this,arguments,"lt")}function Mf(){return ol(this,arguments,"gt")}function Of(i,e){return new this(i).mod(e)}function Lf(i,e){return new this(i).mul(e)}function Rf(i,e){return new this(i).pow(e)}function If(i){var e,t,r,s,n=0,a=new this(1),o=[];if(i===void 0?i=this.precision:Ne(i,1,Ft),r=Math.ceil(i/j),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));n<r;)s=e[n],s>=429e7?e[n]=crypto.getRandomValues(new Uint32Array(1))[0]:o[n++]=s%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(r*=4);n<r;)s=e[n]+(e[n+1]<<8)+(e[n+2]<<16)+((e[n+3]&127)<<24),s>=214e7?crypto.randomBytes(4).copy(e,n):(o.push(s%1e7),n+=4);n=r/4}else throw Error(il);else for(;n<r;)o[n++]=Math.random()*1e7|0;for(r=o[--n],i%=j,r&&i&&(s=Te(10,j-i),o[n]=(r/s|0)*s);o[n]===0;n--)o.pop();if(n<0)t=0,o=[0];else{for(t=-1;o[0]===0;t-=j)o.shift();for(r=1,s=o[0];s>=10;s/=10)r++;r<j&&(t-=j-r)}return a.e=t,a.d=o,a}function Nf(i){return z(i=new this(i),i.e+1,this.rounding)}function Df(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Gf(i){return new this(i).sin()}function Ff(i){return new this(i).sinh()}function Hf(i){return new this(i).sqrt()}function Bf(i,e){return new this(i).sub(e)}function $f(){var i=0,e=arguments,t=new this(e[i]);for(q=!1;t.s&&++i<e.length;)t=t.plus(e[i]);return q=!0,z(t,this.precision,this.rounding)}function Vf(i){return new this(i).tan()}function zf(i){return new this(i).tanh()}function Wf(i){return z(i=new this(i),i.e+1,1)}C[Symbol.for("nodejs.util.inspect.custom")]=C.toString;C[Symbol.toStringTag]="Decimal";var Z=C.constructor=dl(Bs);Ur=new Z(Ur);Zr=new Z(Zr);function Ri(i){return i==null}const da={editable:!0,style:{...Jo,markerSymbolSize:20,periodMarkerHandleType:"start"}};class ua extends Qo{constructor(e,t,r){super({...da,...e,style:{...da.style,...e.style}},t,r)}createSymbol(){switch(this.style.markerSymbolType){case"triangle":let t=Z.sqrt(2).mul(this.style.markerSymbolSize).toNumber()/2;return new M.Line({points:this.style.periodMarkerHandleType==="start"?[-t,0,0,0,0,t]:[0,0,t,0,0,t],fill:this.style.color,closed:!0,offsetY:t/2});case"circle":return new M.Arc({fill:this.style.color,innerRadius:0,outerRadius:this.style.markerSymbolSize/2,angle:180,rotation:this.style.periodMarkerHandleType==="start"?90:-90});case"square":return new M.Line({points:[0,0,this.style.markerSymbolSize,0,this.style.markerSymbolSize,this.style.markerSymbolSize],fill:this.style.color,closed:!0,rotation:this.style.periodMarkerHandleType==="start"?225:45,offsetX:this.style.markerSymbolSize/2,offsetY:this.style.markerSymbolSize/2});default:throw Error("Unknown type")}}}const ca={editable:!0,style:{...Yo,selectedAreaOpacity:.2,markerHandleAreaOpacity:.7}};class ul extends Ko{constructor(e){super({...ca,...e,style:{...ca.style,...e.style}}),this.observation.start=_e.coerce.number().min(0).optional().nullable().parse(this.observation.start),this.observation.end=_e.coerce.number().min(0).optional().nullable().parse(this.observation.end),!Ri(this.observation.end)&&!Ri(this.observation.start)&&(this.observation.start=_e.coerce.number().lte(this.observation.end).parse(this.observation.start))}createCanvasNode(){return super.createCanvasNode(),this.initStartMarkerHandle(),this.initEndMarkerHandle(),this.initSelectedAreaRect(),this.group}onChange(){this.settlePosition();let e={timeObservation:this.observation};this.onChange$.next(e)}onMeasurementsChange(){if(super.onMeasurementsChange(),this.hasStart()&&this.hasEnd()){let e=this.startMarkerHandle.getVerticalMeasurement();this.selectedAreaRect.setAttrs({y:e.y,height:e.height});let t={y:this.startMarkerHandle.getHandleGroup().y(),height:this.startMarkerHandle.getHandleGroup().getClientRect().height};this.markerHandleRect.setAttrs({y:e.y+t.y-t.height/2,height:t.height})}this.settlePosition()}initSelectedAreaRect(){if(this.selectedAreaRect&&this.selectedAreaRect.destroy(),this.markerHandleRect&&this.markerHandleRect.destroy(),!this.hasStart()||!this.hasEnd())return;let e=this.startMarkerHandle.getVerticalMeasurement(),t=this.timeline.timeToTimelinePosition(this.observation.start),r=this.timeline.timeToTimelinePosition(this.observation.end);this.selectedAreaRect=new M.Rect({x:t,y:e.y,width:r-t,height:e.height,listening:!1,fill:this.style.color,opacity:this.style.selectedAreaOpacity});let s={y:this.startMarkerHandle.getHandleGroup().y(),height:this.startMarkerHandle.getHandleGroup().getClientRect().height};this.markerHandleRect=new M.Rect({x:t,y:e.y+s.y-s.height/2,width:r-t,height:s.height,listening:!1,fill:this.style.color,opacity:this.style.markerHandleAreaOpacity}),this.group.add(this.selectedAreaRect),this.group.add(this.markerHandleRect)}initStartMarkerHandle(){if(this.startMarkerHandle&&(this.startMarkerHandle.destroy(),this.startMarkerHandle=void 0),!this.hasStart())return;let e=this.timeline.timeToTimelinePosition(this.observation.start);this.startMarkerHandle=new ua({x:e,editable:this.editable,style:{color:this.style.color,markerRenderType:this.style.renderType,markerSymbolType:this.style.symbolType,periodMarkerHandleType:"start"}},this.markerLane,this.timeline),this.startMarkerHandle.onDrag=t=>{this.editable&&(this.hasEnd()&&t.x()>this.endMarkerHandle.getPosition().x&&t.x(this.endMarkerHandle.getPosition().x),this.settleMeasurements(),this.hasStart()&&this.hasEnd()&&this.markerHandleRect.opacity(1))},this.startMarkerHandle.onDragEnd=t=>{if(this.editable){let r=this.timeline.timelinePositionToTime(t.x());this.setTimeObservation({...this.observation,start:r}),this.hasStart()&&this.hasEnd()&&this.markerHandleRect.opacity(this.style.markerHandleAreaOpacity)}},this.group.add(this.startMarkerHandle.initCanvasNode())}initEndMarkerHandle(){if(this.endMarkerHandle&&(this.endMarkerHandle.destroy(),this.endMarkerHandle=void 0),!this.hasEnd())return;let e=this.hasEnd()?this.timeline.timeToTimelinePosition(this.observation.end):void 0;this.endMarkerHandle=new ua({x:e,editable:this.editable,style:{periodMarkerHandleType:"end",color:this.style.color,markerRenderType:this.style.renderType,markerSymbolType:this.style.symbolType}},this.markerLane,this.timeline),this.endMarkerHandle.onDrag=t=>{this.editable&&(this.hasStart()&&t.x()<this.startMarkerHandle.getPosition().x&&t.x(this.startMarkerHandle.getPosition().x),this.settleMeasurements(),this.hasStart()&&this.hasEnd()&&this.markerHandleRect.opacity(1))},this.endMarkerHandle.onDragEnd=t=>{if(this.editable){let r=this.timeline.timelinePositionToTime(t.x());this.setTimeObservation({...this.observation,end:r}),this.hasStart()&&this.hasEnd()&&this.markerHandleRect.opacity(this.style.markerHandleAreaOpacity)}},this.group.add(this.endMarkerHandle.initCanvasNode())}settlePosition(){this.hasStart()&&this.startMarkerHandle.setPosition({...this.startMarkerHandle.getPosition(),x:this.timeline.timeToTimelinePosition(this.observation.start)}),this.hasEnd()&&this.endMarkerHandle.setPosition({...this.endMarkerHandle.getPosition(),x:this.timeline.timeToTimelinePosition(this.observation.end)}),this.settleMeasurements()}settleMeasurements(){this.hasStart()&&this.hasEnd()&&(this.selectedAreaRect.setAttrs({x:this.startMarkerHandle.getPosition().x,width:this.endMarkerHandle.getPosition().x-this.startMarkerHandle.getPosition().x}),this.markerHandleRect.setAttrs({x:this.startMarkerHandle.getPosition().x,width:this.endMarkerHandle.getPosition().x-this.startMarkerHandle.getPosition().x}))}setTimeObservation(e){this.editable&&(this.observation=e,this.initStartMarkerHandle(),this.initEndMarkerHandle(),this.initSelectedAreaRect(),this.onChange())}setEditable(e){super.setEditable(e)}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.styleAdapter.onChange$.pipe(k(this.onDestroy$)).subscribe(e=>{this.hasStart()&&this.initStartMarkerHandle(),this.hasEnd()&&this.initEndMarkerHandle(),this.hasStart()&&this.hasEnd()&&this.initSelectedAreaRect()})}hasStart(){return this.observation&&!Ri(this.observation.start)}hasEnd(){return this.observation&&!Ri(this.observation.end)}}const fa={editable:!0,style:{...Jo,markerSymbolSize:20}};class Uf extends Qo{constructor(e,t,r){super({...fa,...e,style:{...fa.style,...e.style}},t,r)}createSymbol(){switch(this.style.markerSymbolType){case"triangle":let t=Z.sqrt(2).mul(this.style.markerSymbolSize).toNumber()/2;return new M.Line({points:[-t,0,t,0,0,t],fill:this.style.color,closed:!0,offsetY:t/2});case"circle":return new M.Circle({fill:this.style.color,radius:this.style.markerSymbolSize/2});case"square":return new M.Rect({fill:this.style.color,width:this.style.markerSymbolSize,height:this.style.markerSymbolSize,rotation:45,offsetX:this.style.markerSymbolSize/2,offsetY:this.style.markerSymbolSize/2});default:throw Error("Unknown type")}}}const pa={description:"",editable:!0,style:{...Yo}};class cl extends Ko{constructor(e){super({...pa,...e,style:{...pa.style,...e.style}}),this.observation.time=_e.coerce.number().min(0).parse(this.observation.time)}createCanvasNode(){return super.createCanvasNode(),this.initMarkerHandle(),this.group}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.styleAdapter.onChange$.subscribe(e=>{this.initMarkerHandle()})}initMarkerHandle(){this.markerHandle&&(this.markerHandle.destroy(),this.markerHandle=void 0);let e=this.timeline.timeToTimelinePosition(this.observation.time);this.markerHandle=new Uf({x:e,editable:this.editable,style:{color:this.style.color,markerRenderType:this.style.renderType,markerSymbolType:this.style.symbolType}},this.markerLane,this.timeline),this.markerHandle.onDragEnd=t=>{if(this.editable){let r=this.timeline.timelinePositionToTime(t.x());this.setTimeObservation({...this.observation,time:r})}},this.group.add(this.markerHandle.initCanvasNode())}onChange(){this.settlePosition();let e={timeObservation:this.observation};this.onChange$.next(e)}onMeasurementsChange(){super.onMeasurementsChange(),this.markerHandle.onMeasurementsChange(),this.settlePosition()}settlePosition(){this.markerHandle.setPosition({...this.markerHandle.getPosition(),x:this.timeline.timeToTimelinePosition(this.observation.time)})}setEditable(e){super.setEditable(e)}}const Zf={...rr};class Ws extends sr{constructor(e){super({...e,style:{...Zf,...e.style}}),this.onMarkerFocus$=new V,this.markers=[],this.markersMap=new Map}createCanvasNode(){return super.createCanvasNode(),this.markersGroup=new M.Group({...F.POSITION_TOP_LEFT,...this.timeline.getTimecodedGroupDimension()}),this.timeline.addToTimecodedMarkersGroup(this.markersGroup),this.bodyGroup}settleLayout(){super.settleLayout();let e=this.timeline.getTimecodedGroupHorizontalMeasurement();[this.markersGroup].forEach(t=>{t.width(e.width)}),this.markers&&this.markers.forEach(t=>{t.onMeasurementsChange()})}destroy(){super.destroy(),this.markersGroup.destroy()}clearContent(){this.removeAllMarkers(),this.markers=[],this.markersMap=new Map,this.markersGroup.destroyChildren()}createMomentMarker(e){return this.addMarker(new cl(e))}createPeriodMarker(e){return this.addMarker(new ul(e))}addMarker(e){if(!this.isInitialized())throw new Error("MarkerLane not initalized. Maybe you forgot to add MarkerLane to Timeline?");if(this.markersMap.has(e.getId()))throw new Error(`Marker with id=${e.getId()} already exists`);return e.setMarkerLane(this),e.setTimeline(this.timeline),e.onClick$.pipe(k(this.onDestroy$)).subscribe(t=>{this.focusMarker(e.getId())}),e.onMouseEnter$.pipe(k(this.onDestroy$)).subscribe(t=>{this.focusMarker(e.getId())}),this.markers.push(e),this.markersMap.set(e.getId(),e),this.markersGroup.add(e.initCanvasNode()),e}removeAllMarkers(){this.markers&&this.markers.forEach(e=>{this.removeMarker(e.getId())})}removeMarker(e){let t=this.getMarker(e);t&&(this.markers.splice(this.markers.findIndex(r=>r.getId()===t.getId()),1),this.markersMap.delete(t.getId()),t.destroy())}getMarker(e){return this.markersMap.get(e)}getMarkers(){return this.markers}focusMarker(e){let t=this.getMarker(e);t&&(this.moveToTop(t),this.markerInFocus=t,this.onMarkerFocus$.next({marker:t}))}getMarkerInFocus(){return this.markerInFocus}moveToTop(e){e&&(this.markersGroup.moveToTop(),e.getCanvasNode().moveToTop())}}class jf{static randomHexColor(){return`#${Math.floor(Math.random()*16777215).toString(16)}`}}class wi{static createGoldenRatioWedge(e){let t=new Z(e.height).div(F.GOLDEN_RATIO+1).toDecimalPlaces(2).toNumber(),r=e.height-t,s=r/2;return new M.Line({points:[e.x-s,e.y,e.x+s,e.y,e.x+s,e.y+r,e.x,e.y+r+t,e.x-s,e.y+r],fill:e.color,stroke:e.color,closed:!0,listening:!1})}static createTriangle(e){let t=e.height/2;return new M.Line({points:[e.x-t,e.y,e.x+t,e.y,e.x,e.y+e.height],fill:e.color,closed:!0,listening:!1})}static createEventCatcher(e={}){return new M.Rect({...F.POSITION_TOP_LEFT,opacity:0,listening:!0,...e})}static createDebugRect(){return new M.Rect({...F.POSITION_TOP_LEFT,width:100,height:100,fill:jf.randomHexColor(),opacity:1})}}function fl(i,e){return function(){return i.apply(e,arguments)}}const{toString:pl}=Object.prototype,{getPrototypeOf:gn}=Object,vn=(i=>e=>{const t=pl.call(e);return i[t]||(i[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),St=i=>(i=i.toLowerCase(),e=>vn(e)===i),ss=i=>e=>typeof e===i,{isArray:Si}=Array,Ki=ss("undefined");function Xf(i){return i!==null&&!Ki(i)&&i.constructor!==null&&!Ki(i.constructor)&&It(i.constructor.isBuffer)&&i.constructor.isBuffer(i)}const ml=St("ArrayBuffer");function qf(i){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(i):e=i&&i.buffer&&ml(i.buffer),e}const Yf=ss("string"),It=ss("function"),gl=ss("number"),yn=i=>i!==null&&typeof i=="object",Kf=i=>i===!0||i===!1,xr=i=>{if(vn(i)!=="object")return!1;const e=gn(i);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in i)&&!(Symbol.iterator in i)},Jf=St("Date"),Qf=St("File"),ep=St("Blob"),tp=St("FileList"),ip=i=>yn(i)&&It(i.pipe),rp=i=>{const e="[object FormData]";return i&&(typeof FormData=="function"&&i instanceof FormData||pl.call(i)===e||It(i.toString)&&i.toString()===e)},sp=St("URLSearchParams"),np=i=>i.trim?i.trim():i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function nr(i,e,{allOwnKeys:t=!1}={}){if(i===null||typeof i>"u")return;let r,s;if(typeof i!="object"&&(i=[i]),Si(i))for(r=0,s=i.length;r<s;r++)e.call(null,i[r],r,i);else{const n=t?Object.getOwnPropertyNames(i):Object.keys(i),a=n.length;let o;for(r=0;r<a;r++)o=n[r],e.call(null,i[o],o,i)}}function vl(i,e){e=e.toLowerCase();const t=Object.keys(i);let r=t.length,s;for(;r-- >0;)if(s=t[r],e===s.toLowerCase())return s;return null}const yl=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),bl=i=>!Ki(i)&&i!==yl;function Us(){const{caseless:i}=bl(this)&&this||{},e={},t=(r,s)=>{const n=i&&vl(e,s)||s;xr(e[n])&&xr(r)?e[n]=Us(e[n],r):xr(r)?e[n]=Us({},r):Si(r)?e[n]=r.slice():e[n]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&nr(arguments[r],t);return e}const ap=(i,e,t,{allOwnKeys:r}={})=>(nr(e,(s,n)=>{t&&It(s)?i[n]=fl(s,t):i[n]=s},{allOwnKeys:r}),i),op=i=>(i.charCodeAt(0)===65279&&(i=i.slice(1)),i),lp=(i,e,t,r)=>{i.prototype=Object.create(e.prototype,r),i.prototype.constructor=i,Object.defineProperty(i,"super",{value:e.prototype}),t&&Object.assign(i.prototype,t)},hp=(i,e,t,r)=>{let s,n,a;const o={};if(e=e||{},i==null)return e;do{for(s=Object.getOwnPropertyNames(i),n=s.length;n-- >0;)a=s[n],(!r||r(a,i,e))&&!o[a]&&(e[a]=i[a],o[a]=!0);i=t!==!1&&gn(i)}while(i&&(!t||t(i,e))&&i!==Object.prototype);return e},dp=(i,e,t)=>{i=String(i),(t===void 0||t>i.length)&&(t=i.length),t-=e.length;const r=i.indexOf(e,t);return r!==-1&&r===t},up=i=>{if(!i)return null;if(Si(i))return i;let e=i.length;if(!gl(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=i[e];return t},cp=(i=>e=>i&&e instanceof i)(typeof Uint8Array<"u"&&gn(Uint8Array)),fp=(i,e)=>{const r=(i&&i[Symbol.iterator]).call(i);let s;for(;(s=r.next())&&!s.done;){const n=s.value;e.call(i,n[0],n[1])}},pp=(i,e)=>{let t;const r=[];for(;(t=i.exec(e))!==null;)r.push(t);return r},mp=St("HTMLFormElement"),gp=i=>i.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,s){return r.toUpperCase()+s}),ma=(({hasOwnProperty:i})=>(e,t)=>i.call(e,t))(Object.prototype),vp=St("RegExp"),_l=(i,e)=>{const t=Object.getOwnPropertyDescriptors(i),r={};nr(t,(s,n)=>{e(s,n,i)!==!1&&(r[n]=s)}),Object.defineProperties(i,r)},yp=i=>{_l(i,(e,t)=>{if(It(i)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const r=i[t];if(It(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},bp=(i,e)=>{const t={},r=s=>{s.forEach(n=>{t[n]=!0})};return Si(i)?r(i):r(String(i).split(e)),t},_p=()=>{},wp=(i,e)=>(i=+i,Number.isFinite(i)?i:e),_s="abcdefghijklmnopqrstuvwxyz",ga="0123456789",wl={DIGIT:ga,ALPHA:_s,ALPHA_DIGIT:_s+_s.toUpperCase()+ga},Sp=(i=16,e=wl.ALPHA_DIGIT)=>{let t="";const{length:r}=e;for(;i--;)t+=e[Math.random()*r|0];return t};function Tp(i){return!!(i&&It(i.append)&&i[Symbol.toStringTag]==="FormData"&&i[Symbol.iterator])}const Cp=i=>{const e=new Array(10),t=(r,s)=>{if(yn(r)){if(e.indexOf(r)>=0)return;if(!("toJSON"in r)){e[s]=r;const n=Si(r)?[]:{};return nr(r,(a,o)=>{const h=t(a,s+1);!Ki(h)&&(n[o]=h)}),e[s]=void 0,n}}return r};return t(i,0)},S={isArray:Si,isArrayBuffer:ml,isBuffer:Xf,isFormData:rp,isArrayBufferView:qf,isString:Yf,isNumber:gl,isBoolean:Kf,isObject:yn,isPlainObject:xr,isUndefined:Ki,isDate:Jf,isFile:Qf,isBlob:ep,isRegExp:vp,isFunction:It,isStream:ip,isURLSearchParams:sp,isTypedArray:cp,isFileList:tp,forEach:nr,merge:Us,extend:ap,trim:np,stripBOM:op,inherits:lp,toFlatObject:hp,kindOf:vn,kindOfTest:St,endsWith:dp,toArray:up,forEachEntry:fp,matchAll:pp,isHTMLForm:mp,hasOwnProperty:ma,hasOwnProp:ma,reduceDescriptors:_l,freezeMethods:yp,toObjectSet:bp,toCamelCase:gp,noop:_p,toFiniteNumber:wp,findKey:vl,global:yl,isContextDefined:bl,ALPHABET:wl,generateString:Sp,isSpecCompliantForm:Tp,toJSONObject:Cp};function ie(i,e,t,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=i,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),r&&(this.request=r),s&&(this.response=s)}S.inherits(ie,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:S.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Sl=ie.prototype,Tl={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(i=>{Tl[i]={value:i}});Object.defineProperties(ie,Tl);Object.defineProperty(Sl,"isAxiosError",{value:!0});ie.from=(i,e,t,r,s,n)=>{const a=Object.create(Sl);return S.toFlatObject(i,a,function(h){return h!==Error.prototype},o=>o!=="isAxiosError"),ie.call(a,i.message,e,t,r,s),a.cause=i,a.name=i.name,n&&Object.assign(a,n),a};const Ep=null;function Zs(i){return S.isPlainObject(i)||S.isArray(i)}function Cl(i){return S.endsWith(i,"[]")?i.slice(0,-2):i}function va(i,e,t){return i?i.concat(e).map(function(s,n){return s=Cl(s),!t&&n?"["+s+"]":s}).join(t?".":""):e}function kp(i){return S.isArray(i)&&!i.some(Zs)}const xp=S.toFlatObject(S,{},null,function(e){return/^is[A-Z]/.test(e)});function ns(i,e,t){if(!S.isObject(i))throw new TypeError("target must be an object");e=e||new FormData,t=S.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,g){return!S.isUndefined(g[m])});const r=t.metaTokens,s=t.visitor||d,n=t.dots,a=t.indexes,h=(t.Blob||typeof Blob<"u"&&Blob)&&S.isSpecCompliantForm(e);if(!S.isFunction(s))throw new TypeError("visitor must be a function");function l(f){if(f===null)return"";if(S.isDate(f))return f.toISOString();if(!h&&S.isBlob(f))throw new ie("Blob is not supported. Use a Buffer instead.");return S.isArrayBuffer(f)||S.isTypedArray(f)?h&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function d(f,m,g){let _=f;if(f&&!g&&typeof f=="object"){if(S.endsWith(m,"{}"))m=r?m:m.slice(0,-2),f=JSON.stringify(f);else if(S.isArray(f)&&kp(f)||(S.isFileList(f)||S.endsWith(m,"[]"))&&(_=S.toArray(f)))return m=Cl(m),_.forEach(function(b,T){!(S.isUndefined(b)||b===null)&&e.append(a===!0?va([m],T,n):a===null?m:m+"[]",l(b))}),!1}return Zs(f)?!0:(e.append(va(g,m,n),l(f)),!1)}const u=[],c=Object.assign(xp,{defaultVisitor:d,convertValue:l,isVisitable:Zs});function p(f,m){if(!S.isUndefined(f)){if(u.indexOf(f)!==-1)throw Error("Circular reference detected in "+m.join("."));u.push(f),S.forEach(f,function(_,w){(!(S.isUndefined(_)||_===null)&&s.call(e,_,S.isString(w)?w.trim():w,m,c))===!0&&p(_,m?m.concat(w):[w])}),u.pop()}}if(!S.isObject(i))throw new TypeError("data must be an object");return p(i),e}function ya(i){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(i).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function bn(i,e){this._pairs=[],i&&ns(i,this,e)}const El=bn.prototype;El.append=function(e,t){this._pairs.push([e,t])};El.toString=function(e){const t=e?function(r){return e.call(this,r,ya)}:ya;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function Pp(i){return encodeURIComponent(i).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function kl(i,e,t){if(!e)return i;const r=t&&t.encode||Pp,s=t&&t.serialize;let n;if(s?n=s(e,t):n=S.isURLSearchParams(e)?e.toString():new bn(e,t).toString(r),n){const a=i.indexOf("#");a!==-1&&(i=i.slice(0,a)),i+=(i.indexOf("?")===-1?"?":"&")+n}return i}class Ap{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){S.forEach(this.handlers,function(r){r!==null&&e(r)})}}const ba=Ap,xl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Mp=typeof URLSearchParams<"u"?URLSearchParams:bn,Op=typeof FormData<"u"?FormData:null,Lp=(()=>{let i;return typeof navigator<"u"&&((i=navigator.product)==="ReactNative"||i==="NativeScript"||i==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Rp=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),rt={isBrowser:!0,classes:{URLSearchParams:Mp,FormData:Op,Blob},isStandardBrowserEnv:Lp,isStandardBrowserWebWorkerEnv:Rp,protocols:["http","https","file","blob","url","data"]};function Ip(i,e){return ns(i,new rt.classes.URLSearchParams,Object.assign({visitor:function(t,r,s,n){return rt.isNode&&S.isBuffer(t)?(this.append(r,t.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},e))}function Np(i){return S.matchAll(/\w+|\[(\w*)]/g,i).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Dp(i){const e={},t=Object.keys(i);let r;const s=t.length;let n;for(r=0;r<s;r++)n=t[r],e[n]=i[n];return e}function Pl(i){function e(t,r,s,n){let a=t[n++];const o=Number.isFinite(+a),h=n>=t.length;return a=!a&&S.isArray(s)?s.length:a,h?(S.hasOwnProp(s,a)?s[a]=[s[a],r]:s[a]=r,!o):((!s[a]||!S.isObject(s[a]))&&(s[a]=[]),e(t,r,s[a],n)&&S.isArray(s[a])&&(s[a]=Dp(s[a])),!o)}if(S.isFormData(i)&&S.isFunction(i.entries)){const t={};return S.forEachEntry(i,(r,s)=>{e(Np(r),s,t,0)}),t}return null}const Gp={"Content-Type":void 0};function Fp(i,e,t){if(S.isString(i))try{return(e||JSON.parse)(i),S.trim(i)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(i)}const as={transitional:xl,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",s=r.indexOf("application/json")>-1,n=S.isObject(e);if(n&&S.isHTMLForm(e)&&(e=new FormData(e)),S.isFormData(e))return s&&s?JSON.stringify(Pl(e)):e;if(S.isArrayBuffer(e)||S.isBuffer(e)||S.isStream(e)||S.isFile(e)||S.isBlob(e))return e;if(S.isArrayBufferView(e))return e.buffer;if(S.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(n){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Ip(e,this.formSerializer).toString();if((o=S.isFileList(e))||r.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return ns(o?{"files[]":e}:e,h&&new h,this.formSerializer)}}return n||s?(t.setContentType("application/json",!1),Fp(e)):e}],transformResponse:[function(e){const t=this.transitional||as.transitional,r=t&&t.forcedJSONParsing,s=this.responseType==="json";if(e&&S.isString(e)&&(r&&!this.responseType||s)){const a=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e)}catch(o){if(a)throw o.name==="SyntaxError"?ie.from(o,ie.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:rt.classes.FormData,Blob:rt.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};S.forEach(["delete","get","head"],function(e){as.headers[e]={}});S.forEach(["post","put","patch"],function(e){as.headers[e]=S.merge(Gp)});const _n=as,Hp=S.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Bp=i=>{const e={};let t,r,s;return i&&i.split(`
11
+ `).forEach(function(a){s=a.indexOf(":"),t=a.substring(0,s).trim().toLowerCase(),r=a.substring(s+1).trim(),!(!t||e[t]&&Hp[t])&&(t==="set-cookie"?e[t]?e[t].push(r):e[t]=[r]:e[t]=e[t]?e[t]+", "+r:r)}),e},_a=Symbol("internals");function xi(i){return i&&String(i).trim().toLowerCase()}function Pr(i){return i===!1||i==null?i:S.isArray(i)?i.map(Pr):String(i)}function $p(i){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=t.exec(i);)e[r[1]]=r[2];return e}function Vp(i){return/^[-_a-zA-Z]+$/.test(i.trim())}function ws(i,e,t,r,s){if(S.isFunction(r))return r.call(this,e,t);if(s&&(e=t),!!S.isString(e)){if(S.isString(r))return e.indexOf(r)!==-1;if(S.isRegExp(r))return r.test(e)}}function zp(i){return i.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}function Wp(i,e){const t=S.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(i,r+t,{value:function(s,n,a){return this[r].call(this,e,s,n,a)},configurable:!0})})}class os{constructor(e){e&&this.set(e)}set(e,t,r){const s=this;function n(o,h,l){const d=xi(h);if(!d)throw new Error("header name must be a non-empty string");const u=S.findKey(s,d);(!u||s[u]===void 0||l===!0||l===void 0&&s[u]!==!1)&&(s[u||h]=Pr(o))}const a=(o,h)=>S.forEach(o,(l,d)=>n(l,d,h));return S.isPlainObject(e)||e instanceof this.constructor?a(e,t):S.isString(e)&&(e=e.trim())&&!Vp(e)?a(Bp(e),t):e!=null&&n(t,e,r),this}get(e,t){if(e=xi(e),e){const r=S.findKey(this,e);if(r){const s=this[r];if(!t)return s;if(t===!0)return $p(s);if(S.isFunction(t))return t.call(this,s,r);if(S.isRegExp(t))return t.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=xi(e),e){const r=S.findKey(this,e);return!!(r&&this[r]!==void 0&&(!t||ws(this,this[r],r,t)))}return!1}delete(e,t){const r=this;let s=!1;function n(a){if(a=xi(a),a){const o=S.findKey(r,a);o&&(!t||ws(r,r[o],o,t))&&(delete r[o],s=!0)}}return S.isArray(e)?e.forEach(n):n(e),s}clear(e){const t=Object.keys(this);let r=t.length,s=!1;for(;r--;){const n=t[r];(!e||ws(this,this[n],n,e,!0))&&(delete this[n],s=!0)}return s}normalize(e){const t=this,r={};return S.forEach(this,(s,n)=>{const a=S.findKey(r,n);if(a){t[a]=Pr(s),delete t[n];return}const o=e?zp(n):String(n).trim();o!==n&&delete t[n],t[o]=Pr(s),r[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return S.forEach(this,(r,s)=>{r!=null&&r!==!1&&(t[s]=e&&S.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
12
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[_a]=this[_a]={accessors:{}}).accessors,s=this.prototype;function n(a){const o=xi(a);r[o]||(Wp(s,a),r[o]=!0)}return S.isArray(e)?e.forEach(n):n(e),this}}os.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);S.freezeMethods(os.prototype);S.freezeMethods(os);const mt=os;function Ss(i,e){const t=this||_n,r=e||t,s=mt.from(r.headers);let n=r.data;return S.forEach(i,function(o){n=o.call(t,n,s.normalize(),e?e.status:void 0)}),s.normalize(),n}function Al(i){return!!(i&&i.__CANCEL__)}function ar(i,e,t){ie.call(this,i??"canceled",ie.ERR_CANCELED,e,t),this.name="CanceledError"}S.inherits(ar,ie,{__CANCEL__:!0});function Up(i,e,t){const r=t.config.validateStatus;!t.status||!r||r(t.status)?i(t):e(new ie("Request failed with status code "+t.status,[ie.ERR_BAD_REQUEST,ie.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}const Zp=rt.isStandardBrowserEnv?function(){return{write:function(t,r,s,n,a,o){const h=[];h.push(t+"="+encodeURIComponent(r)),S.isNumber(s)&&h.push("expires="+new Date(s).toGMTString()),S.isString(n)&&h.push("path="+n),S.isString(a)&&h.push("domain="+a),o===!0&&h.push("secure"),document.cookie=h.join("; ")},read:function(t){const r=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function jp(i){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(i)}function Xp(i,e){return e?i.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):i}function Ml(i,e){return i&&!jp(e)?Xp(i,e):e}const qp=rt.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function s(n){let a=n;return e&&(t.setAttribute("href",a),a=t.href),t.setAttribute("href",a),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=s(window.location.href),function(a){const o=S.isString(a)?s(a):a;return o.protocol===r.protocol&&o.host===r.host}}():function(){return function(){return!0}}();function Yp(i){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(i);return e&&e[1]||""}function Kp(i,e){i=i||10;const t=new Array(i),r=new Array(i);let s=0,n=0,a;return e=e!==void 0?e:1e3,function(h){const l=Date.now(),d=r[n];a||(a=l),t[s]=h,r[s]=l;let u=n,c=0;for(;u!==s;)c+=t[u++],u=u%i;if(s=(s+1)%i,s===n&&(n=(n+1)%i),l-a<e)return;const p=d&&l-d;return p?Math.round(c*1e3/p):void 0}}function wa(i,e){let t=0;const r=Kp(50,250);return s=>{const n=s.loaded,a=s.lengthComputable?s.total:void 0,o=n-t,h=r(o),l=n<=a;t=n;const d={loaded:n,total:a,progress:a?n/a:void 0,bytes:o,rate:h||void 0,estimated:h&&a&&l?(a-n)/h:void 0,event:s};d[e?"download":"upload"]=!0,i(d)}}const Jp=typeof XMLHttpRequest<"u",Qp=Jp&&function(i){return new Promise(function(t,r){let s=i.data;const n=mt.from(i.headers).normalize(),a=i.responseType;let o;function h(){i.cancelToken&&i.cancelToken.unsubscribe(o),i.signal&&i.signal.removeEventListener("abort",o)}S.isFormData(s)&&(rt.isStandardBrowserEnv||rt.isStandardBrowserWebWorkerEnv)&&n.setContentType(!1);let l=new XMLHttpRequest;if(i.auth){const p=i.auth.username||"",f=i.auth.password?unescape(encodeURIComponent(i.auth.password)):"";n.set("Authorization","Basic "+btoa(p+":"+f))}const d=Ml(i.baseURL,i.url);l.open(i.method.toUpperCase(),kl(d,i.params,i.paramsSerializer),!0),l.timeout=i.timeout;function u(){if(!l)return;const p=mt.from("getAllResponseHeaders"in l&&l.getAllResponseHeaders()),m={data:!a||a==="text"||a==="json"?l.responseText:l.response,status:l.status,statusText:l.statusText,headers:p,config:i,request:l};Up(function(_){t(_),h()},function(_){r(_),h()},m),l=null}if("onloadend"in l?l.onloadend=u:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(u)},l.onabort=function(){l&&(r(new ie("Request aborted",ie.ECONNABORTED,i,l)),l=null)},l.onerror=function(){r(new ie("Network Error",ie.ERR_NETWORK,i,l)),l=null},l.ontimeout=function(){let f=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const m=i.transitional||xl;i.timeoutErrorMessage&&(f=i.timeoutErrorMessage),r(new ie(f,m.clarifyTimeoutError?ie.ETIMEDOUT:ie.ECONNABORTED,i,l)),l=null},rt.isStandardBrowserEnv){const p=(i.withCredentials||qp(d))&&i.xsrfCookieName&&Zp.read(i.xsrfCookieName);p&&n.set(i.xsrfHeaderName,p)}s===void 0&&n.setContentType(null),"setRequestHeader"in l&&S.forEach(n.toJSON(),function(f,m){l.setRequestHeader(m,f)}),S.isUndefined(i.withCredentials)||(l.withCredentials=!!i.withCredentials),a&&a!=="json"&&(l.responseType=i.responseType),typeof i.onDownloadProgress=="function"&&l.addEventListener("progress",wa(i.onDownloadProgress,!0)),typeof i.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",wa(i.onUploadProgress)),(i.cancelToken||i.signal)&&(o=p=>{l&&(r(!p||p.type?new ar(null,i,l):p),l.abort(),l=null)},i.cancelToken&&i.cancelToken.subscribe(o),i.signal&&(i.signal.aborted?o():i.signal.addEventListener("abort",o)));const c=Yp(d);if(c&&rt.protocols.indexOf(c)===-1){r(new ie("Unsupported protocol "+c+":",ie.ERR_BAD_REQUEST,i));return}l.send(s||null)})},Ar={http:Ep,xhr:Qp};S.forEach(Ar,(i,e)=>{if(i){try{Object.defineProperty(i,"name",{value:e})}catch{}Object.defineProperty(i,"adapterName",{value:e})}});const em={getAdapter:i=>{i=S.isArray(i)?i:[i];const{length:e}=i;let t,r;for(let s=0;s<e&&(t=i[s],!(r=S.isString(t)?Ar[t.toLowerCase()]:t));s++);if(!r)throw r===!1?new ie(`Adapter ${t} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(S.hasOwnProp(Ar,t)?`Adapter '${t}' is not available in the build`:`Unknown adapter '${t}'`);if(!S.isFunction(r))throw new TypeError("adapter is not a function");return r},adapters:Ar};function Ts(i){if(i.cancelToken&&i.cancelToken.throwIfRequested(),i.signal&&i.signal.aborted)throw new ar(null,i)}function Sa(i){return Ts(i),i.headers=mt.from(i.headers),i.data=Ss.call(i,i.transformRequest),["post","put","patch"].indexOf(i.method)!==-1&&i.headers.setContentType("application/x-www-form-urlencoded",!1),em.getAdapter(i.adapter||_n.adapter)(i).then(function(r){return Ts(i),r.data=Ss.call(i,i.transformResponse,r),r.headers=mt.from(r.headers),r},function(r){return Al(r)||(Ts(i),r&&r.response&&(r.response.data=Ss.call(i,i.transformResponse,r.response),r.response.headers=mt.from(r.response.headers))),Promise.reject(r)})}const Ta=i=>i instanceof mt?i.toJSON():i;function mi(i,e){e=e||{};const t={};function r(l,d,u){return S.isPlainObject(l)&&S.isPlainObject(d)?S.merge.call({caseless:u},l,d):S.isPlainObject(d)?S.merge({},d):S.isArray(d)?d.slice():d}function s(l,d,u){if(S.isUndefined(d)){if(!S.isUndefined(l))return r(void 0,l,u)}else return r(l,d,u)}function n(l,d){if(!S.isUndefined(d))return r(void 0,d)}function a(l,d){if(S.isUndefined(d)){if(!S.isUndefined(l))return r(void 0,l)}else return r(void 0,d)}function o(l,d,u){if(u in e)return r(l,d);if(u in i)return r(void 0,l)}const h={url:n,method:n,data:n,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(l,d)=>s(Ta(l),Ta(d),!0)};return S.forEach(Object.keys(i).concat(Object.keys(e)),function(d){const u=h[d]||s,c=u(i[d],e[d],d);S.isUndefined(c)&&u!==o||(t[d]=c)}),t}const Ol="1.3.3",wn={};["object","boolean","number","function","string","symbol"].forEach((i,e)=>{wn[i]=function(r){return typeof r===i||"a"+(e<1?"n ":" ")+i}});const Ca={};wn.transitional=function(e,t,r){function s(n,a){return"[Axios v"+Ol+"] Transitional option '"+n+"'"+a+(r?". "+r:"")}return(n,a,o)=>{if(e===!1)throw new ie(s(a," has been removed"+(t?" in "+t:"")),ie.ERR_DEPRECATED);return t&&!Ca[a]&&(Ca[a]=!0,console.warn(s(a," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(n,a,o):!0}};function tm(i,e,t){if(typeof i!="object")throw new ie("options must be an object",ie.ERR_BAD_OPTION_VALUE);const r=Object.keys(i);let s=r.length;for(;s-- >0;){const n=r[s],a=e[n];if(a){const o=i[n],h=o===void 0||a(o,n,i);if(h!==!0)throw new ie("option "+n+" must be "+h,ie.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new ie("Unknown option "+n,ie.ERR_BAD_OPTION)}}const js={assertOptions:tm,validators:wn},Et=js.validators;class Xr{constructor(e){this.defaults=e,this.interceptors={request:new ba,response:new ba}}request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=mi(this.defaults,t);const{transitional:r,paramsSerializer:s,headers:n}=t;r!==void 0&&js.assertOptions(r,{silentJSONParsing:Et.transitional(Et.boolean),forcedJSONParsing:Et.transitional(Et.boolean),clarifyTimeoutError:Et.transitional(Et.boolean)},!1),s!==void 0&&js.assertOptions(s,{encode:Et.function,serialize:Et.function},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a;a=n&&S.merge(n.common,n[t.method]),a&&S.forEach(["delete","get","head","post","put","patch","common"],f=>{delete n[f]}),t.headers=mt.concat(a,n);const o=[];let h=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(h=h&&m.synchronous,o.unshift(m.fulfilled,m.rejected))});const l=[];this.interceptors.response.forEach(function(m){l.push(m.fulfilled,m.rejected)});let d,u=0,c;if(!h){const f=[Sa.bind(this),void 0];for(f.unshift.apply(f,o),f.push.apply(f,l),c=f.length,d=Promise.resolve(t);u<c;)d=d.then(f[u++],f[u++]);return d}c=o.length;let p=t;for(u=0;u<c;){const f=o[u++],m=o[u++];try{p=f(p)}catch(g){m.call(this,g);break}}try{d=Sa.call(this,p)}catch(f){return Promise.reject(f)}for(u=0,c=l.length;u<c;)d=d.then(l[u++],l[u++]);return d}getUri(e){e=mi(this.defaults,e);const t=Ml(e.baseURL,e.url);return kl(t,e.params,e.paramsSerializer)}}S.forEach(["delete","get","head","options"],function(e){Xr.prototype[e]=function(t,r){return this.request(mi(r||{},{method:e,url:t,data:(r||{}).data}))}});S.forEach(["post","put","patch"],function(e){function t(r){return function(n,a,o){return this.request(mi(o||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:n,data:a}))}}Xr.prototype[e]=t(),Xr.prototype[e+"Form"]=t(!0)});const Mr=Xr;class Sn{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(n){t=n});const r=this;this.promise.then(s=>{if(!r._listeners)return;let n=r._listeners.length;for(;n-- >0;)r._listeners[n](s);r._listeners=null}),this.promise.then=s=>{let n;const a=new Promise(o=>{r.subscribe(o),n=o}).then(s);return a.cancel=function(){r.unsubscribe(n)},a},e(function(n,a,o){r.reason||(r.reason=new ar(n,a,o),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}static source(){let e;return{token:new Sn(function(s){e=s}),cancel:e}}}const im=Sn;function rm(i){return function(t){return i.apply(null,t)}}function sm(i){return S.isObject(i)&&i.isAxiosError===!0}const Xs={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Xs).forEach(([i,e])=>{Xs[e]=i});const nm=Xs;function Ll(i){const e=new Mr(i),t=fl(Mr.prototype.request,e);return S.extend(t,Mr.prototype,e,{allOwnKeys:!0}),S.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return Ll(mi(i,s))},t}const Ce=Ll(_n);Ce.Axios=Mr;Ce.CanceledError=ar;Ce.CancelToken=im;Ce.isCancel=Al;Ce.VERSION=Ol;Ce.toFormData=ns;Ce.AxiosError=ie;Ce.Cancel=Ce.CanceledError;Ce.all=function(e){return Promise.all(e)};Ce.spread=rm;Ce.isAxiosError=sm;Ce.mergeConfig=mi;Ce.AxiosHeaders=mt;Ce.formToJSON=i=>Pl(S.isHTMLForm(i)?new FormData(i):i);Ce.HttpStatusCode=nm;Ce.default=Ce;const Ea=Ce;function am(i,e){return Ri(e)?Ea.get(i):Ea.get(i,e)}function Ve(i,e){this.message=i,this.error=e}Ve.prototype=Object.create(Error.prototype);const Tn=/([0-9]+)?:?([0-9]{2}):([0-9]{2}\.[0-9]{2,3})/;function om(i,e){e||(e={});const{meta:t=!1,strict:r=!0}=e;if(typeof i!="string")throw new Ve("Input must be a string");i=i.trim(),i=i.replace(/\r\n/g,`
13
13
  `),i=i.replace(/\r/g,`
14
14
  `);const s=i.split(`
15
15
 
16
- `),n=s.shift();if(!n.startsWith("WEBVTT"))throw new He('Must start with "WEBVTT"');const a=n.split(`
17
- `),o=a[0].replace("WEBVTT","");if(o.length>0&&o[0]!==" "&&o[0]!==" ")throw new He("Header comment must start with space or tab");if(s.length===0&&a.length===1)return{valid:!0,strict:r,cues:[],errors:[]};if(!t&&a.length>1&&a[1]!=="")throw new He("Missing blank line after signature");const{cues:h,errors:l}=hm(s,r);if(r&&l.length>0)throw l[0];const d=t?lm(a):null,u={valid:l.length===0,strict:r,cues:h,errors:l};return t&&(u.meta=d),u}function lm(i){const e={};return i.slice(1).forEach(t=>{const r=t.indexOf(":"),s=t.slice(0,r).trim(),n=t.slice(r+1).trim();e[s]=n}),Object.keys(e).length>0?e:null}function hm(i,e){const t=[];return{cues:i.map((s,n)=>{try{return dm(s,n,e)}catch(a){return t.push(a),null}}).filter(Boolean),errors:t}}function dm(i,e,t){let r="",s=0,n=.01,a="",o="";const h=i.split(`
18
- `).filter(Boolean);if(h.length>0&&h[0].trim().startsWith("NOTE"))return null;if(h.length===1&&!h[0].includes("-->"))throw new He(`Cue identifier cannot be standalone (cue #${e})`);if(h.length>1&&!(h[0].includes("-->")||h[1].includes("-->"))){const d=`Cue identifier needs to be followed by timestamp (cue #${e})`;throw new He(d)}h.length>1&&h[1].includes("-->")&&(r=h.shift());const l=typeof h[0]=="string"&&h[0].split(" --> ");if(l.length!==2||!ka(l[0])||!ka(l[1]))throw new He(`Invalid cue timestamp (cue #${e})`);if(s=xa(l[0]),n=xa(l[1]),t){if(s>n)throw new He(`Start timestamp greater than end (cue #${e})`);if(n<=s)throw new He(`End must be greater than start (cue #${e})`)}if(!t&&n<s)throw new He(`End must be greater or equal to start when not strict (cue #${e})`);return o=l[1].replace(Tn,"").trim(),h.shift(),a=h.join(`
19
- `),a?{identifier:r,start:s,end:n,text:a,styles:o}:!1}function ka(i){return Tn.test(i)}function xa(i){const e=i.match(Tn);let t=parseFloat(e[1]||0)*60*60;return t+=parseFloat(e[2])*60,t+=parseFloat(e[3]),t}var Rl={ParserError:He,parse:om};function Pe(i,e){this.message=i,this.error=e}Pe.prototype=Object.create(Error.prototype);function um(i){if(!i)throw new Pe("Input must be non-null");if(typeof i!="object")throw new Pe("Input must be an object");if(Array.isArray(i))throw new Pe("Input cannot be array");if(!i.valid)throw new Pe("Input must be valid");let e=`WEBVTT
16
+ `),n=s.shift();if(!n.startsWith("WEBVTT"))throw new Ve('Must start with "WEBVTT"');const a=n.split(`
17
+ `),o=a[0].replace("WEBVTT","");if(o.length>0&&o[0]!==" "&&o[0]!==" ")throw new Ve("Header comment must start with space or tab");if(s.length===0&&a.length===1)return{valid:!0,strict:r,cues:[],errors:[]};if(!t&&a.length>1&&a[1]!=="")throw new Ve("Missing blank line after signature");const{cues:h,errors:l}=hm(s,r);if(r&&l.length>0)throw l[0];const d=t?lm(a):null,u={valid:l.length===0,strict:r,cues:h,errors:l};return t&&(u.meta=d),u}function lm(i){const e={};return i.slice(1).forEach(t=>{const r=t.indexOf(":"),s=t.slice(0,r).trim(),n=t.slice(r+1).trim();e[s]=n}),Object.keys(e).length>0?e:null}function hm(i,e){const t=[];return{cues:i.map((s,n)=>{try{return dm(s,n,e)}catch(a){return t.push(a),null}}).filter(Boolean),errors:t}}function dm(i,e,t){let r="",s=0,n=.01,a="",o="";const h=i.split(`
18
+ `).filter(Boolean);if(h.length>0&&h[0].trim().startsWith("NOTE"))return null;if(h.length===1&&!h[0].includes("-->"))throw new Ve(`Cue identifier cannot be standalone (cue #${e})`);if(h.length>1&&!(h[0].includes("-->")||h[1].includes("-->"))){const d=`Cue identifier needs to be followed by timestamp (cue #${e})`;throw new Ve(d)}h.length>1&&h[1].includes("-->")&&(r=h.shift());const l=typeof h[0]=="string"&&h[0].split(" --> ");if(l.length!==2||!ka(l[0])||!ka(l[1]))throw new Ve(`Invalid cue timestamp (cue #${e})`);if(s=xa(l[0]),n=xa(l[1]),t){if(s>n)throw new Ve(`Start timestamp greater than end (cue #${e})`);if(n<=s)throw new Ve(`End must be greater than start (cue #${e})`)}if(!t&&n<s)throw new Ve(`End must be greater or equal to start when not strict (cue #${e})`);return o=l[1].replace(Tn,"").trim(),h.shift(),a=h.join(`
19
+ `),a?{identifier:r,start:s,end:n,text:a,styles:o}:!1}function ka(i){return Tn.test(i)}function xa(i){const e=i.match(Tn);let t=parseFloat(e[1]||0)*60*60;return t+=parseFloat(e[2])*60,t+=parseFloat(e[3]),t}var Rl={ParserError:Ve,parse:om};function Pe(i,e){this.message=i,this.error=e}Pe.prototype=Object.create(Error.prototype);function um(i){if(!i)throw new Pe("Input must be non-null");if(typeof i!="object")throw new Pe("Input must be an object");if(Array.isArray(i))throw new Pe("Input cannot be array");if(!i.valid)throw new Pe("Input must be valid");let e=`WEBVTT
20
20
  `;if(i.meta){if(typeof i.meta!="object"||Array.isArray(i.meta))throw new Pe("Metadata must be an object");Object.entries(i.meta).forEach(r=>{if(typeof r[1]!="string")throw new Pe(`Metadata value for "${r[0]}" must be string`);e+=`${r[0]}: ${r[1]}
21
21
  `})}let t=null;return i.cues.forEach((r,s)=>{if(t&&t>r.start)throw new Pe(`Cue number ${s} is not in chronological order`);t=r.start,e+=`
22
22
  `,e+=cm(r),e+=`
@@ -28,23 +28,23 @@
28
28
  ${JSON.stringify(i)}`);if(typeof i.styles!="string")throw new Pe(`Cue malformed: null styles value.
29
29
  ${JSON.stringify(i)}`);let e="";i.identifier.length>0&&(e+=`${i.identifier}
30
30
  `);const t=Pa(i.start),r=Pa(i.end);return e+=`${t} --> ${r}`,e+=i.styles?` ${i.styles}`:"",e+=`
31
- ${i.text}`,e}function Pa(i){const e=br(fm(i),2),t=br(pm(i),2),r=br(mm(i),2),s=br(gm(i),3);return`${e}:${t}:${r}.${s}`}function br(i,e){let t=`${i}`;for(;t.length<e;)t=`0${t}`;return t}function fm(i){return Math.floor(i/60/60)}function pm(i){return Math.floor(i/60)%60}function mm(i){return Math.floor(i%60)}function gm(i){return Math.floor((i%1).toFixed(4)*1e3)}var vm={CompilerError:Pe,compile:um};const ym=Rl.parse;function bm(i,e){e=e||10;const t=ym(i),r=[];let s=[],n=null,a=0,o=0;return t.cues.forEach((h,l)=>{const d=l===0,u=l===t.cues.length-1,c=h.start,p=h.end,f=u?1/0:t.cues[l+1].start,m=d?p:p-c,g=d?0:c-t.cues[l-1].end;a=a+m+g,`${l}`,r.length+1,n&&(s.push(n),a+=n.end-o,n=null),s.push(h);let _=f-p<e&&g<e&&a>e;if(_m(o,e,f,g)){const w=wm(u,p,e,a,o);r.push({duration:w,cues:s}),o+=w,a=0,s=[]}else _=!1;_&&(n=h)}),r}function _m(i,e,t,r){const s=Il(r,e);return(r<=e||s+i<t)&&t-i>=e}function wm(i,e,t,r,s){let n=t;return r>t&&(n=Il(r-t,t)),i?n=parseFloat((e-s).toFixed(2)):n=Math.round(n),n}function Il(i,e){return i+=e-i%e,i}var Nl={segment:bm};const Gl=Nl.segment;function Sm(i,e,t){typeof t>"u"&&(t="900000");const r=Gl(i,e),s=[];return r.forEach((n,a)=>{const o=`WEBVTT
31
+ ${i.text}`,e}function Pa(i){const e=br(fm(i),2),t=br(pm(i),2),r=br(mm(i),2),s=br(gm(i),3);return`${e}:${t}:${r}.${s}`}function br(i,e){let t=`${i}`;for(;t.length<e;)t=`0${t}`;return t}function fm(i){return Math.floor(i/60/60)}function pm(i){return Math.floor(i/60)%60}function mm(i){return Math.floor(i%60)}function gm(i){return Math.floor((i%1).toFixed(4)*1e3)}var vm={CompilerError:Pe,compile:um};const ym=Rl.parse;function bm(i,e){e=e||10;const t=ym(i),r=[];let s=[],n=null,a=0,o=0;return t.cues.forEach((h,l)=>{const d=l===0,u=l===t.cues.length-1,c=h.start,p=h.end,f=u?1/0:t.cues[l+1].start,m=d?p:p-c,g=d?0:c-t.cues[l-1].end;a=a+m+g,`${l}`,r.length+1,n&&(s.push(n),a+=n.end-o,n=null),s.push(h);let _=f-p<e&&g<e&&a>e;if(_m(o,e,f,g)){const w=wm(u,p,e,a,o);r.push({duration:w,cues:s}),o+=w,a=0,s=[]}else _=!1;_&&(n=h)}),r}function _m(i,e,t,r){const s=Il(r,e);return(r<=e||s+i<t)&&t-i>=e}function wm(i,e,t,r,s){let n=t;return r>t&&(n=Il(r-t,t)),i?n=parseFloat((e-s).toFixed(2)):n=Math.round(n),n}function Il(i,e){return i+=e-i%e,i}var Nl={segment:bm};const Dl=Nl.segment;function Sm(i,e,t){typeof t>"u"&&(t="900000");const r=Dl(i,e),s=[];return r.forEach((n,a)=>{const o=`WEBVTT
32
32
  X-TIMESTAMP-MAP=MPEGTS:${t},LOCAL:00:00:00.000
33
33
 
34
34
  ${km(n.cues)}
35
- `,h=Dl(a);s.push({filename:h,content:o})}),s}function Tm(i,e){const t=Gl(i,e),r=Cm(t);return`#EXTM3U
35
+ `,h=Gl(a);s.push({filename:h,content:o})}),s}function Tm(i,e){const t=Dl(i,e),r=Cm(t);return`#EXTM3U
36
36
  #EXT-X-TARGETDURATION:${Math.round(Em(t))}
37
37
  #EXT-X-VERSION:3
38
38
  #EXT-X-MEDIA-SEQUENCE:0
39
39
  #EXT-X-PLAYLIST-TYPE:VOD
40
40
  ${r}
41
41
  #EXT-X-ENDLIST
42
- `}function _r(i,e){return`${"0".repeat(Math.max(0,e-i.toString().length))}${i}`}function Dl(i){return`${i}.vtt`}function Cm(i){const e=[];return i.forEach((t,r)=>{e.push(`#EXTINF:${t.duration.toFixed(5)},
43
- ${Dl(r)}`)}),e.join(`
42
+ `}function _r(i,e){return`${"0".repeat(Math.max(0,e-i.toString().length))}${i}`}function Gl(i){return`${i}.vtt`}function Cm(i){const e=[];return i.forEach((t,r)=>{e.push(`#EXTINF:${t.duration.toFixed(5)},
43
+ ${Gl(r)}`)}),e.join(`
44
44
  `)}function Em(i){let e=0;return i.forEach(t=>{t.duration>e&&(e=t.duration)}),e}function km(i){const e=[];return i.forEach(t=>{e.push(xm(t))}),e.join(`
45
45
 
46
46
  `)}function xm(i){const e=[];i.identifier&&e.push(i.identifier);const t=Aa(i.start),r=Aa(i.end),s=i.styles?`${i.styles}`:"";return e.push(`${t} --> ${r} ${s}`),e.push(i.text),e.join(`
47
- `)}function Aa(i){const e=(i%1).toFixed(3);i=Math.round(i-e);const t=Math.floor(i/3600),r=Math.floor((i-t*3600)/60),s=i-t*3600-r*60;return`${`${_r(t,2)}:`}${_r(r,2)}:${_r(s,2)}.${_r(e*1e3,3)}`}var Pm={hlsSegment:Sm,hlsSegmentPlaylist:Tm};const Am=Rl.parse,Mm=vm.compile,Om=Nl.segment,Lm=Pm;var Rm={parse:Am,compile:Mm,segment:Om,hls:Lm};class Cn{constructor(e,t){this.cues=new Map,this.cuesKeysSorted=[],this.url=e,this.axiosConfig=t}fetch(){return tr(am(this.getUrl(),this.axiosConfig)).pipe(ke(e=>{let t=e.data;try{return Rm.parse(t,{strict:!0,meta:!0}).cues.forEach(s=>{let n=this.mapCue(s);this.cues.set(n.startTime,n),this.cuesKeysSorted.push(n.startTime)}),this.cuesKeysSorted.sort((s,n)=>s-n),!0}catch(r){return console.error(r),!1}}))}getUrl(){return this.url}hasCues(){return this.cues&&this.cues.size>0}findCue(e){let t=this.findCues(e,e);if(t&&t.length===1)return t[0]}findCues(e,t){let r=this.findCueIndex(e),s=this.findCueIndex(t);return s===-1?[]:this.cuesKeysSorted.slice(r,s+1).map(n=>this.cues.get(n))}getCues(){return[...this.cues.values()]}findCueIndex(e){let t=0,r=this.cuesKeysSorted.length-1;for(;t<=r;){const s=Math.floor((t+r)/2);if(this.cuesKeysSorted[s]===e)return s;this.cuesKeysSorted[s]<e?t=s+1:r=s-1}return r===-1&&(r=0),r}}class En extends Cn{constructor(e,t){super(e,t)}static create(e,t){let r=new En(e,t);return r.fetch().pipe(ke(s=>r))}mapCue(e){return{id:e.identifier,startTime:new Z(e.start).toDecimalPlaces(3).toNumber(),endTime:new Z(e.end).toDecimalPlaces(3).toNumber(),text:e.text}}}const Ma={listening:!0,style:{height:20,fill:"rgba(255,73,145)",opacity:1,visible:!0}};class Im extends Je{constructor(e,t){super({...Ma,...e,style:{...Ma.style,...e.style}}),this.textTrackCue=this.config.textTrackCue,this.x=this.config.x,this.width=this.config.width,this.listening=this.config.listening,this.subtitlesLane=t,this.subtitlesLane.onSettleLayout$.pipe(k(this.onDestroy$)).subscribe(()=>{let r=this.subtitlesLane.resolveItemHorizontalMeasurement(this.getTextTrackCue());this.setHorizontalMeasurement(r)})}createCanvasNode(){return this.group=new M.Group({x:this.x,y:0,width:this.width,height:this.style.height,visible:this.style.visible,listening:this.listening}),this.backgroundRect=new M.Rect({x:0,y:0,width:this.group.width(),height:this.group.height(),fill:this.style.fill,opacity:this.style.opacity,perfectDrawEnabled:!1,shadowForStrokeEnabled:!1,hitStrokeWidth:0}),this.group.add(this.backgroundRect),this.group}onMeasurementsChange(){this.backgroundRect.size(this.group.getSize())}setPosition(e){this.x=e.x,this.isInitialized()&&this.group.position({x:this.x,y:0})}getPosition(){return this.group.getPosition()}getDimension(){return this.group.getSize()}getRect(){return{...this.getPosition(),...this.getDimension()}}getHorizontalMeasurement(){return{x:this.x,width:this.width}}setHorizontalMeasurement(e){this.x=e.x,this.width=e.width,this.isInitialized()&&this.group.setAttrs({x:this.x,width:this.width}),this.onMeasurementsChange()}setVisible(e){this.style={visible:e},this.isInitialized()&&this.group.visible(e)}getTextTrackCue(){return this.textTrackCue}setTextTrackCue(e){this.textTrackCue=e}compareTo(e){return this.textTrackCue&&e&&this.getTextTrackCue().id===e.getTextTrackCue().id&&this.getTextTrackCue().startTime===e.getTextTrackCue().startTime&&this.getTextTrackCue().endTime===e.getTextTrackCue().endTime?0:-1}destroy(){this.textTrackCue=void 0,this.subtitlesLane=void 0,super.destroy()}}const Nm={...rr,height:40,paddingTop:0,paddingBottom:0,subtitlesLaneItemOpacity:.9,subtitlesLaneItemFill:"rgba(255,73,145)"};class qs extends sr{constructor(e){super({...e,style:{...Nm,...e.style}}),this.subtitlesLaneItemsMap=new Map,this.onSettleLayout$=new V,this._subtitlesVttUrl=this.config.subtitlesVttUrl}createCanvasNode(){return super.createCanvasNode(),this.timecodedGroup=new M.Group({...this.timelinePosition,width:this.timeline.getTimecodedGroupDimension().width,height:this.bodyGroup.height()}),this.timecodedEventCatcher=wi.createEventCatcher({width:this.timecodedGroup.width(),height:this.timecodedGroup.height()}),this.subtitlesLaneItemsGroup=new M.Group({...F.POSITION_TOP_LEFT,y:this.style.paddingTop,width:this.timecodedGroup.width(),height:this.timecodedGroup.height()-(this.style.paddingTop+this.style.paddingBottom)}),this.timecodedGroup.add(this.timecodedEventCatcher),this.timecodedGroup.add(this.subtitlesLaneItemsGroup),this.timeline.addToTimecodedSubtitlesGroup(this.timecodedGroup),this.bodyGroup}settleLayout(){super.settleLayout(),this.timecodedGroup.setAttrs({...this.timelinePosition});let e=this.timeline.getTimecodedGroupHorizontalMeasurement();[this.timecodedGroup,this.timecodedEventCatcher,this.subtitlesLaneItemsGroup].forEach(t=>{t.width(e.width)}),this.onSettleLayout$.next()}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.fetchAndCreateSubtitles()}clearContent(){this.subtitlesVttFile=void 0,this.clearItems()}clearItems(){this.subtitlesLaneItemsMap.forEach(e=>e.destroy()),this.subtitlesLaneItemsMap.clear(),this.subtitlesLaneItemsGroup.destroyChildren()}createEntities(){if(!this.isVttLoaded())return;this.clearItems(),this.subtitlesVttFile.getCues().forEach(t=>{let r=this.resolveItemHorizontalMeasurement(t),s=new Im({...r,textTrackCue:t,style:{height:this.subtitlesLaneItemsGroup.height(),fill:this.style.subtitlesLaneItemFill,opacity:this.style.subtitlesLaneItemOpacity}},this);this.subtitlesLaneItemsMap.set(t.startTime,s),this.subtitlesLaneItemsGroup.add(s.initCanvasNode())})}resolveItemHorizontalMeasurement(e){let t=this.timeline.constrainTimelinePosition(this.timeline.timeToTimelinePosition(e.startTime)),r=this.timeline.constrainTimelinePosition(this.timeline.timeToTimelinePosition(e.endTime));return{x:t,width:r-t}}fetchAndCreateSubtitles(){this.fetchSubtitlesVttFile(this._subtitlesVttUrl).pipe(ft(1)).subscribe(e=>{this.subtitlesVttFile=e,this.createEntities()})}fetchSubtitlesVttFile(e){return e?En.create(e).pipe(ke(t=>t),yi((t,r)=>Ee(void 0))):Ee(void 0)}isVttLoaded(){return!!this.subtitlesVttFile}get subtitlesVttUrl(){return this._subtitlesVttUrl}set subtitlesVttUrl(e){this._subtitlesVttUrl=e,this.clearContent(),this.fetchAndCreateSubtitles()}}const Gm={listening:!1,style:{...F.POSITION_TOP_LEFT,...F.DIMENSION_ZERO,stroke:"rgba(255,73,145)",strokeWidth:5,visible:!1}};class Ys extends Je{constructor(e){super(_i(e,Gm)),this.onClick$=new V,this.onMouseOver$=new V,this.onMouseMove$=new V,this.onMouseOut$=new V,this.onMouseLeave$=new V,this.listening=this.config.listening}createCanvasNode(){return this.group=new M.Group({x:this.style.x,y:this.style.y,width:this.style.width,height:this.style.height,visible:this.style.visible,listening:this.listening}),this.backgroundRect=new M.Rect({x:0,y:0,width:this.group.width(),height:this.group.height(),strokeWidth:this.style.strokeWidth,stroke:this.style.stroke}),this.group.add(this.backgroundRect),this.group}afterCanvasNodeInit(){this.group.on("click",e=>{this.onClick$.next({thumbnail:this})}),this.group.on("mouseover",e=>{this.onMouseOver$.next({thumbnail:this})}),this.group.on("mousemove",e=>{this.onMouseMove$.next({thumbnail:this})}),this.group.on("mouseout",e=>{this.onMouseOut$.next({thumbnail:this})}),this.group.on("mouseleave",e=>{this.onMouseLeave$.next({thumbnail:this})})}destroy(){this.thumbnailVttCue=void 0;for(let t in this.group.eventListeners)this.group.removeEventListener(t);let e=[this.onClick$,this.onMouseOver$,this.onMouseMove$,this.onMouseOut$,this.onMouseLeave$];Vt(...e),bi(...e),super.destroy()}onMeasurementsChange(){this.backgroundRect.size(this.group.getSize())}setImage(e){this.image&&this.image.destroy(),this.image=e,this.style={width:e.width(),height:e.height()},this.group.setAttrs({...this.image.getSize()}),this.backgroundRect.setAttrs({...this.image.getSize()}),this.group.add(this.image)}setVisible(e){this.style={visible:e},this.isInitialized()&&this.group.visible(e)}setPosition(e){this.style={...e},this.isInitialized()&&this.group.position(e)}setVisibleAndX(e,t){this.style={visible:e,x:t},this.isInitialized()&&this.group.setAttrs({visible:e,x:t})}getPosition(){return this.group.getPosition()}getDimension(){return this.group.getSize()}setDimension(e){this.style={...e},this.isInitialized()&&this.group.size(e),this.onMeasurementsChange()}getRect(){return{...this.getPosition(),...this.getDimension()}}getThumbnailVttCue(){return this.thumbnailVttCue}setThumbnailVttCue(e){this.thumbnailVttCue=e}getImage(){return this.image}compareTo(e){return this.thumbnailVttCue&&e&&this.thumbnailVttCue.url===e.thumbnailVttCue.url?0:-1}}class ls extends Cn{constructor(e,t){super(e,t)}static create(e,t){let r=new ls(e,t);return r.fetch().pipe(ke(s=>r))}mapCue(e){return{id:e.identifier,startTime:new Z(e.start).toDecimalPlaces(3).toNumber(),endTime:new Z(e.end).toDecimalPlaces(3).toNumber(),text:e.text,url:this.resolveThumbnailUrl(e)}}resolveThumbnailUrl(e){return this.isUrlAbsolute(e.text)?e.text:this.createThumbnailUrlFromRelativeUrl(e.text)}createThumbnailUrlFromRelativeUrl(e){return this.url.lastIndexOf("/")>2?`${this.url.substring(0,this.url.lastIndexOf("/"))}/${e}`:e}isUrlAbsolute(e){return/^(http(s):\/\/.)[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/.test(e)}}class ut{static createKonvaImage(e){return new se(t=>{M.Image.fromURL(e,r=>{t.next(r),t.complete()},r=>{console.error(r),t.error(r)})})}static createKonvaImageSizedByWidth(e,t){return ut.createKonvaImage(e).pipe(ke(r=>(r.setAttrs({width:t,height:ut.calculateProportionalHeight(t,r)}),r)))}static createKonvaImageSizedByHeight(e,t){return ut.createKonvaImage(e).pipe(ke(r=>(r.setAttrs({width:ut.calculateProportionalWidth(t,r),height:t}),r)))}static calculateProportionalHeight(e,t){return e*t.getAttrs().image.naturalHeight/t.getAttrs().image.naturalWidth}static calculateProportionalWidth(e,t){return e*t.getAttrs().image.naturalWidth/t.getAttrs().image.naturalHeight}}const Dm={...rr,thumbnailHeight:40,thumbnailStroke:"rgba(121,0,255,0.9)",thumbnailStrokeWidth:0,thumbnailHoverScale:1.5,thumbnailHoverStroke:"rgba(0,255,188,0.9)",thumbnailHoverStrokeWidth:5};class Ks extends sr{constructor(e){super({...e,style:{...Dm,...e.style}}),this.thumbnailsMap=new Map,this.thumbnailsVisibleSet=new Set,this.onSettleLayout$=new V,this.eventStreamBreaker$=new V,this.onClick$=new V,this._thumbnailVttUrl=this.config.thumbnailVttUrl,this._axiosConfig=this.config.axiosConfig}createCanvasNode(){return super.createCanvasNode(),this.timecodedGroup=new M.Group({...this.timelinePosition,width:this.timeline.getTimecodedGroupDimension().width,height:this.bodyGroup.height()}),this.timecodedEventCatcher=wi.createEventCatcher({width:this.timecodedGroup.width(),height:this.timecodedGroup.height()}),this.thumbnailsGroup=new M.Group({x:0,y:this.style.height/2-this.style.thumbnailHeight/2,width:this.timecodedGroup.width(),height:this.timecodedGroup.height()}),this.timecodedGroup.add(this.timecodedEventCatcher),this.timecodedGroup.add(this.thumbnailsGroup),this.timeline.addToTimecodedThumbnailsGroup(this.timecodedGroup),this.thumbnailHover=new Ys({style:{visible:!1,stroke:this.style.thumbnailHoverStroke,strokeWidth:this.style.thumbnailHoverStrokeWidth}}),this.timeline.addToTimecodedSurfaceGroup(this.thumbnailHover.initCanvasNode()),this.bodyGroup}settleLayout(){super.settleLayout(),this.timecodedGroup.setAttrs({...this.timelinePosition});let e=this.timeline.getTimecodedGroupHorizontalMeasurement();[this.timecodedGroup,this.timecodedEventCatcher,this.thumbnailsGroup].forEach(t=>{t.width(e.width)}),this.onSettleLayout$.next()}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.fetchAndCreateThumbnails(),this.onSettleLayout$.pipe(k(this.onDestroy$)).subscribe(()=>{this.hideThumbnailHover(),this.adjustThumbnails()}),this.onSettleLayout$.pipe(k(this.onDestroy$)).pipe(Ho(100)).subscribe(()=>{this.createAndAdjustThumbnails()}),this.timecodedGroup.on("mouseout mouseleave",e=>{this.hideThumbnailHover()})}onMeasurementsChange(){super.onMeasurementsChange(),this.hideThumbnailHover(),this.createAndAdjustThumbnails()}destroy(){super.destroy(),this.timecodedGroup.destroy(),this.thumbnailHover.destroy(),this.fireEventStreamBreaker()}clearContent(){this.fireEventStreamBreaker(),this.thumbnailVttFile=void 0,this.clearItems()}clearItems(){this.thumbnailsMap.forEach(e=>e.destroy()),this.thumbnailsMap.clear(),this.thumbnailsVisibleSet.clear(),this.thumbnailsGroup.destroyChildren()}fireEventStreamBreaker(){$e(this.eventStreamBreaker$),this.eventStreamBreaker$=new V}createAndAdjustThumbnails(){this.isVttLoaded()&&(this.resolveVisibleTimestamps(),this.thumbnailVttFile.getCues().forEach(e=>{let t=this.timeline.timeToTimelinePosition(e.startTime),r=this.thumbnailsVisibleSet.has(e.startTime);if(this.timeline.constrainTimelinePosition(t)===t)if(this.thumbnailsMap.has(e.startTime)){let s=this.thumbnailsMap.get(e.startTime);s&&s.setVisibleAndX(r,t)}else r&&(this.thumbnailsMap.set(e.startTime,null),ut.createKonvaImageSizedByHeight(e.url,this.style.thumbnailHeight).subscribe(s=>{let n=this.thumbnailsVisibleSet.has(e.startTime),a=this.createThumbnail(e,s,n);this.thumbnailsMap.set(e.startTime,a),this.thumbnailsGroup.add(a.getCanvasNode())}))}))}adjustThumbnails(){this.isVttLoaded()&&(this.resolveVisibleTimestamps(),this.thumbnailsMap.forEach(e=>{if(e){let t=this.timeline.timeToTimelinePosition(e.getThumbnailVttCue().startTime),r=this.thumbnailsVisibleSet.has(e.getThumbnailVttCue().startTime);e.setVisibleAndX(r,t)}}))}resolveVisibleTimestamps(){let e;this.thumbnailVttFile.getCues().forEach(r=>{let s=this.timeline.timeToTimelinePosition(r.startTime);this.timeline.constrainTimelinePosition(s)===s&&((e?s>=e:!0)?(e=s+this.thumbnailWidth,this.thumbnailsVisibleSet.add(r.startTime)):this.thumbnailsVisibleSet.delete(r.startTime))})}createThumbnail(e,t,r){let s=this.timeline.timeToTimelinePosition(e.startTime),n=new Ys({listening:!0,style:{x:s,y:0,visible:r,stroke:this.style.thumbnailStroke,strokeWidth:this.style.thumbnailStrokeWidth}});return n.setThumbnailVttCue(e),n.initCanvasNode(),n.setImage(t),n.onClick$.pipe(k(this.eventStreamBreaker$)).subscribe(a=>{this.onClick$.next(a)}),n.onMouseOver$.pipe(k(this.eventStreamBreaker$)).subscribe(a=>{this.showThumbnailHover(a.thumbnail)}),n.onMouseMove$.pipe(k(this.eventStreamBreaker$)).subscribe(a=>{this.showThumbnailHover(a.thumbnail)}),n.onMouseOut$.pipe(k(this.eventStreamBreaker$)).subscribe(a=>{this.hideThumbnailHover()}),n.onMouseLeave$.pipe(k(this.eventStreamBreaker$)).subscribe(a=>{this.hideThumbnailHover()}),n}showThumbnailHover(e){if(this.thumbnailHover.setVisible(!0),this.thumbnailHover.compareTo(e)===0){let t=this.resolveThumbnailHoverPosition(e);this.thumbnailHover.setPosition(t),this.thumbnailHover.setVisible(!0)}else ut.createKonvaImageSizedByWidth(e.getThumbnailVttCue().url,e.getImage().width()*this.style.thumbnailHoverScale).subscribe(t=>{this.thumbnailHover.setDimension(t.getSize()),this.thumbnailHover.setImage(t),this.thumbnailHover.setPosition(this.resolveThumbnailHoverPosition(e)),this.thumbnailHover.getCanvasNode().moveToTop()})}hideThumbnailHover(){this.thumbnailHover&&this.thumbnailHover.style.visible&&this.thumbnailHover.setVisible(!1)}resolveThumbnailHoverPosition(e){let t=this.timeline.getTimecodedGroupRect(),r=this.thumbnailHover.getImage().getSize(),s=e.getPosition().x+e.getDimension().width/2-r.width/2,n=e.style.strokeWidth>0?e.style.strokeWidth/2:0;s=s-n<0?n:s+r.width+n>t.width?t.width-r.width-n:s;let h=this.getRect().y+this.thumbnailsGroup.y()+e.getDimension().height/2-this.thumbnailHover.getDimension().height/2;return{x:s,y:h}}fetchAndCreateThumbnails(){this.fetchThumbnailVttFile(this._thumbnailVttUrl,this._axiosConfig,this.style.thumbnailHeight).pipe(ft(1)).subscribe(e=>{e&&(this.thumbnailVttFile=e.thumbnailVttFile,this.thumbnailWidth=e.thumbnailWidth,this.createAndAdjustThumbnails())})}fetchThumbnailVttFile(e,t,r){return e?ls.create(e,t).pipe(tc(s=>{let n=s.getCues()[0];return ut.createKonvaImageSizedByHeight(n.url,r).pipe(ke(a=>{let o=a.getSize().width;return{thumbnailVttFile:s,thumbnailWidth:o}}))}),yi((s,n)=>Ee(void 0))):Ee(void 0)}isVttLoaded(){return!!this.thumbnailVttFile&&!!this.thumbnailWidth}getThumbnailVttFile(){return this.thumbnailVttFile}get thumbnailVttUrl(){return this._thumbnailVttUrl}set thumbnailVttUrl(e){this._thumbnailVttUrl=e,this.clearContent(),this.fetchAndCreateThumbnails()}}class kn extends Cn{constructor(e,t){super(e,t)}static create(e,t){let r=new kn(e,t);return r.fetch().pipe(ke(s=>r))}mapCue(e){let t=e.text.split(","),r=_e.coerce.number().min(-1).max(0).parse(t[0]),s=_e.coerce.number().min(0).max(1).parse(t[1]);return{id:e.identifier,startTime:new Z(e.start).toDecimalPlaces(3).toNumber(),endTime:new Z(e.end).toDecimalPlaces(3).toNumber(),text:e.text,minSample:r,maxSample:s}}}const Oa={listening:!1,style:{height:20,cornerRadius:20,opacity:1,visible:!0,maxSampleFillLinearGradientColorStops:[0,"red",.2,"yellow",1,"green"],minSampleFillLinearGradientColorStops:[0,"green",.8,"yellow",1,"red"]}};class Fm extends Je{constructor(e){super({...Oa,...e,style:{...Oa.style,...e.style}}),this.audioVttCue=this.config.audioVttCue,this.x=this.config.x,this.width=this.config.width,this.listening=this.config.listening}createCanvasNode(){this.group=new M.Group({x:this.x,y:0,width:this.width,height:this.style.height,visible:this.style.visible,listening:this.listening});let e=this.style.height/2,t=this.resolveMaxSampleBarHeight(),r=this.resolveMinSampleBarHeight();return this.maxSampleBar=new M.Rect({x:0,width:this.group.width(),y:e-t,height:t,opacity:this.style.opacity,cornerRadius:[this.style.cornerRadius,this.style.cornerRadius,0,0],fillLinearGradientStartPoint:{x:0,y:-(e-t)},fillLinearGradientEndPoint:{x:0,y:t},fillLinearGradientColorStops:this.style.maxSampleFillLinearGradientColorStops,perfectDrawEnabled:!1,shadowForStrokeEnabled:!1,hitStrokeWidth:0}),this.minSampleBar=new M.Rect({x:0,width:this.group.width(),y:e,height:r,opacity:this.style.opacity,cornerRadius:[0,0,this.style.cornerRadius,this.style.cornerRadius],fillLinearGradientStartPoint:{x:0,y:0},fillLinearGradientEndPoint:{x:0,y:e},fillLinearGradientColorStops:this.style.minSampleFillLinearGradientColorStops,perfectDrawEnabled:!1,shadowForStrokeEnabled:!1,hitStrokeWidth:0}),this.group.add(this.maxSampleBar),this.group.add(this.minSampleBar),this.group}resolveMaxSampleBarHeight(){return new Z(this.audioVttCue.maxSample).mul(this.style.height/2).toDecimalPlaces(2).toNumber()}resolveMinSampleBarHeight(){return new Z(this.audioVttCue.minSample).abs().mul(this.style.height/2).toDecimalPlaces(2).toNumber()}setPosition(e){this.x=e.x,this.isInitialized()&&this.group.position({x:this.x,y:0})}getPosition(){return this.group.getPosition()}getDimension(){return this.group.getSize()}getRect(){return{...this.getPosition(),...this.getDimension()}}getAudioVttCue(){return this.audioVttCue}setAudioVttCue(e){this.audioVttCue=e;let t=this.resolveMaxSampleBarHeight(),r=this.resolveMinSampleBarHeight();this.minSampleBar.setAttrs({height:r}),this.maxSampleBar.setAttrs({y:this.style.height/2-t,height:t,fillLinearGradientStartPoint:{x:0,y:-(this.style.height/2-t)},fillLinearGradientEndPoint:{x:0,y:t}})}destroy(){this.audioVttCue=void 0,super.destroy()}}const Hm={...rr,height:40,paddingTop:0,paddingBottom:0,itemWidth:5,itemMinPadding:2,itemCornerRadius:5,maxSampleFillLinearGradientColorStops:[0,"red",.2,"yellow",1,"green"],minSampleFillLinearGradientColorStops:[0,"green",.8,"yellow",1,"red"]};class Fl extends sr{constructor(e){super({...e,style:{...Hm,...e.style}}),this.audioTrackLaneItemsMap=new Map,this.onSettleLayout$=new V,this._audioVttFileUrl=this.config.audioVttFileUrl}createCanvasNode(){return super.createCanvasNode(),this.timecodedGroup=new M.Group({...this.timelinePosition,width:this.timeline.getTimecodedGroupDimension().width,height:this.bodyGroup.height()}),this.timecodedEventCatcher=wi.createEventCatcher({width:this.timecodedGroup.width(),height:this.timecodedGroup.height()}),this.audioTrackLaneItemsGroup=new M.Group({...F.POSITION_TOP_LEFT,y:this.style.paddingTop,width:this.timecodedGroup.width(),height:this.timecodedGroup.height()-(this.style.paddingTop+this.style.paddingBottom)}),this.timecodedGroup.add(this.timecodedEventCatcher),this.timecodedGroup.add(this.audioTrackLaneItemsGroup),this.timeline.addToTimecodedAudioGroup(this.timecodedGroup),this.bodyGroup}settleLayout(){super.settleLayout(),this.timecodedGroup.setAttrs({...this.timelinePosition});let e=this.timeline.getTimecodedGroupHorizontalMeasurement();[this.timecodedGroup,this.timecodedEventCatcher,this.audioTrackLaneItemsGroup].forEach(t=>{t.width(e.width)}),this.onSettleLayout$.next()}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.fetchAndCreateAudioTrack(),this.onSettleLayout$.pipe(k(this.onDestroy$)).subscribe(()=>{this.settlePosition()}),Nu([this.onSettleLayout$,this.timeline.onScroll$]).pipe(k(this.onDestroy$),Ho(100)).subscribe(()=>{this.settleAll()})}clearContent(){this.audioVttFile=void 0,this.clearItems()}clearItems(){this.audioTrackLaneItemsMap.forEach(e=>e.destroy()),this.audioTrackLaneItemsMap.clear(),this.audioTrackLaneItemsGroup.destroyChildren()}getVisibleCues(){let e=this.timeline.getVisibleTimeRange();return this.audioVttFile.findCues(e.start,e.end)}createEntities(){if(!this.isVttLoaded())return;this.clearItems();let e=this.getVisibleCues(),t=this.timeline.getTimecodedContainerDimension().width;this.numOfInterpolations=new Z(t+this.style.itemMinPadding).div(this.style.itemWidth+this.style.itemMinPadding).floor().toNumber(),this.itemPadding=new Z(t-this.numOfInterpolations*this.style.itemWidth).div(this.numOfInterpolations-1).toNumber();let r=this.resolveNumOfCuesPerInterpolation(e.length),s=this.resolveCuesInterpolations(e,r);for(let n=0;n<this.numOfInterpolations;n++){let a=s.get(n),o=this.resolveInterpolatedItemPosition(n),h=new Fm({x:o,width:this.style.itemWidth,audioVttCue:a,style:{cornerRadius:this.style.itemCornerRadius,height:this.audioTrackLaneItemsGroup.height(),visible:!0,maxSampleFillLinearGradientColorStops:this.style.maxSampleFillLinearGradientColorStops,minSampleFillLinearGradientColorStops:this.style.minSampleFillLinearGradientColorStops}});this.audioTrackLaneItemsMap.set(n,h),this.audioTrackLaneItemsGroup.add(h.initCanvasNode())}}resolveNumOfCuesPerInterpolation(e){return new Z(e).div(this.numOfInterpolations).floor().toNumber()}resolveCuesInterpolations(e,t){let r=e.length-t*this.numOfInterpolations,s=new Map,n=0;for(let a=0;a<this.numOfInterpolations;a++){let o=t+(a<r?1:0),h=n;n=h+o;let l=e.slice(h,n),d=e[h],u=e[n-1],c=0,p=0;l.forEach(m=>{c+=m.minSample,p+=m.maxSample});let f={id:`${a}`,text:"",minSample:new Z(c).div(o).toDecimalPlaces(3).toNumber(),maxSample:new Z(p).div(o).toDecimalPlaces(3).toNumber(),startTime:d.startTime,endTime:u.endTime};s.set(a,f)}return s}settleAll(){if(!this.isVttLoaded()||this.audioTrackLaneItemsMap.size<1)return;let e=this.getVisibleCues(),t=this.resolveNumOfCuesPerInterpolation(e.length),r=this.resolveCuesInterpolations(e,t);for(let s=0;s<this.numOfInterpolations;s++){let n=r.get(s),a=this.audioTrackLaneItemsMap.get(s);a.setAudioVttCue(n),a.setPosition({x:this.resolveInterpolatedItemPosition(s)})}}resolveInterpolatedItemPosition(e){return Math.abs(this.timeline.getTimecodedGroupHorizontalMeasurement().x)+e*this.style.itemWidth+e*this.itemPadding}settlePosition(){if(!(!this.isVttLoaded()||this.audioTrackLaneItemsMap.size<1))for(let e=0;e<this.numOfInterpolations;e++){let t=this.audioTrackLaneItemsMap.get(e),r=this.timeline.timeToTimelinePosition(t.getAudioVttCue().startTime);t.setPosition({x:r})}}fetchAndCreateAudioTrack(){this.fetchAudioTrackVttFile(this._audioVttFileUrl).pipe(ft(1)).subscribe(e=>{this.audioVttFile=e,this.createEntities()})}fetchAudioTrackVttFile(e){return e?kn.create(e).pipe(ke(t=>t),yi((t,r)=>Ee(void 0))):Ee(void 0)}isVttLoaded(){return!!this.audioVttFile}get audioVttFileUrl(){return this._audioVttFileUrl}set audioVttFileUrl(e){this._audioVttFileUrl=e,this.clearContent(),this.fetchAndCreateAudioTrack()}destroy(){this.audioTrackLaneItemsMap.forEach(e=>{e.destroy()}),this.audioVttFile=void 0,$e(this.onSettleLayout$),super.destroy()}}function Js(i){if(i.from===i.to)return;let e=i.from<i.to,t=e?i.to-i.from:i.from-i.to,r=new M.Animation(s=>{let n=M.Easings.StrongEaseInOut(s.time,0,t,i.duration);if(n>=t)i.onUpdateHandler(s,i.to),r.stop(),i.onCompleteHandler&&(i.onCompleteHandler(s,i.to),r=null);else{let a=i.from+n*(e?1:-1);i.onUpdateHandler(s,a)}},i.layer);r.start()}const Bm={...F.POSITION_TOP_LEFT,width:0,zoomMax:1500,scrollStepNumberOfDivisions:10,style:{height:20,backgroundFill:"#000000",backgroundFillOpacity:.3,handleBarFill:"#01a6f0",handleBarOpacity:1,handleOpacity:1}};class $m extends Je{constructor(e){super(_i(e,Bm)),this.onScroll$=new V,this.onZoom$=new V,this.x=this.config.x,this.y=this.config.y,this.width=this.config.width,this.zoomMax=this.config.zoomMax,this.scrollStepNumberOfDivisions=this.config.scrollStepNumberOfDivisions}createCanvasNode(){return this.group=new M.Group({x:this.x,y:this.y,width:this.width,height:this.style.height}),this.background=new M.Rect({...F.POSITION_TOP_LEFT,width:this.group.width(),height:this.style.height,fill:this.style.backgroundFill,opacity:this.style.backgroundFillOpacity}),this.handleGroup=new M.Group({...F.POSITION_TOP_LEFT,width:this.group.width(),height:this.style.height}),this.handleBar=new M.Rect({...F.POSITION_TOP_LEFT,width:this.handleGroup.width(),height:this.style.height,fill:this.style.handleBarFill,opacity:this.style.handleBarOpacity,draggable:!0}),this.leftZoomHandle=new M.Circle({...F.POSITION_TOP_LEFT,fill:this.style.handleBarFill,radius:this.style.height/2,y:this.style.height/2,opacity:this.style.handleOpacity,draggable:!0}),this.rightZoomHandle=new M.Circle({...F.POSITION_TOP_LEFT,fill:this.style.handleBarFill,radius:this.style.height/2,y:this.style.height/2,opacity:this.style.handleOpacity,draggable:!0}),this.handleGroup.add(this.background),this.handleGroup.add(this.handleBar),this.group.add(this.background),this.group.add(this.handleGroup),this.handleGroup.add(this.leftZoomHandle),this.handleGroup.add(this.rightZoomHandle),this.group}afterCanvasNodeInit(){this.styleAdapter.onChange$.pipe(k(this.onDestroy$),Ve(n=>!!n)).subscribe(n=>{this.onStyleChange()}),this.group.on("click",n=>{this.clickScrollTo(this.group.getRelativePointerPosition().x)}),this.handleBar.on("dragstart dragmove dragend",n=>{let a=this.handleBar.getPosition(),o=this.getConstrainedHandleBarX(a.x);this.handleBar.setAttrs({x:o,y:0}),this.syncLeftRightHandles(),this.handleBar.getRelativePointerPosition().x>=0&&this.handleBar.getRelativePointerPosition().x<=this.handleBar.width()&&this.onScroll$.next({scrollPercent:this.getScrollHandlePercent()})});let e={scaleX:1.5,scaleY:1.5,duration:.1},t={scaleX:1,scaleY:1,duration:.1};this.leftZoomHandle.on("mouseover",n=>{this.leftZoomHandle.to({...e}),tt.cursor("ew-resize")}),this.leftZoomHandle.on("mouseout",n=>{this.leftZoomHandle.to({...t}),tt.cursor("default")}),this.rightZoomHandle.on("mouseover",n=>{this.rightZoomHandle.to({...e}),tt.cursor("ew-resize")}),this.rightZoomHandle.on("mouseout",n=>{this.rightZoomHandle.to({...t}),tt.cursor("default")});let r=n=>{let a=n;return a<0?a=0:this.rightZoomHandle.x()-n<=this.minHandleBarWidth&&(a=this.rightZoomHandle.x()-this.minHandleBarWidth),a};this.leftZoomHandle.on("dragstart dragmove dragend",n=>{let a=this.leftZoomHandle.getPosition(),o=r(a.x);this.leftZoomHandle.setAttrs({x:o,y:this.style.height/2}),this.handleBar.setAttrs({x:o,width:this.rightZoomHandle.x()-o}),this.onZoom$.next({zoomPercent:this.getZoomPercent()})});let s=n=>{let a=n,o=this.group.width();return a>o?a=o:n-this.leftZoomHandle.x()<=this.minHandleBarWidth&&(a=this.leftZoomHandle.x()+this.minHandleBarWidth),a};this.rightZoomHandle.on("dragstart dragmove dragend",n=>{let a=this.rightZoomHandle.getPosition(),o=s(a.x);this.rightZoomHandle.setAttrs({x:o,y:this.style.height/2}),this.handleBar.setAttrs({width:o-this.leftZoomHandle.x()}),this.onZoom$.next({zoomPercent:this.getZoomPercent()})})}onMeasurementsChange(){this.group.width(this.width),this.background.width(this.group.width()),this.handleGroup.width(this.group.width()),this.minHandleBarWidth=this.calculateHandleBarWidthFromZoomRatioPercent(this.zoomMax)}onStyleChange(){this.group.setAttrs({height:this.style.height}),this.background.setAttrs({height:this.style.height,fill:this.style.backgroundFill,opacity:this.style.backgroundFillOpacity}),this.handleGroup.setAttrs({height:this.style.height}),this.handleBar.setAttrs({height:this.style.height,fill:this.style.handleBarFill,opacity:this.style.handleBarOpacity}),this.leftZoomHandle.setAttrs({fill:this.style.handleBarFill,radius:this.style.height/2,y:this.style.height/2,opacity:this.style.handleOpacity}),this.rightZoomHandle.setAttrs({fill:this.style.handleBarFill,radius:this.style.height/2,y:this.style.height/2,opacity:this.style.handleOpacity})}getScrollHandleMaxX(){return this.group.width()-this.handleBar.width()}getConstrainedHandleBarX(e){let t=e;return t<0?t=0:t+this.handleBar.width()>this.group.width()&&(t=this.getScrollHandleMaxX()),t}clickScrollTo(e){let t=this.group.width()/this.scrollStepNumberOfDivisions;if(!(e>=this.handleBar.x()&&e<=this.handleBar.x()+this.handleBar.width())){let r=this.handleBar.x()>e,s=this.handleBar.x()+t*(r?-1:1);r?s=s<e?e:s:s=s+this.handleBar.width()>e?e-this.handleBar.width():s,this.scrollToEased(s)}}scrollTo(e){this.handleBar.x(this.getConstrainedHandleBarX(e)),this.syncLeftRightHandles(),this.onScroll$.next({scrollPercent:this.getScrollHandlePercent()})}scrollToEased(e){let t=this.handleBar.x(),r=this.getConstrainedHandleBarX(e);Js({layer:this.handleGroup.getLayer(),duration:F.TIMELINE_SCROLL_EASED_DURATION_MS,from:t,to:r,onUpdateHandler:(s,n)=>{this.scrollTo(n)}})}calculateHandleBarWidthFromZoomRatioPercent(e){return new Z(this.group.width()).mul(100).div(e).toNumber()}getZoomPercent(){return this.group.width()===this.handleBar.width()?100:new Z(this.group.width()).mul(100).div(this.handleBar.width()).toNumber()}getScrollHandlePercent(){return this.handleBar.x()===0?0:new Z(this.handleBar.x()).div(this.group.width()-this.handleBar.width()).mul(100).toNumber()}updateScrollHandle(e){let t=e.getScrollHandleHorizontalMeasurement(this.group.width());this.handleBar.setAttrs({...t}),this.syncLeftRightHandles()}syncLeftRightHandles(){this.leftZoomHandle.x(this.handleBar.x()),this.rightZoomHandle.x(this.handleBar.x()+this.handleBar.width())}setWidth(e){this.width=e,this.onMeasurementsChange()}setPosition(e){this.x=e.x,this.y=e.y,this.group.setAttrs({...e})}getPosition(){return this.group.getPosition()}getRect(){return{...this.group.getPosition(),...this.group.getSize()}}}const Vm={style:{...F.POSITION_TOP_LEFT,height:100,fill:"#737373",fillSnapped:"#ffd500",lineWidth:2,symbolY:0,symbolHeight:15,textFontSize:12,textFill:"#0d0f05",textSnappedFill:"#f43530",visible:!1}};class zm extends Je{constructor(e,t){super(_i(e,Vm)),this.stylesProvider=ht.instance(),this.timeline=t}createCanvasNode(){return this.group=new M.Group({x:this.style.x,y:this.style.y,visible:this.style.visible,listening:!1}),this.line=new M.Line({points:[this.style.x,0,this.style.x,this.style.height],stroke:this.style.fill,strokeWidth:this.style.lineWidth,listening:!1}),this.symbol=new M.Circle({y:this.style.symbolY,fill:this.style.fill,radius:this.style.symbolHeight/2,offsetY:-this.style.symbolHeight/2}),this.group.add(this.symbol),this.group.add(this.line),this.label=new M.Label({...F.POSITION_TOP_LEFT,listening:!1}),this.text=new M.Text({fontSize:this.style.textFontSize,fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily,fill:this.style.textFill,...F.POSITION_TOP_LEFT,text:"",listening:!1}),this.label.y(-this.text.getSelfRect().height),this.label.add(this.text),this.group.add(this.label),this.group}afterCanvasNodeInit(){this.styleAdapter.onChange$.pipe(k(this.onDestroy$)).subscribe(e=>{this.onMeasurementsChange()}),this.stylesProvider.onChange$.pipe(Ve(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.text.setAttrs({fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily})})}onMeasurementsChange(){this.line.points([this.line.x(),0,this.line.x(),this.style.height])}sync(e,t=!1){this.style.visible||this.toggleVisible(!0);let r=this.timeline.timelinePositionToTimeFormatted(e),s=this.text.getSelfRect(),n=s.width/2,a=-n,o=this.timeline.getTimecodedGroupHorizontalMeasurement();o.width-e<n?a=-s.width+(o.width-e):e<n&&(a=-n+(n-e)),this.group.x(e),this.text.text(r),this.label.x(a),t?(this.line.stroke(this.style.fillSnapped),this.text.fill(this.style.fillSnapped),this.symbol.visible(!1)):(this.line.stroke(this.style.fill),this.text.fill(this.style.fill),this.symbol.visible(!0))}toggleVisible(e){this.style={visible:e},this.group.visible(e)}}const Um={style:{visible:!0,fill:"#f43530",lineWidth:2,symbolHeight:15,scrubberHeight:15,backgroundFill:"#ffffff",backgroundOpacity:0,playProgressFill:"#008cbc",playProgressOpacity:.5,bufferedFill:"#a2a2a2",bufferedOpacity:1}};class Wm extends Je{constructor(e,t,r){super(_i(e,Um)),this.timeline=t,this.videoController=r}createCanvasNode(){return this.group=new M.Group({...F.POSITION_TOP_LEFT,listening:!1}),this.background=new M.Rect({...F.POSITION_TOP_LEFT,height:this.style.scrubberHeight,fill:this.style.backgroundFill,opacity:this.style.backgroundOpacity,listening:!1}),this.playProgressBackground=new M.Rect({...F.POSITION_TOP_LEFT,height:this.style.scrubberHeight,fill:this.style.playProgressFill,opacity:this.style.playProgressOpacity,listening:!1}),this.playheadGroup=new M.Group({...F.POSITION_TOP_LEFT,visible:this.style.visible,listening:!1}),this.playheadLine=new M.Line({points:[0,0,0,0],stroke:this.style.fill,strokeWidth:this.style.lineWidth,listening:!1}),this.playheadSymbol=wi.createTriangle({...F.POSITION_TOP_LEFT,height:this.style.symbolHeight,color:this.style.fill}),this.bufferedGroup=new M.Group({...F.POSITION_TOP_LEFT,listening:!1}),this.group.add(this.background),this.group.add(this.bufferedGroup),this.group.add(this.playProgressBackground),this.playheadGroup.add(this.playheadLine),this.playheadGroup.add(this.playheadSymbol),this.group.add(this.playheadGroup),this.group}afterCanvasNodeInit(){this.settleLayout(),this.timeline.onZoom$.pipe(k(this.onDestroy$)).subscribe(e=>{this.settleLayout()}),this.videoController.onVideoLoading$.pipe(k(this.onDestroy$)).subscribe(e=>{this.group.visible(!1)}),this.videoController.onVideoLoaded$.pipe(k(this.onDestroy$)).subscribe(e=>{this.group.visible(!0),this.doPlayProgress(),this.doBufferingProgress()}),this.videoController.onVideoTimeChange$.pipe(k(this.onDestroy$)).subscribe(e=>{this.doPlayProgress()}),this.videoController.onSeeking$.pipe(k(this.onDestroy$)).subscribe(e=>{this.doPlayProgress(),this.doBufferingProgress()}),this.videoController.onBuffering$.pipe(k(this.onDestroy$)).subscribe(e=>{this.doBufferingProgress()})}onMeasurementsChange(){this.settleLayout()}getPlayheadPosition(){return this.playheadGroup.x()}settleLayout(){let e=this.timeline.getTimecodedGroupDimension();[this.group,this.bufferedGroup,this.playheadGroup].forEach(t=>{t.setAttrs({...e})}),[this.background].forEach(t=>{t.setAttrs({width:e.width})}),this.playheadLine.setAttrs({points:[0,0,0,e.height]}),this.doPlayProgress(),this.doBufferingProgress()}doPlayProgress(){let e=this.timeline.timeToTimelinePosition(this.videoController.getCurrentTime());this.playProgressBackground.width(e),this.playheadGroup.x(e)}doBufferingProgress(){let e=this.videoController.getBufferedTimespans();if(e&&e.length>0)if(this.bufferedGroup.hasChildren()){let t=e.length,r=this.bufferedGroup.getChildren().length;t===r?this.bufferedGroup.getChildren().forEach((s,n)=>{let a=e[n],o=this.timeline.timeToTimelinePosition(a.start),h=this.timeline.timeToTimelinePosition(a.end);s.setAttrs({x:o,width:h-o})}):(this.bufferedGroup.getChildren().forEach(s=>s.destroy()),this.createBuffers(e))}else this.createBuffers(e)}createBuffers(e){e.forEach(t=>{let r=this.timeline.timeToTimelinePosition(t.start),s=this.timeline.timeToTimelinePosition(t.end),n=new M.Rect({x:r,y:0,width:s-r,height:this.style.scrubberHeight,fill:this.style.bufferedFill,opacity:this.style.bufferedOpacity,listening:!1});this.bufferedGroup.add(n)})}}const Zm={style:{...F.POSITION_TOP_LEFT,width:150,height:20,textFontSize:20,textFill:"#0d0f05",visible:!0}};class Hl extends Je{constructor(e,t){super(_i(e,Zm)),this.stylesProvider=ht.instance(),this.videoEventStreamBreaker$=new V,this.videoController=t}createCanvasNode(){return this.group=new M.Group({x:this.style.x,y:this.style.y,width:this.style.width,height:this.style.height,listening:!1,visible:this.style.visible}),this.text=new M.Text({...F.POSITION_TOP_LEFT,width:this.group.width(),height:this.group.height(),text:"",fontSize:this.style.textFontSize,fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily,fill:this.style.textFill,visible:!0,align:"left",verticalAlign:"middle"}),this.group.add(this.text),this.group}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.stylesProvider.onChange$.pipe(Ve(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.text.setAttrs({fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily})}),this.videoController.onVideoLoaded$.pipe(Ve(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.onVideoLoadedEvent(e)})}onMeasurementsChange(){this.group.width(this.style.width)}fireVideoEventStreamBreaker(){$e(this.videoEventStreamBreaker$),this.videoEventStreamBreaker$=new V}onVideoLoadedEvent(e){this.fireVideoEventStreamBreaker(),this.text.text(this.videoController.formatTimestamp(0)),this.videoController.onVideoTimeChange$.pipe(k(this.videoEventStreamBreaker$)).subscribe(t=>{this.text.text(this.videoController.formatTimestamp(t.currentTime))})}setVisible(e){this.style={visible:e},this.isInitialized()&&this.group.visible(e)}setPosition(e){this.style={...e},this.group.setAttrs({...e}),this.onMeasurementsChange()}getRect(){return this.group.getClientRect()}}const jm={...rr,height:60,tickDivisor:5,tickDivisionMinWidth:18,tickFill:"#0d0f05",tickHeight:12,divisionTickFill:"#000000",divisionTickHeight:12*F.GOLDEN_RATIO,timecodeShowFirst:!0,timecodeFontSize:11,timecodeFill:"#0d0f05"};class Xm extends sr{constructor(e,t){super({...e,style:{...jm,...e.style}}),this.onClick$=new V,this.onMouseEnter$=new V,this.onMouseOver$=new V,this.onMouseMove$=new V,this.onMouseOut$=new V,this.onMouseLeave$=new V,this.videoController=t}createCanvasNode(){return super.createCanvasNode(),this.timecodedGroup=new M.Group({...this.timelinePosition,width:this.timeline.getTimecodedGroupDimension().width,height:this.bodyGroup.height()}),this.timecodedEventCatcher=wi.createEventCatcher({width:this.timecodedGroup.width(),height:this.timecodedGroup.height()}),this.ticksGroup=new M.Group({...F.POSITION_TOP_LEFT,width:this.timecodedGroup.width(),height:this.timecodedGroup.height()}),this.timecodedGroup.add(this.timecodedEventCatcher),this.timecodedGroup.add(this.ticksGroup),this.timeline.addToTimecodedBaseGroup(this.timecodedGroup),this.timecodeDisplay=new Hl({style:{x:10,y:0,width:this.leftGroup.width(),height:this.getRect().height}},this.videoController),this.leftGroup.add(this.timecodeDisplay.initCanvasNode()),this.bodyGroup}settleLayout(){super.settleLayout();let e=this.timeline.getTimecodedGroupHorizontalMeasurement();[this.timecodedGroup,this.timecodedEventCatcher,this.ticksGroup].forEach(t=>{t.width(e.width)}),this.refreshTimeDivisions()}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.timecodedEventCatcher.on("mousemove",e=>{this.onMouseMove$.next({evt:e.evt,position:this.timecodedGroup.getRelativePointerPosition()})}),this.timecodedEventCatcher.on("mouseenter",e=>{this.onMouseEnter$.next({evt:e.evt,position:this.timecodedGroup.getRelativePointerPosition()})}),this.timecodedEventCatcher.on("mouseout",e=>{this.onMouseOut$.next({evt:e.evt,position:this.timecodedGroup.getRelativePointerPosition()})}),this.timecodedEventCatcher.on("mouseleave",e=>{this.onMouseLeave$.next({evt:e.evt,position:this.timecodedGroup.getRelativePointerPosition()})}),this.timecodedEventCatcher.on("click",e=>{this.onClick$.next({evt:e.evt,position:this.timecodedGroup.getRelativePointerPosition()})}),this.videoController.onVideoLoading$.pipe(k(this.onDestroy$)).subscribe(e=>{this.clearContent()}),this.videoController.onVideoLoaded$.pipe(k(this.onDestroy$)).subscribe(e=>{this.settleLayout()})}onStyleChange(){super.onStyleChange(),this.refreshTimeDivisions(!0)}destroy(){this.timecodedGroup.destroy(),this.videoController=null;let e=[this.onClick$,this.onMouseOver$,this.onMouseMove$,this.onMouseOut$,this.onMouseLeave$];Vt(...e),bi(...e),super.destroy()}clearContent(){this.ticksGroup.destroyChildren()}refreshTimeDivisions(e=!1){if(!this.isTimelineReady())return;let t=this.style.tickDivisor,r=this.style.tickDivisionMinWidth,s=this.timeline.getTimecodedGroupRect().width,n=this.resolveTimeDivisionWidth(s,r,t,t),a=new Z(s).div(n).round().toNumber(),o=!e&&this.tickTotalDivisions===a&&!(this.ticksGroup.getChildren().length<1);o||this.clearContent(),this.tickDivisionWidth=n,this.tickTotalDivisions=a;let h=0,l=2,d=2,u=5;for(let c=0;c<this.tickTotalDivisions+1;c++){let p=c===0,f=c===this.tickTotalDivisions,m=c%t===0,g=c*this.tickDivisionWidth,_=m?this.style.divisionTickHeight:this.style.tickHeight,w=this.ticksGroup.height()-_,b=this.ticksGroup.height()-this.style.divisionTickHeight-u;if(o)this.ticksGroup.getChildren()[c].x(g);else{let T=new M.Group({x:g,y:h}),L=0,A=new M.Line({points:[L,w,L,w+_],stroke:this.style.tickFill,strokeWidth:1,listening:!1});T.add(A);let G=new M.Text({fontSize:this.style.timecodeFontSize,fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily,fill:this.style.timecodeFill,text:`${this.timeline.timelinePositionToTimeFormatted(g)}`,listening:!1}),R=G.getSelfRect(),H=p?L+l:f?L-R.width-d:L-R.width/2,$=b-R.height;G.setAttrs({x:H,y:$});let I=m;I=p?this.style.timecodeShowFirst:I,I&&(T.add(G),T.x()+(G.x()>0?0:G.x()),T.y(),G.width()),this.ticksGroup.add(T)}}}resolveTimeDivisionWidth(e,t,r,s){return new Z(e).div(s).floor().greaterThan(t)?this.resolveTimeDivisionWidth(e,t,r,s*r):new Z(e).div(s/r).toNumber()}}const qm={timelineHTMLElementId:"omakase-timeline",playheadHoverSnapArea:5,zoomScale:1.02,zoomBaseline:100,zoomMax:1500,style:{stageMinWidth:700,backgroundFill:"#f5f5f5",headerBackgroundFill:"#f5f5f5",footerBackgroundFill:"#f5f5f5",scrollbarHeight:15,thumbnailHoverWidth:200,thumbnailHoverStroke:"rgba(255,73,145,0.9)",thumbnailHoverStrokeWidth:5,thumbnailHoverYOffset:0,headerHeight:50,footerHeight:50,leftPanelWidth:200,rightPanelLeftGutterWidth:30,rightPanelRightGutterWidth:30,timecodedContainerClipPadding:20,playheadVisible:!0,playheadFill:"#f43530",playheadLineWidth:2,playheadSymbolHeight:15,playheadScrubberHeight:15,playheadBackgroundFill:"#ffffff",playheadBackgroundOpacity:0,playheadPlayProgressFill:"#008cbc",playheadPlayProgressOpacity:.5,playheadBufferedFill:"#a2a2a2",playheadBufferedOpacity:1}},La="omakase_scrubber_lane";class Ym extends Je{constructor(e,t){super(_i(e,qm)),this.scrollWithPlayhead=!0,this.syncTimelineWithPlayheadInProgress=!1,this.mouseWheelEnabled=!1,this.leftPanelVisible=!0,this.videoEventBreaker$=new V,this.onScroll$=new V,this.onZoom$=new V,this.timelineHTMLElementId=this.config.timelineHTMLElementId,this.thumbnailVttUrl=this.config.thumbnailVttUrl,this.axiosConfig=this.config.axiosConfig,this.playheadHoverSnapArea=this.config.playheadHoverSnapArea,this.zoomScale=this.config.zoomScale,this.zoomBaseline=this.config.zoomBaseline,this.zoomMax=this.config.zoomMax,this.timecodedGroupNodes=[],this.timelineLanes=[],this.timelineLanesMap=new Map,this.timelineHTMLElement=document.getElementById(this.timelineHTMLElementId),this.videoController=t}createCanvasNode(){let e=this.resolveStageDimension();return this.width=e.width,this.stage=new M.Stage({container:this.timelineHTMLElementId,...e}),this.layer=new M.Layer,this.stage.add(this.layer),this.layoutGroup=new M.Group({...F.POSITION_TOP_LEFT}),this.layer.add(this.layoutGroup),this.layoutBackground=new M.Rect({...F.POSITION_TOP_LEFT,fill:this.style.backgroundFill}),this.headerGroup=new M.Group({...F.POSITION_TOP_LEFT}),this.headerBackground=new M.Rect({...F.POSITION_TOP_LEFT,fill:this.style.headerBackgroundFill}),this.footerGroup=new M.Group({...F.POSITION_TOP_LEFT}),this.footerBackground=new M.Rect({...F.POSITION_TOP_LEFT,fill:this.style.footerBackgroundFill}),this.bodyGroup=new M.Group({...F.POSITION_TOP_LEFT}),this.bodyContentGroup=new M.Group({...F.POSITION_TOP_LEFT}),this.leftPanel=new M.Group({...F.POSITION_TOP_LEFT}),this.rightPanel=new M.Group({...F.POSITION_TOP_LEFT}),this.timecodedContainer=new M.Group({...F.POSITION_TOP_LEFT}),this.timecodedGroup=new M.Group({...F.POSITION_TOP_LEFT,draggable:!0}),this.timecodedBaseGroup=new M.Group({...F.POSITION_TOP_LEFT,name:"timecodedBaseGroup"}),this.timecodedThumbnailsGroup=new M.Group({...F.POSITION_TOP_LEFT,name:"timecodedThumbnailsGroup"}),this.timecodedSubtitlesGroup=new M.Group({...F.POSITION_TOP_LEFT,name:"timecodedSubtitlesGroup"}),this.timecodedAudioGroup=new M.Group({...F.POSITION_TOP_LEFT,name:"timecodedAudioGroup"}),this.timecodedMarkersGroup=new M.Group({...F.POSITION_TOP_LEFT,name:"timecodedMarkersGroup"}),this.timecodedSurfaceGroup=new M.Group({...F.POSITION_TOP_LEFT,name:"timecodedSurfaceGroup"}),this.timecodedBackground=new M.Rect({...F.POSITION_TOP_LEFT,fill:"yellow",opacity:0,listening:!1}),this.timecodedEventCatcher=wi.createEventCatcher(),this.thumbnailHover=new Ys({style:{visible:!1,stroke:this.style.thumbnailHoverStroke,strokeWidth:this.style.thumbnailHoverStrokeWidth}}),this.layoutGroup.add(this.layoutBackground),this.layoutGroup.add(this.headerGroup),this.layoutGroup.add(this.footerGroup),this.layoutGroup.add(this.bodyGroup),this.headerGroup.add(this.headerBackground),this.footerGroup.add(this.footerBackground),this.bodyGroup.add(this.bodyContentGroup),this.bodyGroup.add(this.leftPanel),this.bodyGroup.add(this.rightPanel),this.rightPanel.add(this.timecodedContainer),this.timecodedContainer.add(this.timecodedGroup),[this.timecodedBackground,this.timecodedEventCatcher,this.timecodedBaseGroup,this.timecodedThumbnailsGroup,this.timecodedSubtitlesGroup,this.timecodedAudioGroup,this.timecodedMarkersGroup,this.timecodedSurfaceGroup].forEach(t=>{this.timecodedGroupNodes.push(t),this.timecodedGroup.add(t)}),this.scrollbar=new $m({style:{height:this.style.scrollbarHeight}}),this.rightPanel.add(this.scrollbar.initCanvasNode()),this.playhead=new Wm({style:{visible:this.style.playheadVisible,fill:this.style.playheadFill,lineWidth:this.style.playheadLineWidth,symbolHeight:this.style.playheadSymbolHeight,backgroundFill:this.style.playheadBackgroundFill,backgroundOpacity:this.style.playheadBackgroundOpacity,scrubberHeight:this.style.playheadScrubberHeight,playProgressFill:this.style.playheadPlayProgressFill,playProgressOpacity:this.style.playheadPlayProgressOpacity,bufferedFill:this.style.playheadBufferedFill,bufferedOpacity:this.style.playheadBufferedOpacity}},this,this.videoController),this.playheadHover=new zm({},this),[this.playhead,this.playheadHover].forEach(t=>{this.addToTimecodedSurfaceGroup(t.initCanvasNode())}),this.headerTimecodeDisplay=new Hl({style:{x:10,y:10,visible:!1}},this.videoController),this.headerGroup.add(this.headerTimecodeDisplay.initCanvasNode()),this.settleLayout(),this.addToTimecodedSurfaceGroup(this.thumbnailHover.initCanvasNode()),this.scrubberLane=new Xm({id:La,description:""},this.videoController),this.addLanes([this.scrubberLane]),this.stage}afterCanvasNodeInit(){this.videoController.onVideoLoading$.pipe(Ve(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.clearContent()}),this.videoController.onVideoLoaded$.pipe(Ve(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.onVideoLoadedEvent(e)}),be(window,"resize").pipe(k(this.onDestroy$)).subscribe(e=>{setTimeout(()=>{this.onWindowResize(e)},200)}),this.timecodedGroup.on("mouseenter",e=>{this.playheadHover.toggleVisible(this.videoController.isVideoLoaded())}),this.timecodedGroup.on("mouseleave",e=>{this.playheadHover.toggleVisible(!1)}),this.timecodedGroup.on("mousemove",e=>{if(!this.videoController.isVideoLoaded())return;let t=this.timecodedGroup.getRelativePointerPosition().x;this.playheadHoverMove(t)}),this.timecodedMarkersGroup.on("mousemove",e=>{if(!this.videoController.isVideoLoaded())return;let t=this.timecodedGroup.getRelativePointerPosition().x;this.playheadHoverMove(t)}),this.timecodedGroup.on("wheel",e=>{if(!this.videoController.isVideoLoaded())return;if(this.mouseWheelEnabled){let r=e.evt;r.preventDefault();let s=r.deltaY>0?"IN":"OUT";r.ctrlKey&&(s=s==="IN"?"OUT":"IN"),this.zoomStep(s,this.timecodedGroup.getRelativePointerPosition().x),this.updateScrollWithPlayhead()}let t=this.timecodedGroup.getRelativePointerPosition().x;this.playheadHoverMove(t)}),this.timecodedGroup.on("dragstart dragmove dragend",e=>{if(!this.videoController.isVideoLoaded()){this.timecodedGroup.setAttrs({...F.POSITION_TOP_LEFT});return}if(e.target===this.timecodedGroup){let t=this.timecodedGroup.getPosition();this.timecodedGroup.setAttrs({x:this.getConstrainedTimelineX(t.x),y:0}),this.onScroll$.next(this.createScrollEvent()),this.scrollbar.updateScrollHandle(this)}this.updateScrollWithPlayhead()}),this.timecodedGroup.on("dragmove",e=>{tt.cursor("grabbing")}),this.timecodedGroup.on("dragend",e=>{tt.cursor("default")}),this.scrubberLane.onMouseMove$.pipe(k(this.onDestroy$)).subscribe(e=>{if(!this.videoController.isVideoLoaded())return;this.mouseWheelEnabled=!0;let t=this.timecodedGroup.getRelativePointerPosition().x,r=this.timelinePositionToTime(t);if(this.thumbnailVttFile){let s=this.thumbnailVttFile.findCue(r);this.showThumbnailHover(s)}}),this.scrubberLane.onMouseEnter$.pipe(k(this.onDestroy$)).subscribe(e=>{this.mouseWheelEnabled=!0}),this.scrubberLane.onMouseLeave$.pipe(k(this.onDestroy$)).subscribe(e=>{this.hideThumbnailHover(),this.mouseWheelEnabled=!1}),this.scrubberLane.onClick$.pipe(k(this.onDestroy$)).subscribe(e=>{if(!this.videoController.isVideoLoaded())return;this.updateScrollWithPlayhead();let t=this.timecodedGroup.getRelativePointerPosition().x;this.playheadHoverMove(t),this.videoController.isVideoLoaded()&&this.videoController.seekToTimestamp(this.timelinePositionToTime(t)).subscribe(()=>{})}),this.scrollbar.onScroll$.pipe(k(this.onDestroy$)).subscribe(e=>{this.videoController.isVideoLoaded()&&(this.setHorizontalScrollPercent(this.scrollbar.getScrollHandlePercent()),this.updateScrollWithPlayhead(),this.onScroll$.next(this.createScrollEvent()))}),this.scrollbar.onZoom$.pipe(k(this.onDestroy$)).subscribe(e=>{this.videoController.isVideoLoaded()&&(this.zoomByPercent(e.zoomPercent,!1),this.updateScrollWithPlayhead())}),this.thumbnailVttUrl&&this.fetchThumbnailVttFile().subscribe()}settleLayout(){this.stage.setAttrs({...this.resolveStageDimension()});let e=this.calculateHeights();this.headerGroup.setAttrs({width:this.width,height:this.style.headerHeight}),this.bodyGroup.setAttrs({y:this.headerGroup.y()+this.headerGroup.height(),width:this.layoutGroup.width(),height:e.bodyHeight}),this.footerGroup.setAttrs({y:this.bodyGroup.y()+this.bodyGroup.height(),width:this.width,height:this.style.footerHeight}),this.layoutGroup.setAttrs({width:this.width,height:e.layoutHeight}),this.layoutBackground.setAttrs({...this.layoutGroup.getSize()}),this.headerBackground.setAttrs({...this.headerGroup.getSize()}),this.footerBackground.setAttrs({...this.footerGroup.getSize()}),[this.bodyContentGroup].forEach(t=>{t.setAttrs({...this.bodyGroup.getSize()})}),[this.leftPanel,this.rightPanel].forEach(t=>{t.setAttrs({height:this.bodyGroup.getSize().height})}),this.leftPanel.setAttrs({width:this.leftPanelVisible?this.style.leftPanelWidth:0,visible:this.leftPanelVisible}),this.rightPanel.setAttrs({x:this.leftPanel.x()+this.leftPanel.width()+this.style.rightPanelLeftGutterWidth,width:this.layoutGroup.width()-(this.leftPanel.width()+this.style.rightPanelLeftGutterWidth+this.style.rightPanelRightGutterWidth)}),[this.timecodedContainer,this.timecodedGroup,...this.timecodedGroupNodes].forEach(t=>{t.setAttrs({...this.rightPanel.getSize()})}),this.timecodedContainer.clipFunc(t=>{t.rect(-this.style.timecodedContainerClipPadding,-500,this.timecodedContainer.width()+2*this.style.timecodedContainerClipPadding,this.timecodedContainer.height()+500)}),this.timecodedThumbnailsGroup.clipFunc(t=>{t.rect(0,0,this.timecodedThumbnailsGroup.width(),this.timecodedThumbnailsGroup.height())}),this.scrollbar.setPosition({...this.scrollbar.getPosition(),y:this.leftPanel.getSize().height}),this.scrollbar.setWidth(this.timecodedContainer.width()),this.scrollbar.updateScrollHandle(this),this.maxTimecodedGroupWidth=this.calculateWidthFromZoomRatioPercent(this.zoomMax),this.playheadHover.style={height:this.timecodedContainer.height()},this.timelineLanes.forEach(t=>{t.onMeasurementsChange()}),this.playhead.onMeasurementsChange()}onMeasurementsChange(){this.settleLayout();let e=this.getTimecodedGroupDimension();this.timelineLanes.forEach(t=>{t.onMeasurementsChange()}),this.zoomByWidth(e.width,this.resolveZoomFocus()),this.scrollbar.updateScrollHandle(this)}onWindowResize(e){let t=this.resolveStageDimension();this.width=t.width,this.onMeasurementsChange()}calculateHeights(){let t=this.getLanes().map(r=>r.getDimension().height).reduce((r,s)=>r+s,0);return{bodyHeight:t,layoutHeight:this.style.headerHeight+t+this.style.footerHeight}}resolveStageDimension(){let e=this.getTimelineHTMLElementRect(),t=this.calculateHeights();return{width:e.width>=this.style.stageMinWidth?e.width:this.style.stageMinWidth,height:t.layoutHeight}}getTimelineHTMLElementRect(){return{x:this.timelineHTMLElement.offsetLeft,y:this.timelineHTMLElement.offsetTop,width:this.timelineHTMLElement.offsetWidth,height:this.timelineHTMLElement.offsetHeight}}showThumbnailHover(e){if(e)if(this.thumbnailHover.setVisible(!0),this.thumbnailHover.getThumbnailVttCue()===e){this.thumbnailHover.setThumbnailVttCue(e);let t=this.resolveThumbnailPosition(this.thumbnailHover);this.thumbnailHover.setPosition(t),this.thumbnailHover.getCanvasNode().moveToTop()}else ut.createKonvaImageSizedByWidth(e.url,this.style.thumbnailHoverWidth).subscribe(t=>{this.thumbnailHover.setThumbnailVttCue(e),this.thumbnailHover.setDimension(t.getSize()),this.thumbnailHover.setImage(t),this.thumbnailHover.setPosition(this.resolveThumbnailPosition(this.thumbnailHover)),this.thumbnailHover.getCanvasNode().moveToTop()})}hideThumbnailHover(){this.thumbnailHover&&this.thumbnailHover.setVisible(!1)}resolveThumbnailPosition(e){let t=this.timecodedGroup.getRelativePointerPosition(),r=this.getTimecodedGroupDimension(),s=e.getImage().getSize(),n=t.x-s.width/2,a=e.style.strokeWidth>0?e.style.strokeWidth/2:0;n=n-a<0?a:n+s.width+a>r.width?r.width-s.width-a:n;let h=this.scrubberLane.getRect();return{x:n,y:h.y+h.height+e.style.strokeWidth/2+this.style.thumbnailHoverYOffset}}createScrollEvent(){return{scrollPercent:this.getHorizontalScrollPercent()}}createZoomEvent(){return{zoomPercent:this.getZoomPercent()}}getHorizontalScrollPercent(){if(this.isSnappedStart())return 0;if(this.isSnappedEnd())return 100;{let e=new Z(this.getTimecodedContainerDimension().width-this.getTimecodedGroupDimension().width).abs();return new Z(this.getTimecodedGroupPosition().x).abs().mul(100).div(e).toNumber()}}setHorizontalScrollPercent(e){this.setTimelinePosition(this.calculateTimelineXFromScrollPercent(e))}getScrollHandleHorizontalMeasurement(e){let t=this.getTimecodedGroupDimension().width,r=this.getTimecodedGroupPosition().x,s;return t<=e?s={width:e,x:0}:s={width:new Z(e).mul(e).div(t).round().toNumber(),x:new Z(r).abs().mul(e).div(t).toNumber()},s}scrollTo(e){return e=_e.coerce.number().min(0).max(100).parse(e),this.scrollToPercentEased(e)}scrollToPlayhead(){let e=-this.playhead.getPlayheadPosition()+this.getTimecodedContainerDimension().width/2;return this.scrollToEased(e)}scrollToPercent(e){let t=this.calculateTimelineXFromScrollPercent(e);this.scrollTimeline(t)}scrollToPercentEased(e){let t=this.calculateTimelineXFromScrollPercent(e);return this.scrollToEased(t)}scrollToEased(e){return new se(t=>{let r=this.getTimecodedGroupPosition().x;Js({layer:this.timecodedGroup.getLayer(),duration:F.TIMELINE_SCROLL_EASED_DURATION_MS,from:r,to:e,onUpdateHandler:(s,n)=>{this.scrollTimeline(n)},onCompleteHandler:(s,n)=>{t.next(this.getHorizontalScrollPercent()),t.complete()}})})}isPlayheadInTimecodedView(){return this.isInVisiblePositionRange(this.playhead.getPlayheadPosition())}updateScrollWithPlayhead(){let e=this.playhead.getPlayheadPosition(),t=e<this.getVisiblePositionRange().start,r=this.isInVisiblePositionRange(e);this.scrollWithPlayhead=r&&!t}syncTimelineWithPlayhead(){return new se(e=>{this.scrollToEased(-this.playhead.getPlayheadPosition()).pipe(ke(t=>{e.next(this.getHorizontalScrollPercent()),e.complete()})).subscribe()})}setTimelinePosition(e){let t=this.getConstrainedTimelineX(e);this.timecodedGroup.x(t)}scrollTimeline(e){let t=this.getTimecodedGroupPosition().x;this.setTimelinePosition(e),this.getTimecodedGroupPosition().x!==t&&(this.scrollbar.updateScrollHandle(this),this.setHorizontalScrollPercent(this.scrollbar.getScrollHandlePercent()),this.onScroll$.next(this.createScrollEvent()))}calculateTimelineXFromScrollPercent(e){e=this.getConstrainedScrollPercent(e);let t=this.getTimecodedGroupDimension(),r=this.getTimecodedContainerDimension();if(t.width>r.width){let s=new Z(r.width-t.width);return new Z(e).mul(s).div(100).toDecimalPlaces(2).toNumber()}else return 0}getZoomPercent(){let e=this.getTimecodedGroupDimension(),t=this.getTimecodedContainerDimension();return e.width>t.width?new Z(e.width).mul(100).div(t.width).round().toNumber():this.zoomBaseline}zoomTo(e){return e=_e.coerce.number().min(this.getZoomBaseline()).max(this.getZoomMax()).parse(e),this.zoomToEased(e)}zoomIn(){return new se(e=>{this.zoomStep("IN",this.timecodedGroup.getRelativePointerPosition().x),e.next(this.getZoomPercent()),e.complete()})}zoomOut(){return new se(e=>{this.zoomStep("OUT",this.timecodedGroup.getRelativePointerPosition().x),e.next(this.getZoomPercent()),e.complete()})}zoomToEased(e){return new se(t=>{e=this.getConstrainedZoomPercent(e);let r=this.getTimecodedGroupDimension().width,s=this.calculateWidthFromZoomRatioPercent(e);Js({layer:this.timecodedGroup.getLayer(),duration:F.TIMELINE_ZOOM_EASED_DURATION_MS,from:r,to:s,onUpdateHandler:(n,a)=>{this.zoomByWidth(a,this.resolveZoomFocus())},onCompleteHandler:(n,a)=>{t.next(this.getZoomPercent()),t.complete()}})})}zoomStep(e,t){let r=new Z(this.getTimecodedGroupDimension().width),s=(e==="IN"?r.mul(this.zoomScale):r.div(this.zoomScale)).round().toNumber();this.zoomByWidth(s,t)}zoomByPercent(e,t=!0){e=this.getConstrainedZoomPercent(e);let r=this.calculateWidthFromZoomRatioPercent(e);return this.zoomByWidth(r,this.resolveZoomFocus(),t),this.getZoomPercent()}zoomByWidth(e,t,r=!0){let s=this.getTimecodedGroupPosition().x,n=this.getTimecodedGroupDimension().width;e=this.getConstrainedWidth(e);let a=this.calculateNewPosition(e,t);this.hideThumbnailHover(),this.timecodedGroup.setAttrs({width:e,x:a}),this.timecodedGroupNodes.forEach(h=>{h.width(e)}),(this.getTimecodedGroupDimension().width!==n||this.getTimecodedGroupPosition().x!==s)&&(r?this.scrollbar.updateScrollHandle(this):this.playheadHover.toggleVisible(!1),this.setHorizontalScrollPercent(this.scrollbar.getScrollHandlePercent()),this.onZoom$.next(this.createZoomEvent()),this.onScroll$.next(this.createScrollEvent()))}calculateNewPosition(e,t=0){let r=this.getTimecodedGroupPosition().x,s=this.getTimecodedGroupDimension().width,n=this.getTimecodedContainerRect(),a=e>s?"IN":"OUT",o=r;if(e===n.width)o=0;else if(e>n.width){if(t>0){let h=new Z(t).div(s);if(h.greaterThanOrEqualTo(0)&&h.lessThanOrEqualTo(1)){let l=e-s,d=h.mul(l).abs().round().toNumber(),u=r+d*(a==="IN"?-1:1);o=u<0?u:0}}if(e>n.width){let h=n.x+n.width;o+e<=h&&(o=n.width-e)}}return o}resolveZoomFocus(){return this.videoController.isVideoLoaded()?this.resolvePlayheadSyncPosition():this.isSnappedStart()?0:this.isSnappedEnd()?this.getTimecodedGroupDimension().width:this.getTimecodedGroupDimension().width/2}calculateWidthFromZoomRatioPercent(e){return new Z(this.getTimecodedContainerDimension().width).mul(e).div(100).round().toNumber()}getConstrainedWidth(e){let t=this.getTimecodedContainerDimension();return e>=t.width?e<=this.maxTimecodedGroupWidth?e:this.maxTimecodedGroupWidth:t.width}getConstrainedZoomPercent(e){return e<this.zoomBaseline?this.zoomBaseline:e>this.zoomMax?this.zoomMax:e}getConstrainedScrollPercent(e){return e<0?0:e>100?100:e}playheadHoverMove(e){if(this.videoController.isVideoLoaded()&&this.playheadHover){let t=!1;if(!this.videoController.isPlaying()){let r=this.resolvePlayheadSyncPosition();e>r-this.playheadHoverSnapArea&&e<r+this.playheadHoverSnapArea&&(e=r,t=!0)}this.playheadHover.sync(e,t)}}resolvePlayheadSyncPosition(){return this.timeToTimelinePosition(this.videoController.getCurrentTime())}onVideoLoadedEvent(e){this.fireVideoEventBreaker(),this.clearContent(),this.syncVideoMetadata(),this.videoController.onVideoTimeChange$.pipe(k(this.videoEventBreaker$)).subscribe(t=>{this.syncVideoMetadata()}),this.videoController.onPlay$.pipe(k(this.videoEventBreaker$)).subscribe(t=>{this.updateScrollWithPlayhead()})}fireVideoEventBreaker(){$e(this.videoEventBreaker$),this.videoEventBreaker$=new V}setThumbnailVttFile(e){this.thumbnailVttFile=e}syncVideoMetadata(){this.scrollWithPlayhead&&!this.isPlayheadInTimecodedView()&&!this.syncTimelineWithPlayheadInProgress&&(this.syncTimelineWithPlayheadInProgress=!0,this.syncTimelineWithPlayhead().subscribe(e=>{this.syncTimelineWithPlayheadInProgress=!1}))}addLane(e){if(this.timelineLanesMap.has(e.getId()))throw new Error(`TimelineLane with id=${e.getId()} already exist`);let t=this.timelineLanes.length<1,r={...F.POSITION_TOP_LEFT};t||(r.y=this.timelineLanes.map(s=>s.getRect().height).reduce((s,n)=>s+n,0)),e.setTimeline(this),e.setVideoController(this.videoController),e.setTimelinePosition(r),e.initCanvasNode(),this.timelineLanes.push(e),this.timelineLanesMap.set(e.getId(),e),this.bodyContentGroup.add(e.getCanvasNode()),this.settleLayout()}removeLane(e){if(!this.timelineLanesMap.has(e))throw new Error(`TimelineLane with id=${e} doesn't exist`);let t=this.timelineLanesMap.get(e);this.timelineLanes.splice(this.timelineLanes.findIndex(s=>s.getId()===e),1),this.timelineLanesMap.delete(e),t.clearContent(),t.destroy();let r={...F.POSITION_TOP_LEFT};this.timelineLanes.forEach(s=>{s.setTimelinePosition({...r}),r.y=r.y+s.getRect().height}),this.timelineLanes.forEach(s=>{s.onMeasurementsChange()}),this.settleLayout()}getScrollbar(){return this.scrollbar}addLanes(e){e.forEach(t=>this.addLane(t))}getLanes(){return[...this.timelineLanesMap.values()]}getLane(e){return this.timelineLanesMap.get(e)}getScrubberLane(){return this.getLane(La)}getMarkerLane(e){let t=this.getLane(e);return t instanceof Us?t:void 0}getThumbnailLane(e){let t=this.getLane(e);return t instanceof Ks?t:void 0}getSubtitlesLane(e){let t=this.getLane(e);return t instanceof qs?t:void 0}getAudioTrackLane(e){let t=this.getLane(e);return t instanceof Fl?t:void 0}createMarkerLane(e){let t=new Us(e);return this.addLane(t),t}createThumbnailLane(e){let t=new Ks(e);return this.addLane(t),t}createSubtitlesLane(e){let t=new qs(e);return this.addLane(t),t}isTimelineReady(){return this.videoController.isVideoLoaded()}addToTimecodedBaseGroup(e){this.timecodedBaseGroup.add(e)}addToTimecodedSurfaceGroup(e){this.timecodedSurfaceGroup.add(e)}addToTimecodedMarkersGroup(e){this.timecodedMarkersGroup.add(e)}addToTimecodedThumbnailsGroup(e){this.timecodedThumbnailsGroup.add(e)}addToTimecodedSubtitlesGroup(e){this.timecodedSubtitlesGroup.add(e)}addToTimecodedAudioGroup(e){this.timecodedAudioGroup.add(e)}constrainTimelinePosition(e){let t=this.getTimecodedGroupDimension();return e<0?0:e>t.width?t.width:e}timelinePositionToTime(e){let t=this.constrainTimelinePosition(e);return this.videoController.isVideoLoaded()?new Z(t).mul(this.videoController.getDuration()).div(this.getTimecodedGroupDimension().width).toNumber():0}timelinePositionToTimeFormatted(e){return this.videoController.isVideoLoaded()?this.videoController.formatTimestamp(this.timelinePositionToTime(e)):""}timelinePositionToFrame(e){return this.videoController.isVideoLoaded()?this.videoController.calculateTimeToFrame(this.timelinePositionToTime(e)):0}timeToTimelinePosition(e){return new Z(e).mul(this.getTimecodedGroupDimension().width).div(this.videoController.getDuration()).toNumber()}getConstrainedTimelineX(e){let t=this.getTimecodedGroupDimension(),r=this.getTimecodedContainerDimension();if(t.width<=r.width)return 0;{let s=r.width-t.width;return e<s?s:e>0?0:e}}getBodyGroupRect(){return{...this.bodyGroup.getPosition(),...this.bodyGroup.getSize()}}getLeftPanelRect(){return{...this.leftPanel.getPosition(),...this.leftPanel.getSize()}}getLeftPanelVisible(){return this.leftPanelVisible}getRightPanelRect(){return{...this.rightPanel.getSize(),...this.rightPanel.getPosition()}}getTimecodedContainerDimension(){return this.timecodedContainer.getSize()}getTimecodedContainerPosition(){return this.timecodedContainer.getPosition()}getTimecodedContainerRect(){return{...this.getTimecodedContainerDimension(),...this.getTimecodedContainerPosition()}}getTimecodedGroupDimension(){return this.timecodedGroup.getSize()}getTimecodedGroupPosition(){return this.timecodedGroup.getPosition()}getTimecodedGroupRect(){return{...this.timecodedGroup.getPosition(),...this.timecodedGroup.getSize()}}getTimecodedGroupHorizontalMeasurement(){return{x:this.timecodedGroup.x(),width:this.timecodedGroup.width()}}getRelativePointerPosition(){return this.timecodedGroup.getRelativePointerPosition()}getLayoutGroupDimension(){return this.layoutGroup.getSize()}getLayoutGroupPosition(){return this.layoutGroup.getPosition()}getRect(){return{...this.getLayoutGroupDimension(),...this.getLayoutGroupPosition()}}getVisiblePositionRange(){let e=Math.abs(this.timecodedGroup.x()),t=e+this.timecodedContainer.width();return{start:e,end:t}}isInVisiblePositionRange(e){let t=this.getVisiblePositionRange();return e>=t.start&&e<=t.end}isSnappedStart(){return this.getTimecodedGroupPosition().x===0}isSnappedEnd(){return this.getTimecodedContainerDimension().width-this.getTimecodedGroupDimension().width===this.getTimecodedGroupPosition().x}getVisibleTimeRange(){let e=this.getVisiblePositionRange(),t=this.timelinePositionToTime(e.start),r=this.timelinePositionToTime(e.end);return{start:t,end:r}}getZoomBaseline(){return this.zoomBaseline}getZoomMax(){return this.zoomMax}fetchThumbnailVttFile(){return this.thumbnailVttUrl?ls.create(this.thumbnailVttUrl,this.axiosConfig).pipe(ke(e=>(this.thumbnailVttFile=e,e)),yi((e,t)=>Ee(void 0))):Ee(void 0)}toggleLeftPanelVisible(e){this.leftPanelVisible=e,this.leftPanel.visible(e),this.settleLayout(),this.timelineLanes.forEach(t=>{t.onMeasurementsChange()}),this.headerTimecodeDisplay.setVisible(!e)}clearContent(){this.setThumbnailVttFile(void 0),this.timelineLanes.forEach(e=>{e.clearContent()}),this.zoomByPercent(this.zoomBaseline)}destroy(){this.timelineHTMLElement=void 0,this.videoController=void 0,this.thumbnailVttFile=void 0,pn(this.videoEventBreaker$);let e=[this.onScroll$,this.onZoom$];Vt(...e),bi(...e),[this.scrollbar,this.playheadHover,this.playhead,...this.timelineLanes,this.thumbnailHover,this.headerTimecodeDisplay].forEach(r=>{r&&r.destroy()}),super.destroy()}}class Qs{static timeToFrame(e,t){return t.mul(e).floor().toNumber()}static frameToTime(e,t){return new Z(e).dividedBy(t).toNumber()}}class ri{constructor(){this.resolveUserAgent()}static instance(){return ri._instance||(ri._instance=new ri),ri._instance}resolveUserAgent(){this._userAgent=window.navigator&&window.navigator.userAgent||"",this._isAndroid=/Android/i.test(this._userAgent),this._isFirefox=/Firefox/i.test(this._userAgent),this._isEdge=/Edg/i.test(this._userAgent),this._isChromium=/Chrome/i.test(this._userAgent)||/CriOS/i.test(this._userAgent),this._isChrome=!this.isEdge&&this.isChromium,this._isSafari=/Safari/i.test(this._userAgent)&&!this.isChrome&&!this.isAndroid&&!this.isEdge}get isSafari(){return this._isSafari}get isFirefox(){return this._isFirefox}get isEdge(){return this._isEdge}get isChromium(){return this._isChromium}get isChrome(){return this._isChrome}get isAndroid(){return this._isAndroid}}const et=class{static formatVideoTimestamp(i,e){if(i<=0)return et.VIDEO_ZERO_TIMESTAMP;const t=Math.floor(i/3600),r=Math.floor(i%3600/60),s=Math.floor(i%60);let n=new Z(Qs.timeToFrame(i,e)).mod(e).toNumber();return`${et.padZero(t)}:${et.padZero(r)}:${et.padZero(s)}:${et.padZero(n)}`}static padZero(i,e=2){return i.toString().padStart(e,"0")}};let en=et;en.VIDEO_ZERO_TIMESTAMP=`${et.padZero(0)}:${et.padZero(0)}:${et.padZero(0)}:${et.padZero(0)}`;class Km{constructor(){this._state={playing:!1,paused:!0,waiting:!1,seeking:!1,buffering:!1,ended:!1},this.onChange$=new ti(this._state)}updateState(e){let t={...this._state,...e},r=this.compare(this._state,t)===0;this._state=t,r||this.onChange$.next(this._state)}compare(e,t){return e.playing===t.playing&&e.paused===t.paused&&e.waiting===t.waiting&&e.seeking===t.seeking&&e.buffering===t.buffering&&e.ended===t.ended?0:-1}get state(){return this._state}setPlaying(){this.updateState({playing:!0,paused:!1,waiting:!1,seeking:!1,buffering:!1,ended:!1})}setPaused(){this.updateState({playing:!1,paused:!0,waiting:!1,seeking:!1,buffering:!1,ended:!1})}setEnded(){this.updateState({playing:!1,paused:!0,waiting:!1,seeking:!1,buffering:!1,ended:!0})}set waiting(e){this.updateState({waiting:e})}set seeking(e){this.updateState({seeking:e})}set buffering(e){this.updateState({buffering:e})}}function Ra(i){let e;return typeof i=="string"?e=i:i instanceof rt?(console.log(i),e=i.errors.map(t=>t.message).join(". ")):i instanceof Error?e=i.message:e="Unexpected error",e}function Jm(i){return{errorMap:(e,t)=>({message:i})}}const Ue={PAUSE:"pause",WAITING:"waiting",PLAYING:"playing",TIMEUPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",LOADEDDATA:"loadeddata",LOADEDMETEDATA:"loadedmetadata",ENDED:"ended",PROGRESS:"progress"};class Qm{constructor(e,t){if(this.browserProvider=ri.instance(),this.helpMenuGroups=[],this._isVideoLoaded=!1,this.frameDurationSpillOverCorrection=1e-6,this.syncLoopMaxIterations=20,this.seekInProgress=!1,this.videoStalledCheckIntervalMs=700,this.videoFrameCallback$=new ti(null),this.videoEventBreaker$=new V,this.onDestroy$=new V,this.seekBreaker$=new V,this.onVideoLoaded$=new ti(void 0),this.onVideoLoading$=new V,this.onPlay$=new V,this.onPause$=new V,this.onVideoTimeChange$=new V,this.onSeeking$=new V,this.onSeeked$=new V,this.onBuffering$=new V,this.onEnded$=new V,this.onAudioSwitched$=new V,this.onPlaybackState$=new V,this.onHelpMenuChange$=new ti(void 0),this.onVideoError$=new V,this.domController=e,this.crossorigin=t,this.videoElement=this.domController.videoElement,this.videoElement.crossOrigin=this.crossorigin,!this.videoElement)throw new Error("VideoController element not set");this.videoFrameCallback$.pipe(k(this.onDestroy$)).subscribe(r=>{r&&(this.seekInProgress||(this.isPlaying()?this.videoTimeChangeHandlerExecutor():this.isPaused()))})}loadVideo(e,t,r){try{return e=li.url()(e),t=_e.coerce.number().min(0).max(100).parse(t,Jm("Invalid frameRate")),this.onVideoLoading$.next({sourceUrl:e,frameRate:t}),this._isVideoLoaded=!1,this.video=void 0,this.detachVideoEventListeners(),this.videoLoad(e,t,r).pipe(ke(s=>(this.video=s,this.frameRateDecimal=new Z(this.video.frameRate),this.syncStepCurrentTimeMediaTime=new Z(this.video.frameDuration).div(10).toNumber(),this.playbackStateMachine=new Km,this.initEventHandlers(),this.startVideoFrameCallback(),this._isVideoLoaded=!0,this.onVideoLoaded$.next({video:this.video}),s)),yi((s,n)=>{let a=Ra(s);return this.onVideoError$.next({type:"VIDEO_LOAD_ERROR",message:a}),ia(()=>new Error(a))}))}catch(s){let n=Ra(s);return this.onVideoError$.next({type:"VIDEO_LOAD_ERROR",message:n}),ia(()=>new Error(n))}}initEventHandlers(){be(this.videoElement,Ue.PAUSE).pipe(k(this.videoEventBreaker$)).subscribe(e=>{if(this.browserProvider.isSafari){let t=this.getCurrentTime()+this.video.frameDuration;this._seekTimeAndSyncNoEmitEvents(t).subscribe(r=>{this.videoTimeChangeHandlerExecutor(),this.onPause$.next({})})}else this.syncVideoFrames({}).subscribe(t=>{this.videoTimeChangeHandlerExecutor(),this.onPause$.next({})})}),be(this.videoElement,Ue.WAITING).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.waiting=!0}),be(this.videoElement,Ue.PLAYING).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setPlaying(),this.videoStalledCheckLastCurrentTime=void 0}),be(this.videoElement,Ue.PAUSE).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setPaused(),this.videoStalledCheckLastCurrentTime=void 0}),be(this.videoElement,Ue.TIMEUPDATE).pipe(k(this.videoEventBreaker$)).subscribe(e=>{}),be(this.videoElement,Ue.PROGRESS).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.onBuffering$.next({bufferedTimespans:this.getBufferedTimespans()})}),be(this.videoElement,Ue.ENDED).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.onEnded$.next({})}),this.playbackStateMachine.onChange$.pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.onPlaybackState$.next(e)}),this.onPlay$.pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setPlaying(),this.videoStalledCheckLastCurrentTime=void 0}),this.onPause$.pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setPaused(),this.videoStalledCheckLastCurrentTime=void 0}),this.onSeeking$.pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.seeking=!0}),this.onSeeked$.pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.seeking=!1}),this.onEnded$.pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setEnded(),this.videoStalledCheckLastCurrentTime=void 0}),Xu(this.videoStalledCheckIntervalMs).pipe(k(this.videoEventBreaker$)).subscribe(e=>{let t=this.getCurrentTime();if(!this.videoStalledCheckLastCurrentTime){this.videoStalledCheckLastCurrentTime=t;return}if(this.playbackStateMachine.state.playing){let r=this.videoStalledCheckIntervalMs*.8/1e3*this.getPlaybackRate(),s=this.videoStalledCheckLastCurrentTime+r,n=t<s;this.playbackStateMachine.waiting=n,this.videoStalledCheckLastCurrentTime=t}})}getBufferedTimespans(){if(!this.isVideoLoaded())return[];let e=[],t=this.videoElement.buffered;for(let r=0;r<t.length;r++)e.push({start:t.start(r),end:t.end(r)});return e}startVideoFrameCallback(){let e=()=>{this.videoElement?this.videoFrameCallbackHandle=this.videoElement.requestVideoFrameCallback((r,s)=>{t({now:r,metadata:s})}):console.debug("Cannot call requestVideoFrameCallback, videoElement not found")},t=r=>{this.videoFrameCallback$.next(r),e()};e()}detachVideoEventListeners(){$e(this.videoEventBreaker$),this.videoEventBreaker$=new V,this.videoElement&&this.videoFrameCallbackHandle&&this.videoElement.cancelVideoFrameCallback(this.videoFrameCallbackHandle)}syncVideoFrames(e){return console.debug("syncFrames - START",e),new se(t=>{let r=new ti(!1),s=new V,n=this.syncLoopMaxIterations;this.seekBreaker$.pipe(k(s)).subscribe(()=>{console.debug("%csyncFrames - seek breaker triggered","color: gray"),r.next(!0),a()});let a=()=>{$e(s),t.next(!0),t.complete(),console.debug("%csyncFrames - END","color: gray")},o=h=>{r.pipe(ft(1)).subscribe(l=>{l?console.debug("%csyncFrames - seek skipped, breaker already triggered","color: gray"):this._seekTimeFireAndForget(h)})};if(this.isPlaying())console.debug("%csyncFrames - SKIPPED: video is playing","color: gray"),a();else{let h=u=>{let c=this.getCurrentTime(),p=this.calculateTimeToFrame(c),f=u?u.metadata.mediaTime:void 0,m=f?this.calculateTimeToFrame(f):void 0;if(this.isPlaying())return console.debug("%csyncFrames - UNKNOWN: video is playing","color: gray"),!0;if(p===0)return console.debug(`%csyncFrames - OK: currentTimeFrame[${p}] === 0`,"color: green"),!0;if(e.seekToFrame){if(e.seekToFrame===p&&(p===m||!m))return console.debug(`%csyncFrames - OK: ((currentTimeFrame[${p}] === mediaTimeFrame[${m}]) || !mediaTimeFrame[${m}])`,"color: green"),!0}else if(p===m||!m)return console.debug(`%csyncFrames - OK: currentTimeFrame[${p}] === mediaTimeFrame[${m}]`,"color: green"),!0;return!1},l,d=u=>{let c=this.syncLoopMaxIterations-n;if(console.debug(`syncFrames.syncLoop - START (${c})`,{syncConditions:e,videoFrameCallbackData:u,dropped:this.videoElement.getVideoPlaybackQuality()}),this.isPlaying()){a();return}if(h(u)){a();return}let p=this.getCurrentTime(),f=this.calculateTimeToFrame(p),m=u?u.metadata.mediaTime:void 0,g=m?this.calculateTimeToFrame(m):void 0;if(n--<=0){console.debug(`%csyncFrames - TOO MANY SYNCs, EXITING.. : currentTime[${p}], mediaTime[${m}], currentTimeFrame[${f}], mediaTimeFrame[${g}]`,"color: red"),a();return}if(console.debug(`syncFrames - currentTime[${p}|${this.formatTimestamp(p)}], mediaTime[${m}|${this.formatTimestamp(m)}], currentTimeFrame[${f}], mediaTimeFrame[${g}], `),e.seekToFrame)if(l||(l=p),e.seekToFrame===f)if(f===g||!g)console.debug(`%csyncFrames - OK: ((currentTimeFrame[${f}] === mediaTimeFrame[${g}]) || !mediaTimeFrame[${g}])`,"color: green"),a();else{console.debug(`%csyncFrames - CORRECTION SEEK TO FRAME; currentTimeFrame[${f}] ${f>g?">":"<"} mediaTimeFrame[${g}]`,"color: red");let _=Math.abs(f-g);console.debug(`%csyncFrames - frameDiff: ${_}`,"color: orange");let w=this.syncStepCurrentTimeMediaTime*(f>g?1:-1);o(Z.add(p,w).toNumber())}else{console.debug(`%csyncFrames - CORRECTION SEEK TO FRAME; syncConditions.seekToFrame[${e.seekToFrame}] !== currentTimeFrame[${f}] | seekToFrameTimeBaseline=${l}`,"color: red");let _=Math.abs(e.seekToFrame-f),w=_*this.video.frameDuration,T=(e.seekToFrame>=f?Z.add(l,w):Z.sub(l,w)).toNumber();l=T,console.debug(`%csyncFrames - frameDiff: ${_}`,"color: orange"),console.debug(`%csyncFrames - frameCorrectionTime: ${w}`,"color: orange"),console.debug(`%csyncFrames - seekTo: ${T}`,"color: orange"),o(T)}else f===g||!g?(console.debug(`%csyncFrames - OK: currentTimeFrame[${f}] === mediaTimeFrame[${g}]`,"color: green"),a()):(console.debug(`%csyncFrames - CORRECTION; currentTimeFrame[${f}] ${f>g?">":"<"} mediaTimeFrame[${g}]`,"color: red"),c===0?o(p):f>g?o(Z.add(p,this.syncStepCurrentTimeMediaTime).toNumber()):o(m+this.syncStepCurrentTimeMediaTime));console.debug("syncFrames.syncLoop - END")};this.videoFrameCallback$.pipe(Ju((e.seekToFrame,0)),k(s)).subscribe(u=>{console.debug("syncFrames.syncLoop - videoFrameCallback$ trigger",u),d(u)})}})}seekTimeAndSync(e,t={}){return new se(r=>{this.seekInProgress&&($e(this.seekBreaker$),this.seekBreaker$=new V),this.seekInProgress=!0,isNaN(e)||(e=e<0?0:e>this.getDuration()?this.getDuration():e,be(this.videoElement,Ue.SEEKING).pipe(k(this.seekBreaker$),ft(1)).subscribe(s=>{this.onSeeking$.next({newTime:e,currentTime:this.getCurrentTime()})}),be(this.videoElement,Ue.SEEKED).pipe(k(this.seekBreaker$),ft(1)).subscribe(s=>{this.syncVideoFrames(t).subscribe(n=>{this.onSeeked$.next({currentTime:this.getCurrentTime()}),this.seekInProgress=!1,r.next(!0),r.complete(),this.videoTimeChangeHandlerExecutor()})}),console.debug(`Seeking to timestamp: ${e} ${this.formatTimestamp(e)}`),this.setCurrentTime(e))})}_seekTimeFireAndForget(e){if(!isNaN(e)){let t=this.getCurrentTime();e=e<0?0:e>this.getDuration()?this.getDuration():e;let r=e===t?"NONE":e>t?"FORWARD":"BACKWARD",s=Z.sub(t,e).abs();console.debug(`Seeking from currentTime[${t}] to newTime[${e}], direction: ${r} ${s.toNumber()}`),this.setCurrentTime(e)}}_seekTimeAndSyncNoEmitEvents(e){return this.isPlaying()?Ee(!1):new se(t=>{isNaN(e)||(e=e<0?0:e>this.getDuration()?this.getDuration():e,be(this.videoElement,Ue.SEEKED).pipe(ui()).subscribe(r=>{this.syncVideoFrames({}).subscribe(s=>{t.next(!0),t.complete(),this.videoTimeChangeHandlerExecutor()})}),console.debug(`Seeking ${e}`),this.setCurrentTime(e))})}seekFromCurrentTimeAndSync(e,t={}){let r=this.getCurrentTime(),s=Z.add(r,e).toNumber(),n=s===r?"NONE":s>r?"FORWARD":"BACKWARD",a=Z.sub(r,s).abs().toNumber();return console.debug(`Seeking from currentTime ${r} to ${s}, direction: ${n} ${a}`),this.seekTimeAndSync(s,t)}setCurrentTime(e){this.videoElement.currentTime=e}getFrameRateDecimal(){return this.frameRateDecimal}_seekToFrame(e){if(!this.isPlaying()&&!isNaN(e)){if(console.debug(`Seeking to frame: ${e}`),e<=0)return this.seekTimeAndSync(0,{});{let t=this.calculateFrameToTime(e)+new Z(this.frameDurationSpillOverCorrection).toNumber(),r=this.calculateTimeToFrame(t);return r!==e?(console.error(`Frame numbers don't match. Wanted: ${e}, calculated: ${r}`),Ee(!1)):this.seekTimeAndSync(t,{seekToFrame:e,seekToTimestamp:t,currentTime:this.getCurrentTime()}).pipe(ke(s=>s))}}}_seekFromCurrentFrame(e){let t=this.getCurrentFrame(),r=t+e;if(console.debug(`seekFromCurrentFrame - Current frame: ${t}, wanted frame: ${r}`),t!==r){if(r<=0)return this._seekToFrame(0);if(r>=this.getTotalFrames())return this._seekToFrame(this.getTotalFrames());{let s=this.calculateFrameToTime(e);return this.seekFromCurrentTimeAndSync(s,{seekToFrame:r,currentTime:this.getCurrentTime()}).pipe(ke(n=>n))}}else return Ee(!0)}videoTimeChangeHandlerExecutor(){let e=this.getCurrentTime(),t=this.getCurrentFrame();this.onVideoTimeChange$.next({currentTime:e,frame:t})}getPlaybackState(){return this.playbackStateMachine.state}getVideo(){return this.isVideoLoaded()?this.video:void 0}getHTMLVideoElement(){return this.videoElement}calculateTimeToFrame(e){return Qs.timeToFrame(e,this.getFrameRateDecimal())}calculateFrameToTime(e){return Qs.frameToTime(e,this.getFrameRateDecimal())}play(){this.isVideoLoaded()&&!this.isPlaying()&&this.videoElement.play().then(()=>{this.onPlay$.next({})})}pause(){this.isVideoLoaded()&&this.isPlaying()&&this.videoElement.pause()}togglePlayPause(){this.isPlaying()?this.pause():this.play()}isPlaying(){return this.isVideoLoaded()&&this.videoElement.currentTime>0&&this.videoElement.currentTime<this.getDuration()&&!this.videoElement.paused&&!this.videoElement.ended&&this.videoElement.readyState>this.videoElement.HAVE_CURRENT_DATA}isPaused(){return!this.isPlaying()}isSeeking(){return this.seekInProgress}getCurrentTime(){return this.isVideoLoaded()?this.videoElement.currentTime:0}getPlaybackRate(){return this.isVideoLoaded()?this.videoElement.playbackRate:0}setPlaybackRate(e){if(this.isVideoLoaded()){try{e=_e.coerce.number().min(.1).max(16).default(1).parse(e)}catch{e=1}this.videoElement.playbackRate=e}}getVolume(){return this.isVideoLoaded()?this.videoElement.volume:0}setVolume(e){if(this.isVideoLoaded()){try{e=_e.coerce.number().min(0).max(1).default(1).parse(e)}catch{e=1}this.videoElement.volume=e}}getDuration(){return this.isVideoLoaded()?this.video.duration:0}getFrameRate(){return this.isVideoLoaded()?this.video.frameRate:0}getTotalFrames(){return this.isVideoLoaded()?this.video.totalFrames:0}getCurrentFrame(){return this.isVideoLoaded()?this.calculateTimeToFrame(this.getCurrentTime()):0}seekToFrame(e){return this.isVideoLoaded()?(e=_e.coerce.number().min(0).max(this.getTotalFrames()).parse(e),this._seekToFrame(e)):Ee(!1)}seekFromCurrentFrame(e){return this.isVideoLoaded()?(e=_e.coerce.number().parse(e),this._seekFromCurrentFrame(e)):Ee(!1)}seekPreviousFrame(){return this.isVideoLoaded()?this.seekFromCurrentFrame(-1):Ee(!1)}seekNextFrame(){return this.isVideoLoaded()?this.seekFromCurrentFrame(1):Ee(!1)}seekToTimestamp(e){return this.isVideoLoaded()?(e=_e.coerce.number().parse(e),this.seekTimeAndSync(e)):Ee(!1)}formatTimestamp(e){return this.isVideoLoaded()?(e=_e.coerce.number().min(0).max(this.getDuration()).parse(e),en.formatVideoTimestamp(e,this.getFrameRateDecimal())):en.VIDEO_ZERO_TIMESTAMP}mute(){this.isVideoLoaded()&&(this.videoElement.muted=!0)}unmute(){this.isVideoLoaded()&&(this.videoElement.muted=!1)}isFullscreen(){return this.isVideoLoaded()?this.domController.isFullscreen():!1}toggleFullscreen(){this.isVideoLoaded()&&this.domController.toggleFullscreen(this.videoElement)}getAudioTracks(){throw new Error("unsupported")}getCurrentAudioTrack(){throw new Error("unsupported")}setAudioTrack(e){throw new Error("unsupported")}isVideoLoaded(){return this._isVideoLoaded}getHls(){throw new Error("Unsupported or video not loaded with Hls.js")}addHelpMenuGroup(e){this.helpMenuGroups.push(e),this.onHelpMenuChange$.next()}getHelpMenuGroups(){return this.helpMenuGroups}destroy(){pn(this.videoEventBreaker$,this.seekBreaker$),Vt(this.videoFrameCallback$);let e=[this.onVideoLoaded$,this.onVideoLoading$,this.onPlay$,this.onPause$,this.onVideoTimeChange$,this.onSeeking$,this.onSeeked$,this.onBuffering$,this.onEnded$,this.onAudioSwitched$,this.onPlaybackState$,this.onHelpMenuChange$,this.onVideoError$];Vt(...e),bi(...e);try{this.getHls()&&(this.getHls().removeAllListeners(),this.getHls().destroy())}catch(t){console.error(t)}$e(this.onDestroy$),this.videoElement=null,this.domController=null,this._isVideoLoaded=!1,this.playbackStateMachine=null}}class eg{constructor(e,t,r,s){this._element=e,this._sourceUrl=t,this._frameRate=r,this._duration=s,this._totalFrames=new Z(this._duration).mul(this._frameRate).toNumber(),this._frameDuration=new Z(1).div(this._frameRate).toNumber()}get element(){return this._element}get sourceUrl(){return this._sourceUrl}get frameRate(){return this._frameRate}get duration(){return this._duration}get totalFrames(){return this._totalFrames}get frameDuration(){return this._frameDuration}}class tg extends Qm{constructor(e,t){super(e,t),Qe.isSupported()?console.debug("video load with hls.js"):console.error("hls is not supported through MediaSource extensions");let r={...Qe.DefaultConfig,enableWorker:!1};this.hls=new Qe(r)}videoLoad(e,t,r){return new se(s=>{this.hls.on(Qe.Events.ERROR,function(h,l){l.type;let d=l.details;l.fatal,d.includes("audioTrackLoadError")||(s.error(`Error loading video. Hls error details: ${d}`),s.complete())});let n=new se(h=>{this.hls.once(Qe.Events.MEDIA_ATTACHED,function(l,d){console.debug("video element and hls.js are now bound together"),h.next(!0),h.complete()})}),a=new se(h=>{this.hls.once(Qe.Events.MANIFEST_PARSED,function(l,d){console.debug("manifest loaded, found "+d.levels.length+" quality level"),h.next(!0),h.complete()})}),o=be(this.videoElement,Ue.LOADEDDATA).pipe(ui());$u([n,a,o]).pipe(ui()).subscribe(h=>{r=r&&_e.coerce.number().parse(r),r=r||this.videoElement.duration;let l=new eg(this.videoElement,e,t,r);s.next(l),s.complete()}),this.hls.loadSource(e),this.hls.attachMedia(this.videoElement)})}initEventHandlers(){super.initEventHandlers(),this.hls.on(Qe.Events.ERROR,function(e,t){t.type,t.details,t.fatal,console.error(e,t),t.details===Qe.ErrorDetails.BUFFER_STALLED_ERROR||t.details===Qe.ErrorDetails.BUFFER_APPEND_ERROR||(t.details,Qe.ErrorDetails.BUFFER_APPENDING_ERROR)})}getAudioTracks(){return this.isVideoLoaded?this.hls.audioTracks:null}getCurrentAudioTrack(){return this.getAudioTracks()[this.hls.audioTrack]}setAudioTrack(e){if(!this.isVideoLoaded)return null;let t=this.hls.audioTrack;this.hls.audioTrack=e;let r=this.hls.audioTrack;r>=0&&t!==r&&this.onAudioSwitched$.next({audioTrack:this.getCurrentAudioTrack()})}getHls(){return this.hls}}class ig{constructor(e){this.hidden=!0,this.id=e.id,this.src=e.src,this.default=e.default,this.label=e.label,this.language=e.language,this.cues=[]}}class rg extends ig{constructor(e){super(e)}}class xn{constructor(e){this.subtitlesTracks=new Map,this.onCreate$=new V,this.onRemove$=new V,this.onShow$=new V,this.onHide$=new V,this.videoController=e,this.videoController.onVideoLoaded$.pipe(Ve(t=>!!t)).subscribe(t=>{this.removeAllTracks()})}getDomTextTrack(e){if(this.videoController&&this.videoController.getHTMLVideoElement()){let t=this.videoController.getHTMLVideoElement().textTracks.getTrackById(e.id);if(t.kind==="subtitles")return t}}removeDomTextTrack(e){return this.getDomTextTrack(e)?(this.videoController.getHTMLVideoElement().querySelectorAll("track").forEach(r=>{r.getAttribute("id")===e.id&&r.parentElement.removeChild(r)}),!0):!1}static createHTMLTrackElement(e){let t=document.createElement("track");return t.kind="subtitles",t.id=e.id,t.label=e.label,t.srclang=e.language,t.src=e.src,t.default=e.default,t}createVttTrack(e){return this.videoController.isVideoLoaded?new se(t=>{let r=new rg({...e});this.subtitlesTracks.has(r.id)&&this.removeTrack(r.id),r.element=xn.createHTMLTrackElement(r),be(r.element,"load").pipe(ui()).subscribe(n=>{this.subtitlesTracks.set(r.id,r),t.next(r),t.complete(),this.onCreate$.next({textTrack:r})}),this.videoController.getHTMLVideoElement().appendChild(r.element);let s=this.getDomTextTrack(r);s.mode="hidden"}):Ee(void 0)}getTracks(){if(this.videoController.isVideoLoaded)return[...this.subtitlesTracks.values()]}removeAllTracks(){this.videoController.isVideoLoaded&&this.subtitlesTracks.forEach((e,t)=>{this.removeTrack(e.id)})}removeTrack(e){if(!this.videoController.isVideoLoaded)return;let t=this.subtitlesTracks.get(e);t&&(this.subtitlesTracks.delete(e),this.removeDomTextTrack(t),this.onRemove$.next({}))}getCurrentTrack(){return this.currentTrack}showTrack(e=void 0){if(!this.videoController.isVideoLoaded||(e=e||(this.getCurrentTrack()?this.getCurrentTrack().id:void 0),!e))return;let t=this.subtitlesTracks.get(e);if(t){let r=this.getDomTextTrack(t);if(r){for(let s=0;s<this.videoController.getHTMLVideoElement().textTracks.length;s++){let n=this.videoController.getHTMLVideoElement().textTracks[s];n.mode="hidden"}r.mode="showing",t.hidden=!1,this.currentTrack=t,this.onShow$.next({})}}}hideTrack(e=void 0){if(!this.videoController.isVideoLoaded||(e=e||(this.getCurrentTrack()?this.getCurrentTrack().id:void 0),!e))return;let t=this.subtitlesTracks.get(e);if(t){let r=this.getDomTextTrack(t);r&&(r.mode="hidden",t.hidden=!0,this.onHide$.next({}))}}destroy(){this.removeAllTracks();let e=[this.onCreate$,this.onRemove$,this.onShow$,this.onHide$];Vt(...e),bi(...e),this.currentTrack=void 0,this.videoController=void 0}}var tn={},sg={get exports(){return tn},set exports(i){tn=i}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(h,l,d){this.fn=h,this.context=l,this.once=d||!1}function n(h,l,d,u,c){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new s(d,u||h,c),f=t?t+l:l;return h._events[f]?h._events[f].fn?h._events[f]=[h._events[f],p]:h._events[f].push(p):(h._events[f]=p,h._eventsCount++),h}function a(h,l){--h._eventsCount===0?h._events=new r:delete h._events[l]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],d,u;if(this._eventsCount===0)return l;for(u in d=this._events)e.call(d,u)&&l.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(d)):l},o.prototype.listeners=function(l){var d=t?t+l:l,u=this._events[d];if(!u)return[];if(u.fn)return[u.fn];for(var c=0,p=u.length,f=new Array(p);c<p;c++)f[c]=u[c].fn;return f},o.prototype.listenerCount=function(l){var d=t?t+l:l,u=this._events[d];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,d,u,c,p,f){var m=t?t+l:l;if(!this._events[m])return!1;var g=this._events[m],_=arguments.length,w,b;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),_){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,d),!0;case 3:return g.fn.call(g.context,d,u),!0;case 4:return g.fn.call(g.context,d,u,c),!0;case 5:return g.fn.call(g.context,d,u,c,p),!0;case 6:return g.fn.call(g.context,d,u,c,p,f),!0}for(b=1,w=new Array(_-1);b<_;b++)w[b-1]=arguments[b];g.fn.apply(g.context,w)}else{var T=g.length,L;for(b=0;b<T;b++)switch(g[b].once&&this.removeListener(l,g[b].fn,void 0,!0),_){case 1:g[b].fn.call(g[b].context);break;case 2:g[b].fn.call(g[b].context,d);break;case 3:g[b].fn.call(g[b].context,d,u);break;case 4:g[b].fn.call(g[b].context,d,u,c);break;default:if(!w)for(L=1,w=new Array(_-1);L<_;L++)w[L-1]=arguments[L];g[b].fn.apply(g[b].context,w)}}return!0},o.prototype.on=function(l,d,u){return n(this,l,d,u,!1)},o.prototype.once=function(l,d,u){return n(this,l,d,u,!0)},o.prototype.removeListener=function(l,d,u,c){var p=t?t+l:l;if(!this._events[p])return this;if(!d)return a(this,p),this;var f=this._events[p];if(f.fn)f.fn===d&&(!c||f.once)&&(!u||f.context===u)&&a(this,p);else{for(var m=0,g=[],_=f.length;m<_;m++)(f[m].fn!==d||c&&!f[m].once||u&&f[m].context!==u)&&g.push(f[m]);g.length?this._events[p]=g.length===1?g[0]:g:a(this,p)}return this},o.prototype.removeAllListeners=function(l){var d;return l?(d=t?t+l:l,this._events[d]&&a(this,d)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(sg);const ng={OMAKASE_SUBTITLES_HIDE:"omakaseSubtitlesHide",OMAKASE_TIMELINE_ZOOM:"omakaseTimelineZoom",OMAKASE_VIDEO_LOADED:"omakaseVideoLoaded",OMAKASE_VIDEO_PAUSE:"omakaseVideoPause",OMAKASE_VIDEO_PLAY:"omakaseVideoPlay",OMAKASE_VIDEO_SEEKED:"omakaseVideoSeeked",OMAKASE_VIDEO_SEEKING:"omakaseVideoSeeking",OMAKASE_VIDEO_BUFFERING:"omakaseVideoBuffering",OMAKASE_VIDEO_ENDED:"omakaseVideoEnded",OMAKASE_VIDEO_TIME_CHANGE:"omakaseVideoTimeChange",OMAKASE_VIDEO_AUDIO_SWITCHED:"omakaseVideoAudioSwitched",OMAKASE_AUDIO_SWITCHED:"omakaseAudioSwitched",OMAKASE_SUBTITLES_CREATE:"omakaseSubtitlesCreate",OMAKASE_SUBTITLES_REMOVE:"omakaseSubtitlesRemove",OMAKASE_SUBTITLES_SHOW:"omakaseSubtitlesShow",OMAKASE_TIMELINE_SCROLL:"omakaseTimelineScroll"};class ag{constructor(e){this.onAudioSwitched$=new V,this.videoController=e}getAudioTracks(){return this.videoController.getAudioTracks()}getCurrentAudioTrack(){return this.videoController.getCurrentAudioTrack()}setAudioTrack(e){let t=this.getCurrentAudioTrack();this.videoController.setAudioTrack(e);let r=this.getCurrentAudioTrack();t!==r&&this.onAudioSwitched$.next({audioTrack:r})}destroy(){}}class Pi{static isFullscreenEnabled(){const e=document;return e.fullscreenEnabled||e.webkitFullscreenEnabled||!!e.webkitCancelFullScreen||e.mozFullScreenEnabled||e.msFullscreenEnabled||!1}static isFullscreen(){const e=document;return!!(e.fullscreenElement||e.webkitFullscreenElement||e.webkitCurrentFullScreenElement||e.mozFullScreenElement||e.msFullscreenElement)}static requestFullscreen(e,t){const r=e??document.documentElement,s=r.requestFullscreen||r.webkitRequestFullscreen||r.webkitRequestFullScreen||r.mozRequestFullScreen||r.msRequestFullscreen;if(!s)throw new Error("Unsupported");return s.call(r,t)}static exitFullscreen(){const e=document,t=e.exitFullscreen||e.webkitExitFullscreen||e.webkitCancelFullScreen||e.mozCancelFullScreen||e.msExitFullscreen;if(!t)throw new Error("Unsupported");return t.call(e)}}const fe={player:"omakase-player",playerWrapper:"omakase-player-wrapper",video:"omakase-video",videoControls:"omakase-video-controls",buttonPlay:"omakase-button-play",buttonPause:"omakase-button-pause",buttonLoading:"omakase-button-loading",buttonError:"omakase-button-error",buttonReplay:"omakase-button-replay",buttonHelp:"omakase-help-button",help:"omakase-help",helpMenu:"omakase-help-menu",errorMessage:"omakase-error-message"};class og{constructor(e){this._playerHTMLElementId=e,this.divPlayer=this.getElementById(this._playerHTMLElementId),this.createDom()}createDom(){this.divPlayer.classList.add(`${fe.player}`),this.divPlayer.innerHTML=`<div class="${fe.playerWrapper}">
47
+ `)}function Aa(i){const e=(i%1).toFixed(3);i=Math.round(i-e);const t=Math.floor(i/3600),r=Math.floor((i-t*3600)/60),s=i-t*3600-r*60;return`${`${_r(t,2)}:`}${_r(r,2)}:${_r(s,2)}.${_r(e*1e3,3)}`}var Pm={hlsSegment:Sm,hlsSegmentPlaylist:Tm};const Am=Rl.parse,Mm=vm.compile,Om=Nl.segment,Lm=Pm;var Rm={parse:Am,compile:Mm,segment:Om,hls:Lm};class Cn{constructor(e,t){this.cues=new Map,this.cuesKeysSorted=[],this.url=e,this.axiosConfig=t}fetch(){return tr(am(this.getUrl(),this.axiosConfig)).pipe(ke(e=>{let t=e.data;try{return Rm.parse(t,{strict:!0,meta:!0}).cues.forEach(s=>{let n=this.mapCue(s);this.cues.set(n.startTime,n),this.cuesKeysSorted.push(n.startTime)}),this.cuesKeysSorted.sort((s,n)=>s-n),!0}catch(r){return console.error(r),!1}}))}getUrl(){return this.url}hasCues(){return this.cues&&this.cues.size>0}findCue(e){let t=this.findCues(e,e);if(t&&t.length===1)return t[0]}findCues(e,t){let r=this.findCueIndex(e),s=this.findCueIndex(t);return s===-1?[]:this.cuesKeysSorted.slice(r,s+1).map(n=>this.cues.get(n))}getCues(){return[...this.cues.values()]}findCueIndex(e){let t=0,r=this.cuesKeysSorted.length-1;for(;t<=r;){const s=Math.floor((t+r)/2);if(this.cuesKeysSorted[s]===e)return s;this.cuesKeysSorted[s]<e?t=s+1:r=s-1}return r===-1&&(r=0),r}}class En extends Cn{constructor(e,t){super(e,t)}static create(e,t){let r=new En(e,t);return r.fetch().pipe(ke(s=>r))}mapCue(e){return{id:e.identifier,startTime:new Z(e.start).toDecimalPlaces(3).toNumber(),endTime:new Z(e.end).toDecimalPlaces(3).toNumber(),text:e.text}}}const Ma={listening:!0,style:{height:20,fill:"rgba(255,73,145)",opacity:1,visible:!0}};class Im extends et{constructor(e,t){super({...Ma,...e,style:{...Ma.style,...e.style}}),this.textTrackCue=this.config.textTrackCue,this.x=this.config.x,this.width=this.config.width,this.listening=this.config.listening,this.subtitlesLane=t,this.subtitlesLane.onSettleLayout$.pipe(k(this.onDestroy$)).subscribe(()=>{let r=this.subtitlesLane.resolveItemHorizontalMeasurement(this.getTextTrackCue());this.setHorizontalMeasurement(r)})}createCanvasNode(){return this.group=new M.Group({x:this.x,y:0,width:this.width,height:this.style.height,visible:this.style.visible,listening:this.listening}),this.backgroundRect=new M.Rect({x:0,y:0,width:this.group.width(),height:this.group.height(),fill:this.style.fill,opacity:this.style.opacity,perfectDrawEnabled:!1,shadowForStrokeEnabled:!1,hitStrokeWidth:0}),this.group.add(this.backgroundRect),this.group}onMeasurementsChange(){this.backgroundRect.size(this.group.getSize())}setPosition(e){this.x=e.x,this.isInitialized()&&this.group.position({x:this.x,y:0})}getPosition(){return this.group.getPosition()}getDimension(){return this.group.getSize()}getRect(){return{...this.getPosition(),...this.getDimension()}}getHorizontalMeasurement(){return{x:this.x,width:this.width}}setHorizontalMeasurement(e){this.x=e.x,this.width=e.width,this.isInitialized()&&this.group.setAttrs({x:this.x,width:this.width}),this.onMeasurementsChange()}setVisible(e){this.style={visible:e},this.isInitialized()&&this.group.visible(e)}getTextTrackCue(){return this.textTrackCue}setTextTrackCue(e){this.textTrackCue=e}compareTo(e){return this.textTrackCue&&e&&this.getTextTrackCue().id===e.getTextTrackCue().id&&this.getTextTrackCue().startTime===e.getTextTrackCue().startTime&&this.getTextTrackCue().endTime===e.getTextTrackCue().endTime?0:-1}destroy(){this.textTrackCue=void 0,this.subtitlesLane=void 0,super.destroy()}}const Nm={...rr,height:40,paddingTop:0,paddingBottom:0,subtitlesLaneItemOpacity:.9,subtitlesLaneItemFill:"rgba(255,73,145)"};class qs extends sr{constructor(e){super({...e,style:{...Nm,...e.style}}),this.subtitlesLaneItemsMap=new Map,this.onSettleLayout$=new V,this._subtitlesVttUrl=this.config.subtitlesVttUrl}createCanvasNode(){return super.createCanvasNode(),this.timecodedGroup=new M.Group({...this.timelinePosition,width:this.timeline.getTimecodedGroupDimension().width,height:this.bodyGroup.height()}),this.timecodedEventCatcher=wi.createEventCatcher({width:this.timecodedGroup.width(),height:this.timecodedGroup.height()}),this.subtitlesLaneItemsGroup=new M.Group({...F.POSITION_TOP_LEFT,y:this.style.paddingTop,width:this.timecodedGroup.width(),height:this.timecodedGroup.height()-(this.style.paddingTop+this.style.paddingBottom)}),this.timecodedGroup.add(this.timecodedEventCatcher),this.timecodedGroup.add(this.subtitlesLaneItemsGroup),this.timeline.addToTimecodedSubtitlesGroup(this.timecodedGroup),this.bodyGroup}settleLayout(){super.settleLayout(),this.timecodedGroup.setAttrs({...this.timelinePosition});let e=this.timeline.getTimecodedGroupHorizontalMeasurement();[this.timecodedGroup,this.timecodedEventCatcher,this.subtitlesLaneItemsGroup].forEach(t=>{t.width(e.width)}),this.onSettleLayout$.next()}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.fetchAndCreateSubtitles()}clearContent(){this.subtitlesVttFile=void 0,this.clearItems()}clearItems(){this.subtitlesLaneItemsMap.forEach(e=>e.destroy()),this.subtitlesLaneItemsMap.clear(),this.subtitlesLaneItemsGroup.destroyChildren()}createEntities(){if(!this.isVttLoaded())return;this.clearItems(),this.subtitlesVttFile.getCues().forEach(t=>{let r=this.resolveItemHorizontalMeasurement(t),s=new Im({...r,textTrackCue:t,style:{height:this.subtitlesLaneItemsGroup.height(),fill:this.style.subtitlesLaneItemFill,opacity:this.style.subtitlesLaneItemOpacity}},this);this.subtitlesLaneItemsMap.set(t.startTime,s),this.subtitlesLaneItemsGroup.add(s.initCanvasNode())})}resolveItemHorizontalMeasurement(e){let t=this.timeline.constrainTimelinePosition(this.timeline.timeToTimelinePosition(e.startTime)),r=this.timeline.constrainTimelinePosition(this.timeline.timeToTimelinePosition(e.endTime));return{x:t,width:r-t}}fetchAndCreateSubtitles(){this.fetchSubtitlesVttFile(this._subtitlesVttUrl).pipe($e(1)).subscribe(e=>{this.subtitlesVttFile=e,this.createEntities()})}fetchSubtitlesVttFile(e){return e?En.create(e).pipe(ke(t=>t),yi((t,r)=>Se(void 0))):Se(void 0)}isVttLoaded(){return!!this.subtitlesVttFile}get subtitlesVttUrl(){return this._subtitlesVttUrl}set subtitlesVttUrl(e){this._subtitlesVttUrl=e,this.clearContent(),this.fetchAndCreateSubtitles()}}const Dm={listening:!1,style:{...F.POSITION_TOP_LEFT,...F.DIMENSION_ZERO,stroke:"rgba(255,73,145)",strokeWidth:5,visible:!1}};class Ys extends et{constructor(e){super(_i(e,Dm)),this.onClick$=new V,this.onMouseOver$=new V,this.onMouseMove$=new V,this.onMouseOut$=new V,this.onMouseLeave$=new V,this.listening=this.config.listening}createCanvasNode(){return this.group=new M.Group({x:this.style.x,y:this.style.y,width:this.style.width,height:this.style.height,visible:this.style.visible,listening:this.listening}),this.backgroundRect=new M.Rect({x:0,y:0,width:this.group.width(),height:this.group.height(),strokeWidth:this.style.strokeWidth,stroke:this.style.stroke}),this.group.add(this.backgroundRect),this.group}afterCanvasNodeInit(){this.group.on("click",e=>{this.onClick$.next({thumbnail:this})}),this.group.on("mouseover",e=>{this.onMouseOver$.next({thumbnail:this})}),this.group.on("mousemove",e=>{this.onMouseMove$.next({thumbnail:this})}),this.group.on("mouseout",e=>{this.onMouseOut$.next({thumbnail:this})}),this.group.on("mouseleave",e=>{this.onMouseLeave$.next({thumbnail:this})})}destroy(){this.thumbnailVttCue=void 0;for(let t in this.group.eventListeners)this.group.removeEventListener(t);let e=[this.onClick$,this.onMouseOver$,this.onMouseMove$,this.onMouseOut$,this.onMouseLeave$];Vt(...e),bi(...e),super.destroy()}onMeasurementsChange(){this.backgroundRect.size(this.group.getSize())}setImage(e){this.image&&this.image.destroy(),this.image=e,this.style={width:e.width(),height:e.height()},this.group.setAttrs({...this.image.getSize()}),this.backgroundRect.setAttrs({...this.image.getSize()}),this.group.add(this.image)}setVisible(e){this.style={visible:e},this.isInitialized()&&this.group.visible(e)}setPosition(e){this.style={...e},this.isInitialized()&&this.group.position(e)}setVisibleAndX(e,t){this.style={visible:e,x:t},this.isInitialized()&&this.group.setAttrs({visible:e,x:t})}getPosition(){return this.group.getPosition()}getDimension(){return this.group.getSize()}setDimension(e){this.style={...e},this.isInitialized()&&this.group.size(e),this.onMeasurementsChange()}getRect(){return{...this.getPosition(),...this.getDimension()}}getThumbnailVttCue(){return this.thumbnailVttCue}setThumbnailVttCue(e){this.thumbnailVttCue=e}getImage(){return this.image}compareTo(e){return this.thumbnailVttCue&&e&&this.thumbnailVttCue.url===e.thumbnailVttCue.url?0:-1}}class ls extends Cn{constructor(e,t){super(e,t)}static create(e,t){let r=new ls(e,t);return r.fetch().pipe(ke(s=>r))}mapCue(e){return{id:e.identifier,startTime:new Z(e.start).toDecimalPlaces(3).toNumber(),endTime:new Z(e.end).toDecimalPlaces(3).toNumber(),text:e.text,url:this.resolveThumbnailUrl(e)}}resolveThumbnailUrl(e){return this.isUrlAbsolute(e.text)?e.text:this.createThumbnailUrlFromRelativeUrl(e.text)}createThumbnailUrlFromRelativeUrl(e){return this.url.lastIndexOf("/")>2?`${this.url.substring(0,this.url.lastIndexOf("/"))}/${e}`:e}isUrlAbsolute(e){return/^(http(s):\/\/.)[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/.test(e)}}class ct{static createKonvaImage(e){return new re(t=>{M.Image.fromURL(e,r=>{t.next(r),t.complete()},r=>{console.error(r),t.error(r)})})}static createKonvaImageSizedByWidth(e,t){return ct.createKonvaImage(e).pipe(ke(r=>(r.setAttrs({width:t,height:ct.calculateProportionalHeight(t,r)}),r)))}static createKonvaImageSizedByHeight(e,t){return ct.createKonvaImage(e).pipe(ke(r=>(r.setAttrs({width:ct.calculateProportionalWidth(t,r),height:t}),r)))}static calculateProportionalHeight(e,t){return e*t.getAttrs().image.naturalHeight/t.getAttrs().image.naturalWidth}static calculateProportionalWidth(e,t){return e*t.getAttrs().image.naturalWidth/t.getAttrs().image.naturalHeight}}const Gm={...rr,thumbnailHeight:40,thumbnailStroke:"rgba(121,0,255,0.9)",thumbnailStrokeWidth:0,thumbnailHoverScale:1.5,thumbnailHoverStroke:"rgba(0,255,188,0.9)",thumbnailHoverStrokeWidth:5};class Ks extends sr{constructor(e){super({...e,style:{...Gm,...e.style}}),this.thumbnailsMap=new Map,this.thumbnailsVisibleSet=new Set,this.onSettleLayout$=new V,this.eventStreamBreaker$=new V,this.onClick$=new V,this._thumbnailVttUrl=this.config.thumbnailVttUrl,this._axiosConfig=this.config.axiosConfig}createCanvasNode(){return super.createCanvasNode(),this.timecodedGroup=new M.Group({...this.timelinePosition,width:this.timeline.getTimecodedGroupDimension().width,height:this.bodyGroup.height()}),this.timecodedEventCatcher=wi.createEventCatcher({width:this.timecodedGroup.width(),height:this.timecodedGroup.height()}),this.thumbnailsGroup=new M.Group({x:0,y:this.style.height/2-this.style.thumbnailHeight/2,width:this.timecodedGroup.width(),height:this.timecodedGroup.height()}),this.timecodedGroup.add(this.timecodedEventCatcher),this.timecodedGroup.add(this.thumbnailsGroup),this.timeline.addToTimecodedThumbnailsGroup(this.timecodedGroup),this.thumbnailHover=new Ys({style:{visible:!1,stroke:this.style.thumbnailHoverStroke,strokeWidth:this.style.thumbnailHoverStrokeWidth}}),this.timeline.addToTimecodedSurfaceGroup(this.thumbnailHover.initCanvasNode()),this.bodyGroup}settleLayout(){super.settleLayout(),this.timecodedGroup.setAttrs({...this.timelinePosition});let e=this.timeline.getTimecodedGroupHorizontalMeasurement();[this.timecodedGroup,this.timecodedEventCatcher,this.thumbnailsGroup].forEach(t=>{t.width(e.width)}),this.onSettleLayout$.next()}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.fetchAndCreateThumbnails(),this.onSettleLayout$.pipe(k(this.onDestroy$)).subscribe(()=>{this.hideThumbnailHover(),this.adjustThumbnails()}),this.onSettleLayout$.pipe(k(this.onDestroy$)).pipe(Ho(100)).subscribe(()=>{this.createAndAdjustThumbnails()}),this.timecodedGroup.on("mouseout mouseleave",e=>{this.hideThumbnailHover()})}onMeasurementsChange(){super.onMeasurementsChange(),this.hideThumbnailHover(),this.createAndAdjustThumbnails()}destroy(){super.destroy(),this.timecodedGroup.destroy(),this.thumbnailHover.destroy(),this.fireEventStreamBreaker()}clearContent(){this.fireEventStreamBreaker(),this.thumbnailVttFile=void 0,this.clearItems()}clearItems(){this.thumbnailsMap.forEach(e=>e.destroy()),this.thumbnailsMap.clear(),this.thumbnailsVisibleSet.clear(),this.thumbnailsGroup.destroyChildren()}fireEventStreamBreaker(){Ge(this.eventStreamBreaker$),this.eventStreamBreaker$=new V}createAndAdjustThumbnails(){this.isVttLoaded()&&(this.resolveVisibleTimestamps(),this.thumbnailVttFile.getCues().forEach(e=>{let t=this.timeline.timeToTimelinePosition(e.startTime),r=this.thumbnailsVisibleSet.has(e.startTime);if(this.timeline.constrainTimelinePosition(t)===t)if(this.thumbnailsMap.has(e.startTime)){let s=this.thumbnailsMap.get(e.startTime);s&&s.setVisibleAndX(r,t)}else r&&(this.thumbnailsMap.set(e.startTime,null),ct.createKonvaImageSizedByHeight(e.url,this.style.thumbnailHeight).subscribe(s=>{let n=this.thumbnailsVisibleSet.has(e.startTime),a=this.createThumbnail(e,s,n);this.thumbnailsMap.set(e.startTime,a),this.thumbnailsGroup.add(a.getCanvasNode())}))}))}adjustThumbnails(){this.isVttLoaded()&&(this.resolveVisibleTimestamps(),this.thumbnailsMap.forEach(e=>{if(e){let t=this.timeline.timeToTimelinePosition(e.getThumbnailVttCue().startTime),r=this.thumbnailsVisibleSet.has(e.getThumbnailVttCue().startTime);e.setVisibleAndX(r,t)}}))}resolveVisibleTimestamps(){let e;this.thumbnailVttFile.getCues().forEach(r=>{let s=this.timeline.timeToTimelinePosition(r.startTime);this.timeline.constrainTimelinePosition(s)===s&&((e?s>=e:!0)?(e=s+this.thumbnailWidth,this.thumbnailsVisibleSet.add(r.startTime)):this.thumbnailsVisibleSet.delete(r.startTime))})}createThumbnail(e,t,r){let s=this.timeline.timeToTimelinePosition(e.startTime),n=new Ys({listening:!0,style:{x:s,y:0,visible:r,stroke:this.style.thumbnailStroke,strokeWidth:this.style.thumbnailStrokeWidth}});return n.setThumbnailVttCue(e),n.initCanvasNode(),n.setImage(t),n.onClick$.pipe(k(this.eventStreamBreaker$)).subscribe(a=>{this.onClick$.next(a)}),n.onMouseOver$.pipe(k(this.eventStreamBreaker$)).subscribe(a=>{this.showThumbnailHover(a.thumbnail)}),n.onMouseMove$.pipe(k(this.eventStreamBreaker$)).subscribe(a=>{this.showThumbnailHover(a.thumbnail)}),n.onMouseOut$.pipe(k(this.eventStreamBreaker$)).subscribe(a=>{this.hideThumbnailHover()}),n.onMouseLeave$.pipe(k(this.eventStreamBreaker$)).subscribe(a=>{this.hideThumbnailHover()}),n}showThumbnailHover(e){if(this.thumbnailHover.setVisible(!0),this.thumbnailHover.compareTo(e)===0){let t=this.resolveThumbnailHoverPosition(e);this.thumbnailHover.setPosition(t),this.thumbnailHover.setVisible(!0)}else ct.createKonvaImageSizedByWidth(e.getThumbnailVttCue().url,e.getImage().width()*this.style.thumbnailHoverScale).subscribe(t=>{this.thumbnailHover.setDimension(t.getSize()),this.thumbnailHover.setImage(t),this.thumbnailHover.setPosition(this.resolveThumbnailHoverPosition(e)),this.thumbnailHover.getCanvasNode().moveToTop()})}hideThumbnailHover(){this.thumbnailHover&&this.thumbnailHover.style.visible&&this.thumbnailHover.setVisible(!1)}resolveThumbnailHoverPosition(e){let t=this.timeline.getTimecodedGroupRect(),r=this.thumbnailHover.getImage().getSize(),s=e.getPosition().x+e.getDimension().width/2-r.width/2,n=e.style.strokeWidth>0?e.style.strokeWidth/2:0;s=s-n<0?n:s+r.width+n>t.width?t.width-r.width-n:s;let h=this.getRect().y+this.thumbnailsGroup.y()+e.getDimension().height/2-this.thumbnailHover.getDimension().height/2;return{x:s,y:h}}fetchAndCreateThumbnails(){this.fetchThumbnailVttFile(this._thumbnailVttUrl,this._axiosConfig,this.style.thumbnailHeight).pipe($e(1)).subscribe(e=>{e&&(this.thumbnailVttFile=e.thumbnailVttFile,this.thumbnailWidth=e.thumbnailWidth,this.createAndAdjustThumbnails())})}fetchThumbnailVttFile(e,t,r){return e?ls.create(e,t).pipe(tc(s=>{let n=s.getCues()[0];return ct.createKonvaImageSizedByHeight(n.url,r).pipe(ke(a=>{let o=a.getSize().width;return{thumbnailVttFile:s,thumbnailWidth:o}}))}),yi((s,n)=>Se(void 0))):Se(void 0)}isVttLoaded(){return!!this.thumbnailVttFile&&!!this.thumbnailWidth}getThumbnailVttFile(){return this.thumbnailVttFile}get thumbnailVttUrl(){return this._thumbnailVttUrl}set thumbnailVttUrl(e){this._thumbnailVttUrl=e,this.clearContent(),this.fetchAndCreateThumbnails()}}class kn extends Cn{constructor(e,t){super(e,t)}static create(e,t){let r=new kn(e,t);return r.fetch().pipe(ke(s=>r))}mapCue(e){let t=e.text.split(","),r=_e.coerce.number().min(-1).max(0).parse(t[0]),s=_e.coerce.number().min(0).max(1).parse(t[1]);return{id:e.identifier,startTime:new Z(e.start).toDecimalPlaces(3).toNumber(),endTime:new Z(e.end).toDecimalPlaces(3).toNumber(),text:e.text,minSample:r,maxSample:s}}}const Oa={listening:!1,style:{height:20,cornerRadius:20,opacity:1,visible:!0,maxSampleFillLinearGradientColorStops:[0,"red",.2,"yellow",1,"green"],minSampleFillLinearGradientColorStops:[0,"green",.8,"yellow",1,"red"]}};class Fm extends et{constructor(e){super({...Oa,...e,style:{...Oa.style,...e.style}}),this.audioVttCue=this.config.audioVttCue,this.x=this.config.x,this.width=this.config.width,this.listening=this.config.listening}createCanvasNode(){this.group=new M.Group({x:this.x,y:0,width:this.width,height:this.style.height,visible:this.style.visible,listening:this.listening});let e=this.style.height/2,t=this.resolveMaxSampleBarHeight(),r=this.resolveMinSampleBarHeight();return this.maxSampleBar=new M.Rect({x:0,width:this.group.width(),y:e-t,height:t,opacity:this.style.opacity,cornerRadius:[this.style.cornerRadius,this.style.cornerRadius,0,0],fillLinearGradientStartPoint:{x:0,y:-(e-t)},fillLinearGradientEndPoint:{x:0,y:t},fillLinearGradientColorStops:this.style.maxSampleFillLinearGradientColorStops,perfectDrawEnabled:!1,shadowForStrokeEnabled:!1,hitStrokeWidth:0}),this.minSampleBar=new M.Rect({x:0,width:this.group.width(),y:e,height:r,opacity:this.style.opacity,cornerRadius:[0,0,this.style.cornerRadius,this.style.cornerRadius],fillLinearGradientStartPoint:{x:0,y:0},fillLinearGradientEndPoint:{x:0,y:e},fillLinearGradientColorStops:this.style.minSampleFillLinearGradientColorStops,perfectDrawEnabled:!1,shadowForStrokeEnabled:!1,hitStrokeWidth:0}),this.group.add(this.maxSampleBar),this.group.add(this.minSampleBar),this.group}resolveMaxSampleBarHeight(){return new Z(this.audioVttCue.maxSample).mul(this.style.height/2).toDecimalPlaces(2).toNumber()}resolveMinSampleBarHeight(){return new Z(this.audioVttCue.minSample).abs().mul(this.style.height/2).toDecimalPlaces(2).toNumber()}setPosition(e){this.x=e.x,this.isInitialized()&&this.group.position({x:this.x,y:0})}getPosition(){return this.group.getPosition()}getDimension(){return this.group.getSize()}getRect(){return{...this.getPosition(),...this.getDimension()}}getAudioVttCue(){return this.audioVttCue}setAudioVttCue(e){this.audioVttCue=e;let t=this.resolveMaxSampleBarHeight(),r=this.resolveMinSampleBarHeight();this.minSampleBar.setAttrs({height:r}),this.maxSampleBar.setAttrs({y:this.style.height/2-t,height:t,fillLinearGradientStartPoint:{x:0,y:-(this.style.height/2-t)},fillLinearGradientEndPoint:{x:0,y:t}})}destroy(){this.audioVttCue=void 0,super.destroy()}}const Hm={...rr,height:40,paddingTop:0,paddingBottom:0,itemWidth:5,itemMinPadding:2,itemCornerRadius:5,maxSampleFillLinearGradientColorStops:[0,"red",.2,"yellow",1,"green"],minSampleFillLinearGradientColorStops:[0,"green",.8,"yellow",1,"red"]};class Fl extends sr{constructor(e){super({...e,style:{...Hm,...e.style}}),this.audioTrackLaneItemsMap=new Map,this.onSettleLayout$=new V,this._audioVttFileUrl=this.config.audioVttFileUrl}createCanvasNode(){return super.createCanvasNode(),this.timecodedGroup=new M.Group({...this.timelinePosition,width:this.timeline.getTimecodedGroupDimension().width,height:this.bodyGroup.height()}),this.timecodedEventCatcher=wi.createEventCatcher({width:this.timecodedGroup.width(),height:this.timecodedGroup.height()}),this.audioTrackLaneItemsGroup=new M.Group({...F.POSITION_TOP_LEFT,y:this.style.paddingTop,width:this.timecodedGroup.width(),height:this.timecodedGroup.height()-(this.style.paddingTop+this.style.paddingBottom)}),this.timecodedGroup.add(this.timecodedEventCatcher),this.timecodedGroup.add(this.audioTrackLaneItemsGroup),this.timeline.addToTimecodedAudioGroup(this.timecodedGroup),this.bodyGroup}settleLayout(){super.settleLayout(),this.timecodedGroup.setAttrs({...this.timelinePosition});let e=this.timeline.getTimecodedGroupHorizontalMeasurement();[this.timecodedGroup,this.timecodedEventCatcher,this.audioTrackLaneItemsGroup].forEach(t=>{t.width(e.width)}),this.onSettleLayout$.next()}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.fetchAndCreateAudioTrack(),this.onSettleLayout$.pipe(k(this.onDestroy$)).subscribe(()=>{this.settlePosition()}),Nu([this.onSettleLayout$,this.timeline.onScroll$]).pipe(k(this.onDestroy$),Ho(100)).subscribe(()=>{this.settleAll()})}clearContent(){this.audioVttFile=void 0,this.clearItems()}clearItems(){this.audioTrackLaneItemsMap.forEach(e=>e.destroy()),this.audioTrackLaneItemsMap.clear(),this.audioTrackLaneItemsGroup.destroyChildren()}getVisibleCues(){let e=this.timeline.getVisibleTimeRange();return this.audioVttFile.findCues(e.start,e.end)}createEntities(){if(!this.isVttLoaded())return;this.clearItems();let e=this.getVisibleCues(),t=this.timeline.getTimecodedContainerDimension().width;this.numOfInterpolations=new Z(t+this.style.itemMinPadding).div(this.style.itemWidth+this.style.itemMinPadding).floor().toNumber(),this.itemPadding=new Z(t-this.numOfInterpolations*this.style.itemWidth).div(this.numOfInterpolations-1).toNumber();let r=this.resolveNumOfCuesPerInterpolation(e.length),s=this.resolveCuesInterpolations(e,r);for(let n=0;n<this.numOfInterpolations;n++){let a=s.get(n),o=this.resolveInterpolatedItemPosition(n),h=new Fm({x:o,width:this.style.itemWidth,audioVttCue:a,style:{cornerRadius:this.style.itemCornerRadius,height:this.audioTrackLaneItemsGroup.height(),visible:!0,maxSampleFillLinearGradientColorStops:this.style.maxSampleFillLinearGradientColorStops,minSampleFillLinearGradientColorStops:this.style.minSampleFillLinearGradientColorStops}});this.audioTrackLaneItemsMap.set(n,h),this.audioTrackLaneItemsGroup.add(h.initCanvasNode())}}resolveNumOfCuesPerInterpolation(e){return new Z(e).div(this.numOfInterpolations).floor().toNumber()}resolveCuesInterpolations(e,t){let r=e.length-t*this.numOfInterpolations,s=new Map,n=0;for(let a=0;a<this.numOfInterpolations;a++){let o=t+(a<r?1:0),h=n;n=h+o;let l=e.slice(h,n),d=e[h],u=e[n-1],c=0,p=0;l.forEach(m=>{c+=m.minSample,p+=m.maxSample});let f={id:`${a}`,text:"",minSample:new Z(c).div(o).toDecimalPlaces(3).toNumber(),maxSample:new Z(p).div(o).toDecimalPlaces(3).toNumber(),startTime:d.startTime,endTime:u.endTime};s.set(a,f)}return s}settleAll(){if(!this.isVttLoaded()||this.audioTrackLaneItemsMap.size<1)return;let e=this.getVisibleCues(),t=this.resolveNumOfCuesPerInterpolation(e.length),r=this.resolveCuesInterpolations(e,t);for(let s=0;s<this.numOfInterpolations;s++){let n=r.get(s),a=this.audioTrackLaneItemsMap.get(s);a.setAudioVttCue(n),a.setPosition({x:this.resolveInterpolatedItemPosition(s)})}}resolveInterpolatedItemPosition(e){return Math.abs(this.timeline.getTimecodedGroupHorizontalMeasurement().x)+e*this.style.itemWidth+e*this.itemPadding}settlePosition(){if(!(!this.isVttLoaded()||this.audioTrackLaneItemsMap.size<1))for(let e=0;e<this.numOfInterpolations;e++){let t=this.audioTrackLaneItemsMap.get(e),r=this.timeline.timeToTimelinePosition(t.getAudioVttCue().startTime);t.setPosition({x:r})}}fetchAndCreateAudioTrack(){this.fetchAudioTrackVttFile(this._audioVttFileUrl).pipe($e(1)).subscribe(e=>{this.audioVttFile=e,this.createEntities()})}fetchAudioTrackVttFile(e){return e?kn.create(e).pipe(ke(t=>t),yi((t,r)=>Se(void 0))):Se(void 0)}isVttLoaded(){return!!this.audioVttFile}get audioVttFileUrl(){return this._audioVttFileUrl}set audioVttFileUrl(e){this._audioVttFileUrl=e,this.clearContent(),this.fetchAndCreateAudioTrack()}destroy(){this.audioTrackLaneItemsMap.forEach(e=>{e.destroy()}),this.audioVttFile=void 0,Ge(this.onSettleLayout$),super.destroy()}}function Js(i){if(i.from===i.to)return;let e=i.from<i.to,t=e?i.to-i.from:i.from-i.to,r=new M.Animation(s=>{let n=M.Easings.StrongEaseInOut(s.time,0,t,i.duration);if(n>=t)i.onUpdateHandler(s,i.to),r.stop(),i.onCompleteHandler&&(i.onCompleteHandler(s,i.to),r=null);else{let a=i.from+n*(e?1:-1);i.onUpdateHandler(s,a)}},i.layer);r.start()}const Bm={...F.POSITION_TOP_LEFT,width:0,zoomMax:1500,scrollStepNumberOfDivisions:10,style:{height:20,backgroundFill:"#000000",backgroundFillOpacity:.3,handleBarFill:"#01a6f0",handleBarOpacity:1,handleOpacity:1}};class $m extends et{constructor(e){super(_i(e,Bm)),this.onScroll$=new V,this.onZoom$=new V,this.x=this.config.x,this.y=this.config.y,this.width=this.config.width,this.zoomMax=this.config.zoomMax,this.scrollStepNumberOfDivisions=this.config.scrollStepNumberOfDivisions}createCanvasNode(){return this.group=new M.Group({x:this.x,y:this.y,width:this.width,height:this.style.height}),this.background=new M.Rect({...F.POSITION_TOP_LEFT,width:this.group.width(),height:this.style.height,fill:this.style.backgroundFill,opacity:this.style.backgroundFillOpacity}),this.handleGroup=new M.Group({...F.POSITION_TOP_LEFT,width:this.group.width(),height:this.style.height}),this.handleBar=new M.Rect({...F.POSITION_TOP_LEFT,width:this.handleGroup.width(),height:this.style.height,fill:this.style.handleBarFill,opacity:this.style.handleBarOpacity,draggable:!0}),this.leftZoomHandle=new M.Circle({...F.POSITION_TOP_LEFT,fill:this.style.handleBarFill,radius:this.style.height/2,y:this.style.height/2,opacity:this.style.handleOpacity,draggable:!0}),this.rightZoomHandle=new M.Circle({...F.POSITION_TOP_LEFT,fill:this.style.handleBarFill,radius:this.style.height/2,y:this.style.height/2,opacity:this.style.handleOpacity,draggable:!0}),this.handleGroup.add(this.background),this.handleGroup.add(this.handleBar),this.group.add(this.background),this.group.add(this.handleGroup),this.handleGroup.add(this.leftZoomHandle),this.handleGroup.add(this.rightZoomHandle),this.group}afterCanvasNodeInit(){this.styleAdapter.onChange$.pipe(k(this.onDestroy$),We(n=>!!n)).subscribe(n=>{this.onStyleChange()}),this.group.on("click",n=>{this.clickScrollTo(this.group.getRelativePointerPosition().x)}),this.handleBar.on("dragstart dragmove dragend",n=>{let a=this.handleBar.getPosition(),o=this.getConstrainedHandleBarX(a.x);this.handleBar.setAttrs({x:o,y:0}),this.syncLeftRightHandles(),this.handleBar.getRelativePointerPosition().x>=0&&this.handleBar.getRelativePointerPosition().x<=this.handleBar.width()&&this.onScroll$.next({scrollPercent:this.getScrollHandlePercent()})});let e={scaleX:1.5,scaleY:1.5,duration:.1},t={scaleX:1,scaleY:1,duration:.1};this.leftZoomHandle.on("mouseover",n=>{this.leftZoomHandle.to({...e}),it.cursor("ew-resize")}),this.leftZoomHandle.on("mouseout",n=>{this.leftZoomHandle.to({...t}),it.cursor("default")}),this.rightZoomHandle.on("mouseover",n=>{this.rightZoomHandle.to({...e}),it.cursor("ew-resize")}),this.rightZoomHandle.on("mouseout",n=>{this.rightZoomHandle.to({...t}),it.cursor("default")});let r=n=>{let a=n;return a<0?a=0:this.rightZoomHandle.x()-n<=this.minHandleBarWidth&&(a=this.rightZoomHandle.x()-this.minHandleBarWidth),a};this.leftZoomHandle.on("dragstart dragmove dragend",n=>{let a=this.leftZoomHandle.getPosition(),o=r(a.x);this.leftZoomHandle.setAttrs({x:o,y:this.style.height/2}),this.handleBar.setAttrs({x:o,width:this.rightZoomHandle.x()-o}),this.onZoom$.next({zoomPercent:this.getZoomPercent()})});let s=n=>{let a=n,o=this.group.width();return a>o?a=o:n-this.leftZoomHandle.x()<=this.minHandleBarWidth&&(a=this.leftZoomHandle.x()+this.minHandleBarWidth),a};this.rightZoomHandle.on("dragstart dragmove dragend",n=>{let a=this.rightZoomHandle.getPosition(),o=s(a.x);this.rightZoomHandle.setAttrs({x:o,y:this.style.height/2}),this.handleBar.setAttrs({width:o-this.leftZoomHandle.x()}),this.onZoom$.next({zoomPercent:this.getZoomPercent()})})}onMeasurementsChange(){this.group.width(this.width),this.background.width(this.group.width()),this.handleGroup.width(this.group.width()),this.minHandleBarWidth=this.calculateHandleBarWidthFromZoomRatioPercent(this.zoomMax)}onStyleChange(){this.group.setAttrs({height:this.style.height}),this.background.setAttrs({height:this.style.height,fill:this.style.backgroundFill,opacity:this.style.backgroundFillOpacity}),this.handleGroup.setAttrs({height:this.style.height}),this.handleBar.setAttrs({height:this.style.height,fill:this.style.handleBarFill,opacity:this.style.handleBarOpacity}),this.leftZoomHandle.setAttrs({fill:this.style.handleBarFill,radius:this.style.height/2,y:this.style.height/2,opacity:this.style.handleOpacity}),this.rightZoomHandle.setAttrs({fill:this.style.handleBarFill,radius:this.style.height/2,y:this.style.height/2,opacity:this.style.handleOpacity})}getScrollHandleMaxX(){return this.group.width()-this.handleBar.width()}getConstrainedHandleBarX(e){let t=e;return t<0?t=0:t+this.handleBar.width()>this.group.width()&&(t=this.getScrollHandleMaxX()),t}clickScrollTo(e){let t=this.group.width()/this.scrollStepNumberOfDivisions;if(!(e>=this.handleBar.x()&&e<=this.handleBar.x()+this.handleBar.width())){let r=this.handleBar.x()>e,s=this.handleBar.x()+t*(r?-1:1);r?s=s<e?e:s:s=s+this.handleBar.width()>e?e-this.handleBar.width():s,this.scrollToEased(s)}}scrollTo(e){this.handleBar.x(this.getConstrainedHandleBarX(e)),this.syncLeftRightHandles(),this.onScroll$.next({scrollPercent:this.getScrollHandlePercent()})}scrollToEased(e){let t=this.handleBar.x(),r=this.getConstrainedHandleBarX(e);Js({layer:this.handleGroup.getLayer(),duration:F.TIMELINE_SCROLL_EASED_DURATION_MS,from:t,to:r,onUpdateHandler:(s,n)=>{this.scrollTo(n)}})}calculateHandleBarWidthFromZoomRatioPercent(e){return new Z(this.group.width()).mul(100).div(e).toNumber()}getZoomPercent(){return this.group.width()===this.handleBar.width()?100:new Z(this.group.width()).mul(100).div(this.handleBar.width()).toNumber()}getScrollHandlePercent(){return this.handleBar.x()===0?0:new Z(this.handleBar.x()).div(this.group.width()-this.handleBar.width()).mul(100).toNumber()}updateScrollHandle(e){let t=e.getScrollHandleHorizontalMeasurement(this.group.width());this.handleBar.setAttrs({...t}),this.syncLeftRightHandles()}syncLeftRightHandles(){this.leftZoomHandle.x(this.handleBar.x()),this.rightZoomHandle.x(this.handleBar.x()+this.handleBar.width())}setWidth(e){this.width=e,this.onMeasurementsChange()}setPosition(e){this.x=e.x,this.y=e.y,this.group.setAttrs({...e})}getPosition(){return this.group.getPosition()}getRect(){return{...this.group.getPosition(),...this.group.getSize()}}}const Vm={style:{...F.POSITION_TOP_LEFT,height:100,fill:"#737373",fillSnapped:"#ffd500",lineWidth:2,symbolY:0,symbolHeight:15,textFontSize:12,textFill:"#0d0f05",textSnappedFill:"#f43530",visible:!1}};class zm extends et{constructor(e,t){super(_i(e,Vm)),this.stylesProvider=dt.instance(),this.timeline=t}createCanvasNode(){return this.group=new M.Group({x:this.style.x,y:this.style.y,visible:this.style.visible,listening:!1}),this.line=new M.Line({points:[this.style.x,0,this.style.x,this.style.height],stroke:this.style.fill,strokeWidth:this.style.lineWidth,listening:!1}),this.symbol=new M.Circle({y:this.style.symbolY,fill:this.style.fill,radius:this.style.symbolHeight/2,offsetY:-this.style.symbolHeight/2}),this.group.add(this.symbol),this.group.add(this.line),this.label=new M.Label({...F.POSITION_TOP_LEFT,listening:!1}),this.text=new M.Text({fontSize:this.style.textFontSize,fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily,fill:this.style.textFill,...F.POSITION_TOP_LEFT,text:"",listening:!1}),this.label.y(-this.text.getSelfRect().height),this.label.add(this.text),this.group.add(this.label),this.group}afterCanvasNodeInit(){this.styleAdapter.onChange$.pipe(k(this.onDestroy$)).subscribe(e=>{this.onMeasurementsChange()}),this.stylesProvider.onChange$.pipe(We(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.text.setAttrs({fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily})})}onMeasurementsChange(){this.line.points([this.line.x(),0,this.line.x(),this.style.height])}sync(e,t=!1){this.style.visible||this.toggleVisible(!0);let r=this.timeline.timelinePositionToTimeFormatted(e),s=this.text.getSelfRect(),n=s.width/2,a=-n,o=this.timeline.getTimecodedGroupHorizontalMeasurement();o.width-e<n?a=-s.width+(o.width-e):e<n&&(a=-n+(n-e)),this.group.x(e),this.text.text(r),this.label.x(a),t?(this.line.stroke(this.style.fillSnapped),this.text.fill(this.style.fillSnapped),this.symbol.visible(!1)):(this.line.stroke(this.style.fill),this.text.fill(this.style.fill),this.symbol.visible(!0))}toggleVisible(e){this.style={visible:e},this.group.visible(e)}}const Wm={style:{visible:!0,fill:"#f43530",lineWidth:2,symbolHeight:15,scrubberHeight:15,backgroundFill:"#ffffff",backgroundOpacity:0,playProgressFill:"#008cbc",playProgressOpacity:.5,bufferedFill:"#a2a2a2",bufferedOpacity:1}};class Um extends et{constructor(e,t,r){super(_i(e,Wm)),this.timeline=t,this.videoController=r}createCanvasNode(){return this.group=new M.Group({...F.POSITION_TOP_LEFT,listening:!1}),this.background=new M.Rect({...F.POSITION_TOP_LEFT,height:this.style.scrubberHeight,fill:this.style.backgroundFill,opacity:this.style.backgroundOpacity,listening:!1}),this.playProgressBackground=new M.Rect({...F.POSITION_TOP_LEFT,height:this.style.scrubberHeight,fill:this.style.playProgressFill,opacity:this.style.playProgressOpacity,listening:!1}),this.playheadGroup=new M.Group({...F.POSITION_TOP_LEFT,visible:this.style.visible,listening:!1}),this.playheadLine=new M.Line({points:[0,0,0,0],stroke:this.style.fill,strokeWidth:this.style.lineWidth,listening:!1}),this.playheadSymbol=wi.createTriangle({...F.POSITION_TOP_LEFT,height:this.style.symbolHeight,color:this.style.fill}),this.bufferedGroup=new M.Group({...F.POSITION_TOP_LEFT,listening:!1}),this.group.add(this.background),this.group.add(this.bufferedGroup),this.group.add(this.playProgressBackground),this.playheadGroup.add(this.playheadLine),this.playheadGroup.add(this.playheadSymbol),this.group.add(this.playheadGroup),this.group}afterCanvasNodeInit(){this.settleLayout(),this.timeline.onZoom$.pipe(k(this.onDestroy$)).subscribe(e=>{this.settleLayout()}),this.videoController.onVideoLoading$.pipe(k(this.onDestroy$)).subscribe(e=>{this.group.visible(!1)}),this.videoController.onVideoLoaded$.pipe(k(this.onDestroy$)).subscribe(e=>{this.group.visible(!0),this.doPlayProgress(),this.doBufferingProgress()}),this.videoController.onVideoTimeChange$.pipe(k(this.onDestroy$)).subscribe(e=>{this.doPlayProgress()}),this.videoController.onSeeking$.pipe(k(this.onDestroy$)).subscribe(e=>{this.doPlayProgress(),this.doBufferingProgress()}),this.videoController.onBuffering$.pipe(k(this.onDestroy$)).subscribe(e=>{this.doBufferingProgress()})}onMeasurementsChange(){this.settleLayout()}getPlayheadPosition(){return this.playheadGroup.x()}settleLayout(){let e=this.timeline.getTimecodedGroupDimension();[this.group,this.bufferedGroup,this.playheadGroup].forEach(t=>{t.setAttrs({...e})}),[this.background].forEach(t=>{t.setAttrs({width:e.width})}),this.playheadLine.setAttrs({points:[0,0,0,e.height]}),this.doPlayProgress(),this.doBufferingProgress()}doPlayProgress(){let e=this.timeline.timeToTimelinePosition(this.videoController.getCurrentTime());this.playProgressBackground.width(e),this.playheadGroup.x(e)}doBufferingProgress(){let e=this.videoController.getBufferedTimespans();if(e&&e.length>0)if(this.bufferedGroup.hasChildren()){let t=e.length,r=this.bufferedGroup.getChildren().length;t===r?this.bufferedGroup.getChildren().forEach((s,n)=>{let a=e[n],o=this.timeline.timeToTimelinePosition(a.start),h=this.timeline.timeToTimelinePosition(a.end);s.setAttrs({x:o,width:h-o})}):(this.bufferedGroup.getChildren().forEach(s=>s.destroy()),this.createBuffers(e))}else this.createBuffers(e)}createBuffers(e){e.forEach(t=>{let r=this.timeline.timeToTimelinePosition(t.start),s=this.timeline.timeToTimelinePosition(t.end),n=new M.Rect({x:r,y:0,width:s-r,height:this.style.scrubberHeight,fill:this.style.bufferedFill,opacity:this.style.bufferedOpacity,listening:!1});this.bufferedGroup.add(n)})}}const Zm={style:{...F.POSITION_TOP_LEFT,width:150,height:20,textFontSize:20,textFill:"#0d0f05",visible:!0}};class Hl extends et{constructor(e,t){super(_i(e,Zm)),this.stylesProvider=dt.instance(),this.videoEventStreamBreaker$=new V,this.videoController=t}createCanvasNode(){return this.group=new M.Group({x:this.style.x,y:this.style.y,width:this.style.width,height:this.style.height,listening:!1,visible:this.style.visible}),this.text=new M.Text({...F.POSITION_TOP_LEFT,width:this.group.width(),height:this.group.height(),text:"",fontSize:this.style.textFontSize,fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily,fill:this.style.textFill,visible:!0,align:"left",verticalAlign:"middle"}),this.group.add(this.text),this.group}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.stylesProvider.onChange$.pipe(We(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.text.setAttrs({fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily})}),this.videoController.onVideoLoaded$.pipe(We(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.onVideoLoadedEvent(e)})}onMeasurementsChange(){this.group.width(this.style.width)}fireVideoEventStreamBreaker(){Ge(this.videoEventStreamBreaker$),this.videoEventStreamBreaker$=new V}onVideoLoadedEvent(e){this.fireVideoEventStreamBreaker(),this.text.text(this.videoController.formatTimestamp(0)),this.videoController.onVideoTimeChange$.pipe(k(this.videoEventStreamBreaker$)).subscribe(t=>{this.text.text(this.videoController.formatTimestamp(t.currentTime))})}setVisible(e){this.style={visible:e},this.isInitialized()&&this.group.visible(e)}setPosition(e){this.style={...e},this.group.setAttrs({...e}),this.onMeasurementsChange()}getRect(){return this.group.getClientRect()}}const jm={...rr,height:60,tickDivisor:5,tickDivisionMinWidth:18,tickFill:"#0d0f05",tickHeight:12,divisionTickFill:"#000000",divisionTickHeight:12*F.GOLDEN_RATIO,timecodeShowFirst:!0,timecodeFontSize:11,timecodeFill:"#0d0f05"};class Xm extends sr{constructor(e,t){super({...e,style:{...jm,...e.style}}),this.onClick$=new V,this.onMouseEnter$=new V,this.onMouseOver$=new V,this.onMouseMove$=new V,this.onMouseOut$=new V,this.onMouseLeave$=new V,this.videoController=t}createCanvasNode(){return super.createCanvasNode(),this.timecodedGroup=new M.Group({...this.timelinePosition,width:this.timeline.getTimecodedGroupDimension().width,height:this.bodyGroup.height()}),this.timecodedEventCatcher=wi.createEventCatcher({width:this.timecodedGroup.width(),height:this.timecodedGroup.height()}),this.ticksGroup=new M.Group({...F.POSITION_TOP_LEFT,width:this.timecodedGroup.width(),height:this.timecodedGroup.height()}),this.timecodedGroup.add(this.timecodedEventCatcher),this.timecodedGroup.add(this.ticksGroup),this.timeline.addToTimecodedBaseGroup(this.timecodedGroup),this.timecodeDisplay=new Hl({style:{x:10,y:0,width:this.leftGroup.width(),height:this.getRect().height}},this.videoController),this.leftGroup.add(this.timecodeDisplay.initCanvasNode()),this.bodyGroup}settleLayout(){super.settleLayout();let e=this.timeline.getTimecodedGroupHorizontalMeasurement();[this.timecodedGroup,this.timecodedEventCatcher,this.ticksGroup].forEach(t=>{t.width(e.width)}),this.refreshTimeDivisions()}afterCanvasNodeInit(){super.afterCanvasNodeInit(),this.timecodedEventCatcher.on("mousemove",e=>{this.onMouseMove$.next({evt:e.evt,position:this.timecodedGroup.getRelativePointerPosition()})}),this.timecodedEventCatcher.on("mouseenter",e=>{this.onMouseEnter$.next({evt:e.evt,position:this.timecodedGroup.getRelativePointerPosition()})}),this.timecodedEventCatcher.on("mouseout",e=>{this.onMouseOut$.next({evt:e.evt,position:this.timecodedGroup.getRelativePointerPosition()})}),this.timecodedEventCatcher.on("mouseleave",e=>{this.onMouseLeave$.next({evt:e.evt,position:this.timecodedGroup.getRelativePointerPosition()})}),this.timecodedEventCatcher.on("click",e=>{this.onClick$.next({evt:e.evt,position:this.timecodedGroup.getRelativePointerPosition()})}),this.videoController.onVideoLoading$.pipe(k(this.onDestroy$)).subscribe(e=>{this.clearContent()}),this.videoController.onVideoLoaded$.pipe(k(this.onDestroy$)).subscribe(e=>{this.settleLayout()})}onStyleChange(){super.onStyleChange(),this.refreshTimeDivisions(!0)}destroy(){this.timecodedGroup.destroy(),this.videoController=null;let e=[this.onClick$,this.onMouseOver$,this.onMouseMove$,this.onMouseOut$,this.onMouseLeave$];Vt(...e),bi(...e),super.destroy()}clearContent(){this.ticksGroup.destroyChildren()}refreshTimeDivisions(e=!1){if(!this.isTimelineReady())return;let t=this.style.tickDivisor,r=this.style.tickDivisionMinWidth,s=this.timeline.getTimecodedGroupRect().width,n=this.resolveTimeDivisionWidth(s,r,t,t),a=new Z(s).div(n).round().toNumber(),o=!e&&this.tickTotalDivisions===a&&!(this.ticksGroup.getChildren().length<1);o||this.clearContent(),this.tickDivisionWidth=n,this.tickTotalDivisions=a;let h=0,l=2,d=2,u=5;for(let c=0;c<this.tickTotalDivisions+1;c++){let p=c===0,f=c===this.tickTotalDivisions,m=c%t===0,g=c*this.tickDivisionWidth,_=m?this.style.divisionTickHeight:this.style.tickHeight,w=this.ticksGroup.height()-_,b=this.ticksGroup.height()-this.style.divisionTickHeight-u;if(o)this.ticksGroup.getChildren()[c].x(g);else{let T=new M.Group({x:g,y:h}),L=0,A=new M.Line({points:[L,w,L,w+_],stroke:this.style.tickFill,strokeWidth:1,listening:!1});T.add(A);let D=new M.Text({fontSize:this.style.timecodeFontSize,fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily,fill:this.style.timecodeFill,text:`${this.timeline.timelinePositionToTimeFormatted(g)}`,listening:!1}),R=D.getSelfRect(),H=p?L+l:f?L-R.width-d:L-R.width/2,$=b-R.height;D.setAttrs({x:H,y:$});let I=m;I=p?this.style.timecodeShowFirst:I,I&&(T.add(D),T.x()+(D.x()>0?0:D.x()),T.y(),D.width()),this.ticksGroup.add(T)}}}resolveTimeDivisionWidth(e,t,r,s){return new Z(e).div(s).floor().greaterThan(t)?this.resolveTimeDivisionWidth(e,t,r,s*r):new Z(e).div(s/r).toNumber()}}const qm={timelineHTMLElementId:"omakase-timeline",playheadHoverSnapArea:5,zoomScale:1.02,zoomBaseline:100,zoomMax:1500,style:{stageMinWidth:700,backgroundFill:"#f5f5f5",headerBackgroundFill:"#f5f5f5",footerBackgroundFill:"#f5f5f5",scrollbarHeight:15,thumbnailHoverWidth:200,thumbnailHoverStroke:"rgba(255,73,145,0.9)",thumbnailHoverStrokeWidth:5,thumbnailHoverYOffset:0,headerHeight:50,footerHeight:50,leftPanelWidth:200,rightPanelLeftGutterWidth:30,rightPanelRightGutterWidth:30,timecodedContainerClipPadding:20,playheadVisible:!0,playheadFill:"#f43530",playheadLineWidth:2,playheadSymbolHeight:15,playheadScrubberHeight:15,playheadBackgroundFill:"#ffffff",playheadBackgroundOpacity:0,playheadPlayProgressFill:"#008cbc",playheadPlayProgressOpacity:.5,playheadBufferedFill:"#a2a2a2",playheadBufferedOpacity:1}},La="omakase_scrubber_lane";class Ym extends et{constructor(e,t){super(_i(e,qm)),this.scrollWithPlayhead=!0,this.syncTimelineWithPlayheadInProgress=!1,this.mouseWheelEnabled=!1,this.leftPanelVisible=!0,this.videoEventBreaker$=new V,this.onScroll$=new V,this.onZoom$=new V,this.timelineHTMLElementId=this.config.timelineHTMLElementId,this.thumbnailVttUrl=this.config.thumbnailVttUrl,this.axiosConfig=this.config.axiosConfig,this.playheadHoverSnapArea=this.config.playheadHoverSnapArea,this.zoomScale=this.config.zoomScale,this.zoomBaseline=this.config.zoomBaseline,this.zoomMax=this.config.zoomMax,this.timecodedGroupNodes=[],this.timelineLanes=[],this.timelineLanesMap=new Map,this.timelineHTMLElement=document.getElementById(this.timelineHTMLElementId),this.videoController=t}createCanvasNode(){let e=this.resolveStageDimension();return this.width=e.width,this.stage=new M.Stage({container:this.timelineHTMLElementId,...e}),this.layer=new M.Layer,this.stage.add(this.layer),this.layoutGroup=new M.Group({...F.POSITION_TOP_LEFT}),this.layer.add(this.layoutGroup),this.layoutBackground=new M.Rect({...F.POSITION_TOP_LEFT,fill:this.style.backgroundFill}),this.headerGroup=new M.Group({...F.POSITION_TOP_LEFT}),this.headerBackground=new M.Rect({...F.POSITION_TOP_LEFT,fill:this.style.headerBackgroundFill}),this.footerGroup=new M.Group({...F.POSITION_TOP_LEFT}),this.footerBackground=new M.Rect({...F.POSITION_TOP_LEFT,fill:this.style.footerBackgroundFill}),this.bodyGroup=new M.Group({...F.POSITION_TOP_LEFT}),this.bodyContentGroup=new M.Group({...F.POSITION_TOP_LEFT}),this.leftPanel=new M.Group({...F.POSITION_TOP_LEFT}),this.rightPanel=new M.Group({...F.POSITION_TOP_LEFT}),this.timecodedContainer=new M.Group({...F.POSITION_TOP_LEFT}),this.timecodedGroup=new M.Group({...F.POSITION_TOP_LEFT,draggable:!0}),this.timecodedBaseGroup=new M.Group({...F.POSITION_TOP_LEFT,name:"timecodedBaseGroup"}),this.timecodedThumbnailsGroup=new M.Group({...F.POSITION_TOP_LEFT,name:"timecodedThumbnailsGroup"}),this.timecodedSubtitlesGroup=new M.Group({...F.POSITION_TOP_LEFT,name:"timecodedSubtitlesGroup"}),this.timecodedAudioGroup=new M.Group({...F.POSITION_TOP_LEFT,name:"timecodedAudioGroup"}),this.timecodedMarkersGroup=new M.Group({...F.POSITION_TOP_LEFT,name:"timecodedMarkersGroup"}),this.timecodedSurfaceGroup=new M.Group({...F.POSITION_TOP_LEFT,name:"timecodedSurfaceGroup"}),this.timecodedBackground=new M.Rect({...F.POSITION_TOP_LEFT,fill:"yellow",opacity:0,listening:!1}),this.timecodedEventCatcher=wi.createEventCatcher(),this.thumbnailHover=new Ys({style:{visible:!1,stroke:this.style.thumbnailHoverStroke,strokeWidth:this.style.thumbnailHoverStrokeWidth}}),this.layoutGroup.add(this.layoutBackground),this.layoutGroup.add(this.headerGroup),this.layoutGroup.add(this.footerGroup),this.layoutGroup.add(this.bodyGroup),this.headerGroup.add(this.headerBackground),this.footerGroup.add(this.footerBackground),this.bodyGroup.add(this.bodyContentGroup),this.bodyGroup.add(this.leftPanel),this.bodyGroup.add(this.rightPanel),this.rightPanel.add(this.timecodedContainer),this.timecodedContainer.add(this.timecodedGroup),[this.timecodedBackground,this.timecodedEventCatcher,this.timecodedBaseGroup,this.timecodedThumbnailsGroup,this.timecodedSubtitlesGroup,this.timecodedAudioGroup,this.timecodedMarkersGroup,this.timecodedSurfaceGroup].forEach(t=>{this.timecodedGroupNodes.push(t),this.timecodedGroup.add(t)}),this.scrollbar=new $m({style:{height:this.style.scrollbarHeight}}),this.rightPanel.add(this.scrollbar.initCanvasNode()),this.playhead=new Um({style:{visible:this.style.playheadVisible,fill:this.style.playheadFill,lineWidth:this.style.playheadLineWidth,symbolHeight:this.style.playheadSymbolHeight,backgroundFill:this.style.playheadBackgroundFill,backgroundOpacity:this.style.playheadBackgroundOpacity,scrubberHeight:this.style.playheadScrubberHeight,playProgressFill:this.style.playheadPlayProgressFill,playProgressOpacity:this.style.playheadPlayProgressOpacity,bufferedFill:this.style.playheadBufferedFill,bufferedOpacity:this.style.playheadBufferedOpacity}},this,this.videoController),this.playheadHover=new zm({},this),[this.playhead,this.playheadHover].forEach(t=>{this.addToTimecodedSurfaceGroup(t.initCanvasNode())}),this.headerTimecodeDisplay=new Hl({style:{x:10,y:10,visible:!1}},this.videoController),this.headerGroup.add(this.headerTimecodeDisplay.initCanvasNode()),this.settleLayout(),this.addToTimecodedSurfaceGroup(this.thumbnailHover.initCanvasNode()),this.scrubberLane=new Xm({id:La,description:""},this.videoController),this.addLanes([this.scrubberLane]),this.stage}afterCanvasNodeInit(){this.videoController.onVideoLoading$.pipe(We(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.clearContent()}),this.videoController.onVideoLoaded$.pipe(We(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.onVideoLoadedEvent(e)}),be(window,"resize").pipe(k(this.onDestroy$)).subscribe(e=>{setTimeout(()=>{this.onWindowResize(e)},200)}),this.timecodedGroup.on("mouseenter",e=>{this.playheadHover.toggleVisible(this.videoController.isVideoLoaded())}),this.timecodedGroup.on("mouseleave",e=>{this.playheadHover.toggleVisible(!1)}),this.timecodedGroup.on("mousemove",e=>{if(!this.videoController.isVideoLoaded())return;let t=this.timecodedGroup.getRelativePointerPosition().x;this.playheadHoverMove(t)}),this.timecodedMarkersGroup.on("mousemove",e=>{if(!this.videoController.isVideoLoaded())return;let t=this.timecodedGroup.getRelativePointerPosition().x;this.playheadHoverMove(t)}),this.timecodedGroup.on("wheel",e=>{if(!this.videoController.isVideoLoaded())return;if(this.mouseWheelEnabled){let r=e.evt;r.preventDefault();let s=r.deltaY>0?"IN":"OUT";r.ctrlKey&&(s=s==="IN"?"OUT":"IN"),this.zoomStep(s,this.timecodedGroup.getRelativePointerPosition().x),this.updateScrollWithPlayhead()}let t=this.timecodedGroup.getRelativePointerPosition().x;this.playheadHoverMove(t)}),this.timecodedGroup.on("dragstart dragmove dragend",e=>{if(!this.videoController.isVideoLoaded()){this.timecodedGroup.setAttrs({...F.POSITION_TOP_LEFT});return}if(e.target===this.timecodedGroup){let t=this.timecodedGroup.getPosition();this.timecodedGroup.setAttrs({x:this.getConstrainedTimelineX(t.x),y:0}),this.onScroll$.next(this.createScrollEvent()),this.scrollbar.updateScrollHandle(this)}this.updateScrollWithPlayhead()}),this.timecodedGroup.on("dragmove",e=>{it.cursor("grabbing")}),this.timecodedGroup.on("dragend",e=>{it.cursor("default")}),this.scrubberLane.onMouseMove$.pipe(k(this.onDestroy$)).subscribe(e=>{if(!this.videoController.isVideoLoaded())return;this.mouseWheelEnabled=!0;let t=this.timecodedGroup.getRelativePointerPosition().x,r=this.timelinePositionToTime(t);if(this.thumbnailVttFile){let s=this.thumbnailVttFile.findCue(r);this.showThumbnailHover(s)}}),this.scrubberLane.onMouseEnter$.pipe(k(this.onDestroy$)).subscribe(e=>{this.mouseWheelEnabled=!0}),this.scrubberLane.onMouseLeave$.pipe(k(this.onDestroy$)).subscribe(e=>{this.hideThumbnailHover(),this.mouseWheelEnabled=!1}),this.scrubberLane.onClick$.pipe(k(this.onDestroy$)).subscribe(e=>{if(!this.videoController.isVideoLoaded())return;this.updateScrollWithPlayhead();let t=this.timecodedGroup.getRelativePointerPosition().x;this.playheadHoverMove(t),this.videoController.isVideoLoaded()&&this.videoController.seekToTimestamp(this.timelinePositionToTime(t)).subscribe(()=>{})}),this.scrollbar.onScroll$.pipe(k(this.onDestroy$)).subscribe(e=>{this.videoController.isVideoLoaded()&&(this.setHorizontalScrollPercent(this.scrollbar.getScrollHandlePercent()),this.updateScrollWithPlayhead(),this.onScroll$.next(this.createScrollEvent()))}),this.scrollbar.onZoom$.pipe(k(this.onDestroy$)).subscribe(e=>{this.videoController.isVideoLoaded()&&(this.zoomByPercent(e.zoomPercent,!1),this.updateScrollWithPlayhead())}),this.thumbnailVttUrl&&this.fetchThumbnailVttFile().subscribe()}settleLayout(){this.stage.setAttrs({...this.resolveStageDimension()});let e=this.calculateHeights();this.headerGroup.setAttrs({width:this.width,height:this.style.headerHeight}),this.bodyGroup.setAttrs({y:this.headerGroup.y()+this.headerGroup.height(),width:this.layoutGroup.width(),height:e.bodyHeight}),this.footerGroup.setAttrs({y:this.bodyGroup.y()+this.bodyGroup.height(),width:this.width,height:this.style.footerHeight}),this.layoutGroup.setAttrs({width:this.width,height:e.layoutHeight}),this.layoutBackground.setAttrs({...this.layoutGroup.getSize()}),this.headerBackground.setAttrs({...this.headerGroup.getSize()}),this.footerBackground.setAttrs({...this.footerGroup.getSize()}),[this.bodyContentGroup].forEach(t=>{t.setAttrs({...this.bodyGroup.getSize()})}),[this.leftPanel,this.rightPanel].forEach(t=>{t.setAttrs({height:this.bodyGroup.getSize().height})}),this.leftPanel.setAttrs({width:this.leftPanelVisible?this.style.leftPanelWidth:0,visible:this.leftPanelVisible}),this.rightPanel.setAttrs({x:this.leftPanel.x()+this.leftPanel.width()+this.style.rightPanelLeftGutterWidth,width:this.layoutGroup.width()-(this.leftPanel.width()+this.style.rightPanelLeftGutterWidth+this.style.rightPanelRightGutterWidth)}),[this.timecodedContainer,this.timecodedGroup,...this.timecodedGroupNodes].forEach(t=>{t.setAttrs({...this.rightPanel.getSize()})}),this.timecodedContainer.clipFunc(t=>{t.rect(-this.style.timecodedContainerClipPadding,-500,this.timecodedContainer.width()+2*this.style.timecodedContainerClipPadding,this.timecodedContainer.height()+500)}),this.timecodedThumbnailsGroup.clipFunc(t=>{t.rect(0,0,this.timecodedThumbnailsGroup.width(),this.timecodedThumbnailsGroup.height())}),this.scrollbar.setPosition({...this.scrollbar.getPosition(),y:this.leftPanel.getSize().height}),this.scrollbar.setWidth(this.timecodedContainer.width()),this.scrollbar.updateScrollHandle(this),this.maxTimecodedGroupWidth=this.calculateWidthFromZoomRatioPercent(this.zoomMax),this.playheadHover.style={height:this.timecodedContainer.height()},this.timelineLanes.forEach(t=>{t.onMeasurementsChange()}),this.playhead.onMeasurementsChange()}onMeasurementsChange(){this.settleLayout();let e=this.getTimecodedGroupDimension();this.timelineLanes.forEach(t=>{t.onMeasurementsChange()}),this.zoomByWidth(e.width,this.resolveZoomFocus()),this.scrollbar.updateScrollHandle(this)}onWindowResize(e){let t=this.resolveStageDimension();this.width=t.width,this.onMeasurementsChange()}calculateHeights(){let t=this.getLanes().map(r=>r.getDimension().height).reduce((r,s)=>r+s,0);return{bodyHeight:t,layoutHeight:this.style.headerHeight+t+this.style.footerHeight}}resolveStageDimension(){let e=this.getTimelineHTMLElementRect(),t=this.calculateHeights();return{width:e.width>=this.style.stageMinWidth?e.width:this.style.stageMinWidth,height:t.layoutHeight}}getTimelineHTMLElementRect(){return{x:this.timelineHTMLElement.offsetLeft,y:this.timelineHTMLElement.offsetTop,width:this.timelineHTMLElement.offsetWidth,height:this.timelineHTMLElement.offsetHeight}}showThumbnailHover(e){if(e)if(this.thumbnailHover.setVisible(!0),this.thumbnailHover.getThumbnailVttCue()===e){this.thumbnailHover.setThumbnailVttCue(e);let t=this.resolveThumbnailPosition(this.thumbnailHover);this.thumbnailHover.setPosition(t),this.thumbnailHover.getCanvasNode().moveToTop()}else ct.createKonvaImageSizedByWidth(e.url,this.style.thumbnailHoverWidth).subscribe(t=>{this.thumbnailHover.setThumbnailVttCue(e),this.thumbnailHover.setDimension(t.getSize()),this.thumbnailHover.setImage(t),this.thumbnailHover.setPosition(this.resolveThumbnailPosition(this.thumbnailHover)),this.thumbnailHover.getCanvasNode().moveToTop()})}hideThumbnailHover(){this.thumbnailHover&&this.thumbnailHover.setVisible(!1)}resolveThumbnailPosition(e){let t=this.timecodedGroup.getRelativePointerPosition(),r=this.getTimecodedGroupDimension(),s=e.getImage().getSize(),n=t.x-s.width/2,a=e.style.strokeWidth>0?e.style.strokeWidth/2:0;n=n-a<0?a:n+s.width+a>r.width?r.width-s.width-a:n;let h=this.scrubberLane.getRect();return{x:n,y:h.y+h.height+e.style.strokeWidth/2+this.style.thumbnailHoverYOffset}}createScrollEvent(){return{scrollPercent:this.getHorizontalScrollPercent()}}createZoomEvent(){return{zoomPercent:this.getZoomPercent()}}getHorizontalScrollPercent(){if(this.isSnappedStart())return 0;if(this.isSnappedEnd())return 100;{let e=new Z(this.getTimecodedContainerDimension().width-this.getTimecodedGroupDimension().width).abs();return new Z(this.getTimecodedGroupPosition().x).abs().mul(100).div(e).toNumber()}}setHorizontalScrollPercent(e){this.setTimelinePosition(this.calculateTimelineXFromScrollPercent(e))}getScrollHandleHorizontalMeasurement(e){let t=this.getTimecodedGroupDimension().width,r=this.getTimecodedGroupPosition().x,s;return t<=e?s={width:e,x:0}:s={width:new Z(e).mul(e).div(t).round().toNumber(),x:new Z(r).abs().mul(e).div(t).toNumber()},s}scrollTo(e){return e=_e.coerce.number().min(0).max(100).parse(e),this.scrollToPercentEased(e)}scrollToPlayhead(){let e=-this.playhead.getPlayheadPosition()+this.getTimecodedContainerDimension().width/2;return this.scrollToEased(e)}scrollToPercent(e){let t=this.calculateTimelineXFromScrollPercent(e);this.scrollTimeline(t)}scrollToPercentEased(e){let t=this.calculateTimelineXFromScrollPercent(e);return this.scrollToEased(t)}scrollToEased(e){return new re(t=>{let r=this.getTimecodedGroupPosition().x;Js({layer:this.timecodedGroup.getLayer(),duration:F.TIMELINE_SCROLL_EASED_DURATION_MS,from:r,to:e,onUpdateHandler:(s,n)=>{this.scrollTimeline(n)},onCompleteHandler:(s,n)=>{t.next(this.getHorizontalScrollPercent()),t.complete()}})})}isPlayheadInTimecodedView(){return this.isInVisiblePositionRange(this.playhead.getPlayheadPosition())}updateScrollWithPlayhead(){let e=this.playhead.getPlayheadPosition(),t=e<this.getVisiblePositionRange().start,r=this.isInVisiblePositionRange(e);this.scrollWithPlayhead=r&&!t}syncTimelineWithPlayhead(){return new re(e=>{this.scrollToEased(-this.playhead.getPlayheadPosition()).pipe(ke(t=>{e.next(this.getHorizontalScrollPercent()),e.complete()})).subscribe()})}setTimelinePosition(e){let t=this.getConstrainedTimelineX(e);this.timecodedGroup.x(t)}scrollTimeline(e){let t=this.getTimecodedGroupPosition().x;this.setTimelinePosition(e),this.getTimecodedGroupPosition().x!==t&&(this.scrollbar.updateScrollHandle(this),this.setHorizontalScrollPercent(this.scrollbar.getScrollHandlePercent()),this.onScroll$.next(this.createScrollEvent()))}calculateTimelineXFromScrollPercent(e){e=this.getConstrainedScrollPercent(e);let t=this.getTimecodedGroupDimension(),r=this.getTimecodedContainerDimension();if(t.width>r.width){let s=new Z(r.width-t.width);return new Z(e).mul(s).div(100).toDecimalPlaces(2).toNumber()}else return 0}getZoomPercent(){let e=this.getTimecodedGroupDimension(),t=this.getTimecodedContainerDimension();return e.width>t.width?new Z(e.width).mul(100).div(t.width).round().toNumber():this.zoomBaseline}zoomTo(e){return e=_e.coerce.number().min(this.getZoomBaseline()).max(this.getZoomMax()).parse(e),this.zoomToEased(e)}zoomIn(){return new re(e=>{this.zoomStep("IN",this.timecodedGroup.getRelativePointerPosition().x),e.next(this.getZoomPercent()),e.complete()})}zoomOut(){return new re(e=>{this.zoomStep("OUT",this.timecodedGroup.getRelativePointerPosition().x),e.next(this.getZoomPercent()),e.complete()})}zoomToEased(e){return new re(t=>{e=this.getConstrainedZoomPercent(e);let r=this.getTimecodedGroupDimension().width,s=this.calculateWidthFromZoomRatioPercent(e);Js({layer:this.timecodedGroup.getLayer(),duration:F.TIMELINE_ZOOM_EASED_DURATION_MS,from:r,to:s,onUpdateHandler:(n,a)=>{this.zoomByWidth(a,this.resolveZoomFocus())},onCompleteHandler:(n,a)=>{t.next(this.getZoomPercent()),t.complete()}})})}zoomStep(e,t){let r=new Z(this.getTimecodedGroupDimension().width),s=(e==="IN"?r.mul(this.zoomScale):r.div(this.zoomScale)).round().toNumber();this.zoomByWidth(s,t)}zoomByPercent(e,t=!0){e=this.getConstrainedZoomPercent(e);let r=this.calculateWidthFromZoomRatioPercent(e);return this.zoomByWidth(r,this.resolveZoomFocus(),t),this.getZoomPercent()}zoomByWidth(e,t,r=!0){let s=this.getTimecodedGroupPosition().x,n=this.getTimecodedGroupDimension().width;e=this.getConstrainedWidth(e);let a=this.calculateNewPosition(e,t);this.hideThumbnailHover(),this.timecodedGroup.setAttrs({width:e,x:a}),this.timecodedGroupNodes.forEach(h=>{h.width(e)}),(this.getTimecodedGroupDimension().width!==n||this.getTimecodedGroupPosition().x!==s)&&(r?this.scrollbar.updateScrollHandle(this):this.playheadHover.toggleVisible(!1),this.setHorizontalScrollPercent(this.scrollbar.getScrollHandlePercent()),this.onZoom$.next(this.createZoomEvent()),this.onScroll$.next(this.createScrollEvent()))}calculateNewPosition(e,t=0){let r=this.getTimecodedGroupPosition().x,s=this.getTimecodedGroupDimension().width,n=this.getTimecodedContainerRect(),a=e>s?"IN":"OUT",o=r;if(e===n.width)o=0;else if(e>n.width){if(t>0){let h=new Z(t).div(s);if(h.greaterThanOrEqualTo(0)&&h.lessThanOrEqualTo(1)){let l=e-s,d=h.mul(l).abs().round().toNumber(),u=r+d*(a==="IN"?-1:1);o=u<0?u:0}}if(e>n.width){let h=n.x+n.width;o+e<=h&&(o=n.width-e)}}return o}resolveZoomFocus(){return this.videoController.isVideoLoaded()?this.resolvePlayheadSyncPosition():this.isSnappedStart()?0:this.isSnappedEnd()?this.getTimecodedGroupDimension().width:this.getTimecodedGroupDimension().width/2}calculateWidthFromZoomRatioPercent(e){return new Z(this.getTimecodedContainerDimension().width).mul(e).div(100).round().toNumber()}getConstrainedWidth(e){let t=this.getTimecodedContainerDimension();return e>=t.width?e<=this.maxTimecodedGroupWidth?e:this.maxTimecodedGroupWidth:t.width}getConstrainedZoomPercent(e){return e<this.zoomBaseline?this.zoomBaseline:e>this.zoomMax?this.zoomMax:e}getConstrainedScrollPercent(e){return e<0?0:e>100?100:e}playheadHoverMove(e){if(this.videoController.isVideoLoaded()&&this.playheadHover){let t=!1;if(!this.videoController.isPlaying()){let r=this.resolvePlayheadSyncPosition();e>r-this.playheadHoverSnapArea&&e<r+this.playheadHoverSnapArea&&(e=r,t=!0)}this.playheadHover.sync(e,t)}}resolvePlayheadSyncPosition(){return this.timeToTimelinePosition(this.videoController.getCurrentTime())}onVideoLoadedEvent(e){this.fireVideoEventBreaker(),this.clearContent(),this.syncVideoMetadata(),this.videoController.onVideoTimeChange$.pipe(k(this.videoEventBreaker$)).subscribe(t=>{this.syncVideoMetadata()}),this.videoController.onPlay$.pipe(k(this.videoEventBreaker$)).subscribe(t=>{this.updateScrollWithPlayhead()})}fireVideoEventBreaker(){Ge(this.videoEventBreaker$),this.videoEventBreaker$=new V}setThumbnailVttFile(e){this.thumbnailVttFile=e}syncVideoMetadata(){this.scrollWithPlayhead&&!this.isPlayheadInTimecodedView()&&!this.syncTimelineWithPlayheadInProgress&&(this.syncTimelineWithPlayheadInProgress=!0,this.syncTimelineWithPlayhead().subscribe(e=>{this.syncTimelineWithPlayheadInProgress=!1}))}addLane(e){if(this.timelineLanesMap.has(e.getId()))throw new Error(`TimelineLane with id=${e.getId()} already exist`);let t=this.timelineLanes.length<1,r={...F.POSITION_TOP_LEFT};t||(r.y=this.timelineLanes.map(s=>s.getRect().height).reduce((s,n)=>s+n,0)),e.setTimeline(this),e.setVideoController(this.videoController),e.setTimelinePosition(r),e.initCanvasNode(),this.timelineLanes.push(e),this.timelineLanesMap.set(e.getId(),e),this.bodyContentGroup.add(e.getCanvasNode()),this.settleLayout()}removeLane(e){if(!this.timelineLanesMap.has(e))throw new Error(`TimelineLane with id=${e} doesn't exist`);let t=this.timelineLanesMap.get(e);this.timelineLanes.splice(this.timelineLanes.findIndex(s=>s.getId()===e),1),this.timelineLanesMap.delete(e),t.clearContent(),t.destroy();let r={...F.POSITION_TOP_LEFT};this.timelineLanes.forEach(s=>{s.setTimelinePosition({...r}),r.y=r.y+s.getRect().height}),this.timelineLanes.forEach(s=>{s.onMeasurementsChange()}),this.settleLayout()}getScrollbar(){return this.scrollbar}addLanes(e){e.forEach(t=>this.addLane(t))}getLanes(){return[...this.timelineLanesMap.values()]}getLane(e){return this.timelineLanesMap.get(e)}getScrubberLane(){return this.getLane(La)}getMarkerLane(e){let t=this.getLane(e);return t instanceof Ws?t:void 0}getThumbnailLane(e){let t=this.getLane(e);return t instanceof Ks?t:void 0}getSubtitlesLane(e){let t=this.getLane(e);return t instanceof qs?t:void 0}getAudioTrackLane(e){let t=this.getLane(e);return t instanceof Fl?t:void 0}createMarkerLane(e){let t=new Ws(e);return this.addLane(t),t}createThumbnailLane(e){let t=new Ks(e);return this.addLane(t),t}createSubtitlesLane(e){let t=new qs(e);return this.addLane(t),t}isTimelineReady(){return this.videoController.isVideoLoaded()}addToTimecodedBaseGroup(e){this.timecodedBaseGroup.add(e)}addToTimecodedSurfaceGroup(e){this.timecodedSurfaceGroup.add(e)}addToTimecodedMarkersGroup(e){this.timecodedMarkersGroup.add(e)}addToTimecodedThumbnailsGroup(e){this.timecodedThumbnailsGroup.add(e)}addToTimecodedSubtitlesGroup(e){this.timecodedSubtitlesGroup.add(e)}addToTimecodedAudioGroup(e){this.timecodedAudioGroup.add(e)}constrainTimelinePosition(e){let t=this.getTimecodedGroupDimension();return e<0?0:e>t.width?t.width:e}timelinePositionToTime(e){let t=this.constrainTimelinePosition(e);return this.videoController.isVideoLoaded()?new Z(t).mul(this.videoController.getDuration()).div(this.getTimecodedGroupDimension().width).toNumber():0}timelinePositionToTimeFormatted(e){return this.videoController.isVideoLoaded()?this.videoController.formatTimestamp(this.timelinePositionToTime(e)):""}timelinePositionToFrame(e){return this.videoController.isVideoLoaded()?this.videoController.calculateTimeToFrame(this.timelinePositionToTime(e)):0}timeToTimelinePosition(e){return new Z(e).mul(this.getTimecodedGroupDimension().width).div(this.videoController.getDuration()).toNumber()}getConstrainedTimelineX(e){let t=this.getTimecodedGroupDimension(),r=this.getTimecodedContainerDimension();if(t.width<=r.width)return 0;{let s=r.width-t.width;return e<s?s:e>0?0:e}}getBodyGroupRect(){return{...this.bodyGroup.getPosition(),...this.bodyGroup.getSize()}}getLeftPanelRect(){return{...this.leftPanel.getPosition(),...this.leftPanel.getSize()}}getLeftPanelVisible(){return this.leftPanelVisible}getRightPanelRect(){return{...this.rightPanel.getSize(),...this.rightPanel.getPosition()}}getTimecodedContainerDimension(){return this.timecodedContainer.getSize()}getTimecodedContainerPosition(){return this.timecodedContainer.getPosition()}getTimecodedContainerRect(){return{...this.getTimecodedContainerDimension(),...this.getTimecodedContainerPosition()}}getTimecodedGroupDimension(){return this.timecodedGroup.getSize()}getTimecodedGroupPosition(){return this.timecodedGroup.getPosition()}getTimecodedGroupRect(){return{...this.timecodedGroup.getPosition(),...this.timecodedGroup.getSize()}}getTimecodedGroupHorizontalMeasurement(){return{x:this.timecodedGroup.x(),width:this.timecodedGroup.width()}}getRelativePointerPosition(){return this.timecodedGroup.getRelativePointerPosition()}getLayoutGroupDimension(){return this.layoutGroup.getSize()}getLayoutGroupPosition(){return this.layoutGroup.getPosition()}getRect(){return{...this.getLayoutGroupDimension(),...this.getLayoutGroupPosition()}}getVisiblePositionRange(){let e=Math.abs(this.timecodedGroup.x()),t=e+this.timecodedContainer.width();return{start:e,end:t}}isInVisiblePositionRange(e){let t=this.getVisiblePositionRange();return e>=t.start&&e<=t.end}isSnappedStart(){return this.getTimecodedGroupPosition().x===0}isSnappedEnd(){return this.getTimecodedContainerDimension().width-this.getTimecodedGroupDimension().width===this.getTimecodedGroupPosition().x}getVisibleTimeRange(){let e=this.getVisiblePositionRange(),t=this.timelinePositionToTime(e.start),r=this.timelinePositionToTime(e.end);return{start:t,end:r}}getZoomBaseline(){return this.zoomBaseline}getZoomMax(){return this.zoomMax}fetchThumbnailVttFile(){return this.thumbnailVttUrl?ls.create(this.thumbnailVttUrl,this.axiosConfig).pipe(ke(e=>(this.thumbnailVttFile=e,e)),yi((e,t)=>Se(void 0))):Se(void 0)}toggleLeftPanelVisible(e){this.leftPanelVisible=e,this.leftPanel.visible(e),this.settleLayout(),this.timelineLanes.forEach(t=>{t.onMeasurementsChange()}),this.headerTimecodeDisplay.setVisible(!e)}clearContent(){this.setThumbnailVttFile(void 0),this.timelineLanes.forEach(e=>{e.clearContent()}),this.zoomByPercent(this.zoomBaseline)}destroy(){this.timelineHTMLElement=void 0,this.videoController=void 0,this.thumbnailVttFile=void 0,pn(this.videoEventBreaker$);let e=[this.onScroll$,this.onZoom$];Vt(...e),bi(...e),[this.scrollbar,this.playheadHover,this.playhead,...this.timelineLanes,this.thumbnailHover,this.headerTimecodeDisplay].forEach(r=>{r&&r.destroy()}),super.destroy()}}class Qs{static timeToFrame(e,t){return t.mul(e).floor().toNumber()}static frameToTime(e,t){return new Z(e).dividedBy(t).toNumber()}}class ri{constructor(){this.resolveUserAgent()}static instance(){return ri._instance||(ri._instance=new ri),ri._instance}resolveUserAgent(){this._userAgent=window.navigator&&window.navigator.userAgent||"",this._isAndroid=/Android/i.test(this._userAgent),this._isFirefox=/Firefox/i.test(this._userAgent),this._isEdge=/Edg/i.test(this._userAgent),this._isChromium=/Chrome/i.test(this._userAgent)||/CriOS/i.test(this._userAgent),this._isChrome=!this.isEdge&&this.isChromium,this._isSafari=/Safari/i.test(this._userAgent)&&!this.isChrome&&!this.isAndroid&&!this.isEdge}get isSafari(){return this._isSafari}get isFirefox(){return this._isFirefox}get isEdge(){return this._isEdge}get isChromium(){return this._isChromium}get isChrome(){return this._isChrome}get isAndroid(){return this._isAndroid}}const tt=class{static formatVideoTimestamp(i,e){if(i<=0)return tt.VIDEO_ZERO_TIMESTAMP;const t=Math.floor(i/3600),r=Math.floor(i%3600/60),s=Math.floor(i%60);let n=new Z(Qs.timeToFrame(i,e)).mod(e).toNumber();return`${tt.padZero(t)}:${tt.padZero(r)}:${tt.padZero(s)}:${tt.padZero(n)}`}static padZero(i,e=2){return i.toString().padStart(e,"0")}};let en=tt;en.VIDEO_ZERO_TIMESTAMP=`${tt.padZero(0)}:${tt.padZero(0)}:${tt.padZero(0)}:${tt.padZero(0)}`;class Km{constructor(){this._state={playing:!1,paused:!0,waiting:!1,seeking:!1,buffering:!1,ended:!1},this.onChange$=new ti(this._state)}updateState(e){let t={...this._state,...e},r=this.compare(this._state,t)===0;this._state=t,r||this.onChange$.next(this._state)}compare(e,t){return e.playing===t.playing&&e.paused===t.paused&&e.waiting===t.waiting&&e.seeking===t.seeking&&e.buffering===t.buffering&&e.ended===t.ended?0:-1}get state(){return this._state}setPlaying(){this.updateState({playing:!0,paused:!1,waiting:!1,seeking:!1,buffering:!1,ended:!1})}setPaused(){this.updateState({playing:!1,paused:!0,waiting:!1,seeking:!1,buffering:!1,ended:!1})}setEnded(){this.updateState({playing:!1,paused:!0,waiting:!1,seeking:!1,buffering:!1,ended:!0})}set waiting(e){this.updateState({waiting:e})}set seeking(e){this.updateState({seeking:e,ended:!1})}set buffering(e){this.updateState({buffering:e})}}function Ra(i){let e;return typeof i=="string"?e=i:i instanceof st?(console.log(i),e=i.errors.map(t=>t.message).join(". ")):i instanceof Error?e=i.message:e="Unexpected error",e}function Jm(i){return{errorMap:(e,t)=>({message:i})}}const Be={PAUSE:"pause",WAITING:"waiting",PLAYING:"playing",TIMEUPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",LOADEDDATA:"loadeddata",LOADEDMETEDATA:"loadedmetadata",ENDED:"ended",PROGRESS:"progress"};class Qm{constructor(e,t){if(this.browserProvider=ri.instance(),this.helpMenuGroups=[],this._isVideoLoaded=!1,this.frameDurationSpillOverCorrection=.001,this.syncLoopMaxIterations=20,this.seekInProgress=!1,this.videoStalledCheckIntervalMs=700,this.videoFrameCallback$=new ti(null),this.videoEventBreaker$=new V,this.onDestroy$=new V,this.seekBreaker$=new V,this.onVideoLoaded$=new ti(void 0),this.onVideoLoading$=new V,this.onPlay$=new V,this.onPause$=new V,this.onVideoTimeChange$=new V,this.onSeeking$=new V,this.onSeeked$=new V,this.onBuffering$=new V,this.onEnded$=new V,this.onAudioSwitched$=new V,this.onPlaybackState$=new V,this.onHelpMenuChange$=new ti(void 0),this.onVideoError$=new V,this.domController=e,this.crossorigin=t,this.videoElement=this.domController.videoElement,this.videoElement.crossOrigin=this.crossorigin,!this.videoElement)throw new Error("VideoController element not set");this.videoFrameCallback$.pipe(k(this.onDestroy$)).subscribe(r=>{r&&(this.seekInProgress||(this.isPlaying()?this.videoTimeChangeHandlerExecutor():this.isPaused()))})}loadVideo(e,t,r){try{return e=li.url()(e),t=_e.coerce.number().min(0).max(100).parse(t,Jm("Invalid frameRate")),this.onVideoLoading$.next({sourceUrl:e,frameRate:t}),this._isVideoLoaded=!1,this.video=void 0,this.detachVideoEventListeners(),this.videoLoad(e,t,r).pipe(ke(s=>{this.video=s,this.frameRateDecimal=new Z(this.video.frameRate),this.syncStepCurrentTimeMediaTime=0,this.playbackStateMachine=new Km,this.initEventHandlers(),this.startVideoFrameCallback(),this._isVideoLoaded=!0,this.onVideoLoaded$.next({video:this.video});let n=Number.parseFloat(this.getDuration().toFixed(3));return Number.isInteger(n*this.video.frameRate)&&(n=Number.parseFloat((n-this.frameDurationSpillOverCorrection).toFixed(3)),this.video.setCorrectedDuration(n)),this.getHls().on(Ze.Events.FRAG_LOADED,(a,o)=>{o.frag.endList&&o.frag.type=="main"&&this.getCorrectedDuration()>o.frag.start+o.frag.duration&&this.video.setCorrectedDuration(Number.isInteger(o.frag.start+o.frag.duration*this.video.frameRate)?o.frag.start+o.frag.duration-this.frameDurationSpillOverCorrection:o.frag.start+o.frag.duration)}),s}),yi((s,n)=>{let a=Ra(s);return this.onVideoError$.next({type:"VIDEO_LOAD_ERROR",message:a}),ia(()=>new Error(a))}))}catch(s){let n=Ra(s);return this.onVideoError$.next({type:"VIDEO_LOAD_ERROR",message:n}),ia(()=>new Error(n))}}initEventHandlers(){be(this.videoElement,Be.PAUSE).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.getCurrentTime()>=this.getCorrectedDuration()?this.getTotalFrames():this.getCurrentFrame(),this.getCurrentTime()<this.getCorrectedDuration()?this.seekToFrame(this.getCurrentTime()>=this.getCorrectedDuration()?this.getTotalFrames():this.getCurrentFrame()).subscribe(t=>{this.videoTimeChangeHandlerExecutor(),this.onPause$.next({})}):this.syncVideoFrames({}).subscribe(t=>{this.videoTimeChangeHandlerExecutor(),this.onPause$.next({})})}),be(this.videoElement,Be.WAITING).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.waiting=!0}),be(this.videoElement,Be.PLAYING).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setPlaying(),this.videoStalledCheckLastCurrentTime=void 0}),be(this.videoElement,Be.PAUSE).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setPaused(),this.videoStalledCheckLastCurrentTime=void 0}),be(this.videoElement,Be.PROGRESS).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.onBuffering$.next({bufferedTimespans:this.getBufferedTimespans()})}),be(this.videoElement,Be.ENDED).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.onEnded$.next({})}),this.playbackStateMachine.onChange$.pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.onPlaybackState$.next(e)}),this.onPlay$.pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setPlaying(),this.videoStalledCheckLastCurrentTime=void 0}),this.onPause$.pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setPaused(),this.videoStalledCheckLastCurrentTime=void 0}),this.onSeeking$.pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.seeking=!0}),this.onSeeked$.pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.seeking=!1}),this.onEnded$.pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setEnded(),this.videoStalledCheckLastCurrentTime=void 0}),Xu(this.videoStalledCheckIntervalMs).pipe(k(this.videoEventBreaker$)).subscribe(e=>{let t=this.getCurrentTime();if(!this.videoStalledCheckLastCurrentTime){this.videoStalledCheckLastCurrentTime=t;return}if(this.playbackStateMachine.state.playing){let r=this.videoStalledCheckIntervalMs*.8/1e3*this.getPlaybackRate(),s=this.videoStalledCheckLastCurrentTime+r,n=t<s;this.playbackStateMachine.waiting=n,this.videoStalledCheckLastCurrentTime=t}})}getBufferedTimespans(){if(!this.isVideoLoaded())return[];let e=[],t=this.videoElement.buffered;for(let r=0;r<t.length;r++)e.push({start:t.start(r),end:t.end(r)});return e}startVideoFrameCallback(){let e=()=>{this.videoElement?this.videoFrameCallbackHandle=this.videoElement.requestVideoFrameCallback((r,s)=>{t({now:r,metadata:s})}):console.debug("Cannot call requestVideoFrameCallback, videoElement not found")},t=r=>{this.videoFrameCallback$.next(r),e()};e()}detachVideoEventListeners(){Ge(this.videoEventBreaker$),this.videoEventBreaker$=new V,this.videoElement&&this.videoFrameCallbackHandle&&this.videoElement.cancelVideoFrameCallback(this.videoFrameCallbackHandle)}syncVideoFrames(e){return console.debug("syncFrames - START",e),new re(t=>{let r=new ti(!1),s=new V,n=this.syncLoopMaxIterations;this.seekBreaker$.pipe(k(s)).subscribe(()=>{console.debug("%csyncFrames - seek breaker triggered","color: gray"),r.next(!0),a()});let a=()=>{Ge(s),t.next(!0),t.complete(),console.debug("%csyncFrames - END","color: gray")},o=h=>{r.pipe($e(1)).subscribe(l=>{l?console.debug("%csyncFrames - seek skipped, breaker already triggered","color: gray"):this._seekTimeFireAndForget(h)})};if(this.isPlaying())console.debug("%csyncFrames - SKIPPED: video is playing","color: gray"),a();else if(this.getCorrectedDuration()<=this.getCurrentTime())console.debug("%csyncFrames - SKIPPED: video exceeded duration","color: magenta"),a();else{let h=u=>{let c=this.getCurrentTime(),p=this.calculateTimeToFrame(c),f=u?u.metadata.mediaTime:void 0,m=f?this.calculateTimeToFrame(f):void 0;if(this.isPlaying())return console.debug("%csyncFrames - UNKNOWN: video is playing","color: gray"),!0;if(p===0)return console.debug(`%csyncFrames - OK: currentTimeFrame[${p}] === 0`,"color: green"),!0;if(e.seekToFrame){if(e.seekToFrame===p&&(p===m||!m))return console.debug(`%csyncFrames - OK: ((currentTimeFrame[${p}] === mediaTimeFrame[${m}]) || !mediaTimeFrame[${m}])`,"color: green"),!0}else if(p===m||!m)return console.debug(`%csyncFrames - OK: currentTimeFrame[${p}] === mediaTimeFrame[${m}]`,"color: green"),!0;return!1},l,d=u=>{let c=this.syncLoopMaxIterations-n;if(console.debug(`syncFrames.syncLoop - START (${c})`,{syncConditions:e,videoFrameCallbackData:u,dropped:this.videoElement.getVideoPlaybackQuality()}),this.isPlaying()){a();return}if(h(u)){a();return}let p=this.getCurrentTime(),f=this.calculateTimeToFrame(p),m=u?u.metadata.mediaTime:void 0,g=m?this.calculateTimeToFrame(m):void 0;if(n--<=0){console.debug(`%csyncFrames - TOO MANY SYNCs, EXITING.. : currentTime[${p}], mediaTime[${m}], currentTimeFrame[${f}], mediaTimeFrame[${g}]`,"color: red"),a();return}if(console.debug(`syncFrames - currentTime[${p}|${this.formatTimestamp(p)}], mediaTime[${m}|${this.formatTimestamp(m)}], currentTimeFrame[${f}], mediaTimeFrame[${g}], `),e.seekToFrame)if(l||(l=p),e.seekToFrame===f)if(f===g||!g)console.debug(`%csyncFrames - OK: ((currentTimeFrame[${f}] === mediaTimeFrame[${g}]) || !mediaTimeFrame[${g}])`,"color: green"),a();else{console.debug(`%csyncFrames - CORRECTION SEEK TO FRAME; currentTimeFrame[${f}] ${f>g?">":"<"} mediaTimeFrame[${g}]`,"color: red");let _=Math.abs(f-g);console.debug(`%csyncFrames - frameDiff: ${_}`,"color: orange");let w=this.syncStepCurrentTimeMediaTime*(f>g?1:-1);o(Z.add(p,w).toNumber())}else{console.debug(`%csyncFrames - CORRECTION SEEK TO FRAME; syncConditions.seekToFrame[${e.seekToFrame}] !== currentTimeFrame[${f}] | seekToFrameTimeBaseline=${l}`,"color: red");let _=Math.abs(e.seekToFrame-f),w=_*this.video.frameDuration,T=(e.seekToFrame>=f?Z.add(l,w):Z.sub(l,w)).toNumber();l=T,console.debug(`%csyncFrames - frameDiff: ${_}`,"color: orange"),console.debug(`%csyncFrames - frameCorrectionTime: ${w}`,"color: orange"),console.debug(`%csyncFrames - seekTo: ${T}`,"color: orange"),o(T)}else f===g||!g?(console.debug(`%csyncFrames - OK: currentTimeFrame[${f}] === mediaTimeFrame[${g}]`,"color: green"),a()):(console.debug(`%csyncFrames - CORRECTION; currentTimeFrame[${f}] ${f>g?">":"<"} mediaTimeFrame[${g}]`,"color: red"),c===0?o(p):f>g?o(Z.add(p,this.syncStepCurrentTimeMediaTime).toNumber()):o(m+this.syncStepCurrentTimeMediaTime));console.debug("syncFrames.syncLoop - END")};this.videoFrameCallback$.pipe(Ju((e.seekToFrame,0)),k(s)).subscribe(u=>{console.debug("syncFrames.syncLoop - videoFrameCallback$ trigger",u),d(u)})}})}seekTimeAndSync(e,t={}){return new re(r=>{this.seekInProgress&&(Ge(this.seekBreaker$),this.seekBreaker$=new V),this.seekInProgress=!0,isNaN(e)||(e=e<0?0:e>this.getDuration()?this.getDuration():e,be(this.videoElement,Be.SEEKING).pipe(k(this.seekBreaker$),$e(1)).subscribe(s=>{this.onSeeking$.next({newTime:e,currentTime:this.getCurrentTime()})}),be(this.videoElement,Be.SEEKED).pipe(k(this.seekBreaker$),$e(1)).subscribe(s=>{this.syncVideoFrames(t).subscribe(n=>{this.getCorrectedDuration()>this.getHTMLVideoElement().duration&&this.video.setCorrectedDuration(Number.isInteger(this.getHTMLVideoElement().duration*this.video.frameRate)?this.getHTMLVideoElement().duration-this.frameDurationSpillOverCorrection:this.getHTMLVideoElement().duration);let a=()=>{this.seekInProgress=!1,r.next(!0),r.complete(),this.videoTimeChangeHandlerExecutor()};this.getCurrentTime()>this.getCorrectedDuration()?this.seekTimeWithoutSync(this.getCorrectedDuration()).pipe(k(this.seekBreaker$),$e(1)).subscribe(()=>{this.onEnded$.next({}),a()}):(this.onSeeked$.next({currentTime:this.getCurrentTime()}),a())})}),console.debug(`Seeking to timestamp: ${e} ${this.formatTimestamp(e)}`),this.setCurrentTime(e))})}seekTimeWithoutSync(e){return new re(t=>{this.seekInProgress&&(Ge(this.seekBreaker$),this.seekBreaker$=new V),this.seekInProgress=!0,isNaN(e)||(e=e<0?0:e>this.getDuration()?this.getDuration():e,be(this.videoElement,Be.SEEKING).pipe(k(this.seekBreaker$),$e(1)).subscribe(r=>{this.onSeeking$.next({newTime:e,currentTime:this.getCurrentTime()})}),be(this.videoElement,Be.SEEKED).pipe(k(this.seekBreaker$),$e(1)).subscribe(r=>{this.onSeeked$.next({currentTime:this.getCurrentTime()}),this.seekInProgress=!1,t.next(!0),t.complete(),this.videoTimeChangeHandlerExecutor()}),console.debug(`Seeking to timestamp: ${e} ${this.formatTimestamp(e)}`),this.setCurrentTime(e))})}_seekTimeFireAndForget(e){if(!isNaN(e)){let t=this.getCurrentTime();e=e<0?0:e>this.getDuration()?this.getDuration():e;let r=e===t?"NONE":e>t?"FORWARD":"BACKWARD",s=Z.sub(t,e).abs();console.debug(`Seeking from currentTime[${t}] to newTime[${e}], direction: ${r} ${s.toNumber()}`),this.setCurrentTime(e)}}_seekTimeAndSyncNoEmitEvents(e){return this.isPlaying()?Se(!1):new re(t=>{isNaN(e)||(e=e<0?0:e>this.getDuration()?this.getDuration():e,be(this.videoElement,Be.SEEKED).pipe(ui()).subscribe(r=>{this.syncVideoFrames({}).subscribe(s=>{t.next(!0),t.complete(),this.videoTimeChangeHandlerExecutor()})}),console.debug(`Seeking ${e}`),this.setCurrentTime(e))})}seekFromCurrentTimeAndSync(e,t={}){let r=this.getCurrentTime();t.currentTime&&(r=t.currentTime);let s=Z.add(r,e).toNumber(),n;t.seekDirection?n=t.seekDirection:n=s===r?"NONE":s>r?"FORWARD":"BACKWARD";let a=Z.sub(r,s).abs().toNumber();return console.debug(`Seeking from currentTime ${r} to ${s}, direction: ${n} ${a}`),this.seekTimeAndSync(s,t)}setCurrentTime(e){this.videoElement.currentTime=e}getFrameRateDecimal(){return this.frameRateDecimal}_seekToFrame(e){if(!this.isPlaying()&&!isNaN(e)){if(console.debug(`Seeking to frame: ${e}`),e<=0)return this.seekTimeAndSync(0,{});{let t=this.calculateFrameToTime(e)+new Z(this.frameDurationSpillOverCorrection).toNumber(),r=this.calculateTimeToFrame(t);return r!==e&&e!=this.getCorrectedDuration()*this.getFrameRate()?(console.error(`Frame numbers don't match. Wanted: ${e}, calculated: ${r}`),Se(!1)):this.seekTimeAndSync(t,{seekToFrame:e,seekToTimestamp:t,currentTime:this.getCurrentTime()}).pipe(ke(s=>s))}}}_seekFromCurrentFrame(e){let t=this.getCurrentFrame(),r=t+e;if(console.debug(`seekFromCurrentFrame - Current frame: ${t}, wanted frame: ${r}`),t!==r){if(r<=0)return this._seekToFrame(0);if(r>=this.getTotalFrames()||r>=this.getCorrectedDuration()*this.getFrameRate()&&!this.playbackStateMachine.state.ended)return this._seekToFrame(this.getCorrectedDuration()*this.getFrameRate());if(r>=this.getTotalFrames()||r>=this.getCorrectedDuration()*this.getFrameRate()&&this.playbackStateMachine.state.ended)return Se(!1);{let s=this.calculateFrameToTime(e),n=t/this.getFrameRate()+this.frameDurationSpillOverCorrection;return this.seekFromCurrentTimeAndSync(s,{seekToFrame:r,currentTime:n,seekDirection:e>0?"FORWARD":"BACKWARD"}).pipe(ke(a=>a))}}else return Se(!0)}videoTimeChangeHandlerExecutor(){let e=this.getCurrentTime(),t=this.getCurrentFrame();this.onVideoTimeChange$.next({currentTime:e,frame:t})}getPlaybackState(){return this.playbackStateMachine.state}getVideo(){return this.isVideoLoaded()?this.video:void 0}getHTMLVideoElement(){return this.videoElement}calculateTimeToFrame(e){return Qs.timeToFrame(e,this.getFrameRateDecimal())}calculateFrameToTime(e){return Qs.frameToTime(e,this.getFrameRateDecimal())}play(){this.isVideoLoaded()&&!this.isPlaying()&&this.videoElement.play().then(()=>{this.onPlay$.next({})})}pause(){this.isVideoLoaded()&&this.isPlaying()&&this.videoElement.pause()}togglePlayPause(){this.isPlaying()?this.pause():this.play()}isPlaying(){return this.isVideoLoaded()&&this.videoElement.currentTime>0&&this.videoElement.currentTime<this.getDuration()&&!this.videoElement.paused&&!this.videoElement.ended&&this.videoElement.readyState>this.videoElement.HAVE_CURRENT_DATA}isPaused(){return!this.isPlaying()}isSeeking(){return this.seekInProgress}getCurrentTime(){return this.isVideoLoaded()?this.videoElement.currentTime:0}getPlaybackRate(){return this.isVideoLoaded()?this.videoElement.playbackRate:0}setPlaybackRate(e){if(this.isVideoLoaded()){try{e=_e.coerce.number().min(.1).max(16).default(1).parse(e)}catch{e=1}this.videoElement.playbackRate=e}}getVolume(){return this.isVideoLoaded()?this.videoElement.volume:0}setVolume(e){if(this.isVideoLoaded()){try{e=_e.coerce.number().min(0).max(1).default(1).parse(e)}catch{e=1}this.videoElement.volume=e}}getDuration(){return this.isVideoLoaded()?this.video.duration:0}getCorrectedDuration(){return this.isVideoLoaded()?this.video.correctedDuration:0}getFrameRate(){return this.isVideoLoaded()?this.video.frameRate:0}getTotalFrames(){return this.isVideoLoaded()?this.video.totalFrames:0}getCurrentFrame(){return this.isVideoLoaded()?this.calculateTimeToFrame(this.getCurrentTime()):0}seekToFrame(e){return!this.isVideoLoaded()||this.playbackStateMachine.state.ended&&e>=this.getCurrentFrame()?Se(!1):(e=_e.coerce.number().min(0).max(this.getTotalFrames()).parse(e),this._seekToFrame(e))}seekFromCurrentFrame(e){return this.isVideoLoaded()?(e=_e.coerce.number().parse(e),this._seekFromCurrentFrame(e)):Se(!1)}seekPreviousFrame(){return this.isVideoLoaded()?this.seekFromCurrentFrame(-1):Se(!1)}seekNextFrame(){return this.isVideoLoaded()?this.seekFromCurrentFrame(1):Se(!1)}seekToTimestamp(e){return!this.isVideoLoaded()||this.playbackStateMachine.state.ended&&e>=this.getCorrectedDuration()?Se(!1):(e=_e.coerce.number().parse(e),e>this.getCorrectedDuration()&&(e=this.getCorrectedDuration()),this.seekTimeAndSync(e,{seekToTimestamp:e,seekDirection:e===this.getCurrentTime()?"NONE":e>this.getCurrentTime()?"FORWARD":"BACKWARD"}))}formatTimestamp(e){return this.isVideoLoaded()?(e=_e.coerce.number().min(0).parse(e),en.formatVideoTimestamp(e,this.getFrameRateDecimal())):en.VIDEO_ZERO_TIMESTAMP}mute(){this.isVideoLoaded()&&(this.videoElement.muted=!0)}unmute(){this.isVideoLoaded()&&(this.videoElement.muted=!1)}isFullscreen(){return this.isVideoLoaded()?this.domController.isFullscreen():!1}toggleFullscreen(){this.isVideoLoaded()&&this.domController.toggleFullscreen(this.videoElement)}getAudioTracks(){throw new Error("unsupported")}getCurrentAudioTrack(){throw new Error("unsupported")}setAudioTrack(e){throw new Error("unsupported")}isVideoLoaded(){return this._isVideoLoaded}getHls(){throw new Error("Unsupported or video not loaded with Hls.js")}addHelpMenuGroup(e){this.helpMenuGroups.push(e),this.onHelpMenuChange$.next()}getHelpMenuGroups(){return this.helpMenuGroups}destroy(){pn(this.videoEventBreaker$,this.seekBreaker$),Vt(this.videoFrameCallback$);let e=[this.onVideoLoaded$,this.onVideoLoading$,this.onPlay$,this.onPause$,this.onVideoTimeChange$,this.onSeeking$,this.onSeeked$,this.onBuffering$,this.onEnded$,this.onAudioSwitched$,this.onPlaybackState$,this.onHelpMenuChange$,this.onVideoError$];Vt(...e),bi(...e);try{this.getHls()&&(this.getHls().removeAllListeners(),this.getHls().destroy())}catch(t){console.error(t)}Ge(this.onDestroy$),this.videoElement=null,this.domController=null,this._isVideoLoaded=!1,this.playbackStateMachine=null}}class eg{constructor(e,t,r,s){this._element=e,this._sourceUrl=t,this._frameRate=r,this._duration=s,this._totalFrames=new Z(this._duration).mul(this._frameRate).ceil().toNumber(),this._frameDuration=new Z(1).div(this._frameRate).toNumber()}get element(){return this._element}get sourceUrl(){return this._sourceUrl}get frameRate(){return this._frameRate}get duration(){return this._duration}get totalFrames(){return this._totalFrames}get frameDuration(){return this._frameDuration}get correctedDuration(){return this._correctedDuration}setCorrectedDuration(e){console.debug(`%cVideo duration correction: initialDuration:${this.duration} > updatedDuration:${e} `,"color: magenta"),this._correctedDuration=e}}class tg extends Qm{constructor(e,t){super(e,t),Ze.isSupported()?console.debug("video load with hls.js"):console.error("hls is not supported through MediaSource extensions");let r={...Ze.DefaultConfig,enableWorker:!1};this.hls=new Ze(r)}videoLoad(e,t,r){return new re(s=>{this.hls.on(Ze.Events.ERROR,function(h,l){l.type;let d=l.details;l.fatal,d.includes("audioTrackLoadError")||(s.error(`Error loading video. Hls error details: ${d}`),s.complete())});let n=new re(h=>{this.hls.once(Ze.Events.MEDIA_ATTACHED,function(l,d){console.debug("video element and hls.js are now bound together"),h.next(!0),h.complete()})}),a=new re(h=>{this.hls.once(Ze.Events.MANIFEST_PARSED,function(l,d){console.debug("manifest loaded, found "+d.levels.length+" quality level"),h.next(!0),h.complete()})}),o=be(this.videoElement,Be.LOADEDDATA).pipe(ui());$u([n,a,o]).pipe(ui()).subscribe(h=>{r=r&&_e.coerce.number().parse(r),r=r||this.videoElement.duration;let l=new eg(this.videoElement,e,t,r);s.next(l),s.complete()}),this.hls.loadSource(e),this.hls.attachMedia(this.videoElement)})}initEventHandlers(){super.initEventHandlers(),this.hls.on(Ze.Events.ERROR,function(e,t){t.type,t.details,t.fatal,console.error(e,t),t.details===Ze.ErrorDetails.BUFFER_STALLED_ERROR||t.details===Ze.ErrorDetails.BUFFER_APPEND_ERROR||(t.details,Ze.ErrorDetails.BUFFER_APPENDING_ERROR)})}getAudioTracks(){return this.isVideoLoaded?this.hls.audioTracks:null}getCurrentAudioTrack(){return this.getAudioTracks()[this.hls.audioTrack]}setAudioTrack(e){if(!this.isVideoLoaded)return null;let t=this.hls.audioTrack;this.hls.audioTrack=e;let r=this.hls.audioTrack;r>=0&&t!==r&&this.onAudioSwitched$.next({audioTrack:this.getCurrentAudioTrack()})}getHls(){return this.hls}}class ig{constructor(e){this.hidden=!0,this.id=e.id,this.src=e.src,this.default=e.default,this.label=e.label,this.language=e.language,this.cues=[]}}class rg extends ig{constructor(e){super(e)}}class xn{constructor(e){this.subtitlesTracks=new Map,this.onCreate$=new V,this.onRemove$=new V,this.onShow$=new V,this.onHide$=new V,this.videoController=e,this.videoController.onVideoLoaded$.pipe(We(t=>!!t)).subscribe(t=>{this.removeAllTracks()})}getDomTextTrack(e){if(this.videoController&&this.videoController.getHTMLVideoElement()){let t=this.videoController.getHTMLVideoElement().textTracks.getTrackById(e.id);if(t.kind==="subtitles")return t}}removeDomTextTrack(e){return this.getDomTextTrack(e)?(this.videoController.getHTMLVideoElement().querySelectorAll("track").forEach(r=>{r.getAttribute("id")===e.id&&r.parentElement.removeChild(r)}),!0):!1}static createHTMLTrackElement(e){let t=document.createElement("track");return t.kind="subtitles",t.id=e.id,t.label=e.label,t.srclang=e.language,t.src=e.src,t.default=e.default,t}createVttTrack(e){return this.videoController.isVideoLoaded?new re(t=>{let r=new rg({...e});this.subtitlesTracks.has(r.id)&&this.removeTrack(r.id),r.element=xn.createHTMLTrackElement(r),be(r.element,"load").pipe(ui()).subscribe(n=>{this.subtitlesTracks.set(r.id,r),t.next(r),t.complete(),this.onCreate$.next({textTrack:r})}),this.videoController.getHTMLVideoElement().appendChild(r.element);let s=this.getDomTextTrack(r);s.mode="hidden"}):Se(void 0)}getTracks(){if(this.videoController.isVideoLoaded)return[...this.subtitlesTracks.values()]}removeAllTracks(){this.videoController.isVideoLoaded&&this.subtitlesTracks.forEach((e,t)=>{this.removeTrack(e.id)})}removeTrack(e){if(!this.videoController.isVideoLoaded)return;let t=this.subtitlesTracks.get(e);t&&(this.subtitlesTracks.delete(e),this.removeDomTextTrack(t),this.onRemove$.next({}))}getCurrentTrack(){return this.currentTrack}showTrack(e=void 0){if(!this.videoController.isVideoLoaded||(e=e||(this.getCurrentTrack()?this.getCurrentTrack().id:void 0),!e))return;let t=this.subtitlesTracks.get(e);if(t){let r=this.getDomTextTrack(t);if(r){for(let s=0;s<this.videoController.getHTMLVideoElement().textTracks.length;s++){let n=this.videoController.getHTMLVideoElement().textTracks[s];n.mode="hidden"}r.mode="showing",t.hidden=!1,this.currentTrack=t,this.onShow$.next({})}}}hideTrack(e=void 0){if(!this.videoController.isVideoLoaded||(e=e||(this.getCurrentTrack()?this.getCurrentTrack().id:void 0),!e))return;let t=this.subtitlesTracks.get(e);if(t){let r=this.getDomTextTrack(t);r&&(r.mode="hidden",t.hidden=!0,this.onHide$.next({}))}}destroy(){this.removeAllTracks();let e=[this.onCreate$,this.onRemove$,this.onShow$,this.onHide$];Vt(...e),bi(...e),this.currentTrack=void 0,this.videoController=void 0}}var tn={},sg={get exports(){return tn},set exports(i){tn=i}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(h,l,d){this.fn=h,this.context=l,this.once=d||!1}function n(h,l,d,u,c){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new s(d,u||h,c),f=t?t+l:l;return h._events[f]?h._events[f].fn?h._events[f]=[h._events[f],p]:h._events[f].push(p):(h._events[f]=p,h._eventsCount++),h}function a(h,l){--h._eventsCount===0?h._events=new r:delete h._events[l]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],d,u;if(this._eventsCount===0)return l;for(u in d=this._events)e.call(d,u)&&l.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(d)):l},o.prototype.listeners=function(l){var d=t?t+l:l,u=this._events[d];if(!u)return[];if(u.fn)return[u.fn];for(var c=0,p=u.length,f=new Array(p);c<p;c++)f[c]=u[c].fn;return f},o.prototype.listenerCount=function(l){var d=t?t+l:l,u=this._events[d];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,d,u,c,p,f){var m=t?t+l:l;if(!this._events[m])return!1;var g=this._events[m],_=arguments.length,w,b;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),_){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,d),!0;case 3:return g.fn.call(g.context,d,u),!0;case 4:return g.fn.call(g.context,d,u,c),!0;case 5:return g.fn.call(g.context,d,u,c,p),!0;case 6:return g.fn.call(g.context,d,u,c,p,f),!0}for(b=1,w=new Array(_-1);b<_;b++)w[b-1]=arguments[b];g.fn.apply(g.context,w)}else{var T=g.length,L;for(b=0;b<T;b++)switch(g[b].once&&this.removeListener(l,g[b].fn,void 0,!0),_){case 1:g[b].fn.call(g[b].context);break;case 2:g[b].fn.call(g[b].context,d);break;case 3:g[b].fn.call(g[b].context,d,u);break;case 4:g[b].fn.call(g[b].context,d,u,c);break;default:if(!w)for(L=1,w=new Array(_-1);L<_;L++)w[L-1]=arguments[L];g[b].fn.apply(g[b].context,w)}}return!0},o.prototype.on=function(l,d,u){return n(this,l,d,u,!1)},o.prototype.once=function(l,d,u){return n(this,l,d,u,!0)},o.prototype.removeListener=function(l,d,u,c){var p=t?t+l:l;if(!this._events[p])return this;if(!d)return a(this,p),this;var f=this._events[p];if(f.fn)f.fn===d&&(!c||f.once)&&(!u||f.context===u)&&a(this,p);else{for(var m=0,g=[],_=f.length;m<_;m++)(f[m].fn!==d||c&&!f[m].once||u&&f[m].context!==u)&&g.push(f[m]);g.length?this._events[p]=g.length===1?g[0]:g:a(this,p)}return this},o.prototype.removeAllListeners=function(l){var d;return l?(d=t?t+l:l,this._events[d]&&a(this,d)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(sg);const ng={OMAKASE_SUBTITLES_HIDE:"omakaseSubtitlesHide",OMAKASE_TIMELINE_ZOOM:"omakaseTimelineZoom",OMAKASE_VIDEO_LOADED:"omakaseVideoLoaded",OMAKASE_VIDEO_PAUSE:"omakaseVideoPause",OMAKASE_VIDEO_PLAY:"omakaseVideoPlay",OMAKASE_VIDEO_SEEKED:"omakaseVideoSeeked",OMAKASE_VIDEO_SEEKING:"omakaseVideoSeeking",OMAKASE_VIDEO_BUFFERING:"omakaseVideoBuffering",OMAKASE_VIDEO_ENDED:"omakaseVideoEnded",OMAKASE_VIDEO_TIME_CHANGE:"omakaseVideoTimeChange",OMAKASE_VIDEO_AUDIO_SWITCHED:"omakaseVideoAudioSwitched",OMAKASE_AUDIO_SWITCHED:"omakaseAudioSwitched",OMAKASE_SUBTITLES_CREATE:"omakaseSubtitlesCreate",OMAKASE_SUBTITLES_REMOVE:"omakaseSubtitlesRemove",OMAKASE_SUBTITLES_SHOW:"omakaseSubtitlesShow",OMAKASE_TIMELINE_SCROLL:"omakaseTimelineScroll"};class ag{constructor(e){this.onAudioSwitched$=new V,this.videoController=e}getAudioTracks(){return this.videoController.getAudioTracks()}getCurrentAudioTrack(){return this.videoController.getCurrentAudioTrack()}setAudioTrack(e){let t=this.getCurrentAudioTrack();this.videoController.setAudioTrack(e);let r=this.getCurrentAudioTrack();t!==r&&this.onAudioSwitched$.next({audioTrack:r})}destroy(){}}class Pi{static isFullscreenEnabled(){const e=document;return e.fullscreenEnabled||e.webkitFullscreenEnabled||!!e.webkitCancelFullScreen||e.mozFullScreenEnabled||e.msFullscreenEnabled||!1}static isFullscreen(){const e=document;return!!(e.fullscreenElement||e.webkitFullscreenElement||e.webkitCurrentFullScreenElement||e.mozFullScreenElement||e.msFullscreenElement)}static requestFullscreen(e,t){const r=e??document.documentElement,s=r.requestFullscreen||r.webkitRequestFullscreen||r.webkitRequestFullScreen||r.mozRequestFullScreen||r.msRequestFullscreen;if(!s)throw new Error("Unsupported");return s.call(r,t)}static exitFullscreen(){const e=document,t=e.exitFullscreen||e.webkitExitFullscreen||e.webkitCancelFullScreen||e.mozCancelFullScreen||e.msExitFullscreen;if(!t)throw new Error("Unsupported");return t.call(e)}}const fe={player:"omakase-player",playerWrapper:"omakase-player-wrapper",video:"omakase-video",videoControls:"omakase-video-controls",buttonPlay:"omakase-button-play",buttonPause:"omakase-button-pause",buttonLoading:"omakase-button-loading",buttonError:"omakase-button-error",buttonReplay:"omakase-button-replay",buttonHelp:"omakase-help-button",help:"omakase-help",helpMenu:"omakase-help-menu",errorMessage:"omakase-error-message"};class og{constructor(e){this._playerHTMLElementId=e,this.divPlayer=this.getElementById(this._playerHTMLElementId),this.createDom()}createDom(){this.divPlayer.classList.add(`${fe.player}`),this.divPlayer.innerHTML=`<div class="${fe.playerWrapper}">
48
48
  <video class="${fe.video}"></video>
49
49
 
50
50
  <div class="${fe.help} d-none">
@@ -71,5 +71,5 @@ ${Dl(r)}`)}),e.join(`
71
71
  <span class="omakase-help-group-title">${t.name}</span>
72
72
  ${r}
73
73
  </div>
74
- `}).join("")):this.hideElements(this.divHelp)}isFullscreen(){return Pi.isFullscreenEnabled()?Pi.isFullscreen():!1}toggleFullscreen(e){try{Pi.isFullscreenEnabled()&&(this.isFullscreen()?Pi.exitFullscreen().then(()=>{}):Pi.requestFullscreen(e).then(()=>{}))}catch(t){console.trace(t)}}set videoController(e){this._videoController=e,$e(this.videoEventBreaker$),this.videoEventBreaker$=new V;let t=[this.divButtonPlay,this.divButtonPause,this.divButtonLoading,this.divButtonReplay,this.divButtonError],r=()=>{this.showTemporaryOnMouseMoveTimeoutId&&clearTimeout(this.showTemporaryOnMouseMoveTimeoutId)};be(this.divPlayerWrapper,"mousemove").pipe(k(this.videoEventBreaker$)).subscribe(s=>{if(this._videoController.isVideoLoaded()&&!(this._videoController.getPlaybackState().ended||this._videoController.getPlaybackState().waiting||this._videoController.getPlaybackState().seeking)){let n=this._videoController.isPlaying()?this.divButtonPause:this.divButtonPlay;r(),this.hideElements(this.divButtonPause,this.divButtonPlay).showElements(n,this.divButtonHelp),this.showTemporaryOnMouseMoveTimeoutId=setTimeout(()=>{this.hideElements(n),this.isShown(this.divHelpMenu)||this.hideElements(this.divButtonHelp,this.divHelpMenu)},1e3)}}),be(this.divPlayerWrapper,"mouseleave").pipe(k(this.videoEventBreaker$)).subscribe(s=>{this.hideElements(this.divButtonPlay,this.divButtonPause),this.hideElements(this.divButtonHelp,this.divHelpMenu)}),be(this.divPlayerWrapper,"click").pipe(k(this.videoEventBreaker$)).subscribe(s=>{(s.target===this._videoElement||s.target===this.divButtonPlay||s.target===this.divButtonPause||s.target===this.divButtonReplay||s.target===this.divButtonLoading)&&this._videoController.togglePlayPause()}),be(this._videoElement,"contextmenu").pipe(k(this.videoEventBreaker$)).subscribe(s=>{s.preventDefault()}),this._videoElement.controls=!1,this._videoController.onVideoLoading$.pipe(k(this.videoEventBreaker$)).subscribe(s=>{this.hideElements(...t).hideElements(this.divErrorMessage).showElements(this.divButtonLoading)}),this._videoController.onVideoLoaded$.pipe(k(this.videoEventBreaker$)).subscribe(s=>{this.hideElements(...t).hideElements(this.divErrorMessage),s||this.showElements(this.divButtonLoading)}),this._videoController.onPlaybackState$.pipe(k(this.videoEventBreaker$)).subscribe(s=>{r(),s.waiting&&s.playing?this.hideElements(...t).hideElements(this.divErrorMessage).showElements(this.divButtonLoading):s.playing?(this.hideElements(...t).hideElements(this.divErrorMessage),s.seeking&&s.waiting&&this.showElements(this.divButtonLoading)):s.paused?(this.hideElements(...t).hideElements(this.divErrorMessage),s.seeking&&s.waiting?this.showElements(this.divButtonLoading):s.ended&&this.showElements(this.divButtonReplay)):s.seeking&&s.waiting&&this.hideElements(...t).hideElements(this.divErrorMessage).showElements(this.divButtonLoading)}),this._videoController.onVideoError$.pipe(k(this.videoEventBreaker$)).subscribe(s=>{this.hideElements(...t).showElements(this.divErrorMessage,this.divButtonError),this.divErrorMessage.innerHTML=s.message}),be(this.divButtonHelp,"click").pipe(k(this.videoEventBreaker$)).subscribe(s=>{s.target===this.divButtonHelp&&(this.isShown(this.divHelpMenu)?this.hideElements(this.divHelpMenu):this.showElements(this.divHelpMenu))}),this._videoController.onHelpMenuChange$.pipe(k(this.videoEventBreaker$)).subscribe(()=>{this.helpChangeHandler()})}set timeline(e){this._timeline=e}get videoElement(){return this._videoElement}destroy(){pn(this.videoEventBreaker$),this.divPlayer&&this.divPlayer.replaceChildren(),this._videoController=null,this._videoElement=null,this._timeline=null,this._timelineElement=null}}const Pn={fontFamily:"Arial"},Ia={playerHTMLElementId:"omakase-player",crossorigin:"anonymous",style:{...Pn}};class lg{constructor(e){this.stylesProvider=ht.instance(),this.eventEmitter=new tn,this.onDestroy$=new V,this.config={...Ia,...e,style:{...Ia.style,...e.style}},this.styleAdapter=new $o({...Pn,...this.config.style}),this.stylesProvider.styles={omakasePlayerStyle:this.style},this.styleAdapter.onChange$.pipe(k(this.onDestroy$)).subscribe(t=>{this.stylesProvider.styles={omakasePlayerStyle:this.style}}),this.playerHTMLElementId=this.config.playerHTMLElementId,this.domController=new og(this.playerHTMLElementId),this.videoController=new tg(this.domController,this.config.crossorigin),this.audioController=new ag(this.videoController),this.subtitlesController=new xn(this.videoController),this.domController.videoController=this.videoController,this.bindEventHandlers()}loadVideo(e,t,r){return new se(s=>{this.videoController.loadVideo(e,t,r).pipe(ui()).subscribe({next:n=>{s.next(n),s.complete()},error:n=>{s.error(n),s.complete()}})})}createTimeline(e){return new se(t=>{let r=()=>{console.debug("Creating timeline"),this._timeline=new Ym(e,this.videoController),this.domController.timeline=this.timeline,this._timeline.initCanvasNode(),this._timeline.onScroll$.pipe(k(this.onDestroy$)).subscribe(s=>{this.emit("omakaseTimelineScroll",s)}),this._timeline.onZoom$.pipe(k(this.onDestroy$)).subscribe(s=>{this.emit("omakaseTimelineZoom",s)})};this.timeline?(t.next(this._timeline),t.complete()):(console.debug("Timeline creation in progress, checking video load status.."),this.videoController.isVideoLoaded()?(console.debug("Video is already loaded"),r(),t.next(this._timeline),t.complete()):(console.debug("Waiting video to load.."),this.videoController.onVideoLoaded$.pipe(Ve(s=>!!s),ui()).subscribe(s=>{console.debug("Video just loaded"),r(),t.next(this._timeline),t.complete()})))})}bindEventHandlers(){this.videoController.onPlay$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoPlay",e)}),this.videoController.onPause$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoPause",e)}),this.videoController.onVideoLoaded$.pipe(k(this.onDestroy$),Ve(e=>!!e)).subscribe(e=>{this.emit("omakaseVideoLoaded",e)}),this.videoController.onVideoTimeChange$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoTimeChange",e)}),this.videoController.onSeeking$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoSeeking",e)}),this.videoController.onSeeked$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoSeeked",e)}),this.videoController.onBuffering$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoBuffering",e)}),this.videoController.onEnded$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoEnded",e)}),this.videoController.onAudioSwitched$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoAudioSwitched",e)}),this.audioController.onAudioSwitched$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseAudioSwitched",e)}),this.subtitlesController.onCreate$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseSubtitlesCreate",e)}),this.subtitlesController.onRemove$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseSubtitlesRemove",e)}),this.subtitlesController.onShow$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseSubtitlesShow",e)}),this.subtitlesController.onHide$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseSubtitlesHide",e)})}emit(e,t){this.eventEmitter.emit(e,t)}off(e,t){this.eventEmitter.off(e,t)}on(e,t){this.eventEmitter.on(e,t)}listenerCount(e){this.eventEmitter.listenerCount(e)}listeners(e){return this.eventEmitter.listeners(e)}once(e,t){this.eventEmitter.once(e,t)}removeAllListeners(e){this.eventEmitter.removeAllListeners(e)}get style(){return this.styleAdapter.style}set style(e){this.styleAdapter.style=e}get timeline(){return this._timeline}get video(){return this.videoController}get audio(){return this.audioController}get subtitles(){return this.subtitlesController}get EVENTS(){return ng}destroy(){[this._timeline,this.videoController,this.domController,this.audioController,this.subtitlesController].forEach(t=>{t&&t.destroy()}),this.eventEmitter.removeAllListeners(),this._timeline=void 0,this.domController=void 0,this.videoController=void 0,this.audioController=void 0,this.subtitlesController=void 0,this.styleAdapter=void 0,this.stylesProvider=void 0,this.eventEmitter=void 0,$e(this.onDestroy$)}}exports.AudioTrackLane=Fl;exports.MarkerLane=Us;exports.MomentMarker=cl;exports.OMAKASE_PLAYER_STYLE_DEFAULT=Pn;exports.OmakasePlayer=lg;exports.PeriodMarker=ul;exports.SubtitlesLane=qs;exports.ThumbnailLane=Ks;
74
+ `}).join("")):this.hideElements(this.divHelp)}isFullscreen(){return Pi.isFullscreenEnabled()?Pi.isFullscreen():!1}toggleFullscreen(e){try{Pi.isFullscreenEnabled()&&(this.isFullscreen()?Pi.exitFullscreen().then(()=>{}):Pi.requestFullscreen(e).then(()=>{}))}catch(t){console.trace(t)}}set videoController(e){this._videoController=e,Ge(this.videoEventBreaker$),this.videoEventBreaker$=new V;let t=[this.divButtonPlay,this.divButtonPause,this.divButtonLoading,this.divButtonReplay,this.divButtonError],r=()=>{this.showTemporaryOnMouseMoveTimeoutId&&clearTimeout(this.showTemporaryOnMouseMoveTimeoutId)};be(this.divPlayerWrapper,"mousemove").pipe(k(this.videoEventBreaker$)).subscribe(s=>{if(this._videoController.isVideoLoaded()&&!(this._videoController.getPlaybackState().ended||this._videoController.getPlaybackState().waiting||this._videoController.getPlaybackState().seeking)){let n=this._videoController.isPlaying()?this.divButtonPause:this.divButtonPlay;r(),this.hideElements(this.divButtonPause,this.divButtonPlay).showElements(n,this.divButtonHelp),this.showTemporaryOnMouseMoveTimeoutId=setTimeout(()=>{this.hideElements(n),this.isShown(this.divHelpMenu)||this.hideElements(this.divButtonHelp,this.divHelpMenu)},1e3)}}),be(this.divPlayerWrapper,"mouseleave").pipe(k(this.videoEventBreaker$)).subscribe(s=>{this.hideElements(this.divButtonPlay,this.divButtonPause),this.hideElements(this.divButtonHelp,this.divHelpMenu)}),be(this.divPlayerWrapper,"click").pipe(k(this.videoEventBreaker$)).subscribe(s=>{(s.target===this._videoElement||s.target===this.divButtonPlay||s.target===this.divButtonPause||s.target===this.divButtonReplay||s.target===this.divButtonLoading)&&this._videoController.togglePlayPause()}),be(this._videoElement,"contextmenu").pipe(k(this.videoEventBreaker$)).subscribe(s=>{s.preventDefault()}),this._videoElement.controls=!1,this._videoController.onVideoLoading$.pipe(k(this.videoEventBreaker$)).subscribe(s=>{this.hideElements(...t).hideElements(this.divErrorMessage).showElements(this.divButtonLoading)}),this._videoController.onVideoLoaded$.pipe(k(this.videoEventBreaker$)).subscribe(s=>{this.hideElements(...t).hideElements(this.divErrorMessage),s||this.showElements(this.divButtonLoading)}),this._videoController.onPlaybackState$.pipe(k(this.videoEventBreaker$)).subscribe(s=>{r(),s.waiting&&s.playing?this.hideElements(...t).hideElements(this.divErrorMessage).showElements(this.divButtonLoading):s.playing?(this.hideElements(...t).hideElements(this.divErrorMessage),s.seeking&&s.waiting&&this.showElements(this.divButtonLoading)):s.paused?(this.hideElements(...t).hideElements(this.divErrorMessage),s.seeking&&s.waiting?this.showElements(this.divButtonLoading):s.ended&&this.showElements(this.divButtonReplay)):s.seeking&&s.waiting&&this.hideElements(...t).hideElements(this.divErrorMessage).showElements(this.divButtonLoading)}),this._videoController.onVideoError$.pipe(k(this.videoEventBreaker$)).subscribe(s=>{this.hideElements(...t).showElements(this.divErrorMessage,this.divButtonError),this.divErrorMessage.innerHTML=s.message}),be(this.divButtonHelp,"click").pipe(k(this.videoEventBreaker$)).subscribe(s=>{s.target===this.divButtonHelp&&(this.isShown(this.divHelpMenu)?this.hideElements(this.divHelpMenu):this.showElements(this.divHelpMenu))}),this._videoController.onHelpMenuChange$.pipe(k(this.videoEventBreaker$)).subscribe(()=>{this.helpChangeHandler()})}set timeline(e){this._timeline=e}get videoElement(){return this._videoElement}destroy(){pn(this.videoEventBreaker$),this.divPlayer&&this.divPlayer.replaceChildren(),this._videoController=null,this._videoElement=null,this._timeline=null,this._timelineElement=null}}const Pn={fontFamily:"Arial"},Ia={playerHTMLElementId:"omakase-player",crossorigin:"anonymous",style:{...Pn}};class lg{constructor(e){this.stylesProvider=dt.instance(),this.eventEmitter=new tn,this.onDestroy$=new V,this.config={...Ia,...e,style:{...Ia.style,...e.style}},this.styleAdapter=new $o({...Pn,...this.config.style}),this.stylesProvider.styles={omakasePlayerStyle:this.style},this.styleAdapter.onChange$.pipe(k(this.onDestroy$)).subscribe(t=>{this.stylesProvider.styles={omakasePlayerStyle:this.style}}),this.playerHTMLElementId=this.config.playerHTMLElementId,this.domController=new og(this.playerHTMLElementId),this.videoController=new tg(this.domController,this.config.crossorigin),this.audioController=new ag(this.videoController),this.subtitlesController=new xn(this.videoController),this.domController.videoController=this.videoController,this.bindEventHandlers()}loadVideo(e,t,r){return new re(s=>{this.videoController.loadVideo(e,t,r).pipe(ui()).subscribe({next:n=>{s.next(n),s.complete()},error:n=>{s.error(n),s.complete()}})})}createTimeline(e){return new re(t=>{let r=()=>{console.debug("Creating timeline"),this._timeline=new Ym(e,this.videoController),this.domController.timeline=this.timeline,this._timeline.initCanvasNode(),this._timeline.onScroll$.pipe(k(this.onDestroy$)).subscribe(s=>{this.emit("omakaseTimelineScroll",s)}),this._timeline.onZoom$.pipe(k(this.onDestroy$)).subscribe(s=>{this.emit("omakaseTimelineZoom",s)})};this.timeline?(t.next(this._timeline),t.complete()):(console.debug("Timeline creation in progress, checking video load status.."),this.videoController.isVideoLoaded()?(console.debug("Video is already loaded"),r(),t.next(this._timeline),t.complete()):(console.debug("Waiting video to load.."),this.videoController.onVideoLoaded$.pipe(We(s=>!!s),ui()).subscribe(s=>{console.debug("Video just loaded"),r(),t.next(this._timeline),t.complete()})))})}bindEventHandlers(){this.videoController.onPlay$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoPlay",e)}),this.videoController.onPause$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoPause",e)}),this.videoController.onVideoLoaded$.pipe(k(this.onDestroy$),We(e=>!!e)).subscribe(e=>{this.emit("omakaseVideoLoaded",e)}),this.videoController.onVideoTimeChange$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoTimeChange",e)}),this.videoController.onSeeking$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoSeeking",e)}),this.videoController.onSeeked$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoSeeked",e)}),this.videoController.onBuffering$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoBuffering",e)}),this.videoController.onEnded$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoEnded",e)}),this.videoController.onAudioSwitched$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseVideoAudioSwitched",e)}),this.audioController.onAudioSwitched$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseAudioSwitched",e)}),this.subtitlesController.onCreate$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseSubtitlesCreate",e)}),this.subtitlesController.onRemove$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseSubtitlesRemove",e)}),this.subtitlesController.onShow$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseSubtitlesShow",e)}),this.subtitlesController.onHide$.pipe(k(this.onDestroy$)).subscribe(e=>{this.emit("omakaseSubtitlesHide",e)})}emit(e,t){this.eventEmitter.emit(e,t)}off(e,t){this.eventEmitter.off(e,t)}on(e,t){this.eventEmitter.on(e,t)}listenerCount(e){this.eventEmitter.listenerCount(e)}listeners(e){return this.eventEmitter.listeners(e)}once(e,t){this.eventEmitter.once(e,t)}removeAllListeners(e){this.eventEmitter.removeAllListeners(e)}get style(){return this.styleAdapter.style}set style(e){this.styleAdapter.style=e}get timeline(){return this._timeline}get video(){return this.videoController}get audio(){return this.audioController}get subtitles(){return this.subtitlesController}get EVENTS(){return ng}destroy(){[this._timeline,this.videoController,this.domController,this.audioController,this.subtitlesController].forEach(t=>{t&&t.destroy()}),this.eventEmitter.removeAllListeners(),this._timeline=void 0,this.domController=void 0,this.videoController=void 0,this.audioController=void 0,this.subtitlesController=void 0,this.styleAdapter=void 0,this.stylesProvider=void 0,this.eventEmitter=void 0,Ge(this.onDestroy$)}}exports.AudioTrackLane=Fl;exports.MarkerLane=Ws;exports.MomentMarker=cl;exports.OMAKASE_PLAYER_STYLE_DEFAULT=Pn;exports.OmakasePlayer=lg;exports.PeriodMarker=ul;exports.SubtitlesLane=qs;exports.ThumbnailLane=Ks;
75
75
  //# sourceMappingURL=omakase-player.cjs.js.map