@byomakase/omakase-player 0.3.4 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +29 -10
  2. package/dist/audio/audio-controller.d.ts +0 -4
  3. package/dist/common/component.d.ts +0 -3
  4. package/dist/common/style-adapter.d.ts +0 -3
  5. package/dist/common/styles-provider.d.ts +0 -3
  6. package/dist/constants.d.ts +15 -0
  7. package/dist/dom/dom-controller.d.ts +0 -3
  8. package/dist/events.d.ts +15 -0
  9. package/dist/http.d.ts +15 -0
  10. package/dist/index.d.ts +15 -0
  11. package/dist/omakase-player.cjs.js +37 -37
  12. package/dist/omakase-player.cjs.js.map +1 -1
  13. package/dist/omakase-player.d.ts +15 -0
  14. package/dist/omakase-player.es.js +4128 -4138
  15. package/dist/omakase-player.es.js.map +1 -1
  16. package/dist/omakase-player.umd.js +36 -36
  17. package/dist/omakase-player.umd.js.map +1 -1
  18. package/dist/subtitles/subtitles-controller.d.ts +0 -3
  19. package/dist/timeline/audio-track/audio-track-lane-item.d.ts +15 -0
  20. package/dist/timeline/audio-track/audio-track-lane.d.ts +15 -0
  21. package/dist/timeline/audio-track/index.d.ts +15 -0
  22. package/dist/timeline/index.d.ts +15 -0
  23. package/dist/timeline/marker/index.d.ts +15 -0
  24. package/dist/timeline/marker/marker-handle.d.ts +15 -0
  25. package/dist/timeline/marker/marker-lane.d.ts +15 -0
  26. package/dist/timeline/marker/marker.d.ts +15 -0
  27. package/dist/timeline/marker/moment-marker.d.ts +16 -0
  28. package/dist/timeline/marker/period-marker.d.ts +15 -0
  29. package/dist/timeline/playhead-hover.d.ts +15 -0
  30. package/dist/timeline/playhead.d.ts +15 -0
  31. package/dist/timeline/scrollbar.d.ts +15 -0
  32. package/dist/timeline/scrubber-lane.d.ts +15 -0
  33. package/dist/timeline/subtitles/index.d.ts +15 -0
  34. package/dist/timeline/subtitles/subtitles-lane-item.d.ts +15 -0
  35. package/dist/timeline/subtitles/subtitles-lane.d.ts +15 -0
  36. package/dist/timeline/thumbnail/index.d.ts +15 -0
  37. package/dist/timeline/thumbnail/thumbnail-lane.d.ts +15 -0
  38. package/dist/timeline/thumbnail/thumbnail.d.ts +15 -0
  39. package/dist/timeline/timecode-display.d.ts +15 -0
  40. package/dist/timeline/timeline-lane.d.ts +15 -0
  41. package/dist/timeline/timeline.d.ts +15 -0
  42. package/dist/track/audio-vtt-file.d.ts +15 -0
  43. package/dist/track/subtitles-vtt-file.d.ts +15 -0
  44. package/dist/track/subtitles-vtt-track.d.ts +15 -0
  45. package/dist/track/thumbnail-vtt-file.d.ts +15 -0
  46. package/dist/track/track.d.ts +15 -0
  47. package/dist/track/vtt-file.d.ts +15 -0
  48. package/dist/types/common.d.ts +15 -0
  49. package/dist/types/events.d.ts +15 -0
  50. package/dist/types/index.d.ts +15 -0
  51. package/dist/types/model.d.ts +15 -0
  52. package/dist/types/track.d.ts +15 -0
  53. package/dist/types/types.d.ts +15 -0
  54. package/dist/types/vtt.d.ts +15 -0
  55. package/dist/util/animation-util.d.ts +15 -0
  56. package/dist/util/color-util.d.ts +15 -0
  57. package/dist/util/error-util.d.ts +15 -0
  58. package/dist/util/frame-util.d.ts +15 -0
  59. package/dist/util/image-util.d.ts +15 -0
  60. package/dist/util/object-util.d.ts +15 -0
  61. package/dist/util/observable-util.d.ts +15 -0
  62. package/dist/util/shape-util.d.ts +15 -0
  63. package/dist/util/time-util.d.ts +15 -0
  64. package/dist/util/window-util.d.ts +15 -0
  65. package/dist/validators.d.ts +15 -0
  66. package/dist/video/playback-state.d.ts +15 -0
  67. package/dist/video/video-controller.d.ts +15 -0
  68. package/dist/video/video-hls-controller.d.ts +15 -0
  69. package/dist/video/video.d.ts +19 -2
  70. package/package.json +1 -1
@@ -1,50 +1,50 @@
1
- (function(Ie,Le){typeof exports=="object"&&typeof module<"u"?Le(exports,require("hls.js")):typeof define=="function"&&define.amd?define(["exports","hls.js"],Le):(Ie=typeof globalThis<"u"?globalThis:Ie||self,Le(Ie.omakase={},Ie.Hls))})(this,function(Ie,Le){"use strict";var $h=Math.PI/180;function Vh(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}const Jt=typeof global<"u"?global:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},D={_global:Jt,version:"8.3.14",isBrowser:Vh(),isUnminified:/param/.test(function(i){}.toString()),dblClickWindow:400,getAngle(i){return D.angleDeg?i*$h: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:Jt.document,_injectGlobal(i){Jt.Konva=i}},fe=i=>{D[i.prototype.getClassName()]=i};D._injectGlobal(D);class Fe{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 Fe(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 l={x:n,y:a,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||t!=0){var h=Math.sqrt(e*e+t*t);l.rotation=t>0?Math.acos(e/h):-Math.acos(e/h),l.scaleX=h,l.scaleY=o/h,l.skewX=(e*r+t*s)/o,l.skewY=0}else if(r!=0||s!=0){var d=Math.sqrt(r*r+s*s);l.rotation=Math.PI/2-(s>0?Math.acos(-r/d):-Math.acos(r/d)),l.scaleX=o/d,l.scaleY=d,l.skewX=0,l.skewY=(e*r+t*s)/o}return l.rotation=y._getRotation(l.rotation),l}}var zh="[object Array]",Wh="[object Number]",Uh="[object String]",Zh="[object Boolean]",jh=Math.PI/180,Xh=180/Math.PI,us="#",qh="",Yh="0",Kh="Konva warning: ",Mn="Konva error: ",Jh="rgb(",cs={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]},Qh=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,hr=[];const el=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)===zh},_isNumber(i){return Object.prototype.toString.call(i)===Wh&&!isNaN(i)&&isFinite(i)},_isString(i){return Object.prototype.toString.call(i)===Uh},_isBoolean(i){return Object.prototype.toString.call(i)===Zh},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){hr.push(i),hr.length===1&&el(function(){const e=hr;hr=[],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(us,qh);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=Yh+i;return us+i},getRGB(i){var e;return i in cs?(e=cs[i],{r:e[0],g:e[1],b:e[2]}):i[0]===us?this._hexToRgb(i.substring(1)):i.substr(0,4)===Jh?(e=Qh.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=cs[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,l;if(s===0)return l=n*255,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};n<.5?a=n*(1+s):a=n+s-n*s;const h=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?l=h+(a-h)*6*o:2*o<1?l=a:3*o<2?l=h+(a-h)*(2/3-o)*6:l=h,d[u]=l*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*jh},radToDeg(i){return i*Xh},_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(Mn+i)},error(i){console.error(Mn+i)},warn(i){D.showWarnings&&console.warn(Kh+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,l,h=(i-t)*(i-t)+(e-r)*(e-r);if(h==0)a=i,o=e,l=(s-t)*(s-t)+(n-r)*(n-r);else{var d=((s-i)*(t-i)+(n-e)*(r-e))/h;d<0?(a=i,o=e,l=(i-s)*(i-s)+(e-n)*(e-n)):d>1?(a=t,o=r,l=(t-s)*(t-s)+(r-n)*(r-n)):(a=i+d*(t-i),o=e+d*(r-e),l=(a-s)*(a-s)+(o-n)*(o-n))}return[a,o,l]},_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],l=y._getProjectionToSegment(n.x,n.y,o.x,o.y,i.x,i.y),h=l[0],d=l[1],u=l[2];u<s&&(r.x=h,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(l){var h=y._getProjectionToLine(l,s,t);o.push(h.x),o.push(h.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 Ct(i){return y._isString(i)?'"'+i+'"':Object.prototype.toString.call(i)==="[object Number]"||y._isBoolean(i)?i:Object.prototype.toString.call(i)}function On(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(Ct(i)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),i}}function Ln(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(Ct(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or Array<number>('+i+")"),e}}function fs(){if(D.isUnminified)return function(i,e){var t=y._isNumber(i),r=i==="auto";return t||r||y.warn(Ct(i)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),i}}function Qt(){if(D.isUnminified)return function(i,e){return y._isString(i)||y.warn(Ct(i)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),i}}function Rn(){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(Ct(i)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),i}}function tl(){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(Ct(i)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),i}}function je(){if(D.isUnminified)return function(i,e){var t=i===!0||i===!1;return t||y.warn(Ct(i)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),i}}function il(i){if(D.isUnminified)return function(e,t){return e==null||y.isObject(e)||y.warn(Ct(e)+' is a not valid value for "'+t+'" attribute. The value should be an object with properties '+i),e}}var Ci="get",Ei="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=Ci+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=Ei+y._capitalize(e);i.prototype[s]||v.overWriteSetter(i,e,t,r)},overWriteSetter(i,e,t,r){var s=Ei+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=Ci+a(e),l=Ei+a(e),h,d;i.prototype[o]=function(){var c={};for(h=0;h<n;h++)d=t[h],c[d]=this.getAttr(e+a(d));return c};var u=il(t);i.prototype[l]=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=Ei+t,s=Ci+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=Ci+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=Ci+y._capitalize(t),a=Ei+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 rl(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 In=",",sl="(",nl=")",al="([",ol="])",hl=";",ll="()",dl="=",Nn=["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"],ul=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"];const cl=100;class lr{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,l,h;for(a=0;a<s;a++)o=r[a],l=o.method,l?(h=o.args,n+=l,e?n+=ll:y._isArray(h[0])?n+=al+h.join(In)+ol:(t&&(h=h.map(d=>typeof d=="number"?Math.floor(d):d)),n+=sl+h.join(In)+nl)):(n+=o.property,e||(n+=dl+o.val)),n+=hl;return n}clearTrace(){this.traceArr=[]}_trace(e){var t=this.traceArr,r;t.push(e),r=t.length,r>=cl&&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,l,h){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,l,h)}ellipse(e,t,r,s,n,a,o,l){this._context.ellipse(e,t,r,s,n,a,o,l)}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=Nn.length,r=this.setAttr,s,n,a=function(o){var l=e[o],h;e[o]=function(){return n=rl(Array.prototype.slice.call(arguments,0)),h=l.apply(e,arguments),e._trace({method:o,args:n}),h}};for(s=0;s<t;s++)a(Nn[s]);e.setAttr=function(){r.apply(e,arguments);var o=arguments[0],l=arguments[1];(o==="shadowOffsetX"||o==="shadowOffsetY"||o==="shadowBlur")&&(l=l/this.canvas.getPixelRatio()),e._trace({property:o,val:l})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;var r=!t||t==="source-over";r||this.setAttr("globalCompositeOperation",t)}}ul.forEach(function(i){Object.defineProperty(lr.prototype,i,{get(){return this._context[i]},set(e){this._context[i]=e}})});class fl extends lr{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},l=e.getAbsoluteScale(),h=this.canvas.getPixelRatio(),d=l.x*h,u=l.y*h;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 pl extends lr{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 dr;function ml(){if(dr)return dr;var i=y.createCanvasElement(),e=i.getContext("2d");return dr=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),dr}class ur{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var t=e||{},r=t.pixelRatio||D.pixelRatio||ml();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(ur,"pixelRatio",void 0,x());class ei extends ur{constructor(e={width:0,height:0}){super(e),this.context=new fl(this),this.setSize(e.width,e.height)}}class ps extends ur{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new pl(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(h=>h.id===t.pointerId);if(a){if(t.dragStatus!=="dragging"){var o=s.dragDistance(),l=Math.max(Math.abs(a.x-t.startPointerPos.x),Math.abs(a.y-t.startPointerPos.y));if(l<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,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){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)})}};D.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 cr="absoluteOpacity",fr="allEventListeners",dt="absoluteTransform",Dn="absoluteScale",Bt="canvas",gl="Change",vl="children",yl="konva",ms="listening",Gn="mouseenter",Fn="mouseleave",Hn="set",Bn="Shape",pr=" ",$n="stage",Et="transform",bl="Stage",gs="visible",_l=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(pr);let wl=1;class P{constructor(e){this._id=wl++,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===Et||e===dt)&&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===Et||e===dt,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(pr);this.on(s,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,r)}_getCanvasCache(){return this._cache.get(Bt)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===dt&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(Bt)){const{scene:e,filter:t,hit:r}=this._cache.get(Bt);y.releaseCanvas(e,t,r),this._cache.delete(Bt)}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,l=t.y===void 0?Math.floor(r.y):t.y,h=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+=h*2+1,n+=h*2+1,o-=h,l-=h;var c=new ei({pixelRatio:a,width:s,height:n}),p=new ei({pixelRatio:a,width:0,height:0}),f=new ps({pixelRatio:u,width:s,height:n}),m=c.getContext(),g=f.getContext();return f.isCache=!0,c.isCache=!0,this._cache.delete(Bt),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(c.getContext()._context.imageSmoothingEnabled=!1,p.getContext()._context.imageSmoothingEnabled=!1),m.save(),g.save(),m.translate(-o,-l),g.translate(-o,-l),this._isUnderCache=!0,this._clearSelfAndDescendantCache(cr),this._clearSelfAndDescendantCache(Dn),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(Bt,{scene:c,filter:p,hit:f,x:o,y:l}),this._requestDraw(),this}isCached(){return this._cache.has(Bt)}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,l=this.getAbsoluteTransform(t);return r.forEach(function(h){var d=l.point(h);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,l,h;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()),l=0;l<a;l++){if(h=e[l],typeof h!="function"){y.error("Filter should be type of function, but got "+typeof h+" instead. Please check correct filters");continue}h.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(fr),arguments.length===3)return this._delegate.apply(this,arguments);var r=e.split(pr),s=r.length,n,a,o,l,h;for(n=0;n<s;n++)a=r[n],o=a.split("."),l=o[0],h=o[1]||"",this.eventListeners[l]||(this.eventListeners[l]=[]),this.eventListeners[l].push({name:h,handler:t});return this}off(e,t){var r=(e||"").split(pr),s=r.length,n,a,o,l,h,d;if(this._cache&&this._cache.delete(fr),!e)for(a in this.eventListeners)this._off(a);for(n=0;n<s;n++)if(o=r[n],l=o.split("."),h=l[0],d=l[1],h)this.eventListeners[h]&&this._off(h,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(dt),this._clearSelfAndDescendantCache(cr),this._clearSelfAndDescendantCache(Dn),this._clearSelfAndDescendantCache($n),this._clearSelfAndDescendantCache(gs),this._clearSelfAndDescendantCache(ms)}_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!==vl&&(r=Hn+y._capitalize(t),y._isFunction(this[r])?this[r](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(ms,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(gs,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&&!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 l(h){for(s=[],n=h.length,a=0;a<n;a++)o=h[a],r++,o.nodeType!==Bn&&(s=s.concat(o.getChildren().slice())),o._id===t._id&&(a=n);s.length>0&&s[0].getDepth()<=e&&l(s)}return t.nodeType!==bl&&l(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(Et),this._clearSelfAndDescendantCache(dt)),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 Fe,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(Et);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(Et),this._clearSelfAndDescendantCache(dt),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(cr,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($n,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(dt,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var t;if(e)return t=new Fe,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(dt)||new Fe,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(Et,this._getTransform)}_getTransform(){var e,t,r=this._cache.get(Et)||new Fe;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,l=(t=this.attrs.scaleY)!==null&&t!==void 0?t:1,h=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),(h!==0||d!==0)&&r.skew(h,d),(o!==1||l!==1)&&r.scale(o,l),(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 l=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(yl)<0&&(l.eventListeners[r]||(l.eventListeners[r]=[]),l.eventListeners[r].push(o));return l}_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 ei({width:e.width||Math.ceil(t.width)||(r?r.width():0),height:e.height||Math.ceil(t.height)||(r?r.height():0),pixelRatio:a}),l=o.getContext();return e.imageSmoothingEnabled===!1&&(l._context.imageSmoothingEnabled=!1),l.save(),(s||n)&&l.translate(-1*s,-1*n),this.drawScene(o),l.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+gl,{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[Hn+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===Bn&&(t.target=this);var s=(e===Gn||e===Fn)&&(r&&(this===r||this.isAncestorOf&&this.isAncestorOf(r))||this.nodeType==="Stage"&&!r);if(!s){this._fire(e,t);var n=(e===Gn||e===Fn)&&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(fr);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(fr,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||D.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),D[r]||(y.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const l=D[r];if(n=new l(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,_l,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(Et),this._clearSelfAndDescendantCache(dt)}),P.prototype.on.call(P.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(gs)}),P.prototype.on.call(P.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(ms)}),P.prototype.on.call(P.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(cr)});const ue=v.addGetterSetter;ue(P,"zIndex"),ue(P,"absolutePosition"),ue(P,"position"),ue(P,"x",0,x()),ue(P,"y",0,x()),ue(P,"globalCompositeOperation","source-over",Qt()),ue(P,"opacity",1,x()),ue(P,"name","",Qt()),ue(P,"id","",Qt()),ue(P,"rotation",0,x()),v.addComponentsGetterSetter(P,"scale",["x","y"]),ue(P,"scaleX",1,x()),ue(P,"scaleY",1,x()),v.addComponentsGetterSetter(P,"skew",["x","y"]),ue(P,"skewX",0,x()),ue(P,"skewY",0,x()),v.addComponentsGetterSetter(P,"offset",["x","y"]),ue(P,"offsetX",0,x()),ue(P,"offsetY",0,x()),ue(P,"dragDistance",null,x()),ue(P,"width",0,x()),ue(P,"height",0,x()),ue(P,"listening",!0,je()),ue(P,"preventDefault",!0,je()),ue(P,"filters",null,function(i){return this._filterUpToDate=!1,i}),ue(P,"visible",!0,je()),ue(P,"transformsEnabled","all",Qt()),ue(P,"size"),ue(P,"dragBoundFunc"),ue(P,"draggable",!1,je()),v.backCompat(P,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class He 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,l=s&&s.isCache;if(!this.isVisible()&&!l)return this;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._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 l=this.getAbsoluteTransform(t).getMatrix();n.transform(l[0],l[1],l[2],l[3],l[4],l[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(),l=this.clipFunc(),h=a&&o||l;const d=r===this;if(h){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(),l)l.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(),h&&n.restore()}getClientRect(e){var t;e=e||{};var r=e.skipTransform,s=e.relativeTo,n,a,o,l,h={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,l=g.y+g.height):(n=Math.min(n,g.x),a=Math.min(a,g.y),o=Math.max(o,g.x+g.width),l=Math.max(l,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?h={x:n,y:a,width:o-n,height:l-a}:h={x:0,y:0,width:0,height:0},r?h:this._transformedRect(h,s)}}v.addComponentsGetterSetter(He,"clip",["x","y","width","height"]),v.addGetterSetter(He,"clipX",void 0,x()),v.addGetterSetter(He,"clipY",void 0,x()),v.addGetterSetter(He,"clipWidth",void 0,x()),v.addGetterSetter(He,"clipHeight",void 0,x()),v.addGetterSetter(He,"clipFunc");const ki=new Map,Vn=D._global.PointerEvent!==void 0;function vs(i){return ki.get(i)}function ys(i){return{evt:i,pointerId:i.pointerId}}function zn(i,e){return ki.get(i)===e}function Wn(i,e){xi(i),e.getStage()&&(ki.set(i,e),Vn&&e._fire("gotpointercapture",ys(new PointerEvent("gotpointercapture"))))}function xi(i,e){const t=ki.get(i);if(!t)return;const r=t.getStage();r&&r.content,ki.delete(i),Vn&&t._fire("lostpointercapture",ys(new PointerEvent("lostpointercapture")))}var Sl="Stage",Tl="string",Un="px",Cl="mouseout",Zn="mouseleave",jn="mouseover",Xn="mouseenter",qn="mousemove",Yn="mousedown",Kn="mouseup",Pi="pointermove",Ai="pointerdown",ti="pointerup",Mi="pointercancel",El="lostpointercapture",mr="pointerout",gr="pointerleave",vr="pointerover",yr="pointerenter",bs="contextmenu",Jn="touchstart",Qn="touchend",ea="touchmove",ta="touchcancel",_s="wheel",kl=5,xl=[[Xn,"_pointerenter"],[Yn,"_pointerdown"],[qn,"_pointermove"],[Kn,"_pointerup"],[Zn,"_pointerleave"],[Jn,"_pointerdown"],[ea,"_pointermove"],[Qn,"_pointerup"],[ta,"_pointercancel"],[jn,"_pointerover"],[_s,"_wheel"],[bs,"_contextmenu"],[Ai,"_pointerdown"],[Pi,"_pointermove"],[ti,"_pointerup"],[Mi,"_pointercancel"],[El,"_lostpointercapture"]];const ws={mouse:{[mr]:Cl,[gr]:Zn,[vr]:jn,[yr]:Xn,[Pi]:qn,[Ai]:Yn,[ti]:Kn,[Mi]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[mr]:"touchout",[gr]:"touchleave",[vr]:"touchover",[yr]:"touchenter",[Pi]:ea,[Ai]:Jn,[ti]:Qn,[Mi]:ta,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[mr]:mr,[gr]:gr,[vr]:vr,[yr]:yr,[Pi]:Pi,[Ai]:Ai,[ti]:ti,[Mi]:Mi,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},Oi=i=>i.indexOf("pointer")>=0?"pointer":i.indexOf("touch")>=0?"touch":"mouse",ii=i=>{const e=Oi(i);if(e==="pointer")return D.pointerEventsEnabled&&ws.pointer;if(e==="touch")return ws.touch;if(e==="mouse")return ws.mouse};function ia(i={}){return(i.clipFunc||i.clipWidth||i.clipHeight)&&y.warn("Stage does not support clipping. Please use clip for Layers or Groups."),i}const Pl="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);",br=[];class _r extends He{constructor(e){super(ia(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),br.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{ia(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===Tl){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"),He.prototype.clone.call(this,e)}destroy(){super.destroy();var e=this.content;e&&y._isInDocument(e)&&this.container().removeChild(e);var t=br.indexOf(this);return t>-1&&br.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(Pl),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 ei({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+Un,this.content.style.height=t+Un),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>kl&&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 zn(e,this)}setPointerCapture(e){Wn(e,this)}releaseCapture(e){xi(e)}getLayers(){return this.children}_bindContentEvents(){D.isBrowser&&xl.forEach(([e,t])=>{this.content.addEventListener(e,r=>{this[t](r)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=ii(e.type);this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=ii(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=ii(e.type),r=Oi(e.type);if(t){this.setPointersPositions(e);var s=this._getTargetShape(r),n=!se.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=ii(e.type),r=Oi(e.type);if(t){this.setPointersPositions(e);var s=!1;this._changedPointerPositions.forEach(n=>{var a=this.getIntersection(n);if(se.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 l=e.type.indexOf("touch")>=0;a.preventDefault()&&e.cancelable&&l&&e.preventDefault()}),s||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(e){const t=ii(e.type),r=Oi(e.type);if(!t)return;se.isDragging&&se.node.preventDefault()&&e.cancelable&&e.preventDefault(),this.setPointersPositions(e);var s=!se.isDragging||D.hitOnDragEnabled;if(!s)return;var n={};let a=!1;var o=this._getTargetShape(r);this._changedPointerPositions.forEach(l=>{const h=vs(l.id)||this.getIntersection(l),d=l.id,u={evt:e,pointerId:d};var c=o!==h;if(c&&o&&(o._fireAndBubble(t.pointerout,Object.assign({},u),h),o._fireAndBubble(t.pointerleave,Object.assign({},u),h)),h){if(n[h._id])return;n[h._id]=!0}h&&h.isListening()?(a=!0,c&&(h._fireAndBubble(t.pointerover,Object.assign({},u),o),h._fireAndBubble(t.pointerenter,Object.assign({},u),o),this[r+"targetShape"]=h),h._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=ii(e.type),r=Oi(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(l=>{const h=vs(l.id)||this.getIntersection(l);if(h){if(h.releaseCapture(l.id),a[h._id])return;a[h._id]=!0}const d=l.id,u={evt:e,pointerId:d};let c=!1;D["_"+r+"InDblClickWindow"]?(c=!0,clearTimeout(this[r+"DblTimeout"])):se.justDragged||(D["_"+r+"InDblClickWindow"]=!0,clearTimeout(this[r+"DblTimeout"])),this[r+"DblTimeout"]=setTimeout(function(){D["_"+r+"InDblClickWindow"]=!1},D.dblClickWindow),h&&h.isListening()?(o=!0,this[r+"ClickEndShape"]=h,h._fireAndBubble(t.pointerup,Object.assign({},u)),D["_"+r+"ListenClick"]&&s&&s===h&&(h._fireAndBubble(t.pointerclick,Object.assign({},u)),c&&n&&n===h&&h._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(bs,{evt:e}):this._fire(bs,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(_s,{evt:e}):this._fire(_s,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=vs(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(ti,ys(e)),xi(e.pointerId)}_lostpointercapture(e){xi(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 ei({width:this.width(),height:this.height()}),this.bufferHitCanvas=new ps({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}}_r.prototype.nodeType=Sl,fe(_r),v.addGetterSetter(_r,"container");var ra="hasShadow",sa="shadowRGBA",na="patternImage",aa="linearGradient",oa="radialGradient";let wr;function Ss(){return wr||(wr=y.createCanvasElement().getContext("2d"),wr)}const Li={};function Al(i){i.fill()}function Ml(i){i.stroke()}function Ol(i){i.fill()}function Ll(i){i.stroke()}function Rl(){this._clearCache(ra)}function Il(){this._clearCache(sa)}function Nl(){this._clearCache(na)}function Dl(){this._clearCache(aa)}function Gl(){this._clearCache(oa)}class E extends P{constructor(e){super(e);let t;for(;t=y.getRandomColor(),!(t&&!(t in Li)););this.colorKey=t,Li[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(ra,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(na,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){var e=Ss();const t=e.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const r=new Fe;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(aa,this.__getLinearGradient)}__getLinearGradient(){var e=this.fillLinearGradientColorStops();if(e){for(var t=Ss(),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(oa,this.__getRadialGradient)}__getRadialGradient(){var e=this.fillRadialGradientColorStops();if(e){for(var t=Ss(),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(sa,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 Li[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(),l=this.shadowForStrokeEnabled();return!!(s&&n&&o&&l)}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,l=s.height+a,h=!e.skipShadow&&this.hasShadow(),d=h?this.shadowOffsetX():0,u=h?this.shadowOffsetY():0,c=o+Math.abs(d),p=l+Math.abs(u),f=h&&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(),l=this.hasShadow(),h,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){h=this.getStage(),d=h.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;l&&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)}l&&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(),l=this._getCanvasCache(),h=l&&l.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()"),h){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(),l,h,d,u,c,p;n.clear(),n.drawImage(r._canvas,0,0,a,o);try{for(l=n.getImageData(0,0,a,o),h=l.data,d=h.length,u=y._hexToRgb(this.colorKey),c=0;c<d;c+=4)p=h[c+3],p>e?(h[c]=u.r,h[c+1]=u.g,h[c+2]=u.b,h[c+3]=255):h[c+3]=0;n.putImageData(l,0,0)}catch(f){y.error("Unable to draw hit graph from cached scene canvas. "+f.message)}return this}hasPointerCapture(e){return zn(e,this)}setPointerCapture(e){Wn(e,this)}releaseCapture(e){xi(e)}}E.prototype._fillFunc=Al,E.prototype._strokeFunc=Ml,E.prototype._fillFuncHit=Ol,E.prototype._strokeFuncHit=Ll,E.prototype._centroid=!1,E.prototype.nodeType="Shape",fe(E),E.prototype.eventListeners={},E.prototype.on.call(E.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",Rl),E.prototype.on.call(E.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",Il),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",Nl),E.prototype.on.call(E.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",Dl),E.prototype.on.call(E.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",Gl),v.addGetterSetter(E,"stroke",void 0,Rn()),v.addGetterSetter(E,"strokeWidth",2,x()),v.addGetterSetter(E,"fillAfterStrokeEnabled",!1),v.addGetterSetter(E,"hitStrokeWidth","auto",fs()),v.addGetterSetter(E,"strokeHitEnabled",!0,je()),v.addGetterSetter(E,"perfectDrawEnabled",!0,je()),v.addGetterSetter(E,"shadowForStrokeEnabled",!0,je()),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,Qt()),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,Rn()),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 Fl="#",Hl="beforeDraw",Bl="draw",ha=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],$l=ha.length;class $t extends He{constructor(e){super(e),this.canvas=new ei,this.hitCanvas=new ps({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<$l;s++){const n=ha[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=Li[Fl+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(Hl,{node:this}),this.clearBeforeDraw()&&s.getContext().clear(),He.prototype.drawScene.call(this,s,t),this._fire(Bl,{node:this}),this}drawHit(e,t){var r=this.getLayer(),s=e||r&&r.hitCanvas;return r&&r.clearBeforeDraw()&&r.getHitCanvas().getContext().clear(),He.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()}}$t.prototype.nodeType="Layer",fe($t),v.addGetterSetter($t,"imageSmoothingEnabled",!0),v.addGetterSetter($t,"clearBeforeDraw",!0),v.addGetterSetter($t,"hitGraphEnabled",!0,je());class Ts extends $t{constructor(e){super(e),this.listening(!1),y.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}Ts.prototype.nodeType="FastLayer",fe(Ts);class ri extends He{_validateAdd(e){var t=e.getType();t!=="Group"&&t!=="Shape"&&y.throw("You may only add groups and shapes to groups.")}}ri.prototype.nodeType="Group",fe(ri);var Cs=function(){return Jt.performance&&Jt.performance.now?function(){return Jt.performance.now()}:function(){return new Date().getTime()}}();class Ve{constructor(e,t){this.id=Ve.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Cs(),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=Ve,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=Cs(),Ve._addAnimation(this),this}stop(){return Ve._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,l,h,d,u;for(a=0;a<t.length;a++)if(r=t[a],s=r.layers,n=r.func,r._updateFrameObject(Cs()),l=s.length,n?u=n.call(r,r.frame)!==!1:u=!0,!!u)for(o=0;o<l;o++)h=s[o],h._id!==void 0&&(e[h._id]=h);for(d in e)e.hasOwnProperty(d)&&e[d].batchDraw()}static _animationLoop(){var e=Ve;e.animations.length?(e._runFrames(),y.requestAnimFrame(e._animationLoop)):e.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,y.requestAnimFrame(this._animationLoop))}}Ve.animations=[],Ve.animIdCounter=0,Ve.animRunning=!1;var Vl={node:1,duration:1,easing:1,onFinish:1,yoyo:1},zl=1,la=2,da=3,Wl=0,ua=["fill","stroke","shadowColor"];class Ul{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=la,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=da,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===la?this.setTime(e):this.state===da&&this.setTime(this.duration-e)}pause(){this.state=zl,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||Ri.Linear,o=!!e.yoyo,l;typeof e.duration>"u"?n=.3:e.duration===0?n=.001:n=e.duration,this.node=r,this._id=Wl++;var h=r.getLayer()||(r instanceof D.Stage?r.getLayers():null);h||y.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Ve(function(){t.tween.onEnterFrame()},h),this.tween=new Ul(l,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(l in e)Vl[l]===void 0&&this._addAttr(l,e[l]);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,l,h,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=[],h=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(l=0;l<h;l++)if(l%2===0)a.push(t[l]-n[l]);else{var p=y.colorToRGBA(n[l]);c=y.colorToRGBA(t[l]),n[l]=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(l=0;l<h;l++)a.push(t[l]-n[l]);else ua.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,l,h,d,u;for(s in r){if(n=r[s],a=n.start,o=n.diff,u=n.end,y._isArray(a))if(l=[],d=Math.max(a.length,u.length),s.indexOf("fill")===0)for(h=0;h<d;h++)h%2===0?l.push((a[h]||0)+o[h]*e):l.push("rgba("+Math.round(a[h].r+o[h].r*e)+","+Math.round(a[h].g+o[h].g*e)+","+Math.round(a[h].b+o[h].b*e)+","+(a[h].a+o[h].a*e)+")");else for(h=0;h<d;h++)l.push((a[h]||0)+o[h]*e);else ua.indexOf(s)!==-1?l="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)+")":l=a+o*e;t.setAttr(s,l)}}_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 Ri={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-Ri.BounceEaseOut(r-i,0,t,r)+e},BounceEaseInOut(i,e,t,r){return i<r/2?Ri.BounceEaseIn(i*2,0,t,r)*.5+e:Ri.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}},ca=y._assign(D,{Util:y,Transform:Fe,Node:P,Container:He,Stage:_r,stages:br,Layer:$t,FastLayer:Ts,Group:ri,DD:se,Shape:E,shapes:Li,Animation:Ve,Tween:ye,Easings:Ri,Context:lr,Canvas:ur});class ut 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)),l=Math.sin(Math.min(s,Math.PI/2)),h=n*(n>0?e:t),d=a*t,u=o*(o>0?e:t),c=l*(l>0?t:e);return{x:h,y:r?-1*c:u,width:d-h,height:c-u}}}ut.prototype._centroid=!0,ut.prototype.className="Arc",ut.prototype._attrsAffectingSize=["innerRadius","outerRadius"],fe(ut),v.addGetterSetter(ut,"innerRadius",0,x()),v.addGetterSetter(ut,"outerRadius",0,x()),v.addGetterSetter(ut,"angle",0,x()),v.addGetterSetter(ut,"clockwise",!1,je());function Es(i,e,t,r,s,n,a){var o=Math.sqrt(Math.pow(t-i,2)+Math.pow(r-e,2)),l=Math.sqrt(Math.pow(s-t,2)+Math.pow(n-r,2)),h=a*o/(o+l),d=a*l/(o+l),u=t-h*(s-i),c=r-h*(n-e),p=t+d*(s-i),f=r+d*(n-e);return[u,c,p,f]}function fa(i,e){var t=i.length,r=[],s,n;for(s=2;s<t-2;s+=2)n=Es(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 ct 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,l,h;if(r){if(e.beginPath(),e.moveTo(t[0],t[1]),s!==0&&r>4){for(o=this.getTensionPoints(),l=o.length,h=n?0:4,n||e.quadraticCurveTo(o[0],o[1],o[2],o[3]);h<l-2;)e.bezierCurveTo(o[h++],o[h++],o[h++],o[h++],o[h++],o[h++]);n||e.quadraticCurveTo(o[l-2],o[l-1],t[r-2],t[r-1])}else if(a)for(h=2;h<r;)e.bezierCurveTo(t[h++],t[h++],t[h++],t[h++],t[h++],t[h++]);else for(h=2;h<r;h+=2)e.lineTo(t[h],t[h+1]);n?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():fa(this.points(),this.tension())}_getTensionPointsClosed(){var e=this.points(),t=e.length,r=this.tension(),s=Es(e[t-2],e[t-1],e[0],e[1],e[2],e[3],r),n=Es(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],r),a=fa(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,l=0;l<e.length/2;l++)a=e[l*2],o=e[l*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}}}ct.prototype.className="Line",ct.prototype._attrsAffectingSize=["points","bezier","tension"],fe(ct),v.addGetterSetter(ct,"closed",!1),v.addGetterSetter(ct,"bezier",!1),v.addGetterSetter(ct,"tension",0,x()),v.addGetterSetter(ct,"points",[],tl());class le extends E{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this.dataArray=le.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=le.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],l=a[1],h=a[2],d=a[3],u=a[4],c=a[5],p=a[6],f=a[7],m=h>d?h:d,g=h>d?1:h/d,_=h>d?d/h:1;e.translate(o,l),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,-l);break;case"z":r=!0,e.closePath();break}}!r&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getSelfRect(){var e=[];this.dataArray.forEach(function(h){if(h.command==="A"){var d=h.points[4],u=h.points[5],c=h.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=le.getPointOnEllipticalArc(h.points[0],h.points[1],h.points[2],h.points[3],f,0);e.push(m.x,m.y)}else for(let f=d+p;f<c;f+=p){const m=le.getPointOnEllipticalArc(h.points[0],h.points[1],h.points[2],h.points[3],f,0);e.push(m.x,m.y)}}else if(h.command==="C")for(let f=0;f<=1;f+=.01){const m=le.getPointOnCubicBezier(f,h.start.x,h.start.y,h.points[0],h.points[1],h.points[2],h.points[3],h.points[4],h.points[5]);e.push(m.x,m.y)}else e=e.concat(h.points)});for(var t=e[0],r=e[0],s=e[1],n=e[1],a,o,l=0;l<e.length/2;l++)a=e[l*2],o=e[l*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 le.getPointOnLine(e,n.start.x,n.start.y,a[0],a[1]);case"C":return le.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 le.getPointOnQuadraticBezier(e/n.pathLength,n.start.x,n.start.y,a[0],a[1],a[2],a[3]);case"A":var o=a[0],l=a[1],h=a[2],d=a[3],u=a[4],c=a[5],p=a[6];return u+=c*e/n.pathLength,le.getPointOnEllipticalArc(o,l,h,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 l=(n-r)/(s-t+1e-8),h=Math.sqrt(e*e/(1+l*l));s<t&&(h*=-1);var d=l*h,u;if(s===t)u={x:a,y:o+d};else if((o-r)/(a-t+1e-8)===l)u={x:a+h,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);h=Math.sqrt(_*_/(1+l*l)),s<t&&(h*=-1),d=l*h,u={x:c+h,y:p+d}}return u}static getPointOnCubicBezier(e,t,r,s,n,a,o,l,h){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=l*d(e)+a*u(e)+s*c(e)+t*p(e),m=h*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 l(p){return p*p}function h(p){return 2*p*(1-p)}function d(p){return(1-p)*(1-p)}var u=a*l(e)+s*h(e)+t*d(e),c=o*l(e)+n*h(e)+r*d(e);return{x:u,y:c}}static getPointOnEllipticalArc(e,t,r,s,n,a){var o=Math.cos(a),l=Math.sin(a),h={x:r*Math.cos(n),y:s*Math.sin(n)};return{x:e+(h.x*o-h.y*l),y:t+(h.x*l+h.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=[],l=0,h=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=l,L=h,A,G,R,H,V,I,K,W,he,ae;switch(p){case"l":l+=f.shift(),h+=f.shift(),w="L",b.push(l,h);break;case"L":l=f.shift(),h=f.shift(),b.push(l,h);break;case"m":var U=f.shift(),Ee=f.shift();if(l+=U,h+=Ee,w="M",a.length>2&&a[a.length-1].command==="z"){for(var De=a.length-2;De>=0;De--)if(a[De].command==="M"){l=a[De].points[0]+U,h=a[De].points[1]+Ee;break}}b.push(l,h),p="l";break;case"M":l=f.shift(),h=f.shift(),w="M",b.push(l,h),p="L";break;case"h":l+=f.shift(),w="L",b.push(l,h);break;case"H":l=f.shift(),w="L",b.push(l,h);break;case"v":h+=f.shift(),w="L",b.push(l,h);break;case"V":h=f.shift(),w="L",b.push(l,h);break;case"C":b.push(f.shift(),f.shift(),f.shift(),f.shift()),l=f.shift(),h=f.shift(),b.push(l,h);break;case"c":b.push(l+f.shift(),h+f.shift(),l+f.shift(),h+f.shift()),l+=f.shift(),h+=f.shift(),w="C",b.push(l,h);break;case"S":G=l,R=h,A=a[a.length-1],A.command==="C"&&(G=l+(l-A.points[2]),R=h+(h-A.points[3])),b.push(G,R,f.shift(),f.shift()),l=f.shift(),h=f.shift(),w="C",b.push(l,h);break;case"s":G=l,R=h,A=a[a.length-1],A.command==="C"&&(G=l+(l-A.points[2]),R=h+(h-A.points[3])),b.push(G,R,l+f.shift(),h+f.shift()),l+=f.shift(),h+=f.shift(),w="C",b.push(l,h);break;case"Q":b.push(f.shift(),f.shift()),l=f.shift(),h=f.shift(),b.push(l,h);break;case"q":b.push(l+f.shift(),h+f.shift()),l+=f.shift(),h+=f.shift(),w="Q",b.push(l,h);break;case"T":G=l,R=h,A=a[a.length-1],A.command==="Q"&&(G=l+(l-A.points[0]),R=h+(h-A.points[1])),l=f.shift(),h=f.shift(),w="Q",b.push(G,R,l,h);break;case"t":G=l,R=h,A=a[a.length-1],A.command==="Q"&&(G=l+(l-A.points[0]),R=h+(h-A.points[1])),l+=f.shift(),h+=f.shift(),w="Q",b.push(G,R,l,h);break;case"A":H=f.shift(),V=f.shift(),I=f.shift(),K=f.shift(),W=f.shift(),he=l,ae=h,l=f.shift(),h=f.shift(),w="A",b=this.convertEndpointToCenterParameterization(he,ae,l,h,K,W,H,V,I);break;case"a":H=f.shift(),V=f.shift(),I=f.shift(),K=f.shift(),W=f.shift(),he=l,ae=h,l+=f.shift(),h+=f.shift(),w="A",b=this.convertEndpointToCenterParameterization(he,ae,l,h,K,W,H,V,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,l,h=le;switch(r){case"L":return h.getLineLength(e,t,s[0],s[1]);case"C":for(n=0,a=h.getPointOnCubicBezier(0,e,t,s[0],s[1],s[2],s[3],s[4],s[5]),l=.01;l<=1;l+=.01)o=h.getPointOnCubicBezier(l,e,t,s[0],s[1],s[2],s[3],s[4],s[5]),n+=h.getLineLength(a.x,a.y,o.x,o.y),a=o;return n;case"Q":for(n=0,a=h.getPointOnQuadraticBezier(0,e,t,s[0],s[1],s[2],s[3]),l=.01;l<=1;l+=.01)o=h.getPointOnQuadraticBezier(l,e,t,s[0],s[1],s[2],s[3]),n+=h.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=h.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],d,0),u<0)for(l=d-p;l>c;l-=p)o=h.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],l,0),n+=h.getLineLength(a.x,a.y,o.x,o.y),a=o;else for(l=d+p;l<c;l+=p)o=h.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],l,0),n+=h.getLineLength(a.x,a.y,o.x,o.y),a=o;return o=h.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],c,0),n+=h.getLineLength(a.x,a.y,o.x,o.y),n}return 0}static convertEndpointToCenterParameterization(e,t,r,s,n,a,o,l,h){var d=h*(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/(l*l);p>1&&(o*=Math.sqrt(p),l*=Math.sqrt(p));var f=Math.sqrt((o*o*(l*l)-o*o*(c*c)-l*l*(u*u))/(o*o*(c*c)+l*l*(u*u)));n===a&&(f*=-1),isNaN(f)&&(f=0);var m=f*o*c/l,g=f*-l*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(V){return Math.sqrt(V[0]*V[0]+V[1]*V[1])},T=function(V,I){return(V[0]*I[0]+V[1]*I[1])/(b(V)*b(I))},L=function(V,I){return(V[0]*I[1]<V[1]*I[0]?-1:1)*Math.acos(T(V,I))},A=L([1,0],[(u-m)/o,(c-g)/l]),G=[(u-m)/o,(c-g)/l],R=[(-1*u-m)/o,(-1*c-g)/l],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,l,A,H,d,a]}}le.prototype.className="Path",le.prototype._attrsAffectingSize=["data"],fe(le),v.addGetterSetter(le,"data");class Vt extends ct{_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,l,h;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=le.calcLength(s[s.length-4],s[s.length-3],"C",c),f=le.getPointOnQuadraticBezier(Math.min(1,1-a/p),c[0],c[1],c[2],c[3],c[4],c[5]);l=r[o-2]-f.x,h=r[o-1]-f.y}else l=r[o-2]-r[o-4],h=r[o-1]-r[o-3];var d=(Math.atan2(h,l)+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?(l=(s[0]+s[2])/2-r[0],h=(s[1]+s[3])/2-r[1]):(l=r[2]-r[0],h=r[3]-r[1]),e.rotate((Math.atan2(-h,-l)+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}}}Vt.prototype.className="Arrow",fe(Vt),v.addGetterSetter(Vt,"pointerLength",10,x()),v.addGetterSetter(Vt,"pointerWidth",10,x()),v.addGetterSetter(Vt,"pointerAtBeginning",!1),v.addGetterSetter(Vt,"pointerAtEnding",!0);class si 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)}}si.prototype._centroid=!0,si.prototype.className="Circle",si.prototype._attrsAffectingSize=["radius"],fe(si),v.addGetterSetter(si,"radius",0,x());class kt 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)}}kt.prototype.className="Ellipse",kt.prototype._centroid=!0,kt.prototype._attrsAffectingSize=["radiusX","radiusY"],fe(kt),v.addComponentsGetterSetter(kt,"radius",["x","y"]),v.addGetterSetter(kt,"radiusX",0,x()),v.addGetterSetter(kt,"radiusY",0,x());class Xe 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 Xe({image:s});t(n)},s.onerror=r,s.crossOrigin="Anonymous",s.src=e}}Xe.prototype.className="Image",fe(Xe),v.addGetterSetter(Xe,"image"),v.addComponentsGetterSetter(Xe,"crop",["x","y","width","height"]),v.addGetterSetter(Xe,"cropX",0,x()),v.addGetterSetter(Xe,"cropY",0,x()),v.addGetterSetter(Xe,"cropWidth",0,x()),v.addGetterSetter(Xe,"cropHeight",0,x());var pa=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Zl="Change.konva",jl="none",ks="up",xs="right",Ps="down",As="left",Xl=pa.length;class Ms extends ri{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<Xl;r++)e.on(pa[r]+Zl,s)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e=this.getText(),t=this.getTag(),r,s,n,a,o,l,h;if(e&&t){switch(r=e.width(),s=e.height(),n=t.pointerDirection(),a=t.pointerWidth(),h=t.pointerHeight(),o=0,l=0,n){case ks:o=r/2,l=-1*h;break;case xs:o=r+a,l=s/2;break;case Ps:o=r/2,l=s+h;break;case As:o=-1*a,l=s/2;break}t.setAttrs({x:-1*o,y:-1*l,width:r,height:s}),e.setAttrs({x:-1*o,y:-1*l})}}}Ms.prototype.className="Label",fe(Ms);class zt extends E{_sceneFunc(e){var t=this.width(),r=this.height(),s=this.pointerDirection(),n=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius();let l=0,h=0,d=0,u=0;typeof o=="number"?l=h=d=u=Math.min(o,t/2,r/2):(l=Math.min(o[0]||0,t/2,r/2),h=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(l,0),s===ks&&(e.lineTo((t-n)/2,0),e.lineTo(t/2,-1*a),e.lineTo((t+n)/2,0)),e.lineTo(t-h,0),e.arc(t-h,h,h,Math.PI*3/2,0,!1),s===xs&&(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===Ps&&(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===As&&(e.lineTo(0,(r+a)/2),e.lineTo(-1*n,r/2),e.lineTo(0,(r-a)/2)),e.lineTo(0,l),e.arc(l,l,l,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===ks?(t-=s,o+=s):n===Ps?o+=s:n===As?(e-=r*1.5,a+=r):n===xs&&(a+=r*1.5),{x:e,y:t,width:a,height:o}}}zt.prototype.className="Tag",fe(zt),v.addGetterSetter(zt,"pointerDirection",jl),v.addGetterSetter(zt,"pointerWidth",0,x()),v.addGetterSetter(zt,"pointerHeight",0,x()),v.addGetterSetter(zt,"cornerRadius",0,Ln(4));class Ii 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,l=0;typeof t=="number"?n=a=o=l=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),l=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-l),e.arc(r-l,s-l,l,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)}}Ii.prototype.className="Rect",fe(Ii),v.addGetterSetter(Ii,"cornerRadius",0,Ln(4));class Wt 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)}}Wt.prototype.className="RegularPolygon",Wt.prototype._centroid=!0,Wt.prototype._attrsAffectingSize=["radius"],fe(Wt),v.addGetterSetter(Wt,"radius",0,x()),v.addGetterSetter(Wt,"sides",0,x());var ma=Math.PI*2;class Ut extends E{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,ma,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),ma,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)}}Ut.prototype.className="Ring",Ut.prototype._centroid=!0,Ut.prototype._attrsAffectingSize=["innerRadius","outerRadius"],fe(Ut),v.addGetterSetter(Ut,"innerRadius",0,x()),v.addGetterSetter(Ut,"outerRadius",0,x());class it extends E{constructor(e){super(e),this._updated=!0,this.anim=new Ve(()=>{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],l=n[s+1],h=n[s+2],d=n[s+3],u=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,h,d),e.closePath(),e.fillStrokeShape(this)),u)if(a){var c=a[t],p=r*2;e.drawImage(u,o,l,h,d,c[p+0],c[p+1],h,d)}else e.drawImage(u,o,l,h,d,0,0,h,d)}_hitFunc(e){var t=this.animation(),r=this.frameIndex(),s=r*4,n=this.animations()[t],a=this.frameOffsets(),o=n[s+2],l=n[s+3];if(e.beginPath(),a){var h=a[t],d=r*2;e.rect(h[d+0],h[d+1],o,l)}else e.rect(0,0,o,l);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)}}it.prototype.className="Sprite",fe(it),v.addGetterSetter(it,"animation"),v.addGetterSetter(it,"animations"),v.addGetterSetter(it,"frameOffsets"),v.addGetterSetter(it,"image"),v.addGetterSetter(it,"frameIndex",0,x()),v.addGetterSetter(it,"frameRate",17,x()),v.backCompat(it,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class xt 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),l=-1*a*Math.cos(n*Math.PI/s);e.lineTo(o,l)}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)}}xt.prototype.className="Star",xt.prototype._centroid=!0,xt.prototype._attrsAffectingSize=["innerRadius","outerRadius"],fe(xt),v.addGetterSetter(xt,"numPoints",5,x()),v.addGetterSetter(xt,"innerRadius",0,x()),v.addGetterSetter(xt,"outerRadius",0,x());function ga(i){return Array.from(i)}var ni="auto",ql="center",Ni="justify",Yl="Change.konva",Kl="2d",va="-",ya="left",Jl="text",Ql="Text",ed="top",td="bottom",ba="middle",_a="normal",id="px ",Sr=" ",rd="right",sd="word",nd="char",wa="none",Os="…",Sa=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],ad=Sa.length;function od(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 Tr;function Ls(){return Tr||(Tr=y.createCanvasElement().getContext(Kl),Tr)}function hd(i){i.fillText(this._partialText,this._partialTextX,this._partialTextY)}function ld(i){i.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function dd(i){return i=i||{},!i.fillLinearGradientColorStops&&!i.fillRadialGradientColorStops&&!i.fillPatternImage&&(i.fill=i.fill||"black"),i}class pe extends E{constructor(e){super(dd(e)),this._partialTextX=0,this._partialTextY=0;for(var t=0;t<ad;t++)this.on(Sa[t]+Yl,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(),l=0,h=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",ba),e.setAttr("textAlign",ya),o===ba?l=(this.getHeight()-r*a-s*2)/2:o===td&&(l=this.getHeight()-r*a-s*2),e.translate(s,l+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,V;if(e.save(),h===rd?w+=d-A-s*2:h===ql&&(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,V=h===Ni&&G&&!H?d-s*2:A,e.lineTo(w+Math.round(V),_+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,V=h===Ni&&G&&!H?d-s*2:A,e.lineTo(w+Math.round(V),_+b),e.lineWidth=n/15,e.strokeStyle=c,e.stroke(),e.restore()),u!==0||h===Ni){R=L.split(" ").length-1;for(var I=ga(L),K=0;K<I.length;K++){var W=I[K];W===" "&&!G&&h===Ni&&(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(Jl,t),this}getWidth(){var e=this.attrs.width===ni||this.attrs.width===void 0;return e?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){var e=this.attrs.height===ni||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=Ls(),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()+Sr+this.fontVariant()+Sr+(this.fontSize()+id)+od(this.fontFamily())}_addTextLine(e){this.align()===Ni&&(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 Ls().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!==ni&&n!==void 0,l=a!==ni&&a!==void 0,h=this.padding(),d=n-h*2,u=a-h*2,c=0,p=this.wrap(),f=p!==wa,m=p!==nd&&f,g=this.ellipsis();this.textArr=[],Ls().font=this._getContextFont();for(var _=g?this._getTextWidth(Os):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 V=A+G>>>1,I=T.slice(0,V+1),K=this._getTextWidth(I)+_;K<=d?(A=V+1,R=I,H=K):G=V}if(R){if(m){var W,he=T[R.length],ae=he===Sr||he===va;ae&&H<=d?W=R.length:W=Math.max(R.lastIndexOf(Sr),R.lastIndexOf(va))+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(l&&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!==ni&&s!==void 0,a=this.padding(),o=s-a*2,l=this.wrap(),h=l!==wa;return!h||n&&e+r>o}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,t=e!==ni&&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+Os)<s;o||(a.text=a.text.slice(0,a.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(a.text+Os)}}getStrokeScaleEnabled(){return!0}}pe.prototype._fillFunc=hd,pe.prototype._strokeFunc=ld,pe.prototype.className=Ql,pe.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],fe(pe),v.overWriteSetter(pe,"width",fs()),v.overWriteSetter(pe,"height",fs()),v.addGetterSetter(pe,"fontFamily","Arial"),v.addGetterSetter(pe,"fontSize",12,x()),v.addGetterSetter(pe,"fontStyle",_a),v.addGetterSetter(pe,"fontVariant",_a),v.addGetterSetter(pe,"padding",0,x()),v.addGetterSetter(pe,"align",ya),v.addGetterSetter(pe,"verticalAlign",ed),v.addGetterSetter(pe,"lineHeight",1,x()),v.addGetterSetter(pe,"wrap",sd),v.addGetterSetter(pe,"ellipsis",!1,je()),v.addGetterSetter(pe,"letterSpacing",0,x()),v.addGetterSetter(pe,"text","",Qt()),v.addGetterSetter(pe,"textDecoration","");var ud="",Ta="normal";function Ca(i){i.fillText(this.partialText,0,0)}function Ea(i){i.strokeText(this.partialText,0,0)}class we extends E{constructor(e){super(e),this.dummyCanvas=y.createCanvasElement(),this.dataArray=[],this.dataArray=le.parsePathData(this.attrs.data),this.on("dataChange.konva",function(){this.dataArray=le.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 pe.prototype.setText.call(this,e)}_getContextFont(){return pe.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,l=0;l<e.dataArray.length;l++)e.dataArray[l].pathLength>0&&(o+=e.dataArray[l].pathLength);var h=0;s==="center"&&(h=Math.max(0,o/2-a/2)),s==="right"&&(h=Math.max(0,o-a));for(var d=ga(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 he=0,ae=0;for(p=void 0;Math.abs(W-he)/W>.01&&ae<20;){ae++;for(var U=he;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 Ee=!1;switch(f.command){case"L":le.getLineLength(c.x,c.y,f.points[0],f.points[1])>W?p=le.getPointOnLine(W,c.x,c.y,f.points[0],f.points[1],c.x,c.y):f=void 0;break;case"A":var De=f.points[4],tt=f.points[5],te=f.points[4]+tt;g===0?g=De+1e-8:W>he?g+=Math.PI/180*tt/Math.abs(tt):g-=Math.PI/360*tt/Math.abs(tt),(tt<0&&g<te||tt>=0&&g>te)&&(g=te,Ee=!0),p=le.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>he?g+=(W-he)/f.pathLength/2:g=Math.max(g-(he-W)/f.pathLength/2,0),g>1&&(g=1,Ee=!0),p=le.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>he?g+=(W-he)/f.pathLength:g-=(he-W)/f.pathLength,g>1&&(g=1,Ee=!0),p=le.getPointOnQuadraticBezier(g,f.start.x,f.start.y,f.points[0],f.points[1],f.points[2],f.points[3]);break}p!==void 0&&(he=le.getLineLength(c.x,c.y,p.x,p.y)),Ee&&(Ee=!1,f=void 0)}},b="C",T=e._getTextSize(b).width+r,L=h/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=le.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 V=le.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:V.x,transposeY:V.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,l=0;l<e.length/2;l++)a=e[l*2],o=e[l*2+1],t=Math.min(t,a),r=Math.max(r,a),s=Math.min(s,o),n=Math.max(n,o);var h=this.fontSize();return{x:t-h/2,y:s-h/2,width:r-t+h,height:n-s+h}}destroy(){return y.releaseCanvas(this.dummyCanvas),super.destroy()}}we.prototype._fillFunc=Ca,we.prototype._strokeFunc=Ea,we.prototype._fillFuncHit=Ca,we.prototype._strokeFuncHit=Ea,we.prototype.className="TextPath",we.prototype._attrsAffectingSize=["text","fontSize","data"],fe(we),v.addGetterSetter(we,"data"),v.addGetterSetter(we,"fontFamily","Arial"),v.addGetterSetter(we,"fontSize",12,x()),v.addGetterSetter(we,"fontStyle",Ta),v.addGetterSetter(we,"align","left"),v.addGetterSetter(we,"letterSpacing",0,x()),v.addGetterSetter(we,"textBaseline","middle"),v.addGetterSetter(we,"fontVariant",Ta),v.addGetterSetter(we,"text",ud),v.addGetterSetter(we,"textDecoration",null),v.addGetterSetter(we,"kerningFunc",null);var ka="tr-konva",cd=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange"].map(i=>i+`.${ka}`).join(" "),xa="nodesRect",fd=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],pd={"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 md="ontouchstart"in D._global;function gd(i,e){if(i==="rotater")return"crosshair";e+=y.degToRad(pd[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 Cr=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],Pa=1e8;function vd(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 Aa(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 yd(i,e){const t=vd(i);return Aa(i,e,t)}function bd(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 ri{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(cd,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 ka+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(fd.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 l=o.getAbsolutePosition();o.setAbsolutePosition({x:l.x+n,y:l.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(xa),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(xa,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,l=s.y*n.y-e.offsetY()*n.y;const h=(D.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),d={x:a.x+o*Math.cos(h)+l*Math.sin(-h),y:a.y+l*Math.cos(h)+o*Math.sin(h),width:s.width*n.x,height:s.height*n.y,rotation:h};return Aa(d,-D.getAngle(t),{x:0,y:0})}__getNodeRect(){var e=this.getNode();if(!e)return{x:-Pa,y:-Pa,width:0,height:0,rotation:0};const t=[];this.nodes().map(h=>{const d=h.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=h.getAbsoluteTransform();u.forEach(function(p){var f=c.point(p);t.push(f)})});const r=new Fe;r.rotate(-D.getAngle(this.rotation()));var s,n,a,o;t.forEach(function(h){var d=r.point(h);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 l=r.point({x:s,y:n});return{x:l.x,y:l.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(),Cr.forEach(function(e){this._createAnchor(e)}.bind(this)),this._createAnchor("rotater")}_createAnchor(e){var t=new Ii({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:md?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=gd(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(l=>{l._fire("transformstart",{evt:e.evt,target:l})})}_handleMouseMove(e){var t,r,s,n=this.findOne("."+this._movingAnchorName),a=n.getStage();a.setPointersPositions(e);const o=a.getPointerPosition();let l={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y};const h=n.getAbsolutePosition();this.anchorDragBoundFunc()&&(l=this.anchorDragBoundFunc()(h,l,e)),n.setAbsolutePosition(l);const d=n.getAbsolutePosition();if(!(h.x===d.x&&h.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 W=c+K,he=D.getAngle(this.rotationSnapTolerance()),U=bd(this.rotationSnaps(),W,he)-u.rotation,Ee=yd(u,U);this._fitNodesInto(Ee,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 V=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:V,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 Fe;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,l=new Fe;l.translate(r.x,r.y),l.rotate(r.rotation),l.scale(r.width/o,r.height/o);const h=new Fe;h.translate(e.x,e.y),h.rotate(e.rotation),h.scale(e.width/o,e.height/o);const d=h.multiply(l.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 Fe;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(),l=this.anchorSize();this.find("._anchor").forEach(h=>{h.setAttrs({width:l,height:l,offsetX:l/2,offsetY:l/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:l/2+o,offsetY:l/2+o,visible:a&&n.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:r/2,y:0,offsetY:l/2+o,visible:a&&n.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:r,y:0,offsetX:l/2-o,offsetY:l/2+o,visible:a&&n.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:s/2,offsetX:l/2+o,visible:a&&n.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:r,y:s/2,offsetX:l/2-o,visible:a&&n.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:s,offsetX:l/2+o,offsetY:l/2-o,visible:a&&n.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:r/2,y:s,offsetY:l/2-o,visible:a&&n.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:r,y:s,offsetX:l/2-o,offsetY:l/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=""),ri.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 _d(i){return i instanceof Array||y.warn("enabledAnchors value should be an array"),i instanceof Array&&i.forEach(function(e){Cr.indexOf(e)===-1&&y.warn("Unknown anchor name: "+e+". Available names are: "+Cr.join(", "))}),i||[]}oe.prototype.className="Transformer",fe(oe),v.addGetterSetter(oe,"enabledAnchors",Cr,_d),v.addGetterSetter(oe,"flipEnabled",!0,je()),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 ft 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)}}ft.prototype.className="Wedge",ft.prototype._centroid=!0,ft.prototype._attrsAffectingSize=["radius"],fe(ft),v.addGetterSetter(ft,"radius",0,x()),v.addGetterSetter(ft,"angle",0,x()),v.addGetterSetter(ft,"clockwise",!1),v.backCompat(ft,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function Ma(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var wd=[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],Sd=[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 Td(i,e){var t=i.data,r=i.width,s=i.height,n,a,o,l,h,d,u,c,p,f,m,g,_,w,b,T,L,A,G,R,H,V,I,K,W=e+e+1,he=r-1,ae=s-1,U=e+1,Ee=U*(U+1)/2,De=new Ma,tt=null,te=De,ve=null,Ge=null,Ft=wd[e],Ht=Sd[e];for(o=1;o<W;o++)te=te.next=new Ma,o===U&&(tt=te);for(te.next=De,u=d=0,a=0;a<s;a++){for(T=L=A=G=c=p=f=m=0,g=U*(R=t[d]),_=U*(H=t[d+1]),w=U*(V=t[d+2]),b=U*(I=t[d+3]),c+=Ee*R,p+=Ee*H,f+=Ee*V,m+=Ee*I,te=De,o=0;o<U;o++)te.r=R,te.g=H,te.b=V,te.a=I,te=te.next;for(o=1;o<U;o++)l=d+((he<o?he:o)<<2),c+=(te.r=R=t[l])*(K=U-o),p+=(te.g=H=t[l+1])*K,f+=(te.b=V=t[l+2])*K,m+=(te.a=I=t[l+3])*K,T+=R,L+=H,A+=V,G+=I,te=te.next;for(ve=De,Ge=tt,n=0;n<r;n++)t[d+3]=I=m*Ft>>Ht,I!==0?(I=255/I,t[d]=(c*Ft>>Ht)*I,t[d+1]=(p*Ft>>Ht)*I,t[d+2]=(f*Ft>>Ht)*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,l=u+((l=n+e+1)<he?l:he)<<2,T+=ve.r=t[l],L+=ve.g=t[l+1],A+=ve.b=t[l+2],G+=ve.a=t[l+3],c+=T,p+=L,f+=A,m+=G,ve=ve.next,g+=R=Ge.r,_+=H=Ge.g,w+=V=Ge.b,b+=I=Ge.a,T-=R,L-=H,A-=V,G-=I,Ge=Ge.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=U*(R=t[d]),_=U*(H=t[d+1]),w=U*(V=t[d+2]),b=U*(I=t[d+3]),c+=Ee*R,p+=Ee*H,f+=Ee*V,m+=Ee*I,te=De,o=0;o<U;o++)te.r=R,te.g=H,te.b=V,te.a=I,te=te.next;for(h=r,o=1;o<=e;o++)d=h+n<<2,c+=(te.r=R=t[d])*(K=U-o),p+=(te.g=H=t[d+1])*K,f+=(te.b=V=t[d+2])*K,m+=(te.a=I=t[d+3])*K,T+=R,L+=H,A+=V,G+=I,te=te.next,o<ae&&(h+=r);for(d=n,ve=De,Ge=tt,a=0;a<s;a++)l=d<<2,t[l+3]=I=m*Ft>>Ht,I>0?(I=255/I,t[l]=(c*Ft>>Ht)*I,t[l+1]=(p*Ft>>Ht)*I,t[l+2]=(f*Ft>>Ht)*I):t[l]=t[l+1]=t[l+2]=0,c-=g,p-=_,f-=w,m-=b,g-=ve.r,_-=ve.g,w-=ve.b,b-=ve.a,l=n+((l=a+U)<ae?l:ae)*r<<2,c+=T+=ve.r=t[l],p+=L+=ve.g=t[l+1],f+=A+=ve.b=t[l+2],m+=G+=ve.a=t[l+3],ve=ve.next,g+=R=Ge.r,_+=H=Ge.g,w+=V=Ge.b,b+=I=Ge.a,T-=R,L-=H,A-=V,G-=I,Ge=Ge.next,d+=r}}const Cd=function(e){var t=Math.round(this.blurRadius());t>0&&Td(e,t)};v.addGetterSetter(P,"blurRadius",0,x(),v.afterSetFilter);const Ed=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 kd=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 xd=function(i){var e=this.embossStrength()*10,t=this.embossWhiteLevel()*255,r=this.embossDirection(),s=this.embossBlend(),n=0,a=0,o=i.data,l=i.width,h=i.height,d=l*4,u=h;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>h&&(p=0);var f=(u-1+p)*l*4,m=l;do{var g=c+(m-1)*4,_=a;m+_<1&&(_=0),m+_>l&&(_=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 V=o[g]+A,I=o[g+1]+A,K=o[g+2]+A;o[g]=V>255?255:V<0?0:V,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 Rs(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 Pd=function(i){var e=i.data,t=e.length,r=e[0],s=r,n,a=e[1],o=a,l,h=e[2],d=h,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),l=e[c+1],l<a?a=l:l>o&&(o=l),u=e[c+2],u<h?h=u:u>d&&(d=u);s===r&&(s=255,r=0),o===a&&(o=255,a=0),d===h&&(d=255,h=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=h-p*(h-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+h)*.5,L=d+p*(d-T),A=h+p*(h-T)),c=0;c<t;c+=4)e[c+0]=Rs(e[c+0],r,s,g,m),e[c+1]=Rs(e[c+1],a,o,b,w),e[c+2]=Rs(e[c+2],h,d,A,L)}};v.addGetterSetter(P,"enhance",0,x(),v.afterSetFilter);const Ad=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 Md=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,l=r*s*Math.cos(n*Math.PI/180),h=r*s*Math.sin(n*Math.PI/180),d=.299*r+.701*l+.167*h,u=.587*r-.587*l+.33*h,c=.114*r-.114*l-.497*h,p=.299*r-.299*l-.328*h,f=.587*r+.413*l+.035*h,m=.114*r-.114*l+.293*h,g=.299*r-.3*l+1.25*h,_=.587*r-.586*l-1.05*h,w=.114*r+.886*l-.2*h,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},Od=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),l=r*s*Math.sin(n*Math.PI/180),h=.299*r+.701*o+.167*l,d=.587*r-.587*o+.33*l,u=.114*r-.114*o-.497*l,c=.299*r-.299*o-.328*l,p=.587*r+.413*o+.035*l,f=.114*r-.114*o+.293*l,m=.299*r-.3*o+1.25*l,g=.587*r-.586*o-1.05*l,_=.114*r+.886*o-.2*l,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]=h*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 Ld=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 Rd=function(i,e,t){var r=i.data,s=e.data,n=i.width,a=i.height,o=t.polarCenterX||n/2,l=t.polarCenterY||a/2,h,d,u,c=0,p=0,f=0,m=0,g,_=Math.sqrt(o*o+l*l);d=n-o,u=a-l,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(l+_*T/w*G),h=(u*n+d)*4,c=r[h+0],p=r[h+1],f=r[h+2],m=r[h+3],h=(L+T*n)*4,s[h+0]=c,s[h+1]=p,s[h+2]=f,s[h+3]=m},Id=function(i,e,t){var r=i.data,s=e.data,n=i.width,a=i.height,o=t.polarCenterX||n/2,l=t.polarCenterY||a/2,h,d,u,c,p,f=0,m=0,g=0,_=0,w,b=Math.sqrt(o*o+l*l);d=n-o,u=a-l,w=Math.sqrt(d*d+u*u),b=w>b?w:b;var T=a,L=n,A,G,R=t.polarRotation||0,H,V;for(d=0;d<n;d+=1)for(u=0;u<a;u+=1)c=d-o,p=u-l,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),V=Math.floor(A),h=(V*n+H)*4,f=r[h+0],m=r[h+1],g=r[h+2],_=r[h+3],h=(u*n+d)*4,s[h+0]=f,s[h+1]=m,s[h+2]=g,s[h+3]=_};const Nd=function(i){var e=i.width,t=i.height,r,s,n,a,o,l,h,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),Rd(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],l=_.data[u+1],h=_.data[u+2],d=_.data[u+3],c=(e*s+r)*4,_.data[c+0]=o,_.data[c+1]=l,_.data[c+2]=h,_.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],l=_.data[u+1],h=_.data[u+2],d=_.data[u+3],c=(e*s+b*2-r-1)*4,_.data[c+0]=o,_.data[c+1]=l,_.data[c+2]=h,_.data[c+3]=d;b*=2}Id(_,i,{polarRotation:0})}};v.addGetterSetter(P,"kaleidoscopePower",2,x(),v.afterSetFilter),v.addGetterSetter(P,"kaleidoscopeAngle",0,x(),v.afterSetFilter);function Er(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 Di(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 Dd(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=Er(i,0,0),r=Er(i,i.width-1,0),s=Er(i,0,i.height-1),n=Er(i,i.width-1,i.height-1),a=e||10;if(Di(t,r)<a&&Di(r,n)<a&&Di(n,s)<a&&Di(s,t)<a){for(var o=Dd([r,t,n,s]),l=[],h=0;h<i.width*i.height;h++){var d=Di(o,[i.data[h*4],i.data[h*4+1],i.data[h*4+2]]);l[h]=d<a?0:255}return l}}function Fd(i,e){for(var t=0;t<i.width*i.height;t++)i.data[4*t+3]=e[t]}function Hd(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 l=0;l<e;l++){for(var h=o*e+l,d=0,u=0;u<s;u++)for(var c=0;c<s;c++){var p=o+u-n,f=l+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[h]=d===255*8?255:0}return a}function Bd(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 l=0;l<e;l++){for(var h=o*e+l,d=0,u=0;u<s;u++)for(var c=0;c<s;c++){var p=o+u-n,f=l+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[h]=d>=255*4?255:0}return a}function $d(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 l=0;l<e;l++){for(var h=o*e+l,d=0,u=0;u<s;u++)for(var c=0;c<s;c++){var p=o+u-n,f=l+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[h]=d}return a}const Vd=function(i){var e=this.threshold(),t=Gd(i,e);return t&&(t=Hd(t,i.width,i.height),t=Bd(t,i.width,i.height),t=$d(t,i.width,i.height),Fd(i,t)),i};v.addGetterSetter(P,"threshold",0,x(),v.afterSetFilter);const zd=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 Wd=function(i){var e=Math.ceil(this.pixelSize()),t=i.width,r=i.height,s,n,a,o,l,h,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,l=0,h=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],l+=T[a+1],h+=T[a+2],d+=T[a+3],b+=1);for(o=o/b,l=l/b,h=h/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]=l,T[a+2]=h,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 Zd=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,On,v.afterSetFilter);const jd=function(i){var e=i.data,t=e.length,r=this.red(),s=this.green(),n=this.blue(),a=this.alpha(),o,l;for(o=0;o<t;o+=4)l=1-a,e[o]=r*a+e[o]*l,e[o+1]=s*a+e[o+1]*l,e[o+2]=n*a+e[o+2]*l};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,On,v.afterSetFilter),v.addGetterSetter(P,"alpha",1,function(i){return this._filterUpToDate=!1,i>1?1:i<0?0:i});const Xd=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)},qd=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 l=a+(o-1)*4,h=e[l],d=e[l+1],u=e[l+2];h>127&&(h=255-h),d>127&&(d=255-d),u>127&&(u=255-u),e[l]=h,e[l+1]=d,e[l+2]=u}while(--o)}while(--n)},Yd=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=ca.Util._assign(ca,{Arc:ut,Arrow:Vt,Circle:si,Ellipse:kt,Image:Xe,Label:Ms,Tag:zt,Line:ct,Path:le,Rect:Ii,RegularPolygon:Wt,Ring:Ut,Sprite:it,Star:xt,Text:pe,TextPath:we,Transformer:oe,Wedge:ft,Filters:{Blur:Cd,Brighten:Ed,Contrast:kd,Emboss:xd,Enhance:Pd,Grayscale:Ad,HSL:Md,HSV:Od,Invert:Ld,Kaleidoscope:Nd,Mask:Vd,Noise:zd,Pixelate:Wd,Posterize:Ud,RGB:Zd,RGBA:jd,Sepia:Xd,Solarize:qd,Threshold:Yd}});var Is=function(i,e){return Is=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])},Is(i,e)};function pt(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Is(i,e);function t(){this.constructor=i}i.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Kd(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{h(r.next(d))}catch(u){a(u)}}function l(d){try{h(r.throw(d))}catch(u){a(u)}}function h(d){d.done?n(d.value):s(d.value).then(o,l)}h((r=r.apply(i,e||[])).next())})}function Oa(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(h){return function(d){return l([h,d])}}function l(h){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,h[0]&&(t=0)),t;)try{if(r=1,s&&(n=h[0]&2?s.return:h[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,h[1])).done)return n;switch(s=0,n&&(h=[h[0]&2,n.value]),h[0]){case 0:case 1:n=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,s=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(n=t.trys,!(n=n.length>0&&n[n.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!n||h[1]>n[0]&&h[1]<n[3])){t.label=h[1];break}if(h[0]===6&&t.label<n[1]){t.label=n[1],n=h;break}if(n&&t.label<n[2]){t.label=n[2],t.ops.push(h);break}n[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(i,t)}catch(d){h=[6,d],s=0}finally{r=n=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function ai(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 Pt(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 Zt(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 oi(i){return this instanceof oi?(this.v=i,this):new oi(i)}function Jd(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{l(r[c](p))}catch(f){u(n[0][3],f)}}function l(c){c.value instanceof oi?Promise.resolve(c.value.v).then(h,d):u(n[0][2],c)}function h(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 Qd(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 ai=="function"?ai(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,l){a=i[n](a),s(o,l,a.done,a.value)})}}function s(n,a,o,l){Promise.resolve(l).then(function(h){n({value:h,done:o})},a)}}function de(i){return typeof i=="function"}function Ns(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 Ds=Ns(function(i){return function(t){i(this),this.message=t?t.length+` errors occurred during unsubscription:
3
- `+t.map(function(r,s){return s+1+") "+r.toString()}).join(`
4
- `):"",this.name="UnsubscriptionError",this.errors=t}});function kr(i,e){if(i){var t=i.indexOf(e);0<=t&&i.splice(t,1)}}var Gi=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=ai(a),l=o.next();!l.done;l=o.next()){var h=l.value;h.remove(this)}}catch(m){e={error:m}}finally{try{l&&!l.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 Ds?m.errors:[m]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var c=ai(u),p=c.next();!p.done;p=c.next()){var f=p.value;try{Ia(f)}catch(m){n=n??[],m instanceof Ds?n=Zt(Zt([],Pt(n)),Pt(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 Ds(n)}},i.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)Ia(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)&&kr(t,e)},i.prototype.remove=function(e){var t=this._finalizers;t&&kr(t,e),e instanceof i&&e._removeParent(this)},i.EMPTY=function(){var e=new i;return e.closed=!0,e}(),i}(),La=Gi.EMPTY;function Ra(i){return i instanceof Gi||i&&"closed"in i&&de(i.remove)&&de(i.add)&&de(i.unsubscribe)}function Ia(i){de(i)?i():i.unsubscribe()}var Na={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Gs={setTimeout:function(i,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];var s=Gs.delegate;return s!=null&&s.setTimeout?s.setTimeout.apply(s,Zt([i,e],Pt(t))):setTimeout.apply(void 0,Zt([i,e],Pt(t)))},clearTimeout:function(i){var e=Gs.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(i)},delegate:void 0};function Da(i){Gs.setTimeout(function(){throw i})}function xr(){}function Pr(i){i()}var Fs=function(i){pt(e,i);function e(t){var r=i.call(this)||this;return r.isStopped=!1,t?(r.destination=t,Ra(t)&&t.add(r)):r.destination=ru,r}return e.create=function(t,r,s){return new Bs(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}(Gi),eu=Function.prototype.bind;function Hs(i,e){return eu.call(i,e)}var tu=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){Ar(r)}},i.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(r){Ar(r)}else Ar(e)},i.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Ar(t)}},i}(),Bs=function(i){pt(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&&Na.useDeprecatedNextContext?(o=Object.create(t),o.unsubscribe=function(){return n.unsubscribe()},a={next:t.next&&Hs(t.next,o),error:t.error&&Hs(t.error,o),complete:t.complete&&Hs(t.complete,o)}):a=t}return n.destination=new tu(a),n}return e}(Fs);function Ar(i){Da(i)}function iu(i){throw i}var ru={closed:!0,next:xr,error:iu,complete:xr},$s=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Fi(i){return i}function su(i){return i.length===0?Fi:i.length===1?i[0]:function(t){return i.reduce(function(r,s){return s(r)},t)}}var ie=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=au(e)?e:new Bs(e,t,r);return Pr(function(){var a=s,o=a.operator,l=a.source;n.add(o?o.call(n,l):l?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=Ga(t),new t(function(s,n){var a=new Bs({next:function(o){try{e(o)}catch(l){n(l),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[$s]=function(){return this},i.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return su(e)(this)},i.prototype.toPromise=function(e){var t=this;return e=Ga(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 Ga(i){var e;return(e=i??Na.Promise)!==null&&e!==void 0?e:Promise}function nu(i){return i&&de(i.next)&&de(i.error)&&de(i.complete)}function au(i){return i&&i instanceof Fs||nu(i)&&Ra(i)}function ou(i){return de(i==null?void 0:i.lift)}function Be(i){return function(e){if(ou(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 Pe(i,e,t,r,s){return new hu(i,e,t,r,s)}var hu=function(i){pt(e,i);function e(t,r,s,n,a,o){var l=i.call(this,t)||this;return l.onFinalize=a,l.shouldUnsubscribe=o,l._next=r?function(h){try{r(h)}catch(d){t.error(d)}}:i.prototype._next,l._error=n?function(h){try{n(h)}catch(d){t.error(d)}finally{this.unsubscribe()}}:i.prototype._error,l._complete=s?function(){try{s()}catch(h){t.error(h)}finally{this.unsubscribe()}}:i.prototype._complete,l}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}(Fs),lu=Ns(function(i){return function(){i(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),$=function(i){pt(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 Fa(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;Pr(function(){var s,n;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var a=ai(r.currentObservers),o=a.next();!o.done;o=a.next()){var l=o.value;l.next(t)}}catch(h){s={error:h}}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;Pr(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;Pr(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?La:(this.currentObservers=null,o.push(t),new Gi(function(){r.currentObservers=null,kr(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 ie;return t.source=this,t},e.create=function(t,r){return new Fa(t,r)},e}(ie),Fa=function(i){pt(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:La},e}($),hi=function(i){pt(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}($),Ha={now:function(){return(Ha.delegate||Date).now()},delegate:void 0},du=function(i){pt(e,i);function e(t,r){return i.call(this)||this}return e.prototype.schedule=function(t,r){return this},e}(Gi),Mr={setInterval:function(i,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];var s=Mr.delegate;return s!=null&&s.setInterval?s.setInterval.apply(s,Zt([i,e],Pt(t))):setInterval.apply(void 0,Zt([i,e],Pt(t)))},clearInterval:function(i){var e=Mr.delegate;return((e==null?void 0:e.clearInterval)||clearInterval)(i)},delegate:void 0},uu=function(i){pt(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),Mr.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&&Mr.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,kr(n,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,i.prototype.unsubscribe.call(this)}},e}(du),Ba=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=Ha.now,i}(),cu=function(i){pt(e,i);function e(t,r){r===void 0&&(r=Ba.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}(Ba),Or=new cu(uu),fu=Or,pu=new ie(function(i){return i.complete()});function $a(i){return i&&de(i.schedule)}function Va(i){return i[i.length-1]}function za(i){return de(Va(i))?i.pop():void 0}function Vs(i){return $a(Va(i))?i.pop():void 0}var zs=function(i){return i&&typeof i.length=="number"&&typeof i!="function"};function Wa(i){return de(i==null?void 0:i.then)}function Ua(i){return de(i[$s])}function Za(i){return Symbol.asyncIterator&&de(i==null?void 0:i[Symbol.asyncIterator])}function ja(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 mu(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Xa=mu();function qa(i){return de(i==null?void 0:i[Xa])}function Ya(i){return Jd(this,arguments,function(){var t,r,s,n;return Oa(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,oi(t.read())];case 3:return r=a.sent(),s=r.value,n=r.done,n?[4,oi(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,oi(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 Ka(i){return de(i==null?void 0:i.getReader)}function qe(i){if(i instanceof ie)return i;if(i!=null){if(Ua(i))return gu(i);if(zs(i))return vu(i);if(Wa(i))return yu(i);if(Za(i))return Ja(i);if(qa(i))return bu(i);if(Ka(i))return _u(i)}throw ja(i)}function gu(i){return new ie(function(e){var t=i[$s]();if(de(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function vu(i){return new ie(function(e){for(var t=0;t<i.length&&!e.closed;t++)e.next(i[t]);e.complete()})}function yu(i){return new ie(function(e){i.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,Da)})}function bu(i){return new ie(function(e){var t,r;try{for(var s=ai(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 Ja(i){return new ie(function(e){wu(i,e).catch(function(t){return e.error(t)})})}function _u(i){return Ja(Ya(i))}function wu(i,e){var t,r,s,n;return Kd(this,void 0,void 0,function(){var a,o;return Oa(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),t=Qd(i),l.label=1;case 1:return[4,t.next()];case 2:if(r=l.sent(),!!r.done)return[3,4];if(a=r.value,e.next(a),e.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return o=l.sent(),s={error:o},[3,11];case 6:return l.trys.push([6,,9,10]),r&&!r.done&&(n=t.return)?[4,n.call(t)]:[3,8];case 7:l.sent(),l.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 mt(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 Qa(i,e){return e===void 0&&(e=0),Be(function(t,r){t.subscribe(Pe(r,function(s){return mt(r,i,function(){return r.next(s)},e)},function(){return mt(r,i,function(){return r.complete()},e)},function(s){return mt(r,i,function(){return r.error(s)},e)}))})}function eo(i,e){return e===void 0&&(e=0),Be(function(t,r){r.add(i.schedule(function(){return t.subscribe(r)},e))})}function Su(i,e){return qe(i).pipe(eo(e),Qa(e))}function Tu(i,e){return qe(i).pipe(eo(e),Qa(e))}function Cu(i,e){return new ie(function(t){var r=0;return e.schedule(function(){r===i.length?t.complete():(t.next(i[r++]),t.closed||this.schedule())})})}function Eu(i,e){return new ie(function(t){var r;return mt(t,e,function(){r=i[Xa](),mt(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 to(i,e){if(!i)throw new Error("Iterable cannot be null");return new ie(function(t){mt(t,e,function(){var r=i[Symbol.asyncIterator]();mt(t,e,function(){r.next().then(function(s){s.done?t.complete():t.next(s.value)})},0,!0)})})}function ku(i,e){return to(Ya(i),e)}function xu(i,e){if(i!=null){if(Ua(i))return Su(i,e);if(zs(i))return Cu(i,e);if(Wa(i))return Tu(i,e);if(Za(i))return to(i,e);if(qa(i))return Eu(i,e);if(Ka(i))return ku(i,e)}throw ja(i)}function Hi(i,e){return e?xu(i,e):qe(i)}function Se(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];var t=Vs(i);return Hi(i,t)}function io(i,e){var t=de(i)?i:function(){return i},r=function(s){return s.error(t())};return new ie(e?function(s){return e.schedule(r,0,s)}:r)}var ro=Ns(function(i){return function(){i(this),this.name="EmptyError",this.message="no elements in sequence"}});function Pu(i){return i instanceof Date&&!isNaN(i)}function ke(i,e){return Be(function(t,r){var s=0;t.subscribe(Pe(r,function(n){r.next(i.call(e,n,s++))}))})}var Au=Array.isArray;function Mu(i,e){return Au(e)?i.apply(void 0,Zt([],Pt(e))):i(e)}function Ws(i){return ke(function(e){return Mu(i,e)})}var Ou=Array.isArray,Lu=Object.getPrototypeOf,Ru=Object.prototype,Iu=Object.keys;function so(i){if(i.length===1){var e=i[0];if(Ou(e))return{args:e,keys:null};if(Nu(e)){var t=Iu(e);return{args:t.map(function(r){return e[r]}),keys:t}}}return{args:i,keys:null}}function Nu(i){return i&&typeof i=="object"&&Lu(i)===Ru}function no(i,e){return i.reduce(function(t,r,s){return t[r]=e[s],t},{})}function Du(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];var t=Vs(i),r=za(i),s=so(i),n=s.args,a=s.keys;if(n.length===0)return Hi([],t);var o=new ie(Gu(n,t,a?function(l){return no(a,l)}:Fi));return r?o.pipe(Ws(r)):o}function Gu(i,e,t){return t===void 0&&(t=Fi),function(r){ao(e,function(){for(var s=i.length,n=new Array(s),a=s,o=s,l=function(d){ao(e,function(){var u=Hi(i[d],e),c=!1;u.subscribe(Pe(r,function(p){n[d]=p,c||(c=!0,o--),o||r.next(t(n.slice()))},function(){--a||r.complete()}))},r)},h=0;h<s;h++)l(h)},r)}}function ao(i,e,t){i?mt(t,i,e):e()}function Fu(i,e,t,r,s,n,a,o){var l=[],h=0,d=0,u=!1,c=function(){u&&!l.length&&!h&&e.complete()},p=function(m){return h<r?f(m):l.push(m)},f=function(m){n&&e.next(m),h++;var g=!1;qe(t(m,d++)).subscribe(Pe(e,function(_){s==null||s(_),n?p(_):e.next(_)},function(){g=!0},void 0,function(){if(g)try{h--;for(var _=function(){var w=l.shift();a?mt(e,a,function(){return f(w)}):f(w)};l.length&&h<r;)_();c()}catch(w){e.error(w)}}))};return i.subscribe(Pe(e,p,function(){u=!0,c()})),function(){o==null||o()}}function Lr(i,e,t){return t===void 0&&(t=1/0),de(e)?Lr(function(r,s){return ke(function(n,a){return e(r,n,s,a)})(qe(i(r,s)))},t):(typeof e=="number"&&(t=e),Be(function(r,s){return Fu(r,s,i,t)}))}function Hu(i){return i===void 0&&(i=1/0),Lr(Fi,i)}function Bu(){return Hu(1)}function $u(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];return Bu()(Hi(i,Vs(i)))}function Vu(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];var t=za(i),r=so(i),s=r.args,n=r.keys,a=new ie(function(o){var l=s.length;if(!l){o.complete();return}for(var h=new Array(l),d=l,u=l,c=function(f){var m=!1;qe(s[f]).subscribe(Pe(o,function(g){m||(m=!0,u--),h[f]=g},function(){return d--},void 0,function(){(!d||!m)&&(u||o.next(n?no(n,h):h),o.complete())}))},p=0;p<l;p++)c(p)});return t?a.pipe(Ws(t)):a}var zu=["addListener","removeListener"],Wu=["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(Ws(r));var s=Pt(Xu(i)?Wu.map(function(o){return function(l){return i[o](e,l,t)}}):Zu(i)?zu.map(oo(i,e)):ju(i)?Uu.map(oo(i,e)):[],2),n=s[0],a=s[1];if(!n&&zs(i))return Lr(function(o){return be(o,e,t)})(qe(i));if(!n)throw new TypeError("Invalid event target");return new ie(function(o){var l=function(){for(var h=[],d=0;d<arguments.length;d++)h[d]=arguments[d];return o.next(1<h.length?h:h[0])};return n(l),function(){return a(l)}})}function oo(i,e){return function(t){return function(r){return i[t](e,r)}}}function Zu(i){return de(i.addListener)&&de(i.removeListener)}function ju(i){return de(i.on)&&de(i.off)}function Xu(i){return de(i.addEventListener)&&de(i.removeEventListener)}function ho(i,e,t){i===void 0&&(i=0),t===void 0&&(t=fu);var r=-1;return e!=null&&($a(e)?t=e:r=e),new ie(function(s){var n=Pu(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 qu(i,e){return i===void 0&&(i=0),e===void 0&&(e=Or),i<0&&(i=0),ho(i,i,e)}function ze(i,e){return Be(function(t,r){var s=0;t.subscribe(Pe(r,function(n){return i.call(e,n,s++)&&r.next(n)}))})}function li(i){return Be(function(e,t){var r=null,s=!1,n;r=e.subscribe(Pe(t,void 0,void 0,function(a){n=qe(i(a,li(i)(e))),r?(r.unsubscribe(),r=null,n.subscribe(t)):s=!0})),s&&(r.unsubscribe(),r=null,n.subscribe(t))})}function lo(i,e){return e===void 0&&(e=Or),Be(function(t,r){var s=null,n=null,a=null,o=function(){if(s){s.unsubscribe(),s=null;var h=n;n=null,r.next(h)}};function l(){var h=a+i,d=e.now();if(d<h){s=this.schedule(void 0,h-d),r.add(s);return}o()}t.subscribe(Pe(r,function(h){n=h,a=e.now(),s||(s=e.schedule(l,i),r.add(s))},function(){o(),r.complete()},void 0,function(){n=s=null}))})}function Yu(i){return Be(function(e,t){var r=!1;e.subscribe(Pe(t,function(s){r=!0,t.next(s)},function(){r||t.next(i),t.complete()}))})}function We(i){return i<=0?function(){return pu}:Be(function(e,t){var r=0;e.subscribe(Pe(t,function(s){++r<=i&&(t.next(s),i<=r&&t.complete())}))})}function Ku(){return Be(function(i,e){i.subscribe(Pe(e,xr))})}function Ju(i){return ke(function(){return i})}function uo(i,e){return e?function(t){return $u(e.pipe(We(1),Ku()),t.pipe(uo(i)))}:Lr(function(t,r){return qe(i(t,r)).pipe(We(1),Ju(t))})}function Qu(i,e){e===void 0&&(e=Or);var t=ho(i,e);return uo(function(){return t})}function ec(i){return i===void 0&&(i=tc),Be(function(e,t){var r=!1;e.subscribe(Pe(t,function(s){r=!0,t.next(s)},function(){return r?t.complete():t.error(i())}))})}function tc(){return new ro}function di(i,e){var t=arguments.length>=2;return function(r){return r.pipe(i?ze(function(s,n){return i(s,n,r)}):Fi,We(1),t?Yu(e):ec(function(){return new ro}))}}function ic(i,e){return Be(function(t,r){var s=null,n=0,a=!1,o=function(){return a&&!s&&r.complete()};t.subscribe(Pe(r,function(l){s==null||s.unsubscribe();var h=0,d=n++;qe(i(l,d)).subscribe(s=Pe(r,function(u){return r.next(e?e(l,u,d,h++):u)},function(){s=null,o()}))},function(){a=!0,o()}))})}function k(i){return Be(function(e,t){qe(i).subscribe(Pe(t,function(){return t.complete()},xr)),!t.closed&&e.subscribe(t)})}class co{constructor(e){this.onChange$=new $,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 Us(...i){i.forEach(e=>{$e(e)})}function rc(i){i&&(i.closed||i.complete())}function jt(...i){i.forEach(e=>{rc(e)})}function ui(...i){i.forEach(e=>{sc(e)})}function sc(i){i&&(i.closed||i.unsubscribe())}const ci=(i,e)=>({...e,...i,style:{...e.style,...i.style}});class Ye{constructor(e){this.onDestroy$=new $,this.config=e,this.styleAdapter=new co(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(),$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 ne;(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})(ne||(ne={}));const N=ne.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),At=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=ne.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"]),nc=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,l=0;for(;l<a.path.length;){const h=a.path[l];l===a.path.length-1?(o[h]=o[h]||{_errors:[]},o[h]._errors.push(t(a))):o[h]=o[h]||{_errors:[]},o=o[h],l++}}};return s(this),r}toString(){return this.message}get message(){return JSON.stringify(this.issues,ne.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 Bi=(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,ne.jsonStringifyReplacer)}`;break;case O.unrecognized_keys:t=`Unrecognized key(s) in object: ${ne.joinValues(i.keys,", ")}`;break;case O.invalid_union:t="Invalid input";break;case O.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${ne.joinValues(i.options)}`;break;case O.invalid_enum_value:t=`Invalid enum value. Expected ${ne.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}"`:ne.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,ne.assertNever(i)}return{message:t}};let fo=Bi;function ac(i){fo=i}function Rr(){return fo}const Ir=i=>{const{data:e,path:t,errorMaps:r,issueData:s}=i,n=[...t,...s.path||[]],a={...s,path:n};let o="";const l=r.filter(h=>!!h).slice().reverse();for(const h of l)o=h(a,{data:e,defaultError:o}).message;return{...s,path:n,message:s.message||o}},oc=[];function B(i,e){const t=Ir({issueData:e,data:i.data,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,Rr(),Bi].filter(r=>!!r)});i.common.issues.push(t)}class Re{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 Re.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"}),po=i=>({status:"dirty",value:i}),Ae=i=>({status:"valid",value:i}),Zs=i=>i.status==="aborted",js=i=>i.status==="dirty",Nr=i=>i.status==="valid",Dr=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 mo=(i,e)=>{if(Nr(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 At(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Re,ctx:{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Dr(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:At(e)},n=this._parseSync({data:e,path:s.path,parent:s});return mo(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:At(e)},s=this._parse({data:e,path:r.path,parent:r}),n=await(Dr(s)?s:Promise.resolve(s));return mo(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(l=>l?!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 Je({schema:this,typeName:X.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return yt.create(this,this._def)}nullable(){return Kt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ke.create(this,this._def)}promise(){return gi.create(this,this._def)}or(e){return Ui.create([this,e],this._def)}and(e){return Zi.create(this,e,this._def)}transform(e){return new Je({...J(this._def),schema:this,typeName:X.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ki({...J(this._def),innerType:this,defaultValue:t,typeName:X.ZodDefault})}brand(){return new vo({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 Ji.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const hc=/^c[^\s-]{8,}$/i,lc=/^[a-z][a-z0-9]*$/,dc=/^([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,uc=/^(([^<>()[\]\\.,;:\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,}))$/,cc=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 Re;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")uc.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")dc.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")hc.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"?cc(n).test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:"datetime",message:n.message}),r.dirty()):ne.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 fc(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 Mt 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 Re;for(const n of this._def.checks)n.kind==="int"?ne.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"?fc(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()):ne.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 Mt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:ee.toString(s)}]})}_addCheck(e){return new Mt({...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"&&ne.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)}}Mt.create=i=>new Mt({checks:[],typeName:X.ZodNumber,coerce:(i==null?void 0:i.coerce)||!1,...J(i)});class $i 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 Ae(e.data)}}$i.create=i=>{var e;return new $i({typeName:X.ZodBigInt,coerce:(e=i==null?void 0:i.coerce)!==null&&e!==void 0?e:!1,...J(i)})};class Vi 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 Ae(e.data)}}Vi.create=i=>new Vi({typeName:X.ZodBoolean,coerce:(i==null?void 0:i.coerce)||!1,...J(i)});class Xt 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 Re;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()):ne.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Xt({...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}}Xt.create=i=>new Xt({checks:[],coerce:(i==null?void 0:i.coerce)||!1,typeName:X.ZodDate,...J(i)});class Gr 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 Ae(e.data)}}Gr.create=i=>new Gr({typeName:X.ZodSymbol,...J(i)});class zi 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 Ae(e.data)}}zi.create=i=>new zi({typeName:X.ZodUndefined,...J(i)});class Wi 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 Ae(e.data)}}Wi.create=i=>new Wi({typeName:X.ZodNull,...J(i)});class fi extends Q{constructor(){super(...arguments),this._any=!0}_parse(e){return Ae(e.data)}}fi.create=i=>new fi({typeName:X.ZodAny,...J(i)});class qt extends Q{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ae(e.data)}}qt.create=i=>new qt({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 Fr 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 Ae(e.data)}}Fr.create=i=>new Fr({typeName:X.ZodVoid,...J(i)});class Ke 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=>Re.mergeArray(r,a));const n=[...t.data].map((a,o)=>s.type._parseSync(new st(t,a,t.path,o)));return Re.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new Ke({...this._def,minLength:{value:e,message:ee.toString(t)}})}max(e,t){return new Ke({...this._def,maxLength:{value:e,message:ee.toString(t)}})}length(e,t){return new Ke({...this._def,exactLength:{value:e,message:ee.toString(t)}})}nonempty(e){return this.min(1,e)}}Ke.create=(i,e)=>new Ke({type:i,minLength:null,maxLength:null,exactLength:null,typeName:X.ZodArray,...J(e)});var Hr;(function(i){i.mergeShapes=(e,t)=>({...e,...t})})(Hr||(Hr={}));function pi(i){if(i instanceof me){const e={};for(const t in i.shape){const r=i.shape[t];e[t]=yt.create(pi(r))}return new me({...i._def,shape:()=>e})}else return i instanceof Ke?Ke.create(pi(i.element)):i instanceof yt?yt.create(pi(i.unwrap())):i instanceof Kt?Kt.create(pi(i.unwrap())):i instanceof nt?nt.create(i.items.map(e=>pi(e))):i}class me 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=ne.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==N.object){const h=this._getOrReturnCtx(e);return B(h,{code:O.invalid_type,expected:N.object,received:h.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 h in s.data)a.includes(h)||o.push(h);const l=[];for(const h of a){const d=n[h],u=s.data[h];l.push({key:{status:"valid",value:h},value:d._parse(new st(s,u,s.path,h)),alwaysSet:h in s.data})}if(this._def.catchall instanceof vt){const h=this._def.unknownKeys;if(h==="passthrough")for(const d of o)l.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(h==="strict")o.length>0&&(B(s,{code:O.unrecognized_keys,keys:o}),r.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const h=this._def.catchall;for(const d of o){const u=s.data[d];l.push({key:{status:"valid",value:d},value:h._parse(new st(s,u,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const h=[];for(const d of l){const u=await d.key;h.push({key:u,value:await d.value,alwaysSet:d.alwaysSet})}return h}).then(h=>Re.mergeObjectSync(r,h)):Re.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return ee.errToObj,new me({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,n,a,o;const l=(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:l}:{message:l}}}:{}})}strip(){return new me({...this._def,unknownKeys:"strip"})}passthrough(){return new me({...this._def,unknownKeys:"passthrough"})}extend(e){return new me({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new me({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>Hr.mergeShapes(this._def.shape(),e._def.shape()),typeName:X.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new me({...this._def,catchall:e})}pick(e){const t={};return ne.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new me({...this._def,shape:()=>t})}omit(e){const t={};return ne.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new me({...this._def,shape:()=>t})}deepPartial(){return pi(this)}partial(e){const t={};return ne.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new me({...this._def,shape:()=>t})}required(e){const t={};return ne.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let n=this.shape[r];for(;n instanceof yt;)n=n._def.innerType;t[r]=n}}),new me({...this._def,shape:()=>t})}keyof(){return go(ne.objectKeys(this.shape))}}me.create=(i,e)=>new me({shape:()=>i,unknownKeys:"strip",catchall:vt.create(),typeName:X.ZodObject,...J(e)}),me.strictCreate=(i,e)=>new me({shape:()=>i,unknownKeys:"strict",catchall:vt.create(),typeName:X.ZodObject,...J(e)}),me.lazycreate=(i,e)=>new me({shape:i,unknownKeys:"strip",catchall:vt.create(),typeName:X.ZodObject,...J(e)});class Ui 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 l of r){const h={...t,common:{...t.common,issues:[]},parent:null},d=l._parseSync({data:t.data,path:t.path,parent:h});if(d.status==="valid")return d;d.status==="dirty"&&!n&&(n={result:d,ctx:h}),h.common.issues.length&&a.push(h.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const o=a.map(l=>new rt(l));return B(t,{code:O.invalid_union,unionErrors:o}),Y}}get options(){return this._def.options}}Ui.create=(i,e)=>new Ui({options:i,typeName:X.ZodUnion,...J(e)});const Br=i=>i instanceof Xi?Br(i.schema):i instanceof Je?Br(i.innerType()):i instanceof qi?[i.value]:i instanceof Ot?i.options:i instanceof Yi?Object.keys(i.enum):i instanceof Ki?Br(i._def.innerType):i instanceof zi?[void 0]:i instanceof Wi?[null]:null;class $r 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=Br(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 $r({typeName:X.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...J(r)})}}function Xs(i,e){const t=At(i),r=At(e);if(i===e)return{valid:!0,data:i};if(t===N.object&&r===N.object){const s=ne.objectKeys(e),n=ne.objectKeys(i).filter(o=>s.indexOf(o)!==-1),a={...i,...e};for(const o of n){const l=Xs(i[o],e[o]);if(!l.valid)return{valid:!1};a[o]=l.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],l=Xs(a,o);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return t===N.date&&r===N.date&&+i==+e?{valid:!0,data:i}:{valid:!1}}class Zi extends Q{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(n,a)=>{if(Zs(n)||Zs(a))return Y;const o=Xs(n.value,a.value);return o.valid?((js(n)||js(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}))}}Zi.create=(i,e,t)=>new Zi({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 l=this._def.items[o]||this._def.rest;return l?l._parse(new st(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(n).then(a=>Re.mergeArray(t,a)):Re.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 ji 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?Re.mergeObjectAsync(t,s):Re.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof Q?new ji({keyType:e,valueType:t,typeName:X.ZodRecord,...J(r)}):new ji({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,l],h)=>({key:s._parse(new st(r,o,r.path,[h,"key"])),value:n._parse(new st(r,l,r.path,[h,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of a){const h=await l.key,d=await l.value;if(h.status==="aborted"||d.status==="aborted")return Y;(h.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(h.value,d.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const l of a){const h=l.key,d=l.value;if(h.status==="aborted"||d.status==="aborted")return Y;(h.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(h.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 Yt 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(l){const h=new Set;for(const d of l){if(d.status==="aborted")return Y;d.status==="dirty"&&t.dirty(),h.add(d.value)}return{status:t.value,value:h}}const o=[...r.data.values()].map((l,h)=>n._parse(new st(r,l,r.path,h)));return r.common.async?Promise.all(o).then(l=>a(l)):a(o)}min(e,t){return new Yt({...this._def,minSize:{value:e,message:ee.toString(t)}})}max(e,t){return new Yt({...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)}}Yt.create=(i,e)=>new Yt({valueType:i,minSize:null,maxSize:null,typeName:X.ZodSet,...J(e)});class mi 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,l){return Ir({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Rr(),Bi].filter(h=>!!h),issueData:{code:O.invalid_arguments,argumentsError:l}})}function s(o,l){return Ir({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Rr(),Bi].filter(h=>!!h),issueData:{code:O.invalid_return_type,returnTypeError:l}})}const n={errorMap:t.common.contextualErrorMap},a=t.data;return this._def.returns instanceof gi?Ae(async(...o)=>{const l=new rt([]),h=await this._def.args.parseAsync(o,n).catch(c=>{throw l.addIssue(r(o,c)),l}),d=await a(...h);return await this._def.returns._def.type.parseAsync(d,n).catch(c=>{throw l.addIssue(s(d,c)),l})}):Ae((...o)=>{const l=this._def.args.safeParse(o,n);if(!l.success)throw new rt([r(o,l.error)]);const h=a(...l.data),d=this._def.returns.safeParse(h,n);if(!d.success)throw new rt([s(h,d.error)]);return d.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new mi({...this._def,args:nt.create(e).rest(qt.create())})}returns(e){return new mi({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new mi({args:e||nt.create([]).rest(qt.create()),returns:t||qt.create(),typeName:X.ZodFunction,...J(r)})}}class Xi 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})}}Xi.create=(i,e)=>new Xi({getter:i,typeName:X.ZodLazy,...J(e)});class qi 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}}qi.create=(i,e)=>new qi({value:i,typeName:X.ZodLiteral,...J(e)});function go(i,e){return new Ot({values:i,typeName:X.ZodEnum,...J(e)})}class Ot extends Q{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return B(t,{expected:ne.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 Ae(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 Ot.create(e)}exclude(e){return Ot.create(this.options.filter(t=>!e.includes(t)))}}Ot.create=go;class Yi extends Q{_parse(e){const t=ne.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==N.string&&r.parsedType!==N.number){const s=ne.objectValues(t);return B(r,{expected:ne.joinValues(s),received:r.parsedType,code:O.invalid_type}),Y}if(t.indexOf(e.data)===-1){const s=ne.objectValues(t);return B(r,{received:r.data,code:O.invalid_enum_value,options:s}),Y}return Ae(e.data)}get enum(){return this._def.values}}Yi.create=(i,e)=>new Yi({values:i,typeName:X.ZodNativeEnum,...J(e)});class gi 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 Ae(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}gi.create=(i,e)=>new gi({type:i,typeName:X.ZodPromise,...J(e)});class Je 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 l=s.refinement(o,n);if(r.common.async)return Promise.resolve(l);if(l 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(!Nr(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=>Nr(a)?Promise.resolve(s.transform(a.value,n)).then(o=>({status:t.value,value:o})):a);ne.assertNever(s)}}Je.create=(i,e,t)=>new Je({schema:i,typeName:X.ZodEffects,effect:e,...J(t)}),Je.createWithPreprocess=(i,e,t)=>new Je({schema:e,effect:{type:"preprocess",transform:i},typeName:X.ZodEffects,...J(t)});class yt extends Q{_parse(e){return this._getType(e)===N.undefined?Ae(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}yt.create=(i,e)=>new yt({innerType:i,typeName:X.ZodOptional,...J(e)});class Kt extends Q{_parse(e){return this._getType(e)===N.null?Ae(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Kt.create=(i,e)=>new Kt({innerType:i,typeName:X.ZodNullable,...J(e)});class Ki 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}}Ki.create=(i,e)=>new Ki({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 Dr(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 pc=Symbol("zod_brand");class vo 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 Ji 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(),po(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 Ji({in:e,out:t,typeName:X.ZodPipeline})}}const yo=(i,e={},t)=>i?fi.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})}}):fi.create(),mc={object:me.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 gc=(i,e={message:`Input not instance of ${i.name}`})=>yo(t=>t instanceof i,e,!0),bo=gt.create,_o=Mt.create,vc=Wr.create,yc=$i.create,wo=Vi.create,bc=Xt.create,_c=Gr.create,wc=zi.create,Sc=Wi.create,Tc=fi.create,Cc=qt.create,Ec=vt.create,kc=Fr.create,xc=Ke.create,Pc=me.create,Ac=me.strictCreate,Mc=Ui.create,Oc=$r.create,Lc=Zi.create,Rc=nt.create,Ic=ji.create,Nc=Vr.create,Dc=Yt.create,Gc=mi.create,Fc=Xi.create,Hc=qi.create,Bc=Ot.create,$c=Yi.create,Vc=gi.create,So=Je.create,zc=yt.create,Wc=Kt.create,Uc=Je.createWithPreprocess,Zc=Ji.create;var _e=Object.freeze({__proto__:null,defaultErrorMap:Bi,setErrorMap:ac,getErrorMap:Rr,makeIssue:Ir,EMPTY_PATH:oc,addIssueToContext:B,ParseStatus:Re,INVALID:Y,DIRTY:po,OK:Ae,isAborted:Zs,isDirty:js,isValid:Nr,isAsync:Dr,get util(){return ne},ZodParsedType:N,getParsedType:At,ZodType:Q,ZodString:gt,ZodNumber:Mt,ZodBigInt:$i,ZodBoolean:Vi,ZodDate:Xt,ZodSymbol:Gr,ZodUndefined:zi,ZodNull:Wi,ZodAny:fi,ZodUnknown:qt,ZodNever:vt,ZodVoid:Fr,ZodArray:Ke,get objectUtil(){return Hr},ZodObject:me,ZodUnion:Ui,ZodDiscriminatedUnion:$r,ZodIntersection:Zi,ZodTuple:nt,ZodRecord:ji,ZodMap:Vr,ZodSet:Yt,ZodFunction:mi,ZodLazy:Xi,ZodLiteral:qi,ZodEnum:Ot,ZodNativeEnum:Yi,ZodPromise:gi,ZodEffects:Je,ZodTransformer:Je,ZodOptional:yt,ZodNullable:Kt,ZodDefault:Ki,ZodCatch:zr,ZodNaN:Wr,BRAND:pc,ZodBranded:vo,ZodPipeline:Ji,custom:yo,Schema:Q,ZodSchema:Q,late:mc,get ZodFirstPartyTypeKind(){return X},coerce:{string:i=>gt.create({...i,coerce:!0}),number:i=>Mt.create({...i,coerce:!0}),boolean:i=>Vi.create({...i,coerce:!0}),bigint:i=>$i.create({...i,coerce:!0}),date:i=>Xt.create({...i,coerce:!0})},any:Tc,array:xc,bigint:yc,boolean:wo,date:bc,discriminatedUnion:Oc,effect:So,enum:Bc,function:Gc,instanceof:gc,intersection:Lc,lazy:Fc,literal:Hc,map:Nc,nan:vc,nativeEnum:$c,never:Ec,null:Sc,nullable:Wc,number:_o,object:Pc,oboolean:()=>wo().optional(),onumber:()=>_o().optional(),optional:zc,ostring:()=>bo().optional(),pipeline:Zc,preprocess:Uc,promise:Vc,record:Ic,set:Dc,strictObject:Ac,string:bo,symbol:_c,transformer:So,tuple:Rc,undefined:wc,union:Mc,unknown:Cc,void:kc,NEVER:Y,ZodIssueCode:O,quotelessJson:nc,ZodError:rt});class vi{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 bt{constructor(){this.onChange$=new hi(void 0)}static instance(){return bt._instance||(bt._instance=new bt),bt._instance}get styles(){return this._styles}set styles(e){this._styles={...this._styles,...e},this.onChange$.next(this._styles)}}const Qi={height:80,backgroundFill:"#ffffff",backgroundOpacity:1,descriptionTextFill:"#1c1c1c",descriptionFontSize:15,leftBackgroundFill:"#ffffff",leftBackgroundOpacity:1};class er extends Ye{constructor(e){super(e),this.stylesProvider=bt.instance(),this.id=vi.id()(this.config.id),this.description=vi.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$),ze(e=>!!e)).subscribe(e=>{this.onStylesProviderChange()}),this.styleAdapter.onChange$.pipe(k(this.onDestroy$),ze(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 To={color:"rgba(255,73,145)",renderType:"lane",symbolType:"square"};class Co extends Ye{constructor(e){super(e),this.onChange$=new $,this.onClick$=new $,this.onMouseEnter$=new $,this.onMouseLeave$=new $,this.id=vi.id()(this.config.id),this.description=vi.description()(this.config.description),this.editable=vi.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$];jt(...e),ui(...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 at{static resetCursorStyle(){this.cursor("default")}static cursor(e){document.body.style.cursor=e}}const Eo={color:"#ff6c6c",markerRenderType:"lane",markerSymbolType:"square",lineStrokeWidth:1,lineOpacity:.7};class ko extends Ye{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}),at.cursor("grab"))}),this.handleGroup.on("mouseleave",()=>{this.editable&&(this.handleGroup.to({scaleX:1,scaleY:1,duration:.1}),at.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=>{at.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),at.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)}}/*!
1
+ (function(Ie,Le){typeof exports=="object"&&typeof module<"u"?Le(exports,require("hls.js")):typeof define=="function"&&define.amd?define(["exports","hls.js"],Le):(Ie=typeof globalThis<"u"?globalThis:Ie||self,Le(Ie.omakase={},Ie.Hls))})(this,function(Ie,Le){"use strict";var zh=Math.PI/180;function Wh(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}const Qt=typeof global<"u"?global:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},D={_global:Qt,version:"8.3.14",isBrowser:Wh(),isUnminified:/param/.test((function(r){}).toString()),dblClickWindow:400,getAngle(r){return D.angleDeg?r*zh:r},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,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:Qt.document,_injectGlobal(r){Qt.Konva=r}},fe=r=>{D[r.prototype.getClassName()]=r};D._injectGlobal(D);class Fe{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 Fe(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),i=Math.sin(e),s=this.m[0]*t+this.m[2]*i,n=this.m[1]*t+this.m[3]*i,a=this.m[0]*-i+this.m[2]*t,o=this.m[1]*-i+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 i=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]=i,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],i=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]=i,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,i=-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]=i,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],i=this.m[2],s=this.m[3],n=this.m[4],a=this.m[5],o=e*s-t*i;let l={x:n,y:a,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||t!=0){var h=Math.sqrt(e*e+t*t);l.rotation=t>0?Math.acos(e/h):-Math.acos(e/h),l.scaleX=h,l.scaleY=o/h,l.skewX=(e*i+t*s)/o,l.skewY=0}else if(i!=0||s!=0){var d=Math.sqrt(i*i+s*s);l.rotation=Math.PI/2-(s>0?Math.acos(-i/d):-Math.acos(i/d)),l.scaleX=o/d,l.scaleY=d,l.skewX=0,l.skewY=(e*i+t*s)/o}return l.rotation=y._getRotation(l.rotation),l}}var Uh="[object Array]",Zh="[object Number]",jh="[object String]",Xh="[object Boolean]",qh=Math.PI/180,Yh=180/Math.PI,cs="#",Kh="",Jh="0",Qh="Konva warning: ",On="Konva error: ",el="rgb(",fs={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]},tl=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,lr=[];const il=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(r){setTimeout(r,60)},y={_isElement(r){return!!(r&&r.nodeType==1)},_isFunction(r){return!!(r&&r.constructor&&r.call&&r.apply)},_isPlainObject(r){return!!r&&r.constructor===Object},_isArray(r){return Object.prototype.toString.call(r)===Uh},_isNumber(r){return Object.prototype.toString.call(r)===Zh&&!isNaN(r)&&isFinite(r)},_isString(r){return Object.prototype.toString.call(r)===jh},_isBoolean(r){return Object.prototype.toString.call(r)===Xh},isObject(r){return r instanceof Object},isValidSelector(r){if(typeof r!="string")return!1;var e=r[0];return e==="#"||e==="."||e===e.toUpperCase()},_sign(r){return r===0||r>0?1:-1},requestAnimFrame(r){lr.push(r),lr.length===1&&il(function(){const e=lr;lr=[],e.forEach(function(t){t()})})},createCanvasElement(){var r=document.createElement("canvas");try{r.style=r.style||{}}catch{}return r},createImageElement(){return document.createElement("img")},_isInDocument(r){for(;r=r.parentNode;)if(r==document)return!0;return!1},_urlToImage(r,e){var t=y.createImageElement();t.onload=function(){e(t)},t.src=r},_rgbToHex(r,e,t){return((1<<24)+(r<<16)+(e<<8)+t).toString(16).slice(1)},_hexToRgb(r){r=r.replace(cs,Kh);var e=parseInt(r,16);return{r:e>>16&255,g:e>>8&255,b:e&255}},getRandomColor(){for(var r=(Math.random()*16777215<<0).toString(16);r.length<6;)r=Jh+r;return cs+r},getRGB(r){var e;return r in fs?(e=fs[r],{r:e[0],g:e[1],b:e[2]}):r[0]===cs?this._hexToRgb(r.substring(1)):r.substr(0,4)===el?(e=tl.exec(r.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA(r){return r=r||"black",y._namedColorToRBA(r)||y._hex3ColorToRGBA(r)||y._hex6ColorToRGBA(r)||y._rgbColorToRGBA(r)||y._rgbaColorToRGBA(r)||y._hslColorToRGBA(r)},_namedColorToRBA(r){var e=fs[r.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(r){if(r.indexOf("rgb(")===0){r=r.match(/rgb\(([^)]+)\)/)[1];var e=r.split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(r){if(r.indexOf("rgba(")===0){r=r.match(/rgba\(([^)]+)\)/)[1];var e=r.split(/ *, */).map((t,i)=>t.slice(-1)==="%"?i===3?parseInt(t)/100:parseInt(t)/100*255:Number(t));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex6ColorToRGBA(r){if(r[0]==="#"&&r.length===7)return{r:parseInt(r.slice(1,3),16),g:parseInt(r.slice(3,5),16),b:parseInt(r.slice(5,7),16),a:1}},_hex3ColorToRGBA(r){if(r[0]==="#"&&r.length===4)return{r:parseInt(r[1]+r[1],16),g:parseInt(r[2]+r[2],16),b:parseInt(r[3]+r[3],16),a:1}},_hslColorToRGBA(r){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(r)){const[e,...t]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(r),i=Number(t[0])/360,s=Number(t[1])/100,n=Number(t[2])/100;let a,o,l;if(s===0)return l=n*255,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};n<.5?a=n*(1+s):a=n+s-n*s;const h=2*n-a,d=[0,0,0];for(let u=0;u<3;u++)o=i+1/3*-(u-1),o<0&&o++,o>1&&o--,6*o<1?l=h+(a-h)*6*o:2*o<1?l=a:3*o<2?l=h+(a-h)*(2/3-o)*6:l=h,d[u]=l*255;return{r:Math.round(d[0]),g:Math.round(d[1]),b:Math.round(d[2]),a:1}}},haveIntersection(r,e){return!(e.x>r.x+r.width||e.x+e.width<r.x||e.y>r.y+r.height||e.y+e.height<r.y)},cloneObject(r){var e={};for(var t in r)this._isPlainObject(r[t])?e[t]=this.cloneObject(r[t]):this._isArray(r[t])?e[t]=this.cloneArray(r[t]):e[t]=r[t];return e},cloneArray(r){return r.slice(0)},degToRad(r){return r*qh},radToDeg(r){return r*Yh},_degToRad(r){return y.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),y.degToRad(r)},_radToDeg(r){return y.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),y.radToDeg(r)},_getRotation(r){return D.angleDeg?y.radToDeg(r):r},_capitalize(r){return r.charAt(0).toUpperCase()+r.slice(1)},throw(r){throw new Error(On+r)},error(r){console.error(On+r)},warn(r){D.showWarnings&&console.warn(Qh+r)},each(r,e){for(var t in r)e(t,r[t])},_inRange(r,e,t){return e<=r&&r<t},_getProjectionToSegment(r,e,t,i,s,n){var a,o,l,h=(r-t)*(r-t)+(e-i)*(e-i);if(h==0)a=r,o=e,l=(s-t)*(s-t)+(n-i)*(n-i);else{var d=((s-r)*(t-r)+(n-e)*(i-e))/h;d<0?(a=r,o=e,l=(r-s)*(r-s)+(e-n)*(e-n)):d>1?(a=t,o=i,l=(t-s)*(t-s)+(i-n)*(i-n)):(a=r+d*(t-r),o=e+d*(i-e),l=(a-s)*(a-s)+(o-n)*(o-n))}return[a,o,l]},_getProjectionToLine(r,e,t){var i=y.cloneObject(r),s=Number.MAX_VALUE;return e.forEach(function(n,a){if(!(!t&&a===e.length-1)){var o=e[(a+1)%e.length],l=y._getProjectionToSegment(n.x,n.y,o.x,o.y,r.x,r.y),h=l[0],d=l[1],u=l[2];u<s&&(i.x=h,i.y=d,s=u)}}),i},_prepareArrayForTween(r,e,t){var i,s=[],n=[];if(r.length>e.length){var a=e;e=r,r=a}for(i=0;i<r.length;i+=2)s.push({x:r[i],y:r[i+1]});for(i=0;i<e.length;i+=2)n.push({x:e[i],y:e[i+1]});var o=[];return n.forEach(function(l){var h=y._getProjectionToLine(l,s,t);o.push(h.x),o.push(h.y)}),o},_prepareToStringify(r){var e;r.visitedByCircularReferenceRemoval=!0;for(var t in r)if(r.hasOwnProperty(t)&&r[t]&&typeof r[t]=="object"){if(e=Object.getOwnPropertyDescriptor(r,t),r[t].visitedByCircularReferenceRemoval||y._isElement(r[t]))if(e.configurable)delete r[t];else return null;else if(y._prepareToStringify(r[t])===null)if(e.configurable)delete r[t];else return null}return delete r.visitedByCircularReferenceRemoval,r},_assign(r,e){for(var t in e)r[t]=e[t];return r},_getFirstPointerId(r){return r.touches?r.changedTouches[0].identifier:r.pointerId||999},releaseCanvas(...r){D.releaseCanvasOnDestroy&&r.forEach(e=>{e.width=0,e.height=0})}};function Ct(r){return y._isString(r)?'"'+r+'"':Object.prototype.toString.call(r)==="[object Number]"||y._isBoolean(r)?r:Object.prototype.toString.call(r)}function Mn(r){return r>255?255:r<0?0:Math.round(r)}function x(){if(D.isUnminified)return function(r,e){return y._isNumber(r)||y.warn(Ct(r)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),r}}function Ln(r){if(D.isUnminified)return function(e,t){let i=y._isNumber(e),s=y._isArray(e)&&e.length==r;return!i&&!s&&y.warn(Ct(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or Array<number>('+r+")"),e}}function ps(){if(D.isUnminified)return function(r,e){var t=y._isNumber(r),i=r==="auto";return t||i||y.warn(Ct(r)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),r}}function ei(){if(D.isUnminified)return function(r,e){return y._isString(r)||y.warn(Ct(r)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),r}}function Rn(){if(D.isUnminified)return function(r,e){const t=y._isString(r),i=Object.prototype.toString.call(r)==="[object CanvasGradient]"||r&&r.addColorStop;return t||i||y.warn(Ct(r)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),r}}function rl(){if(D.isUnminified)return function(r,e){const t=Int8Array?Object.getPrototypeOf(Int8Array):null;return t&&r instanceof t||(y._isArray(r)?r.forEach(function(i){y._isNumber(i)||y.warn('"'+e+'" attribute has non numeric element '+i+". Make sure that all elements are numbers.")}):y.warn(Ct(r)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),r}}function Xe(){if(D.isUnminified)return function(r,e){var t=r===!0||r===!1;return t||y.warn(Ct(r)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),r}}function sl(r){if(D.isUnminified)return function(e,t){return e==null||y.isObject(e)||y.warn(Ct(e)+' is a not valid value for "'+t+'" attribute. The value should be an object with properties '+r),e}}var Ei="get",ki="set";const v={addGetterSetter(r,e,t,i,s){v.addGetter(r,e,t),v.addSetter(r,e,i,s),v.addOverloadedGetterSetter(r,e)},addGetter(r,e,t){var i=Ei+y._capitalize(e);r.prototype[i]=r.prototype[i]||function(){var s=this.attrs[e];return s===void 0?t:s}},addSetter(r,e,t,i){var s=ki+y._capitalize(e);r.prototype[s]||v.overWriteSetter(r,e,t,i)},overWriteSetter(r,e,t,i){var s=ki+y._capitalize(e);r.prototype[s]=function(n){return t&&n!==void 0&&n!==null&&(n=t.call(this,n,e)),this._setAttr(e,n),i&&i.call(this),this}},addComponentsGetterSetter(r,e,t,i,s){var n=t.length,a=y._capitalize,o=Ei+a(e),l=ki+a(e),h,d;r.prototype[o]=function(){var c={};for(h=0;h<n;h++)d=t[h],c[d]=this.getAttr(e+a(d));return c};var u=sl(t);r.prototype[l]=function(c){var p=this.attrs[e],f;i&&(c=i.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(r,e)},addOverloadedGetterSetter(r,e){var t=y._capitalize(e),i=ki+t,s=Ei+t;r.prototype[e]=function(){return arguments.length?(this[i](arguments[0]),this):this[s]()}},addDeprecatedGetterSetter(r,e,t,i){y.error("Adding deprecated "+e);var s=Ei+y._capitalize(e),n=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";r.prototype[s]=function(){y.error(n);var a=this.attrs[e];return a===void 0?t:a},v.addSetter(r,e,i,function(){y.error(n)}),v.addOverloadedGetterSetter(r,e)},backCompat(r,e){y.each(e,function(t,i){var s=r.prototype[i],n=Ei+y._capitalize(t),a=ki+y._capitalize(t);function o(){s.apply(this,arguments),y.error('"'+t+'" method is deprecated and will be removed soon. Use ""'+i+'" instead.')}r.prototype[t]=o,r.prototype[n]=o,r.prototype[a]=o})},afterSetFilter(){this._filterUpToDate=!1}};function nl(r){var e=[],t=r.length,i=y,s,n;for(s=0;s<t;s++)n=r[s],i._isNumber(n)?n=Math.round(n*1e3)/1e3:i._isString(n)||(n=n+""),e.push(n);return e}var In=",",al="(",ol=")",hl="([",ll="])",dl=";",ul="()",cl="=",Nn=["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"],fl=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"];const pl=100;class dr{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 i=this.traceArr,s=i.length,n="",a,o,l,h;for(a=0;a<s;a++)o=i[a],l=o.method,l?(h=o.args,n+=l,e?n+=ul:y._isArray(h[0])?n+=hl+h.join(In)+ll:(t&&(h=h.map(d=>typeof d=="number"?Math.floor(d):d)),n+=al+h.join(In)+ol)):(n+=o.property,e||(n+=cl+o.val)),n+=dl;return n}clearTrace(){this.traceArr=[]}_trace(e){var t=this.traceArr,i;t.push(e),i=t.length,i>=pl&&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,i,s,n,a){this._context.arc(e,t,i,s,n,a)}arcTo(e,t,i,s,n){this._context.arcTo(e,t,i,s,n)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,i,s,n,a){this._context.bezierCurveTo(e,t,i,s,n,a)}clearRect(e,t,i,s){this._context.clearRect(e,t,i,s)}clip(){this._context.clip()}closePath(){this._context.closePath()}createImageData(e,t){var i=arguments;if(i.length===2)return this._context.createImageData(e,t);if(i.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,i,s){return this._context.createLinearGradient(e,t,i,s)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,i,s,n,a){return this._context.createRadialGradient(e,t,i,s,n,a)}drawImage(e,t,i,s,n,a,o,l,h){var d=arguments,u=this._context;d.length===3?u.drawImage(e,t,i):d.length===5?u.drawImage(e,t,i,s,n):d.length===9&&u.drawImage(e,t,i,s,n,a,o,l,h)}ellipse(e,t,i,s,n,a,o,l){this._context.ellipse(e,t,i,s,n,a,o,l)}isPointInPath(e,t){return this._context.isPointInPath(e,t)}fill(e){e?this._context.fill(e):this._context.fill()}fillRect(e,t,i,s){this._context.fillRect(e,t,i,s)}strokeRect(e,t,i,s){this._context.strokeRect(e,t,i,s)}fillText(e,t,i,s){s?this._context.fillText(e,t,i,s):this._context.fillText(e,t,i)}measureText(e){return this._context.measureText(e)}getImageData(e,t,i,s){return this._context.getImageData(e,t,i,s)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,i,s){this._context.rect(e,t,i,s)}putImageData(e,t,i){this._context.putImageData(e,t,i)}quadraticCurveTo(e,t,i,s){this._context.quadraticCurveTo(e,t,i,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,i,s,n,a){this._context.setTransform(e,t,i,s,n,a)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,i,s){this._context.strokeText(e,t,i,s)}transform(e,t,i,s,n,a){this._context.transform(e,t,i,s,n,a)}translate(e,t){this._context.translate(e,t)}_enableTrace(){var e=this,t=Nn.length,i=this.setAttr,s,n,a=function(o){var l=e[o],h;e[o]=function(){return n=nl(Array.prototype.slice.call(arguments,0)),h=l.apply(e,arguments),e._trace({method:o,args:n}),h}};for(s=0;s<t;s++)a(Nn[s]);e.setAttr=function(){i.apply(e,arguments);var o=arguments[0],l=arguments[1];(o==="shadowOffsetX"||o==="shadowOffsetY"||o==="shadowBlur")&&(l=l/this.canvas.getPixelRatio()),e._trace({property:o,val:l})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;var i=!t||t==="source-over";i||this.setAttr("globalCompositeOperation",t)}}fl.forEach(function(r){Object.defineProperty(dr.prototype,r,{get(){return this._context[r]},set(e){this._context[r]=e}})});class ml extends dr{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(),i=e.getFillPriority();if(t&&i==="color"){this._fillColor(e);return}var s=e.getFillPatternImage();if(s&&i==="pattern"){this._fillPattern(e);return}var n=e.getFillLinearGradientColorStops();if(n&&i==="linear-gradient"){this._fillLinearGradient(e);return}var a=e.getFillRadialGradientColorStops();if(a&&i==="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(),i=e.getStrokeLinearGradientEndPoint(),s=e.getStrokeLinearGradientColorStops(),n=this.createLinearGradient(t.x,t.y,i.x,i.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(),i=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!i){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),i||this.restore()}}_applyShadow(e){var t,i,s,n=(t=e.getShadowRGBA())!==null&&t!==void 0?t:"black",a=(i=e.getShadowBlur())!==null&&i!==void 0?i:5,o=(s=e.getShadowOffset())!==null&&s!==void 0?s:{x:0,y:0},l=e.getAbsoluteScale(),h=this.canvas.getPixelRatio(),d=l.x*h,u=l.y*h;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 gl extends dr{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 i=this.getCanvas().getPixelRatio();this.setTransform(i,0,0,i,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 ur;function vl(){if(ur)return ur;var r=y.createCanvasElement(),e=r.getContext("2d");return ur=function(){var t=D._global.devicePixelRatio||1,i=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return t/i}(),y.releaseCanvas(r),ur}class cr{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var t=e||{},i=t.pixelRatio||D.pixelRatio||vl();this.pixelRatio=i,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,i=this.getContext()._context;i.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var t=this.pixelRatio,i=this.getContext()._context;i.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(cr,"pixelRatio",void 0,x());class ti extends cr{constructor(e={width:0,height:0}){super(e),this.context=new ml(this),this.setSize(e.width,e.height)}}class ms extends cr{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new gl(this),this.setSize(e.width,e.height)}}const se={get isDragging(){var r=!1;return se._dragElements.forEach(e=>{e.dragStatus==="dragging"&&(r=!0)}),r},justDragged:!1,get node(){var r;return se._dragElements.forEach(e=>{r=e.node}),r},_dragElements:new Map,_drag(r){const e=[];se._dragElements.forEach((t,i)=>{const{node:s}=t,n=s.getStage();n.setPointersPositions(r),t.pointerId===void 0&&(t.pointerId=y._getFirstPointerId(r));const a=n._changedPointerPositions.find(h=>h.id===t.pointerId);if(a){if(t.dragStatus!=="dragging"){var o=s.dragDistance(),l=Math.max(Math.abs(a.x-t.startPointerPos.x),Math.abs(a.y-t.startPointerPos.y));if(l<o||(s.startDrag({evt:r}),!s.isDragging()))return}s._setDragPosition(r,t),e.push(s)}}),e.forEach(t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:r},!0)})},_endDragBefore(r){const e=[];se._dragElements.forEach(t=>{const{node:i}=t,s=i.getStage();if(r&&s.setPointersPositions(r),!s._changedPointerPositions.find(o=>o.id===t.pointerId))return;(t.dragStatus==="dragging"||t.dragStatus==="stopped")&&(se.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(r){se._dragElements.forEach((e,t)=>{e.dragStatus==="stopped"&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:r},!0),e.dragStatus!=="dragging"&&se._dragElements.delete(t)})}};D.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 fr="absoluteOpacity",pr="allEventListeners",dt="absoluteTransform",Dn="absoluteScale",$t="canvas",yl="Change",bl="children",_l="konva",gs="listening",Gn="mouseenter",Fn="mouseleave",Hn="set",Bn="Shape",mr=" ",$n="stage",Et="transform",wl="Stage",vs="visible",Sl=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(mr);let Tl=1;class P{constructor(e){this._id=Tl++,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===Et||e===dt)&&this._cache.get(e)?this._cache.get(e).dirty=!0:e?this._cache.delete(e):this._cache.clear()}_getCache(e,t){var i=this._cache.get(e),s=e===Et||e===dt,n=i===void 0||s&&i.dirty===!0;return n&&(i=t.call(this),this._cache.set(e,i)),i}_calculate(e,t,i){if(!this._attachedDepsListeners.get(e)){const s=t.map(n=>n+"Change.konva").join(mr);this.on(s,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,i)}_getCanvasCache(){return this._cache.get($t)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===dt&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has($t)){const{scene:e,filter:t,hit:i}=this._cache.get($t);y.releaseCanvas(e,t,i),this._cache.delete($t)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var t=e||{},i={};(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)&&(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()}));var s=Math.ceil(t.width||i.width),n=Math.ceil(t.height||i.height),a=t.pixelRatio,o=t.x===void 0?Math.floor(i.x):t.x,l=t.y===void 0?Math.floor(i.y):t.y,h=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+=h*2+1,n+=h*2+1,o-=h,l-=h;var c=new ti({pixelRatio:a,width:s,height:n}),p=new ti({pixelRatio:a,width:0,height:0}),f=new ms({pixelRatio:u,width:s,height:n}),m=c.getContext(),g=f.getContext();return f.isCache=!0,c.isCache=!0,this._cache.delete($t),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(c.getContext()._context.imageSmoothingEnabled=!1,p.getContext()._context.imageSmoothingEnabled=!1),m.save(),g.save(),m.translate(-o,-l),g.translate(-o,-l),this._isUnderCache=!0,this._clearSelfAndDescendantCache(fr),this._clearSelfAndDescendantCache(Dn),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($t,{scene:c,filter:p,hit:f,x:o,y:l}),this._requestDraw(),this}isCached(){return this._cache.has($t)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,t){var i=[{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,l=this.getAbsoluteTransform(t);return i.forEach(function(h){var d=l.point(h);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 i=this._getCachedSceneCanvas(),s=i.pixelRatio;e.drawImage(i._canvas,0,0,i.width/s,i.height/s),e.restore()}_drawCachedHitCanvas(e){var t=this._getCanvasCache(),i=t.hit;e.save(),e.translate(t.x,t.y),e.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e=this.filters(),t=this._getCanvasCache(),i=t.scene,s=t.filter,n=s.getContext(),a,o,l,h;if(e){if(!this._filterUpToDate){var d=i.pixelRatio;s.setSize(i.width/i.pixelRatio,i.height/i.pixelRatio);try{for(a=e.length,n.clear(),n.drawImage(i._canvas,0,0,i.getWidth()/d,i.getHeight()/d),o=n.getImageData(0,0,s.getWidth(),s.getHeight()),l=0;l<a;l++){if(h=e[l],typeof h!="function"){y.error("Filter should be type of function, but got "+typeof h+" instead. Please check correct filters");continue}h.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 i}on(e,t){if(this._cache&&this._cache.delete(pr),arguments.length===3)return this._delegate.apply(this,arguments);var i=e.split(mr),s=i.length,n,a,o,l,h;for(n=0;n<s;n++)a=i[n],o=a.split("."),l=o[0],h=o[1]||"",this.eventListeners[l]||(this.eventListeners[l]=[]),this.eventListeners[l].push({name:h,handler:t});return this}off(e,t){var i=(e||"").split(mr),s=i.length,n,a,o,l,h,d;if(this._cache&&this._cache.delete(pr),!e)for(a in this.eventListeners)this._off(a);for(n=0;n<s;n++)if(o=i[n],l=o.split("."),h=l[0],d=l[1],h)this.eventListeners[h]&&this._off(h,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(i){t.call(this,i.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,t,i){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],i.call(a[o],n)})}remove(){return this.isDragging()&&this.stopDrag(),se._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(dt),this._clearSelfAndDescendantCache(fr),this._clearSelfAndDescendantCache(Dn),this._clearSelfAndDescendantCache($n),this._clearSelfAndDescendantCache(vs),this._clearSelfAndDescendantCache(gs)}_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,i;if(!e)return this;for(t in e)t!==bl&&(i=Hn+y._capitalize(t),y._isFunction(this[i])?this[i](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(gs,this._isListening)}_isListening(e){if(!this.listening())return!1;const i=this.getParent();return i&&i!==e&&this!==e?i._isListening(e):!0}isVisible(){return this._getCache(vs,this._isVisible)}_isVisible(e){if(!this.visible())return!1;const i=this.getParent();return i&&i!==e&&this!==e?i._isVisible(e):!0}shouldDrawHit(e,t=!1){if(e)return this._isVisible(e)&&this._isListening(e);var i=this.getLayer(),s=!1;se._dragElements.forEach(a=>{a.dragStatus==="dragging"&&(a.node.nodeType==="Stage"||a.node.getLayer()===i)&&(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,i=0,s,n,a,o;function l(h){for(s=[],n=h.length,a=0;a<n;a++)o=h[a],i++,o.nodeType!==Bn&&(s=s.concat(o.getChildren().slice())),o._id===t._id&&(a=n);s.length>0&&s[0].getDepth()<=e&&l(s)}return t.nodeType!==wl&&l(t.getStage().getChildren()),i}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(Et),this._clearSelfAndDescendantCache(dt)),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,i=this.parent;for(;i;){if(i.isCached()){t=!0;break}i=i.parent}t&&!e&&(e=!0);var s=this.getAbsoluteTransform(e).getMatrix(),n=new Fe,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(Et);var i=this._getAbsoluteTransform().copy();return i.invert(),i.translate(e.x,e.y),e={x:this.attrs.x+i.getTranslation().x,y:this.attrs.y+i.getTranslation().y},this._setTransform(t),this.setPosition({x:e.x,y:e.y}),this._clearCache(Et),this._clearSelfAndDescendantCache(dt),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,i=e.y,s=this.x(),n=this.y();return t!==void 0&&(s+=t),i!==void 0&&(n+=i),this.setPosition({x:s,y:n}),this}_eachAncestorReverse(e,t){var i=[],s=this.getParent(),n,a;if(!(t&&t._id===this._id)){for(i.unshift(this);s&&(!t||s._id!==t._id);)i.unshift(s),s=s.parent;for(n=i.length,a=0;a<n;a++)e(i[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(fr,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(),i,s,n,a,o;e.attrs={};for(i in t)s=t[i],o=y.isObject(s)&&!y._isPlainObject(s)&&!y._isArray(s),!o&&(n=typeof this[i]=="function"&&this[i],delete t[i],a=n?n.call(this):null,t[i]=s,a!==s&&(e.attrs[i]=s));return e.className=this.getClassName(),y._prepareToStringify(e)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,i){var s=[];t&&this._isMatch(e)&&s.push(this);for(var n=this.parent;n;){if(n===i)return s;n._isMatch(e)&&s.push(n),n=n.parent}return s}isAncestorOf(e){return!1}findAncestor(e,t,i){return this.findAncestors(e,t,i)[0]}_isMatch(e){if(!e)return!1;if(typeof e=="function")return e(this);var t=e.replace(/ /g,"").split(","),i=t.length,s,n;for(s=0;s<i;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($n,this._getStage)}_getStage(){var e=this.getParent();if(e)return e.getStage()}fire(e,t={},i){return t.target=t.target||this,i?this._fireAndBubble(e,t):this._fire(e,t),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(dt,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var t;if(e)return t=new Fe,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(dt)||new Fe,this.parent?this.parent.getAbsoluteTransform().copyInto(t):t.reset();var i=this.transformsEnabled();if(i==="all")t.multiply(this.getTransform());else if(i==="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(Et,this._getTransform)}_getTransform(){var e,t,i=this._cache.get(Et)||new Fe;i.reset();var s=this.x(),n=this.y(),a=D.getAngle(this.rotation()),o=(e=this.attrs.scaleX)!==null&&e!==void 0?e:1,l=(t=this.attrs.scaleY)!==null&&t!==void 0?t:1,h=this.attrs.skewX||0,d=this.attrs.skewY||0,u=this.attrs.offsetX||0,c=this.attrs.offsetY||0;return(s!==0||n!==0)&&i.translate(s,n),a!==0&&i.rotate(a),(h!==0||d!==0)&&i.skew(h,d),(o!==1||l!==1)&&i.scale(o,l),(u!==0||c!==0)&&i.translate(-1*u,-1*c),i.dirty=!1,i}clone(e){var t=y.cloneObject(this.attrs),i,s,n,a,o;for(i in e)t[i]=e[i];var l=new this.constructor(t);for(i in this.eventListeners)for(s=this.eventListeners[i],n=s.length,a=0;a<n;a++)o=s[a],o.name.indexOf(_l)<0&&(l.eventListeners[i]||(l.eventListeners[i]=[]),l.eventListeners[i].push(o));return l}_toKonvaCanvas(e){e=e||{};var t=this.getClientRect(),i=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 ti({width:e.width||Math.ceil(t.width)||(i?i.width():0),height:e.height||Math.ceil(t.height)||(i?i.height():0),pixelRatio:a}),l=o.getContext();return e.imageSmoothingEnabled===!1&&(l._context.imageSmoothingEnabled=!1),l.save(),(s||n)&&l.translate(-1*s,-1*n),this.drawScene(o),l.restore(),o}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e=e||{};var t=e.mimeType||null,i=e.quality||null,s=this._toKonvaCanvas(e).toDataURL(t,i);return e.callback&&e.callback(s),s}toImage(e){return new Promise((t,i)=>{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){i(s)}})}toBlob(e){return new Promise((t,i)=>{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){i(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,i){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)&&(!i||i===o)){if(s.splice(n,1),s.length===0){delete this.eventListeners[e];break}n--}}_fireChangeEvent(e,t,i){this._fire(e+yl,{oldVal:t,newVal:i})}addName(e){if(!this.hasName(e)){var t=this.name(),i=t?t+" "+e:e;this.name(i)}return this}hasName(e){if(!e)return!1;const t=this.name();if(!t)return!1;var i=(t||"").split(/\s/g);return i.indexOf(e)!==-1}removeName(e){var t=(this.name()||"").split(/\s/g),i=t.indexOf(e);return i!==-1&&(t.splice(i,1),this.name(t.join(" "))),this}setAttr(e,t){var i=this[Hn+y._capitalize(e)];return y._isFunction(i)?i.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 i=this.attrs[e];i===t&&!y.isObject(t)||(t==null?delete this.attrs[e]:this.attrs[e]=t,this._shouldFireChangeEvents&&this._fireChangeEvent(e,i,t),this._requestDraw())}_setComponentAttr(e,t,i){var s;i!==void 0&&(s=this.attrs[e],s||(this.attrs[e]=this.getAttr(e)),this.attrs[e][t]=i,this._fireChangeEvent(e,s,i))}_fireAndBubble(e,t,i){t&&this.nodeType===Bn&&(t.target=this);var s=(e===Gn||e===Fn)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||this.nodeType==="Stage"&&!i);if(!s){this._fire(e,t);var n=(e===Gn||e===Fn)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(t&&!t.cancelBubble||!t)&&this.parent&&this.parent.isListening()&&!n&&(i&&i.parent?this._fireAndBubble.call(this.parent,e,t,i):this._fireAndBubble.call(this.parent,e,t))}}_getProtoListeners(e){let t=this._cache.get(pr);if(!t){t={};let s=Object.getPrototypeOf(this);for(;s;){if(!s.eventListeners){s=Object.getPrototypeOf(s);continue}for(var i in s.eventListeners){const n=s.eventListeners[i],a=t[i]||[];t[i]=n.concat(a)}s=Object.getPrototypeOf(s)}this._cache.set(pr,t)}return t[e]}_fire(e,t){t=t||{},t.currentTarget=this,t.type=e;const i=this._getProtoListeners(e);if(i)for(var s=0;s<i.length;s++)i[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,i=this.getStage(),s=this.getAbsolutePosition(),n=i._getPointerById(t)||i._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 i=se._dragElements.get(this._id);i.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:e&&e.evt},t)}_setDragPosition(e,t){const i=this.getStage()._getPointerById(t.pointerId);if(i){var s={x:i.x-t.offset.x,y:i.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,i=!t||D.dragButtons.indexOf(e.evt.button)>=0;if(i&&!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),i=t&&t.dragStatus==="dragging",s=t&&t.dragStatus==="ready";i?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 i={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return y.haveIntersection(i,this.getClientRect())}static create(e,t){return y._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(e,t){var i=P.prototype.getClassName.call(e),s=e.children,n,a,o;t&&(e.attrs.container=t),D[i]||(y.warn('Can not find a node with class name "'+i+'". Fallback to "Shape".'),i="Shape");const l=D[i];if(n=new l(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,Sl,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(Et),this._clearSelfAndDescendantCache(dt)}),P.prototype.on.call(P.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(vs)}),P.prototype.on.call(P.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(gs)}),P.prototype.on.call(P.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(fr)});const ue=v.addGetterSetter;ue(P,"zIndex"),ue(P,"absolutePosition"),ue(P,"position"),ue(P,"x",0,x()),ue(P,"y",0,x()),ue(P,"globalCompositeOperation","source-over",ei()),ue(P,"opacity",1,x()),ue(P,"name","",ei()),ue(P,"id","",ei()),ue(P,"rotation",0,x()),v.addComponentsGetterSetter(P,"scale",["x","y"]),ue(P,"scaleX",1,x()),ue(P,"scaleY",1,x()),v.addComponentsGetterSetter(P,"skew",["x","y"]),ue(P,"skewX",0,x()),ue(P,"skewY",0,x()),v.addComponentsGetterSetter(P,"offset",["x","y"]),ue(P,"offsetX",0,x()),ue(P,"offsetY",0,x()),ue(P,"dragDistance",null,x()),ue(P,"width",0,x()),ue(P,"height",0,x()),ue(P,"listening",!0,Xe()),ue(P,"preventDefault",!0,Xe()),ue(P,"filters",null,function(r){return this._filterUpToDate=!1,r}),ue(P,"visible",!0,Xe()),ue(P,"transformsEnabled","all",ei()),ue(P,"size"),ue(P,"dragBoundFunc"),ue(P,"draggable",!1,Xe()),v.backCompat(P,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class He extends P{constructor(){super(...arguments),this.children=[]}getChildren(e){if(!e)return this.children||[];const t=this.children||[];var i=[];return t.forEach(function(s){e(s)&&i.push(s)}),i}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 i=e[0];return i.getParent()?(i.moveTo(this),this):(this._validateAdd(i),i.index=this.getChildren().length,i.parent=this,i._clearCaches(),this.getChildren().push(i),this._fire("add",{child:i}),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 i=[];return this._descendants(s=>{const n=s._isMatch(e);return n&&i.push(s),!!(n&&t)}),i}_descendants(e){let t=!1;const i=this.getChildren();for(const s of i){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(i){t.add(i.clone())}),t}getAllIntersections(e){var t=[];return this.find("Shape").forEach(function(i){i.isVisible()&&i.intersects(e)&&t.push(i)}),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),!this.isCached()&&((t=this.children)===null||t===void 0||t.forEach(function(i){i._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(t,i){t.index=i}),this._requestDraw()}drawScene(e,t){var i=this.getLayer(),s=e||i&&i.getCanvas(),n=s&&s.getContext(),a=this._getCanvasCache(),o=a&&a.scene,l=s&&s.isCache;if(!this.isVisible()&&!l)return this;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._drawCachedSceneCanvas(n),n.restore()}else this._drawChildren("drawScene",s,t);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;var i=this.getLayer(),s=e||i&&i.hitCanvas,n=s&&s.getContext(),a=this._getCanvasCache(),o=a&&a.hit;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._drawCachedHitCanvas(n),n.restore()}else this._drawChildren("drawHit",s,t);return this}_drawChildren(e,t,i){var s,n=t&&t.getContext(),a=this.clipWidth(),o=this.clipHeight(),l=this.clipFunc(),h=a&&o||l;const d=i===this;if(h){n.save();var u=this.getAbsoluteTransform(i),c=u.getMatrix();if(n.transform(c[0],c[1],c[2],c[3],c[4],c[5]),n.beginPath(),l)l.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,i)}),m&&n.restore(),h&&n.restore()}getClientRect(e){var t;e=e||{};var i=e.skipTransform,s=e.relativeTo,n,a,o,l,h={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,l=g.y+g.height):(n=Math.min(n,g.x),a=Math.min(a,g.y),o=Math.max(o,g.x+g.width),l=Math.max(l,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?h={x:n,y:a,width:o-n,height:l-a}:h={x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,s)}}v.addComponentsGetterSetter(He,"clip",["x","y","width","height"]),v.addGetterSetter(He,"clipX",void 0,x()),v.addGetterSetter(He,"clipY",void 0,x()),v.addGetterSetter(He,"clipWidth",void 0,x()),v.addGetterSetter(He,"clipHeight",void 0,x()),v.addGetterSetter(He,"clipFunc");const xi=new Map,Vn=D._global.PointerEvent!==void 0;function ys(r){return xi.get(r)}function bs(r){return{evt:r,pointerId:r.pointerId}}function zn(r,e){return xi.get(r)===e}function Wn(r,e){Pi(r),e.getStage()&&(xi.set(r,e),Vn&&e._fire("gotpointercapture",bs(new PointerEvent("gotpointercapture"))))}function Pi(r,e){const t=xi.get(r);if(!t)return;const i=t.getStage();i&&i.content,xi.delete(r),Vn&&t._fire("lostpointercapture",bs(new PointerEvent("lostpointercapture")))}var Cl="Stage",El="string",Un="px",kl="mouseout",Zn="mouseleave",jn="mouseover",Xn="mouseenter",qn="mousemove",Yn="mousedown",Kn="mouseup",Ai="pointermove",Oi="pointerdown",ii="pointerup",Mi="pointercancel",xl="lostpointercapture",gr="pointerout",vr="pointerleave",yr="pointerover",br="pointerenter",_s="contextmenu",Jn="touchstart",Qn="touchend",ea="touchmove",ta="touchcancel",ws="wheel",Pl=5,Al=[[Xn,"_pointerenter"],[Yn,"_pointerdown"],[qn,"_pointermove"],[Kn,"_pointerup"],[Zn,"_pointerleave"],[Jn,"_pointerdown"],[ea,"_pointermove"],[Qn,"_pointerup"],[ta,"_pointercancel"],[jn,"_pointerover"],[ws,"_wheel"],[_s,"_contextmenu"],[Oi,"_pointerdown"],[Ai,"_pointermove"],[ii,"_pointerup"],[Mi,"_pointercancel"],[xl,"_lostpointercapture"]];const Ss={mouse:{[gr]:kl,[vr]:Zn,[yr]:jn,[br]:Xn,[Ai]:qn,[Oi]:Yn,[ii]:Kn,[Mi]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[gr]:"touchout",[vr]:"touchleave",[yr]:"touchover",[br]:"touchenter",[Ai]:ea,[Oi]:Jn,[ii]:Qn,[Mi]:ta,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[gr]:gr,[vr]:vr,[yr]:yr,[br]:br,[Ai]:Ai,[Oi]:Oi,[ii]:ii,[Mi]:Mi,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},Li=r=>r.indexOf("pointer")>=0?"pointer":r.indexOf("touch")>=0?"touch":"mouse",ri=r=>{const e=Li(r);if(e==="pointer")return D.pointerEventsEnabled&&Ss.pointer;if(e==="touch")return Ss.touch;if(e==="mouse")return Ss.mouse};function ia(r={}){return(r.clipFunc||r.clipWidth||r.clipHeight)&&y.warn("Stage does not support clipping. Please use clip for Layers or Groups."),r}const Ol="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);",_r=[];class wr extends He{constructor(e){super(ia(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),_r.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{ia(this.attrs)}),this._checkVisibility()}_validateAdd(e){const t=e.getType()==="Layer",i=e.getType()==="FastLayer";t||i||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===El){if(e.charAt(0)==="."){var t=e.slice(1);e=document.getElementsByClassName(t)[0]}else{var i;e.charAt(0)!=="#"?i=e:i=e.slice(1),e=document.getElementById(i)}if(!e)throw"Can not find container in document with id "+i}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,i;for(i=0;i<t;i++)e[i].clear();return this}clone(e){return e||(e={}),e.container=typeof document<"u"&&document.createElement("div"),He.prototype.clone.call(this,e)}destroy(){super.destroy();var e=this.content;e&&y._isInDocument(e)&&this.container().removeChild(e);var t=_r.indexOf(this);return t>-1&&_r.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(Ol),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 ti({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),i=t.getContext()._context,s=this.children;return(e.x||e.y)&&i.translate(-1*e.x,-1*e.y),s.forEach(function(n){if(n.isVisible()){var a=n._toKonvaCanvas(e);i.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,i=t.length,s=i-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+Un,this.content.style.height=t+Un),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach(i=>{i.setSize({width:e,height:t}),i.draw()})}add(e,...t){if(arguments.length>1){for(var i=0;i<arguments.length;i++)this.add(arguments[i]);return this}super.add(e);var s=this.children.length;return s>Pl&&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 zn(e,this)}setPointerCapture(e){Wn(e,this)}releaseCapture(e){Pi(e)}getLayers(){return this.children}_bindContentEvents(){D.isBrowser&&Al.forEach(([e,t])=>{this.content.addEventListener(e,i=>{this[t](i)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=ri(e.type);this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=ri(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=ri(e.type),i=Li(e.type);if(t){this.setPointersPositions(e);var s=this._getTargetShape(i),n=!se.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[i+"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=ri(e.type),i=Li(e.type);if(t){this.setPointersPositions(e);var s=!1;this._changedPointerPositions.forEach(n=>{var a=this.getIntersection(n);if(se.justDragged=!1,D["_"+i+"ListenClick"]=!0,!(a&&a.isListening()))return;D.capturePointerEventsEnabled&&a.setPointerCapture(n.id),this[i+"ClickStartShape"]=a,a._fireAndBubble(t.pointerdown,{evt:e,pointerId:n.id}),s=!0;const l=e.type.indexOf("touch")>=0;a.preventDefault()&&e.cancelable&&l&&e.preventDefault()}),s||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(e){const t=ri(e.type),i=Li(e.type);if(!t)return;se.isDragging&&se.node.preventDefault()&&e.cancelable&&e.preventDefault(),this.setPointersPositions(e);var s=!se.isDragging||D.hitOnDragEnabled;if(!s)return;var n={};let a=!1;var o=this._getTargetShape(i);this._changedPointerPositions.forEach(l=>{const h=ys(l.id)||this.getIntersection(l),d=l.id,u={evt:e,pointerId:d};var c=o!==h;if(c&&o&&(o._fireAndBubble(t.pointerout,Object.assign({},u),h),o._fireAndBubble(t.pointerleave,Object.assign({},u),h)),h){if(n[h._id])return;n[h._id]=!0}h&&h.isListening()?(a=!0,c&&(h._fireAndBubble(t.pointerover,Object.assign({},u),o),h._fireAndBubble(t.pointerenter,Object.assign({},u),o),this[i+"targetShape"]=h),h._fireAndBubble(t.pointermove,Object.assign({},u))):o&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:d}),this[i+"targetShape"]=null)}),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=ri(e.type),i=Li(e.type);if(!t)return;this.setPointersPositions(e);const s=this[i+"ClickStartShape"],n=this[i+"ClickEndShape"];var a={};let o=!1;this._changedPointerPositions.forEach(l=>{const h=ys(l.id)||this.getIntersection(l);if(h){if(h.releaseCapture(l.id),a[h._id])return;a[h._id]=!0}const d=l.id,u={evt:e,pointerId:d};let c=!1;D["_"+i+"InDblClickWindow"]?(c=!0,clearTimeout(this[i+"DblTimeout"])):se.justDragged||(D["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout(function(){D["_"+i+"InDblClickWindow"]=!1},D.dblClickWindow),h&&h.isListening()?(o=!0,this[i+"ClickEndShape"]=h,h._fireAndBubble(t.pointerup,Object.assign({},u)),D["_"+i+"ListenClick"]&&s&&s===h&&(h._fireAndBubble(t.pointerclick,Object.assign({},u)),c&&n&&n===h&&h._fireAndBubble(t.pointerdblclick,Object.assign({},u)))):(this[i+"ClickEndShape"]=null,D["_"+i+"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["_"+i+"ListenClick"]=!1,e.cancelable&&i!=="touch"&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(_s,{evt:e}):this._fire(_s,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(ws,{evt:e}):this._fire(ws,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=ys(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(ii,bs(e)),Pi(e.pointerId)}_lostpointercapture(e){Pi(e.pointerId)}setPointersPositions(e){var t=this._getContentPosition(),i=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})})):(i=(e.clientX-t.left)/t.scaleX,s=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:i,y:s},this._pointerPositions=[{x:i,y:s,id:y._getFirstPointerId(e)}],this._changedPointerPositions=[{x:i,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 ti({width:this.width(),height:this.height()}),this.bufferHitCanvas=new ms({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}}wr.prototype.nodeType=Cl,fe(wr),v.addGetterSetter(wr,"container");var ra="hasShadow",sa="shadowRGBA",na="patternImage",aa="linearGradient",oa="radialGradient";let Sr;function Ts(){return Sr||(Sr=y.createCanvasElement().getContext("2d"),Sr)}const Ri={};function Ml(r){r.fill()}function Ll(r){r.stroke()}function Rl(r){r.fill()}function Il(r){r.stroke()}function Nl(){this._clearCache(ra)}function Dl(){this._clearCache(sa)}function Gl(){this._clearCache(na)}function Fl(){this._clearCache(aa)}function Hl(){this._clearCache(oa)}class E extends P{constructor(e){super(e);let t;for(;t=y.getRandomColor(),!(t&&!(t in Ri)););this.colorKey=t,Ri[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(ra,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(na,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){var e=Ts();const t=e.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const i=new Fe;i.translate(this.fillPatternX(),this.fillPatternY()),i.rotate(D.getAngle(this.fillPatternRotation())),i.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),i.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const s=i.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(aa,this.__getLinearGradient)}__getLinearGradient(){var e=this.fillLinearGradientColorStops();if(e){for(var t=Ts(),i=this.fillLinearGradientStartPoint(),s=this.fillLinearGradientEndPoint(),n=t.createLinearGradient(i.x,i.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(oa,this.__getRadialGradient)}__getRadialGradient(){var e=this.fillRadialGradientColorStops();if(e){for(var t=Ts(),i=this.fillRadialGradientStartPoint(),s=this.fillRadialGradientEndPoint(),n=t.createRadialGradient(i.x,i.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(sa,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(),i=t.bufferHitCanvas,s;return i.getContext().clear(),this.drawHit(i,null,!0),s=i.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data,s[3]>0}destroy(){return P.prototype.destroy.call(this),delete Ri[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(),l=this.shadowForStrokeEnabled();return!!(s&&n&&o&&l)}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,i=e.relativeTo,s=this.getSelfRect(),a=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=s.width+a,l=s.height+a,h=!e.skipShadow&&this.hasShadow(),d=h?this.shadowOffsetX():0,u=h?this.shadowOffsetY():0,c=o+Math.abs(d),p=l+Math.abs(u),f=h&&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(_,i)}drawScene(e,t){var i=this.getLayer(),s=e||i.getCanvas(),n=s.getContext(),a=this._getCanvasCache(),o=this.getSceneFunc(),l=this.hasShadow(),h,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){h=this.getStage(),d=h.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;l&&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)}l&&n._applyShadow(this),o.call(this,n,this)}return n.restore(),this}drawHit(e,t,i=!1){if(!this.shouldDrawHit(t,i))return this;var s=this.getLayer(),n=e||s.hitCanvas,a=n&&n.getContext(),o=this.hitFunc()||this.sceneFunc(),l=this._getCanvasCache(),h=l&&l.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()"),h){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(),i=this._getCachedSceneCanvas(),s=t.hit,n=s.getContext(),a=s.getWidth(),o=s.getHeight(),l,h,d,u,c,p;n.clear(),n.drawImage(i._canvas,0,0,a,o);try{for(l=n.getImageData(0,0,a,o),h=l.data,d=h.length,u=y._hexToRgb(this.colorKey),c=0;c<d;c+=4)p=h[c+3],p>e?(h[c]=u.r,h[c+1]=u.g,h[c+2]=u.b,h[c+3]=255):h[c+3]=0;n.putImageData(l,0,0)}catch(f){y.error("Unable to draw hit graph from cached scene canvas. "+f.message)}return this}hasPointerCapture(e){return zn(e,this)}setPointerCapture(e){Wn(e,this)}releaseCapture(e){Pi(e)}}E.prototype._fillFunc=Ml,E.prototype._strokeFunc=Ll,E.prototype._fillFuncHit=Rl,E.prototype._strokeFuncHit=Il,E.prototype._centroid=!1,E.prototype.nodeType="Shape",fe(E),E.prototype.eventListeners={},E.prototype.on.call(E.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",Nl),E.prototype.on.call(E.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",Dl),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",Gl),E.prototype.on.call(E.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",Fl),E.prototype.on.call(E.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",Hl),v.addGetterSetter(E,"stroke",void 0,Rn()),v.addGetterSetter(E,"strokeWidth",2,x()),v.addGetterSetter(E,"fillAfterStrokeEnabled",!1),v.addGetterSetter(E,"hitStrokeWidth","auto",ps()),v.addGetterSetter(E,"strokeHitEnabled",!0,Xe()),v.addGetterSetter(E,"perfectDrawEnabled",!0,Xe()),v.addGetterSetter(E,"shadowForStrokeEnabled",!0,Xe()),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,ei()),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,Rn()),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 Bl="#",$l="beforeDraw",Vl="draw",ha=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],zl=ha.length;class Vt extends He{constructor(e){super(e),this.canvas=new ti,this.hitCanvas=new ms({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,i=!1;;){for(let s=0;s<zl;s++){const n=ha[s],a=this._getIntersection({x:e.x+n.x*t,y:e.y+n.y*t}),o=a.shape;if(o)return o;if(i=!!a.antialiased,!a.antialiased)break}if(i)t+=1;else return null}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,s=i[3];if(s===255){const n=y._rgbToHex(i[0],i[1],i[2]),a=Ri[Bl+n];return a?{shape:a}:{antialiased:!0}}else if(s>0)return{antialiased:!0};return{}}drawScene(e,t){var i=this.getLayer(),s=e||i&&i.getCanvas();return this._fire($l,{node:this}),this.clearBeforeDraw()&&s.getContext().clear(),He.prototype.drawScene.call(this,s,t),this._fire(Vl,{node:this}),this}drawHit(e,t){var i=this.getLayer(),s=e||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),He.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()}}Vt.prototype.nodeType="Layer",fe(Vt),v.addGetterSetter(Vt,"imageSmoothingEnabled",!0),v.addGetterSetter(Vt,"clearBeforeDraw",!0),v.addGetterSetter(Vt,"hitGraphEnabled",!0,Xe());class Cs extends Vt{constructor(e){super(e),this.listening(!1),y.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}Cs.prototype.nodeType="FastLayer",fe(Cs);class si extends He{_validateAdd(e){var t=e.getType();t!=="Group"&&t!=="Shape"&&y.throw("You may only add groups and shapes to groups.")}}si.prototype.nodeType="Group",fe(si);var Es=function(){return Qt.performance&&Qt.performance.now?function(){return Qt.performance.now()}:function(){return new Date().getTime()}}();class Ve{constructor(e,t){this.id=Ve.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Es(),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,i=t.length,s;for(s=0;s<i;s++)if(t[s]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){var e=Ve,t=e.animations,i=t.length,s;for(s=0;s<i;s++)if(t[s].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=Es(),Ve._addAnimation(this),this}stop(){return Ve._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,i=this.animations,s=i.length,n;for(n=0;n<s;n++)if(i[n].id===t){this.animations.splice(n,1);break}}static _runFrames(){var e={},t=this.animations,i,s,n,a,o,l,h,d,u;for(a=0;a<t.length;a++)if(i=t[a],s=i.layers,n=i.func,i._updateFrameObject(Es()),l=s.length,n?u=n.call(i,i.frame)!==!1:u=!0,!!u)for(o=0;o<l;o++)h=s[o],h._id!==void 0&&(e[h._id]=h);for(d in e)e.hasOwnProperty(d)&&e[d].batchDraw()}static _animationLoop(){var e=Ve;e.animations.length?(e._runFrames(),y.requestAnimFrame(e._animationLoop)):e.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,y.requestAnimFrame(this._animationLoop))}}Ve.animations=[],Ve.animIdCounter=0,Ve.animRunning=!1;var Wl={node:1,duration:1,easing:1,onFinish:1,yoyo:1},Ul=1,la=2,da=3,Zl=0,ua=["fill","stroke","shadowColor"];class jl{constructor(e,t,i,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=i,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=la,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=da,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===la?this.setTime(e):this.state===da&&this.setTime(this.duration-e)}pause(){this.state=Ul,this.fire("onPause")}getTimer(){return new Date().getTime()}}class ye{constructor(e){var t=this,i=e.node,s=i._id,n,a=e.easing||Ii.Linear,o=!!e.yoyo,l;typeof e.duration>"u"?n=.3:e.duration===0?n=.001:n=e.duration,this.node=i,this._id=Zl++;var h=i.getLayer()||(i instanceof D.Stage?i.getLayers():null);h||y.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Ve(function(){t.tween.onEnterFrame()},h),this.tween=new jl(l,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(l in e)Wl[l]===void 0&&this._addAttr(l,e[l]);this.reset(),this.onFinish=e.onFinish,this.onReset=e.onReset,this.onUpdate=e.onUpdate}_addAttr(e,t){var i=this.node,s=i._id,n,a,o,l,h,d,u,c;if(o=ye.tweens[s][e],o&&delete ye.attrs[s][o][e],n=i.getAttr(e),y._isArray(t))if(a=[],h=Math.max(t.length,n.length),e==="points"&&t.length!==n.length&&(t.length>n.length?(u=n,n=y._prepareArrayForTween(n,t,i.closed())):(d=t,t=y._prepareArrayForTween(t,n,i.closed()))),e.indexOf("fill")===0)for(l=0;l<h;l++)if(l%2===0)a.push(t[l]-n[l]);else{var p=y.colorToRGBA(n[l]);c=y.colorToRGBA(t[l]),n[l]=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(l=0;l<h;l++)a.push(t[l]-n[l]);else ua.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,i=ye.attrs[t._id][this._id],s,n,a,o,l,h,d,u;for(s in i){if(n=i[s],a=n.start,o=n.diff,u=n.end,y._isArray(a))if(l=[],d=Math.max(a.length,u.length),s.indexOf("fill")===0)for(h=0;h<d;h++)h%2===0?l.push((a[h]||0)+o[h]*e):l.push("rgba("+Math.round(a[h].r+o[h].r*e)+","+Math.round(a[h].g+o[h].g*e)+","+Math.round(a[h].b+o[h].b*e)+","+(a[h].a+o[h].a*e)+")");else for(h=0;h<d;h++)l.push((a[h]||0)+o[h]*e);else ua.indexOf(s)!==-1?l="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)+")":l=a+o*e;t.setAttr(s,l)}}_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,i=ye.tweens[e],s;this.pause();for(s in i)delete ye.tweens[e][s];delete ye.attrs[e][t]}}ye.attrs={},ye.tweens={},P.prototype.to=function(r){var e=r.onFinish;r.node=this,r.onFinish=function(){this.destroy(),e&&e()};var t=new ye(r);t.play()};const Ii={BackEaseIn(r,e,t,i){var s=1.70158;return t*(r/=i)*r*((s+1)*r-s)+e},BackEaseOut(r,e,t,i){var s=1.70158;return t*((r=r/i-1)*r*((s+1)*r+s)+1)+e},BackEaseInOut(r,e,t,i){var s=1.70158;return(r/=i/2)<1?t/2*(r*r*(((s*=1.525)+1)*r-s))+e:t/2*((r-=2)*r*(((s*=1.525)+1)*r+s)+2)+e},ElasticEaseIn(r,e,t,i,s,n){var a=0;return r===0?e:(r/=i)===1?e+t:(n||(n=i*.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*(r-=1))*Math.sin((r*i-a)*(2*Math.PI)/n))+e)},ElasticEaseOut(r,e,t,i,s,n){var a=0;return r===0?e:(r/=i)===1?e+t:(n||(n=i*.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*r)*Math.sin((r*i-a)*(2*Math.PI)/n)+t+e)},ElasticEaseInOut(r,e,t,i,s,n){var a=0;return r===0?e:(r/=i/2)===2?e+t:(n||(n=i*(.3*1.5)),!s||s<Math.abs(t)?(s=t,a=n/4):a=n/(2*Math.PI)*Math.asin(t/s),r<1?-.5*(s*Math.pow(2,10*(r-=1))*Math.sin((r*i-a)*(2*Math.PI)/n))+e:s*Math.pow(2,-10*(r-=1))*Math.sin((r*i-a)*(2*Math.PI)/n)*.5+t+e)},BounceEaseOut(r,e,t,i){return(r/=i)<1/2.75?t*(7.5625*r*r)+e:r<2/2.75?t*(7.5625*(r-=1.5/2.75)*r+.75)+e:r<2.5/2.75?t*(7.5625*(r-=2.25/2.75)*r+.9375)+e:t*(7.5625*(r-=2.625/2.75)*r+.984375)+e},BounceEaseIn(r,e,t,i){return t-Ii.BounceEaseOut(i-r,0,t,i)+e},BounceEaseInOut(r,e,t,i){return r<i/2?Ii.BounceEaseIn(r*2,0,t,i)*.5+e:Ii.BounceEaseOut(r*2-i,0,t,i)*.5+t*.5+e},EaseIn(r,e,t,i){return t*(r/=i)*r+e},EaseOut(r,e,t,i){return-t*(r/=i)*(r-2)+e},EaseInOut(r,e,t,i){return(r/=i/2)<1?t/2*r*r+e:-t/2*(--r*(r-2)-1)+e},StrongEaseIn(r,e,t,i){return t*(r/=i)*r*r*r*r+e},StrongEaseOut(r,e,t,i){return t*((r=r/i-1)*r*r*r*r+1)+e},StrongEaseInOut(r,e,t,i){return(r/=i/2)<1?t/2*r*r*r*r*r+e:t/2*((r-=2)*r*r*r*r+2)+e},Linear(r,e,t,i){return t*r/i+e}},ca=y._assign(D,{Util:y,Transform:Fe,Node:P,Container:He,Stage:wr,stages:_r,Layer:Vt,FastLayer:Cs,Group:si,DD:se,Shape:E,shapes:Ri,Animation:Ve,Tween:ye,Easings:Ii,Context:dr,Canvas:cr});class ut extends E{_sceneFunc(e){var t=D.getAngle(this.angle()),i=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,i),e.arc(0,0,this.innerRadius(),t,0,!i),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(),i=this.clockwise(),s=D.getAngle(i?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)),l=Math.sin(Math.min(s,Math.PI/2)),h=n*(n>0?e:t),d=a*t,u=o*(o>0?e:t),c=l*(l>0?t:e);return{x:h,y:i?-1*c:u,width:d-h,height:c-u}}}ut.prototype._centroid=!0,ut.prototype.className="Arc",ut.prototype._attrsAffectingSize=["innerRadius","outerRadius"],fe(ut),v.addGetterSetter(ut,"innerRadius",0,x()),v.addGetterSetter(ut,"outerRadius",0,x()),v.addGetterSetter(ut,"angle",0,x()),v.addGetterSetter(ut,"clockwise",!1,Xe());function ks(r,e,t,i,s,n,a){var o=Math.sqrt(Math.pow(t-r,2)+Math.pow(i-e,2)),l=Math.sqrt(Math.pow(s-t,2)+Math.pow(n-i,2)),h=a*o/(o+l),d=a*l/(o+l),u=t-h*(s-r),c=i-h*(n-e),p=t+d*(s-r),f=i+d*(n-e);return[u,c,p,f]}function fa(r,e){var t=r.length,i=[],s,n;for(s=2;s<t-2;s+=2)n=ks(r[s-2],r[s-1],r[s],r[s+1],r[s+2],r[s+3],e),!isNaN(n[0])&&(i.push(n[0]),i.push(n[1]),i.push(r[s]),i.push(r[s+1]),i.push(n[2]),i.push(n[3]));return i}class ct 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(),i=t.length,s=this.tension(),n=this.closed(),a=this.bezier(),o,l,h;if(i){if(e.beginPath(),e.moveTo(t[0],t[1]),s!==0&&i>4){for(o=this.getTensionPoints(),l=o.length,h=n?0:4,n||e.quadraticCurveTo(o[0],o[1],o[2],o[3]);h<l-2;)e.bezierCurveTo(o[h++],o[h++],o[h++],o[h++],o[h++],o[h++]);n||e.quadraticCurveTo(o[l-2],o[l-1],t[i-2],t[i-1])}else if(a)for(h=2;h<i;)e.bezierCurveTo(t[h++],t[h++],t[h++],t[h++],t[h++],t[h++]);else for(h=2;h<i;h+=2)e.lineTo(t[h],t[h+1]);n?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():fa(this.points(),this.tension())}_getTensionPointsClosed(){var e=this.points(),t=e.length,i=this.tension(),s=ks(e[t-2],e[t-1],e[0],e[1],e[2],e[3],i),n=ks(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],i),a=fa(e,i),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],i=e[0],s=e[1],n=e[1],a,o,l=0;l<e.length/2;l++)a=e[l*2],o=e[l*2+1],t=Math.min(t,a),i=Math.max(i,a),s=Math.min(s,o),n=Math.max(n,o);return{x:t,y:s,width:i-t,height:n-s}}}ct.prototype.className="Line",ct.prototype._attrsAffectingSize=["points","bezier","tension"],fe(ct),v.addGetterSetter(ct,"closed",!1),v.addGetterSetter(ct,"bezier",!1),v.addGetterSetter(ct,"tension",0,x()),v.addGetterSetter(ct,"points",[],rl());class le extends E{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this.dataArray=le.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=le.parsePathData(this.data()),this.pathLength=0;for(var i=0;i<this.dataArray.length;++i)this.pathLength+=this.dataArray[i].pathLength})}_sceneFunc(e){var t=this.dataArray;e.beginPath();for(var i=!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],l=a[1],h=a[2],d=a[3],u=a[4],c=a[5],p=a[6],f=a[7],m=h>d?h:d,g=h>d?1:h/d,_=h>d?d/h:1;e.translate(o,l),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,-l);break;case"z":i=!0,e.closePath();break}}!i&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getSelfRect(){var e=[];this.dataArray.forEach(function(h){if(h.command==="A"){var d=h.points[4],u=h.points[5],c=h.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=le.getPointOnEllipticalArc(h.points[0],h.points[1],h.points[2],h.points[3],f,0);e.push(m.x,m.y)}else for(let f=d+p;f<c;f+=p){const m=le.getPointOnEllipticalArc(h.points[0],h.points[1],h.points[2],h.points[3],f,0);e.push(m.x,m.y)}}else if(h.command==="C")for(let f=0;f<=1;f+=.01){const m=le.getPointOnCubicBezier(f,h.start.x,h.start.y,h.points[0],h.points[1],h.points[2],h.points[3],h.points[4],h.points[5]);e.push(m.x,m.y)}else e=e.concat(h.points)});for(var t=e[0],i=e[0],s=e[1],n=e[1],a,o,l=0;l<e.length/2;l++)a=e[l*2],o=e[l*2+1],isNaN(a)||(t=Math.min(t,a),i=Math.max(i,a)),isNaN(o)||(s=Math.min(s,o),n=Math.max(n,o));return{x:t,y:s,width:i-t,height:n-s}}getLength(){return this.pathLength}getPointAtLength(e){var t,i=0,s=this.dataArray.length;if(!s)return null;for(;i<s&&e>this.dataArray[i].pathLength;)e-=this.dataArray[i].pathLength,++i;if(i===s)return t=this.dataArray[i-1].points.slice(-2),{x:t[0],y:t[1]};if(e<.01)return t=this.dataArray[i].points.slice(0,2),{x:t[0],y:t[1]};var n=this.dataArray[i],a=n.points;switch(n.command){case"L":return le.getPointOnLine(e,n.start.x,n.start.y,a[0],a[1]);case"C":return le.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 le.getPointOnQuadraticBezier(e/n.pathLength,n.start.x,n.start.y,a[0],a[1],a[2],a[3]);case"A":var o=a[0],l=a[1],h=a[2],d=a[3],u=a[4],c=a[5],p=a[6];return u+=c*e/n.pathLength,le.getPointOnEllipticalArc(o,l,h,d,u,p)}return null}static getLineLength(e,t,i,s){return Math.sqrt((i-e)*(i-e)+(s-t)*(s-t))}static getPointOnLine(e,t,i,s,n,a,o){a===void 0&&(a=t),o===void 0&&(o=i);var l=(n-i)/(s-t+1e-8),h=Math.sqrt(e*e/(1+l*l));s<t&&(h*=-1);var d=l*h,u;if(s===t)u={x:a,y:o+d};else if((o-i)/(a-t+1e-8)===l)u={x:a+h,y:o+d};else{var c,p,f=this.getLineLength(t,i,s,n),m=(a-t)*(s-t)+(o-i)*(n-i);m=m/(f*f),c=t+m*(s-t),p=i+m*(n-i);var g=this.getLineLength(a,o,c,p),_=Math.sqrt(e*e-g*g);h=Math.sqrt(_*_/(1+l*l)),s<t&&(h*=-1),d=l*h,u={x:c+h,y:p+d}}return u}static getPointOnCubicBezier(e,t,i,s,n,a,o,l,h){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=l*d(e)+a*u(e)+s*c(e)+t*p(e),m=h*d(e)+o*u(e)+n*c(e)+i*p(e);return{x:f,y:m}}static getPointOnQuadraticBezier(e,t,i,s,n,a,o){function l(p){return p*p}function h(p){return 2*p*(1-p)}function d(p){return(1-p)*(1-p)}var u=a*l(e)+s*h(e)+t*d(e),c=o*l(e)+n*h(e)+i*d(e);return{x:u,y:c}}static getPointOnEllipticalArc(e,t,i,s,n,a){var o=Math.cos(a),l=Math.sin(a),h={x:i*Math.cos(n),y:s*Math.sin(n)};return{x:e+(h.x*o-h.y*l),y:t+(h.x*l+h.y*o)}}static parsePathData(e){if(!e)return[];var t=e,i=["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<i.length;s++)t=t.replace(new RegExp(i[s],"g"),"|"+i[s]);var n=t.split("|"),a=[],o=[],l=0,h=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=l,L=h,A,G,R,F,V,I,K,W,he,ae;switch(p){case"l":l+=f.shift(),h+=f.shift(),w="L",b.push(l,h);break;case"L":l=f.shift(),h=f.shift(),b.push(l,h);break;case"m":var U=f.shift(),Ee=f.shift();if(l+=U,h+=Ee,w="M",a.length>2&&a[a.length-1].command==="z"){for(var De=a.length-2;De>=0;De--)if(a[De].command==="M"){l=a[De].points[0]+U,h=a[De].points[1]+Ee;break}}b.push(l,h),p="l";break;case"M":l=f.shift(),h=f.shift(),w="M",b.push(l,h),p="L";break;case"h":l+=f.shift(),w="L",b.push(l,h);break;case"H":l=f.shift(),w="L",b.push(l,h);break;case"v":h+=f.shift(),w="L",b.push(l,h);break;case"V":h=f.shift(),w="L",b.push(l,h);break;case"C":b.push(f.shift(),f.shift(),f.shift(),f.shift()),l=f.shift(),h=f.shift(),b.push(l,h);break;case"c":b.push(l+f.shift(),h+f.shift(),l+f.shift(),h+f.shift()),l+=f.shift(),h+=f.shift(),w="C",b.push(l,h);break;case"S":G=l,R=h,A=a[a.length-1],A.command==="C"&&(G=l+(l-A.points[2]),R=h+(h-A.points[3])),b.push(G,R,f.shift(),f.shift()),l=f.shift(),h=f.shift(),w="C",b.push(l,h);break;case"s":G=l,R=h,A=a[a.length-1],A.command==="C"&&(G=l+(l-A.points[2]),R=h+(h-A.points[3])),b.push(G,R,l+f.shift(),h+f.shift()),l+=f.shift(),h+=f.shift(),w="C",b.push(l,h);break;case"Q":b.push(f.shift(),f.shift()),l=f.shift(),h=f.shift(),b.push(l,h);break;case"q":b.push(l+f.shift(),h+f.shift()),l+=f.shift(),h+=f.shift(),w="Q",b.push(l,h);break;case"T":G=l,R=h,A=a[a.length-1],A.command==="Q"&&(G=l+(l-A.points[0]),R=h+(h-A.points[1])),l=f.shift(),h=f.shift(),w="Q",b.push(G,R,l,h);break;case"t":G=l,R=h,A=a[a.length-1],A.command==="Q"&&(G=l+(l-A.points[0]),R=h+(h-A.points[1])),l+=f.shift(),h+=f.shift(),w="Q",b.push(G,R,l,h);break;case"A":F=f.shift(),V=f.shift(),I=f.shift(),K=f.shift(),W=f.shift(),he=l,ae=h,l=f.shift(),h=f.shift(),w="A",b=this.convertEndpointToCenterParameterization(he,ae,l,h,K,W,F,V,I);break;case"a":F=f.shift(),V=f.shift(),I=f.shift(),K=f.shift(),W=f.shift(),he=l,ae=h,l+=f.shift(),h+=f.shift(),w="A",b=this.convertEndpointToCenterParameterization(he,ae,l,h,K,W,F,V,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,i,s){var n,a,o,l,h=le;switch(i){case"L":return h.getLineLength(e,t,s[0],s[1]);case"C":for(n=0,a=h.getPointOnCubicBezier(0,e,t,s[0],s[1],s[2],s[3],s[4],s[5]),l=.01;l<=1;l+=.01)o=h.getPointOnCubicBezier(l,e,t,s[0],s[1],s[2],s[3],s[4],s[5]),n+=h.getLineLength(a.x,a.y,o.x,o.y),a=o;return n;case"Q":for(n=0,a=h.getPointOnQuadraticBezier(0,e,t,s[0],s[1],s[2],s[3]),l=.01;l<=1;l+=.01)o=h.getPointOnQuadraticBezier(l,e,t,s[0],s[1],s[2],s[3]),n+=h.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=h.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],d,0),u<0)for(l=d-p;l>c;l-=p)o=h.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],l,0),n+=h.getLineLength(a.x,a.y,o.x,o.y),a=o;else for(l=d+p;l<c;l+=p)o=h.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],l,0),n+=h.getLineLength(a.x,a.y,o.x,o.y),a=o;return o=h.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],c,0),n+=h.getLineLength(a.x,a.y,o.x,o.y),n}return 0}static convertEndpointToCenterParameterization(e,t,i,s,n,a,o,l,h){var d=h*(Math.PI/180),u=Math.cos(d)*(e-i)/2+Math.sin(d)*(t-s)/2,c=-1*Math.sin(d)*(e-i)/2+Math.cos(d)*(t-s)/2,p=u*u/(o*o)+c*c/(l*l);p>1&&(o*=Math.sqrt(p),l*=Math.sqrt(p));var f=Math.sqrt((o*o*(l*l)-o*o*(c*c)-l*l*(u*u))/(o*o*(c*c)+l*l*(u*u)));n===a&&(f*=-1),isNaN(f)&&(f=0);var m=f*o*c/l,g=f*-l*u/o,_=(e+i)/2+Math.cos(d)*m-Math.sin(d)*g,w=(t+s)/2+Math.sin(d)*m+Math.cos(d)*g,b=function(V){return Math.sqrt(V[0]*V[0]+V[1]*V[1])},T=function(V,I){return(V[0]*I[0]+V[1]*I[1])/(b(V)*b(I))},L=function(V,I){return(V[0]*I[1]<V[1]*I[0]?-1:1)*Math.acos(T(V,I))},A=L([1,0],[(u-m)/o,(c-g)/l]),G=[(u-m)/o,(c-g)/l],R=[(-1*u-m)/o,(-1*c-g)/l],F=L(G,R);return T(G,R)<=-1&&(F=Math.PI),T(G,R)>=1&&(F=0),a===0&&F>0&&(F=F-2*Math.PI),a===1&&F<0&&(F=F+2*Math.PI),[_,w,o,l,A,F,d,a]}}le.prototype.className="Path",le.prototype._attrsAffectingSize=["data"],fe(le),v.addGetterSetter(le,"data");class zt extends ct{_sceneFunc(e){super._sceneFunc(e);var t=Math.PI*2,i=this.points(),s=i,n=this.tension()!==0&&i.length>4;n&&(s=this.getTensionPoints());var a=this.pointerLength(),o=i.length,l,h;if(n){const c=[s[s.length-4],s[s.length-3],s[s.length-2],s[s.length-1],i[o-2],i[o-1]],p=le.calcLength(s[s.length-4],s[s.length-3],"C",c),f=le.getPointOnQuadraticBezier(Math.min(1,1-a/p),c[0],c[1],c[2],c[3],c[4],c[5]);l=i[o-2]-f.x,h=i[o-1]-f.y}else l=i[o-2]-i[o-4],h=i[o-1]-i[o-3];var d=(Math.atan2(h,l)+t)%t,u=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(i[o-2],i[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(i[0],i[1]),n?(l=(s[0]+s[2])/2-i[0],h=(s[1]+s[3])/2-i[1]):(l=i[2]-i[0],h=i[3]-i[1]),e.rotate((Math.atan2(-h,-l)+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}}}zt.prototype.className="Arrow",fe(zt),v.addGetterSetter(zt,"pointerLength",10,x()),v.addGetterSetter(zt,"pointerWidth",10,x()),v.addGetterSetter(zt,"pointerAtBeginning",!1),v.addGetterSetter(zt,"pointerAtEnding",!0);class ni 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)}}ni.prototype._centroid=!0,ni.prototype.className="Circle",ni.prototype._attrsAffectingSize=["radius"],fe(ni),v.addGetterSetter(ni,"radius",0,x());class kt extends E{_sceneFunc(e){var t=this.radiusX(),i=this.radiusY();e.beginPath(),e.save(),t!==i&&e.scale(1,i/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)}}kt.prototype.className="Ellipse",kt.prototype._centroid=!0,kt.prototype._attrsAffectingSize=["radiusX","radiusY"],fe(kt),v.addComponentsGetterSetter(kt,"radius",["x","y"]),v.addGetterSetter(kt,"radiusX",0,x()),v.addGetterSetter(kt,"radiusY",0,x());class qe 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(),i=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,i]:n=[s,0,0,t,i]}(this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,t,i),e.closePath(),e.fillStrokeShape(this)),s&&e.drawImage.apply(e,n)}_hitFunc(e){var t=this.width(),i=this.height();e.beginPath(),e.rect(0,0,t,i),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,i=null){var s=y.createImageElement();s.onload=function(){var n=new qe({image:s});t(n)},s.onerror=i,s.crossOrigin="Anonymous",s.src=e}}qe.prototype.className="Image",fe(qe),v.addGetterSetter(qe,"image"),v.addComponentsGetterSetter(qe,"crop",["x","y","width","height"]),v.addGetterSetter(qe,"cropX",0,x()),v.addGetterSetter(qe,"cropY",0,x()),v.addGetterSetter(qe,"cropWidth",0,x()),v.addGetterSetter(qe,"cropHeight",0,x());var pa=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Xl="Change.konva",ql="none",xs="up",Ps="right",As="down",Os="left",Yl=pa.length;class Ms extends si{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,i,s=function(){t._sync()};for(i=0;i<Yl;i++)e.on(pa[i]+Xl,s)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e=this.getText(),t=this.getTag(),i,s,n,a,o,l,h;if(e&&t){switch(i=e.width(),s=e.height(),n=t.pointerDirection(),a=t.pointerWidth(),h=t.pointerHeight(),o=0,l=0,n){case xs:o=i/2,l=-1*h;break;case Ps:o=i+a,l=s/2;break;case As:o=i/2,l=s+h;break;case Os:o=-1*a,l=s/2;break}t.setAttrs({x:-1*o,y:-1*l,width:i,height:s}),e.setAttrs({x:-1*o,y:-1*l})}}}Ms.prototype.className="Label",fe(Ms);class Wt extends E{_sceneFunc(e){var t=this.width(),i=this.height(),s=this.pointerDirection(),n=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius();let l=0,h=0,d=0,u=0;typeof o=="number"?l=h=d=u=Math.min(o,t/2,i/2):(l=Math.min(o[0]||0,t/2,i/2),h=Math.min(o[1]||0,t/2,i/2),u=Math.min(o[2]||0,t/2,i/2),d=Math.min(o[3]||0,t/2,i/2)),e.beginPath(),e.moveTo(l,0),s===xs&&(e.lineTo((t-n)/2,0),e.lineTo(t/2,-1*a),e.lineTo((t+n)/2,0)),e.lineTo(t-h,0),e.arc(t-h,h,h,Math.PI*3/2,0,!1),s===Ps&&(e.lineTo(t,(i-a)/2),e.lineTo(t+n,i/2),e.lineTo(t,(i+a)/2)),e.lineTo(t,i-u),e.arc(t-u,i-u,u,0,Math.PI/2,!1),s===As&&(e.lineTo((t+n)/2,i),e.lineTo(t/2,i+a),e.lineTo((t-n)/2,i)),e.lineTo(d,i),e.arc(d,i-d,d,Math.PI/2,Math.PI,!1),s===Os&&(e.lineTo(0,(i+a)/2),e.lineTo(-1*n,i/2),e.lineTo(0,(i-a)/2)),e.lineTo(0,l),e.arc(l,l,l,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){var e=0,t=0,i=this.pointerWidth(),s=this.pointerHeight(),n=this.pointerDirection(),a=this.width(),o=this.height();return n===xs?(t-=s,o+=s):n===As?o+=s:n===Os?(e-=i*1.5,a+=i):n===Ps&&(a+=i*1.5),{x:e,y:t,width:a,height:o}}}Wt.prototype.className="Tag",fe(Wt),v.addGetterSetter(Wt,"pointerDirection",ql),v.addGetterSetter(Wt,"pointerWidth",0,x()),v.addGetterSetter(Wt,"pointerHeight",0,x()),v.addGetterSetter(Wt,"cornerRadius",0,Ln(4));class Ni extends E{_sceneFunc(e){var t=this.cornerRadius(),i=this.width(),s=this.height();if(e.beginPath(),!t)e.rect(0,0,i,s);else{let n=0,a=0,o=0,l=0;typeof t=="number"?n=a=o=l=Math.min(t,i/2,s/2):(n=Math.min(t[0]||0,i/2,s/2),a=Math.min(t[1]||0,i/2,s/2),l=Math.min(t[2]||0,i/2,s/2),o=Math.min(t[3]||0,i/2,s/2)),e.moveTo(n,0),e.lineTo(i-a,0),e.arc(i-a,a,a,Math.PI*3/2,0,!1),e.lineTo(i,s-l),e.arc(i-l,s-l,l,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)}}Ni.prototype.className="Rect",fe(Ni),v.addGetterSetter(Ni,"cornerRadius",0,Ln(4));class Ut extends E{_sceneFunc(e){const t=this._getPoints();e.beginPath(),e.moveTo(t[0].x,t[0].y);for(var i=1;i<t.length;i++)e.lineTo(t[i].x,t[i].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,i=[];for(var s=0;s<e;s++)i.push({x:t*Math.sin(s*2*Math.PI/e),y:-1*t*Math.cos(s*2*Math.PI/e)});return i}getSelfRect(){const e=this._getPoints();var t=e[0].x,i=e[0].y,s=e[0].x,n=e[0].y;return e.forEach(a=>{t=Math.min(t,a.x),i=Math.max(i,a.x),s=Math.min(s,a.y),n=Math.max(n,a.y)}),{x:t,y:s,width:i-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)}}Ut.prototype.className="RegularPolygon",Ut.prototype._centroid=!0,Ut.prototype._attrsAffectingSize=["radius"],fe(Ut),v.addGetterSetter(Ut,"radius",0,x()),v.addGetterSetter(Ut,"sides",0,x());var ma=Math.PI*2;class Zt extends E{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,ma,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),ma,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)}}Zt.prototype.className="Ring",Zt.prototype._centroid=!0,Zt.prototype._attrsAffectingSize=["innerRadius","outerRadius"],fe(Zt),v.addGetterSetter(Zt,"innerRadius",0,x()),v.addGetterSetter(Zt,"outerRadius",0,x());class rt extends E{constructor(e){super(e),this._updated=!0,this.anim=new Ve(()=>{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(),i=this.frameIndex(),s=i*4,n=this.animations()[t],a=this.frameOffsets(),o=n[s+0],l=n[s+1],h=n[s+2],d=n[s+3],u=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,h,d),e.closePath(),e.fillStrokeShape(this)),u)if(a){var c=a[t],p=i*2;e.drawImage(u,o,l,h,d,c[p+0],c[p+1],h,d)}else e.drawImage(u,o,l,h,d,0,0,h,d)}_hitFunc(e){var t=this.animation(),i=this.frameIndex(),s=i*4,n=this.animations()[t],a=this.frameOffsets(),o=n[s+2],l=n[s+3];if(e.beginPath(),a){var h=a[t],d=i*2;e.rect(h[d+0],h[d+1],o,l)}else e.rect(0,0,o,l);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(),i=this.animations(),s=i[t],n=s.length/4;e<n-1?this.frameIndex(e+1):this.frameIndex(0)}}rt.prototype.className="Sprite",fe(rt),v.addGetterSetter(rt,"animation"),v.addGetterSetter(rt,"animations"),v.addGetterSetter(rt,"frameOffsets"),v.addGetterSetter(rt,"image"),v.addGetterSetter(rt,"frameIndex",0,x()),v.addGetterSetter(rt,"frameRate",17,x()),v.backCompat(rt,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class xt extends E{_sceneFunc(e){var t=this.innerRadius(),i=this.outerRadius(),s=this.numPoints();e.beginPath(),e.moveTo(0,0-i);for(var n=1;n<s*2;n++){var a=n%2===0?i:t,o=a*Math.sin(n*Math.PI/s),l=-1*a*Math.cos(n*Math.PI/s);e.lineTo(o,l)}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)}}xt.prototype.className="Star",xt.prototype._centroid=!0,xt.prototype._attrsAffectingSize=["innerRadius","outerRadius"],fe(xt),v.addGetterSetter(xt,"numPoints",5,x()),v.addGetterSetter(xt,"innerRadius",0,x()),v.addGetterSetter(xt,"outerRadius",0,x());function ga(r){return Array.from(r)}var ai="auto",Kl="center",Di="justify",Jl="Change.konva",Ql="2d",va="-",ya="left",ed="text",td="Text",id="top",rd="bottom",ba="middle",_a="normal",sd="px ",Tr=" ",nd="right",ad="word",od="char",wa="none",Ls="…",Sa=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],hd=Sa.length;function ld(r){return r.split(",").map(e=>{e=e.trim();const t=e.indexOf(" ")>=0,i=e.indexOf('"')>=0||e.indexOf("'")>=0;return t&&!i&&(e=`"${e}"`),e}).join(", ")}var Cr;function Rs(){return Cr||(Cr=y.createCanvasElement().getContext(Ql),Cr)}function dd(r){r.fillText(this._partialText,this._partialTextX,this._partialTextY)}function ud(r){r.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function cd(r){return r=r||{},!r.fillLinearGradientColorStops&&!r.fillRadialGradientColorStops&&!r.fillPatternImage&&(r.fill=r.fill||"black"),r}class pe extends E{constructor(e){super(cd(e)),this._partialTextX=0,this._partialTextY=0;for(var t=0;t<hd;t++)this.on(Sa[t]+Jl,this._setTextData);this._setTextData()}_sceneFunc(e){var t=this.textArr,i=t.length;if(this.text()){var s=this.padding(),n=this.fontSize(),a=this.lineHeight()*n,o=this.verticalAlign(),l=0,h=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",ba),e.setAttr("textAlign",ya),o===ba?l=(this.getHeight()-i*a-s*2)/2:o===rd&&(l=this.getHeight()-i*a-s*2),e.translate(s,l+s),g=0;g<i;g++){var w=0,b=0,T=t[g],L=T.text,A=T.width,G=T.lastInParagraph,R,F,V;if(e.save(),h===nd?w+=d-A-s*2:h===Kl&&(w+=(d-A-s*2)/2),f&&(e.save(),e.beginPath(),e.moveTo(w,_+b+Math.round(n/2)),R=L.split(" ").length-1,F=R===0,V=h===Di&&G&&!F?d-s*2:A,e.lineTo(w+Math.round(V),_+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,F=R===0,V=h===Di&&G&&!F?d-s*2:A,e.lineTo(w+Math.round(V),_+b),e.lineWidth=n/15,e.strokeStyle=c,e.stroke(),e.restore()),u!==0||h===Di){R=L.split(" ").length-1;for(var I=ga(L),K=0;K<I.length;K++){var W=I[K];W===" "&&!G&&h===Di&&(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(),i>1&&(_+=a)}}}_hitFunc(e){var t=this.getWidth(),i=this.getHeight();e.beginPath(),e.rect(0,0,t,i),e.closePath(),e.fillStrokeShape(this)}setText(e){var t=y._isString(e)?e:e==null?"":e+"";return this._setAttr(ed,t),this}getWidth(){var e=this.attrs.width===ai||this.attrs.width===void 0;return e?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){var e=this.attrs.height===ai||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=Rs(),i=this.fontSize(),s;return t.save(),t.font=this._getContextFont(),s=t.measureText(e),t.restore(),{width:s.width,height:i}}_getContextFont(){return this.fontStyle()+Tr+this.fontVariant()+Tr+(this.fontSize()+sd)+ld(this.fontFamily())}_addTextLine(e){this.align()===Di&&(e=e.trim());var t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){var t=this.letterSpacing(),i=e.length;return Rs().measureText(e).width+(i?t*(i-1):0)}_setTextData(){var e=this.text().split(`
2
+ `),t=+this.fontSize(),i=0,s=this.lineHeight()*t,n=this.attrs.width,a=this.attrs.height,o=n!==ai&&n!==void 0,l=a!==ai&&a!==void 0,h=this.padding(),d=n-h*2,u=a-h*2,c=0,p=this.wrap(),f=p!==wa,m=p!==od&&f,g=this.ellipsis();this.textArr=[],Rs().font=this._getContextFont();for(var _=g?this._getTextWidth(Ls):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="",F=0;A<G;){var V=A+G>>>1,I=T.slice(0,V+1),K=this._getTextWidth(I)+_;K<=d?(A=V+1,R=I,F=K):G=V}if(R){if(m){var W,he=T[R.length],ae=he===Tr||he===va;ae&&F<=d?W=R.length:W=Math.max(R.lastIndexOf(Tr),R.lastIndexOf(va))+1,W>0&&(A=W,R=R.slice(0,A),F=this._getTextWidth(R))}R=R.trimRight(),this._addTextLine(R),i=Math.max(i,F),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,i=Math.max(i,L);break}}else break}else this._addTextLine(T),c+=s,i=Math.max(i,L),this._shouldHandleEllipsis(c)&&w<b-1&&this._tryToAddEllipsisToLastLine();if(l&&c+s>u)break;this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0)}this.textHeight=t,this.textWidth=i}_shouldHandleEllipsis(e){var t=+this.fontSize(),i=this.lineHeight()*t,s=this.attrs.height,n=s!==ai&&s!==void 0,a=this.padding(),o=s-a*2,l=this.wrap(),h=l!==wa;return!h||n&&e+i>o}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,t=e!==ai&&e!==void 0,i=this.padding(),s=e-i*2,n=this.ellipsis(),a=this.textArr[this.textArr.length-1];if(!(!a||!n)){if(t){var o=this._getTextWidth(a.text+Ls)<s;o||(a.text=a.text.slice(0,a.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(a.text+Ls)}}getStrokeScaleEnabled(){return!0}}pe.prototype._fillFunc=dd,pe.prototype._strokeFunc=ud,pe.prototype.className=td,pe.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],fe(pe),v.overWriteSetter(pe,"width",ps()),v.overWriteSetter(pe,"height",ps()),v.addGetterSetter(pe,"fontFamily","Arial"),v.addGetterSetter(pe,"fontSize",12,x()),v.addGetterSetter(pe,"fontStyle",_a),v.addGetterSetter(pe,"fontVariant",_a),v.addGetterSetter(pe,"padding",0,x()),v.addGetterSetter(pe,"align",ya),v.addGetterSetter(pe,"verticalAlign",id),v.addGetterSetter(pe,"lineHeight",1,x()),v.addGetterSetter(pe,"wrap",ad),v.addGetterSetter(pe,"ellipsis",!1,Xe()),v.addGetterSetter(pe,"letterSpacing",0,x()),v.addGetterSetter(pe,"text","",ei()),v.addGetterSetter(pe,"textDecoration","");var fd="",Ta="normal";function Ca(r){r.fillText(this.partialText,0,0)}function Ea(r){r.strokeText(this.partialText,0,0)}class we extends E{constructor(e){super(e),this.dummyCanvas=y.createCanvasElement(),this.dataArray=[],this.dataArray=le.parsePathData(this.attrs.data),this.on("dataChange.konva",function(){this.dataArray=le.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(),i=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=i,e.lineWidth=s/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var t=this.glyphInfo;if(t.length>=1){var i=t[0].p0;e.moveTo(i.x,i.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 pe.prototype.setText.call(this,e)}_getContextFont(){return pe.prototype._getContextFont.call(this)}_getTextSize(e){var t=this.dummyCanvas,i=t.getContext("2d");i.save(),i.font=this._getContextFont();var s=i.measureText(e);return i.restore(),{width:s.width,height:parseInt(this.attrs.fontSize,10)}}_setTextData(){var e=this,t=this._getTextSize(this.attrs.text),i=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)*i,0);this.glyphInfo=[];for(var o=0,l=0;l<e.dataArray.length;l++)e.dataArray[l].pathLength>0&&(o+=e.dataArray[l].pathLength);var h=0;s==="center"&&(h=Math.max(0,o/2-a/2)),s==="right"&&(h=Math.max(0,o-a));for(var d=ga(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+i;K===" "&&s==="justify"&&(W+=(o-a)/u);var he=0,ae=0;for(p=void 0;Math.abs(W-he)/W>.01&&ae<20;){ae++;for(var U=he;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 Ee=!1;switch(f.command){case"L":le.getLineLength(c.x,c.y,f.points[0],f.points[1])>W?p=le.getPointOnLine(W,c.x,c.y,f.points[0],f.points[1],c.x,c.y):f=void 0;break;case"A":var De=f.points[4],it=f.points[5],te=f.points[4]+it;g===0?g=De+1e-8:W>he?g+=Math.PI/180*it/Math.abs(it):g-=Math.PI/360*it/Math.abs(it),(it<0&&g<te||it>=0&&g>te)&&(g=te,Ee=!0),p=le.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>he?g+=(W-he)/f.pathLength/2:g=Math.max(g-(he-W)/f.pathLength/2,0),g>1&&(g=1,Ee=!0),p=le.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>he?g+=(W-he)/f.pathLength:g-=(he-W)/f.pathLength,g>1&&(g=1,Ee=!0),p=le.getPointOnQuadraticBezier(g,f.start.x,f.start.y,f.points[0],f.points[1],f.points[2],f.points[3]);break}p!==void 0&&(he=le.getLineLength(c.x,c.y,p.x,p.y)),Ee&&(Ee=!1,f=void 0)}},b="C",T=e._getTextSize(b).width+i,L=h/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=le.getLineLength(c.x,c.y,p.x,p.y),F=0;if(n)try{F=n(d[G-1],d[G])*this.fontSize()}catch{F=0}c.x+=F,p.x+=F,this.textWidth+=F;var V=le.getPointOnLine(F+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:V.x,transposeY:V.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,i=e[0]||0,s=e[1]||0,n=e[1]||0,a,o,l=0;l<e.length/2;l++)a=e[l*2],o=e[l*2+1],t=Math.min(t,a),i=Math.max(i,a),s=Math.min(s,o),n=Math.max(n,o);var h=this.fontSize();return{x:t-h/2,y:s-h/2,width:i-t+h,height:n-s+h}}destroy(){return y.releaseCanvas(this.dummyCanvas),super.destroy()}}we.prototype._fillFunc=Ca,we.prototype._strokeFunc=Ea,we.prototype._fillFuncHit=Ca,we.prototype._strokeFuncHit=Ea,we.prototype.className="TextPath",we.prototype._attrsAffectingSize=["text","fontSize","data"],fe(we),v.addGetterSetter(we,"data"),v.addGetterSetter(we,"fontFamily","Arial"),v.addGetterSetter(we,"fontSize",12,x()),v.addGetterSetter(we,"fontStyle",Ta),v.addGetterSetter(we,"align","left"),v.addGetterSetter(we,"letterSpacing",0,x()),v.addGetterSetter(we,"textBaseline","middle"),v.addGetterSetter(we,"fontVariant",Ta),v.addGetterSetter(we,"text",fd),v.addGetterSetter(we,"textDecoration",null),v.addGetterSetter(we,"kerningFunc",null);var ka="tr-konva",pd=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange"].map(r=>r+`.${ka}`).join(" "),xa="nodesRect",md=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],gd={"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 vd="ontouchstart"in D._global;function yd(r,e){if(r==="rotater")return"crosshair";e+=y.degToRad(gd[r]||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 Er=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],Pa=1e8;function bd(r){return{x:r.x+r.width/2*Math.cos(r.rotation)+r.height/2*Math.sin(-r.rotation),y:r.y+r.height/2*Math.cos(r.rotation)+r.width/2*Math.sin(r.rotation)}}function Aa(r,e,t){const i=t.x+(r.x-t.x)*Math.cos(e)-(r.y-t.y)*Math.sin(e),s=t.y+(r.x-t.x)*Math.sin(e)+(r.y-t.y)*Math.cos(e);return Object.assign(Object.assign({},r),{rotation:r.rotation+e,x:i,y:s})}function _d(r,e){const t=bd(r);return Aa(r,e,t)}function wd(r,e,t){let i=e;for(let s=0;s<r.length;s++){const n=D.getAngle(r[s]),a=Math.abs(n-e)%(Math.PI*2);Math.min(a,Math.PI*2-a)<t&&(i=n)}return i}class oe extends si{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(pd,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 ka+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(i=>{const s=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()},n=i._attrsAffectingSize.map(a=>a+"Change."+this._getEventNamespace()).join(" ");i.on(n,s),i.on(md.map(a=>a+`.${this._getEventNamespace()}`).join(" "),s),i.on(`absoluteTransformChange.${this._getEventNamespace()}`,s),this._proxyDrag(i)}),this._resetTransformCache();var t=!!this.findOne(".top-left");return t&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,i=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(i,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,i=>{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 l=o.getAbsolutePosition();o.setAbsolutePosition({x:l.x+n,y:l.y+a}),o.startDrag(i)}),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(xa),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(xa,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),i){var s=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=e.getAbsoluteScale(i),a=e.getAbsolutePosition(i),o=s.x*n.x-e.offsetX()*n.x,l=s.y*n.y-e.offsetY()*n.y;const h=(D.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),d={x:a.x+o*Math.cos(h)+l*Math.sin(-h),y:a.y+l*Math.cos(h)+o*Math.sin(h),width:s.width*n.x,height:s.height*n.y,rotation:h};return Aa(d,-D.getAngle(t),{x:0,y:0})}__getNodeRect(){var e=this.getNode();if(!e)return{x:-Pa,y:-Pa,width:0,height:0,rotation:0};const t=[];this.nodes().map(h=>{const d=h.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=h.getAbsoluteTransform();u.forEach(function(p){var f=c.point(p);t.push(f)})});const i=new Fe;i.rotate(-D.getAngle(this.rotation()));var s,n,a,o;t.forEach(function(h){var d=i.point(h);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)}),i.invert();const l=i.point({x:s,y:n});return{x:l.x,y:l.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(),Er.forEach((function(e){this._createAnchor(e)}).bind(this)),this._createAnchor("rotater")}_createAnchor(e){var t=new Ni({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:vd?10:"auto"}),i=this;t.on("mousedown touchstart",function(s){i._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=yd(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 i=this.getParent(),s=i.padding();t.beginPath(),t.rect(-s,-s,this.width()+s*2,this.height()+s*2),t.moveTo(this.width()/2,-s),i.rotateEnabled()&&t.lineTo(this.width()/2,-i.rotateAnchorOffset()*y._sign(this.height())-s),t.fillStrokeShape(this)},hitFunc:(t,i)=>{if(this.shouldOverdrawWholeArea()){var s=this.padding();t.beginPath(),t.rect(-s,-s,i.width()+s*2,i.height()+s*2),t.fillStrokeShape(i)}}});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(),i=t.width,s=t.height,n=Math.sqrt(Math.pow(i,2)+Math.pow(s,2));this.sin=Math.abs(s/n),this.cos=Math.abs(i/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(l=>{l._fire("transformstart",{evt:e.evt,target:l})})}_handleMouseMove(e){var t,i,s,n=this.findOne("."+this._movingAnchorName),a=n.getStage();a.setPointersPositions(e);const o=a.getPointerPosition();let l={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y};const h=n.getAbsolutePosition();this.anchorDragBoundFunc()&&(l=this.anchorDragBoundFunc()(h,l,e)),n.setAbsolutePosition(l);const d=n.getAbsolutePosition();if(!(h.x===d.x&&h.y===d.y)){if(this._movingAnchorName==="rotater"){var u=this._getNodeRect();t=n.x()-u.width/2,i=-n.y()+u.height/2;let K=Math.atan2(-i,t)+Math.PI/2;u.height<0&&(K-=Math.PI);var c=D.getAngle(this.rotation());const W=c+K,he=D.getAngle(this.rotationSnapTolerance()),U=wd(this.rotationSnaps(),W,he)-u.rotation,Ee=_d(u,U);this._fitNodesInto(Ee,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,i=s*this.sin*g,this.findOne(".top-left").x(f.x-t),this.findOne(".top-left").y(f.y-i)}}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,i=s*this.sin*g,this.findOne(".top-right").x(f.x+t),this.findOne(".top-right").y(f.y-i)}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,i=s*this.sin*g,n.x(f.x-t),n.y(f.y+i)}_=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,i=s*this.sin*g,this.findOne(".bottom-right").x(f.x+t),this.findOne(".bottom-right").y(f.y+i)}}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 F=this.findOne(".top-left").getAbsolutePosition();t=F.x,i=F.y;var V=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:i,width:V,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(i=>{i._fire("transformend",{evt:e,target:i})}),this._movingAnchorName=null}}_fitNodesInto(e,t){var i=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 Fe;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()(i,e);u?e=u:y.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,l=new Fe;l.translate(i.x,i.y),l.rotate(i.rotation),l.scale(i.width/o,i.height/o);const h=new Fe;h.translate(e.x,e.y),h.rotate(e.rotation),h.scale(e.width/o,e.height/o);const d=h.multiply(l.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 Fe;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 i=t.width,s=t.height,n=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),l=this.anchorSize();this.find("._anchor").forEach(h=>{h.setAttrs({width:l,height:l,offsetX:l/2,offsetY:l/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:l/2+o,offsetY:l/2+o,visible:a&&n.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:l/2+o,visible:a&&n.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:l/2-o,offsetY:l/2+o,visible:a&&n.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:s/2,offsetX:l/2+o,visible:a&&n.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:s/2,offsetX:l/2-o,visible:a&&n.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:s,offsetX:l/2+o,offsetY:l/2-o,visible:a&&n.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:s,offsetY:l/2-o,visible:a&&n.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:s,offsetX:l/2-o,offsetY:l/2-o,visible:a&&n.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:i/2,y:-this.rotateAnchorOffset()*y._sign(s)-o,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,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=""),si.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 Sd(r){return r instanceof Array||y.warn("enabledAnchors value should be an array"),r instanceof Array&&r.forEach(function(e){Er.indexOf(e)===-1&&y.warn("Unknown anchor name: "+e+". Available names are: "+Er.join(", "))}),r||[]}oe.prototype.className="Transformer",fe(oe),v.addGetterSetter(oe,"enabledAnchors",Er,Sd),v.addGetterSetter(oe,"flipEnabled",!0,Xe()),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 ft 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)}}ft.prototype.className="Wedge",ft.prototype._centroid=!0,ft.prototype._attrsAffectingSize=["radius"],fe(ft),v.addGetterSetter(ft,"radius",0,x()),v.addGetterSetter(ft,"angle",0,x()),v.addGetterSetter(ft,"clockwise",!1),v.backCompat(ft,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function Oa(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var Td=[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],Cd=[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 Ed(r,e){var t=r.data,i=r.width,s=r.height,n,a,o,l,h,d,u,c,p,f,m,g,_,w,b,T,L,A,G,R,F,V,I,K,W=e+e+1,he=i-1,ae=s-1,U=e+1,Ee=U*(U+1)/2,De=new Oa,it=null,te=De,ve=null,Ge=null,Ht=Td[e],Bt=Cd[e];for(o=1;o<W;o++)te=te.next=new Oa,o===U&&(it=te);for(te.next=De,u=d=0,a=0;a<s;a++){for(T=L=A=G=c=p=f=m=0,g=U*(R=t[d]),_=U*(F=t[d+1]),w=U*(V=t[d+2]),b=U*(I=t[d+3]),c+=Ee*R,p+=Ee*F,f+=Ee*V,m+=Ee*I,te=De,o=0;o<U;o++)te.r=R,te.g=F,te.b=V,te.a=I,te=te.next;for(o=1;o<U;o++)l=d+((he<o?he:o)<<2),c+=(te.r=R=t[l])*(K=U-o),p+=(te.g=F=t[l+1])*K,f+=(te.b=V=t[l+2])*K,m+=(te.a=I=t[l+3])*K,T+=R,L+=F,A+=V,G+=I,te=te.next;for(ve=De,Ge=it,n=0;n<i;n++)t[d+3]=I=m*Ht>>Bt,I!==0?(I=255/I,t[d]=(c*Ht>>Bt)*I,t[d+1]=(p*Ht>>Bt)*I,t[d+2]=(f*Ht>>Bt)*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,l=u+((l=n+e+1)<he?l:he)<<2,T+=ve.r=t[l],L+=ve.g=t[l+1],A+=ve.b=t[l+2],G+=ve.a=t[l+3],c+=T,p+=L,f+=A,m+=G,ve=ve.next,g+=R=Ge.r,_+=F=Ge.g,w+=V=Ge.b,b+=I=Ge.a,T-=R,L-=F,A-=V,G-=I,Ge=Ge.next,d+=4;u+=i}for(n=0;n<i;n++){for(L=A=G=T=p=f=m=c=0,d=n<<2,g=U*(R=t[d]),_=U*(F=t[d+1]),w=U*(V=t[d+2]),b=U*(I=t[d+3]),c+=Ee*R,p+=Ee*F,f+=Ee*V,m+=Ee*I,te=De,o=0;o<U;o++)te.r=R,te.g=F,te.b=V,te.a=I,te=te.next;for(h=i,o=1;o<=e;o++)d=h+n<<2,c+=(te.r=R=t[d])*(K=U-o),p+=(te.g=F=t[d+1])*K,f+=(te.b=V=t[d+2])*K,m+=(te.a=I=t[d+3])*K,T+=R,L+=F,A+=V,G+=I,te=te.next,o<ae&&(h+=i);for(d=n,ve=De,Ge=it,a=0;a<s;a++)l=d<<2,t[l+3]=I=m*Ht>>Bt,I>0?(I=255/I,t[l]=(c*Ht>>Bt)*I,t[l+1]=(p*Ht>>Bt)*I,t[l+2]=(f*Ht>>Bt)*I):t[l]=t[l+1]=t[l+2]=0,c-=g,p-=_,f-=w,m-=b,g-=ve.r,_-=ve.g,w-=ve.b,b-=ve.a,l=n+((l=a+U)<ae?l:ae)*i<<2,c+=T+=ve.r=t[l],p+=L+=ve.g=t[l+1],f+=A+=ve.b=t[l+2],m+=G+=ve.a=t[l+3],ve=ve.next,g+=R=Ge.r,_+=F=Ge.g,w+=V=Ge.b,b+=I=Ge.a,T-=R,L-=F,A-=V,G-=I,Ge=Ge.next,d+=i}}const kd=function(e){var t=Math.round(this.blurRadius());t>0&&Ed(e,t)};v.addGetterSetter(P,"blurRadius",0,x(),v.afterSetFilter);const xd=function(r){var e=this.brightness()*255,t=r.data,i=t.length,s;for(s=0;s<i;s+=4)t[s]+=e,t[s+1]+=e,t[s+2]+=e};v.addGetterSetter(P,"brightness",0,x(),v.afterSetFilter);const Pd=function(r){var e=Math.pow((this.contrast()+100)/100,2),t=r.data,i=t.length,s=150,n=150,a=150,o;for(o=0;o<i;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 Ad=function(r){var e=this.embossStrength()*10,t=this.embossWhiteLevel()*255,i=this.embossDirection(),s=this.embossBlend(),n=0,a=0,o=r.data,l=r.width,h=r.height,d=l*4,u=h;switch(i){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: "+i)}do{var c=(u-1)*d,p=n;u+p<1&&(p=0),u+p>h&&(p=0);var f=(u-1+p)*l*4,m=l;do{var g=c+(m-1)*4,_=a;m+_<1&&(_=0),m+_>l&&(_=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,F=L>0?L:-L;if(R>G&&(A=T),F>G&&(A=L),A*=e,s){var V=o[g]+A,I=o[g+1]+A,K=o[g+2]+A;o[g]=V>255?255:V<0?0:V,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 Is(r,e,t,i,s){var n=t-e,a=s-i,o;return n===0?i+a/2:a===0?i:(o=(r-e)/n,o=a*o+i,o)}const Od=function(r){var e=r.data,t=e.length,i=e[0],s=i,n,a=e[1],o=a,l,h=e[2],d=h,u,c,p=this.enhance();if(p!==0){for(c=0;c<t;c+=4)n=e[c+0],n<i?i=n:n>s&&(s=n),l=e[c+1],l<a?a=l:l>o&&(o=l),u=e[c+2],u<h?h=u:u>d&&(d=u);s===i&&(s=255,i=0),o===a&&(o=255,a=0),d===h&&(d=255,h=0);var f,m,g,_,w,b,T,L,A;for(p>0?(m=s+p*(255-s),g=i-p*(i-0),w=o+p*(255-o),b=a-p*(a-0),L=d+p*(255-d),A=h-p*(h-0)):(f=(s+i)*.5,m=s+p*(s-f),g=i+p*(i-f),_=(o+a)*.5,w=o+p*(o-_),b=a+p*(a-_),T=(d+h)*.5,L=d+p*(d-T),A=h+p*(h-T)),c=0;c<t;c+=4)e[c+0]=Is(e[c+0],i,s,g,m),e[c+1]=Is(e[c+1],a,o,b,w),e[c+2]=Is(e[c+2],h,d,A,L)}};v.addGetterSetter(P,"enhance",0,x(),v.afterSetFilter);const Md=function(r){var e=r.data,t=e.length,i,s;for(i=0;i<t;i+=4)s=.34*e[i]+.5*e[i+1]+.16*e[i+2],e[i]=s,e[i+1]=s,e[i+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 Ld=function(r){var e=r.data,t=e.length,i=1,s=Math.pow(2,this.saturation()),n=Math.abs(this.hue()+360)%360,a=this.luminance()*127,o,l=i*s*Math.cos(n*Math.PI/180),h=i*s*Math.sin(n*Math.PI/180),d=.299*i+.701*l+.167*h,u=.587*i-.587*l+.33*h,c=.114*i-.114*l-.497*h,p=.299*i-.299*l-.328*h,f=.587*i+.413*l+.035*h,m=.114*i-.114*l+.293*h,g=.299*i-.3*l+1.25*h,_=.587*i-.586*l-1.05*h,w=.114*i+.886*l-.2*h,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},Rd=function(r){var e=r.data,t=e.length,i=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),n=Math.abs(this.hue()+360)%360,a,o=i*s*Math.cos(n*Math.PI/180),l=i*s*Math.sin(n*Math.PI/180),h=.299*i+.701*o+.167*l,d=.587*i-.587*o+.33*l,u=.114*i-.114*o-.497*l,c=.299*i-.299*o-.328*l,p=.587*i+.413*o+.035*l,f=.114*i-.114*o+.293*l,m=.299*i-.3*o+1.25*l,g=.587*i-.586*o-1.05*l,_=.114*i+.886*o-.2*l,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]=h*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 Id=function(r){var e=r.data,t=e.length,i;for(i=0;i<t;i+=4)e[i]=255-e[i],e[i+1]=255-e[i+1],e[i+2]=255-e[i+2]};var Nd=function(r,e,t){var i=r.data,s=e.data,n=r.width,a=r.height,o=t.polarCenterX||n/2,l=t.polarCenterY||a/2,h,d,u,c=0,p=0,f=0,m=0,g,_=Math.sqrt(o*o+l*l);d=n-o,u=a-l,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(l+_*T/w*G),h=(u*n+d)*4,c=i[h+0],p=i[h+1],f=i[h+2],m=i[h+3],h=(L+T*n)*4,s[h+0]=c,s[h+1]=p,s[h+2]=f,s[h+3]=m},Dd=function(r,e,t){var i=r.data,s=e.data,n=r.width,a=r.height,o=t.polarCenterX||n/2,l=t.polarCenterY||a/2,h,d,u,c,p,f=0,m=0,g=0,_=0,w,b=Math.sqrt(o*o+l*l);d=n-o,u=a-l,w=Math.sqrt(d*d+u*u),b=w>b?w:b;var T=a,L=n,A,G,R=t.polarRotation||0,F,V;for(d=0;d<n;d+=1)for(u=0;u<a;u+=1)c=d-o,p=u-l,A=Math.sqrt(c*c+p*p)*T/b,G=(Math.atan2(p,c)*180/Math.PI+360+R)%360,G=G*L/360,F=Math.floor(G),V=Math.floor(A),h=(V*n+F)*4,f=i[h+0],m=i[h+1],g=i[h+2],_=i[h+3],h=(u*n+d)*4,s[h+0]=f,s[h+1]=m,s[h+2]=g,s[h+3]=_};const Gd=function(r){var e=r.width,t=r.height,i,s,n,a,o,l,h,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),Nd(r,_,{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(i=T;i!==L;i+=A)n=Math.round(i+m)%e,u=(e*s+n)*4,o=_.data[u+0],l=_.data[u+1],h=_.data[u+2],d=_.data[u+3],c=(e*s+i)*4,_.data[c+0]=o,_.data[c+1]=l,_.data[c+2]=h,_.data[c+3]=d;for(s=0;s<t;s+=1)for(b=Math.floor(w),a=0;a<p;a+=1){for(i=0;i<b+1;i+=1)u=(e*s+i)*4,o=_.data[u+0],l=_.data[u+1],h=_.data[u+2],d=_.data[u+3],c=(e*s+b*2-i-1)*4,_.data[c+0]=o,_.data[c+1]=l,_.data[c+2]=h,_.data[c+3]=d;b*=2}Dd(_,r,{polarRotation:0})}};v.addGetterSetter(P,"kaleidoscopePower",2,x(),v.afterSetFilter),v.addGetterSetter(P,"kaleidoscopeAngle",0,x(),v.afterSetFilter);function kr(r,e,t){var i=(t*r.width+e)*4,s=[];return s.push(r.data[i++],r.data[i++],r.data[i++],r.data[i++]),s}function Gi(r,e){return Math.sqrt(Math.pow(r[0]-e[0],2)+Math.pow(r[1]-e[1],2)+Math.pow(r[2]-e[2],2))}function Fd(r){for(var e=[0,0,0],t=0;t<r.length;t++)e[0]+=r[t][0],e[1]+=r[t][1],e[2]+=r[t][2];return e[0]/=r.length,e[1]/=r.length,e[2]/=r.length,e}function Hd(r,e){var t=kr(r,0,0),i=kr(r,r.width-1,0),s=kr(r,0,r.height-1),n=kr(r,r.width-1,r.height-1),a=e||10;if(Gi(t,i)<a&&Gi(i,n)<a&&Gi(n,s)<a&&Gi(s,t)<a){for(var o=Fd([i,t,n,s]),l=[],h=0;h<r.width*r.height;h++){var d=Gi(o,[r.data[h*4],r.data[h*4+1],r.data[h*4+2]]);l[h]=d<a?0:255}return l}}function Bd(r,e){for(var t=0;t<r.width*r.height;t++)r.data[4*t+3]=e[t]}function $d(r,e,t){for(var i=[1,1,1,1,0,1,1,1,1],s=Math.round(Math.sqrt(i.length)),n=Math.floor(s/2),a=[],o=0;o<t;o++)for(var l=0;l<e;l++){for(var h=o*e+l,d=0,u=0;u<s;u++)for(var c=0;c<s;c++){var p=o+u-n,f=l+c-n;if(p>=0&&p<t&&f>=0&&f<e){var m=p*e+f,g=i[u*s+c];d+=r[m]*g}}a[h]=d===255*8?255:0}return a}function Vd(r,e,t){for(var i=[1,1,1,1,1,1,1,1,1],s=Math.round(Math.sqrt(i.length)),n=Math.floor(s/2),a=[],o=0;o<t;o++)for(var l=0;l<e;l++){for(var h=o*e+l,d=0,u=0;u<s;u++)for(var c=0;c<s;c++){var p=o+u-n,f=l+c-n;if(p>=0&&p<t&&f>=0&&f<e){var m=p*e+f,g=i[u*s+c];d+=r[m]*g}}a[h]=d>=255*4?255:0}return a}function zd(r,e,t){for(var i=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],s=Math.round(Math.sqrt(i.length)),n=Math.floor(s/2),a=[],o=0;o<t;o++)for(var l=0;l<e;l++){for(var h=o*e+l,d=0,u=0;u<s;u++)for(var c=0;c<s;c++){var p=o+u-n,f=l+c-n;if(p>=0&&p<t&&f>=0&&f<e){var m=p*e+f,g=i[u*s+c];d+=r[m]*g}}a[h]=d}return a}const Wd=function(r){var e=this.threshold(),t=Hd(r,e);return t&&(t=$d(t,r.width,r.height),t=Vd(t,r.width,r.height),t=zd(t,r.width,r.height),Bd(r,t)),r};v.addGetterSetter(P,"threshold",0,x(),v.afterSetFilter);const Ud=function(r){var e=this.noise()*255,t=r.data,i=t.length,s=e/2,n;for(n=0;n<i;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(r){var e=Math.ceil(this.pixelSize()),t=r.width,i=r.height,s,n,a,o,l,h,d,u=Math.ceil(t/e),c=Math.ceil(i/e),p,f,m,g,_,w,b,T=r.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,l=0,h=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>=i||(a=(t*n+s)*4,o+=T[a+0],l+=T[a+1],h+=T[a+2],d+=T[a+3],b+=1);for(o=o/b,l=l/b,h=h/b,d=d/b,s=p;s<f;s+=1)if(!(s>=t))for(n=m;n<g;n+=1)n>=i||(a=(t*n+s)*4,T[a+0]=o,T[a+1]=l,T[a+2]=h,T[a+3]=d)}};v.addGetterSetter(P,"pixelSize",8,x(),v.afterSetFilter);const jd=function(r){var e=Math.round(this.levels()*254)+1,t=r.data,i=t.length,s=255/e,n;for(n=0;n<i;n+=1)t[n]=Math.floor(t[n]/s)*s};v.addGetterSetter(P,"levels",.5,x(),v.afterSetFilter);const Xd=function(r){var e=r.data,t=e.length,i=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*i,e[a+1]=o*s,e[a+2]=o*n,e[a+3]=e[a+3]};v.addGetterSetter(P,"red",0,function(r){return this._filterUpToDate=!1,r>255?255:r<0?0:Math.round(r)}),v.addGetterSetter(P,"green",0,function(r){return this._filterUpToDate=!1,r>255?255:r<0?0:Math.round(r)}),v.addGetterSetter(P,"blue",0,Mn,v.afterSetFilter);const qd=function(r){var e=r.data,t=e.length,i=this.red(),s=this.green(),n=this.blue(),a=this.alpha(),o,l;for(o=0;o<t;o+=4)l=1-a,e[o]=i*a+e[o]*l,e[o+1]=s*a+e[o+1]*l,e[o+2]=n*a+e[o+2]*l};v.addGetterSetter(P,"red",0,function(r){return this._filterUpToDate=!1,r>255?255:r<0?0:Math.round(r)}),v.addGetterSetter(P,"green",0,function(r){return this._filterUpToDate=!1,r>255?255:r<0?0:Math.round(r)}),v.addGetterSetter(P,"blue",0,Mn,v.afterSetFilter),v.addGetterSetter(P,"alpha",1,function(r){return this._filterUpToDate=!1,r>1?1:r<0?0:r});const Yd=function(r){var e=r.data,t=e.length,i,s,n,a;for(i=0;i<t;i+=4)s=e[i+0],n=e[i+1],a=e[i+2],e[i+0]=Math.min(255,s*.393+n*.769+a*.189),e[i+1]=Math.min(255,s*.349+n*.686+a*.168),e[i+2]=Math.min(255,s*.272+n*.534+a*.131)},Kd=function(r){var e=r.data,t=r.width,i=r.height,s=t*4,n=i;do{var a=(n-1)*s,o=t;do{var l=a+(o-1)*4,h=e[l],d=e[l+1],u=e[l+2];h>127&&(h=255-h),d>127&&(d=255-d),u>127&&(u=255-u),e[l]=h,e[l+1]=d,e[l+2]=u}while(--o)}while(--n)},Jd=function(r){var e=this.threshold()*255,t=r.data,i=t.length,s;for(s=0;s<i;s+=1)t[s]=t[s]<e?0:255};v.addGetterSetter(P,"threshold",.5,x(),v.afterSetFilter);const O=ca.Util._assign(ca,{Arc:ut,Arrow:zt,Circle:ni,Ellipse:kt,Image:qe,Label:Ms,Tag:Wt,Line:ct,Path:le,Rect:Ni,RegularPolygon:Ut,Ring:Zt,Sprite:rt,Star:xt,Text:pe,TextPath:we,Transformer:oe,Wedge:ft,Filters:{Blur:kd,Brighten:xd,Contrast:Pd,Emboss:Ad,Enhance:Od,Grayscale:Md,HSL:Ld,HSV:Rd,Invert:Id,Kaleidoscope:Gd,Mask:Wd,Noise:Ud,Pixelate:Zd,Posterize:jd,RGB:Xd,RGBA:qd,Sepia:Yd,Solarize:Kd,Threshold:Jd}});var Ns=function(r,e){return Ns=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])},Ns(r,e)};function pt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ns(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Qd(r,e,t,i){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{h(i.next(d))}catch(u){a(u)}}function l(d){try{h(i.throw(d))}catch(u){a(u)}}function h(d){d.done?n(d.value):s(d.value).then(o,l)}h((i=i.apply(r,e||[])).next())})}function Ma(r,e){var t={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,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(h){return function(d){return l([h,d])}}function l(h){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,h[0]&&(t=0)),t;)try{if(i=1,s&&(n=h[0]&2?s.return:h[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,h[1])).done)return n;switch(s=0,n&&(h=[h[0]&2,n.value]),h[0]){case 0:case 1:n=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,s=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(n=t.trys,!(n=n.length>0&&n[n.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!n||h[1]>n[0]&&h[1]<n[3])){t.label=h[1];break}if(h[0]===6&&t.label<n[1]){t.label=n[1],n=h;break}if(n&&t.label<n[2]){t.label=n[2],t.ops.push(h);break}n[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(r,t)}catch(d){h=[6,d],s=0}finally{i=n=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function oi(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Pt(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),s,n=[],a;try{for(;(e===void 0||e-- >0)&&!(s=i.next()).done;)n.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(a)throw a.error}}return n}function jt(r,e,t){if(t||arguments.length===2)for(var i=0,s=e.length,n;i<s;i++)(n||!(i in e))&&(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return r.concat(n||Array.prototype.slice.call(e))}function hi(r){return this instanceof hi?(this.v=r,this):new hi(r)}function eu(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(r,e||[]),s,n=[];return s={},a("next"),a("throw"),a("return"),s[Symbol.asyncIterator]=function(){return this},s;function a(c){i[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{l(i[c](p))}catch(f){u(n[0][3],f)}}function l(c){c.value instanceof hi?Promise.resolve(c.value.v).then(h,d):u(n[0][2],c)}function h(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 tu(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof oi=="function"?oi(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=r[n]&&function(a){return new Promise(function(o,l){a=r[n](a),s(o,l,a.done,a.value)})}}function s(n,a,o,l){Promise.resolve(l).then(function(h){n({value:h,done:o})},a)}}typeof SuppressedError=="function"&&SuppressedError;function de(r){return typeof r=="function"}function Ds(r){var e=function(i){Error.call(i),i.stack=new Error().stack},t=r(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var Gs=Ds(function(r){return function(t){r(this),this.message=t?t.length+` errors occurred during unsubscription:
3
+ `+t.map(function(i,s){return s+1+") "+i.toString()}).join(`
4
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function xr(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var Fi=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,i,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=oi(a),l=o.next();!l.done;l=o.next()){var h=l.value;h.remove(this)}}catch(m){e={error:m}}finally{try{l&&!l.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 Gs?m.errors:[m]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var c=oi(u),p=c.next();!p.done;p=c.next()){var f=p.value;try{Ia(f)}catch(m){n=n??[],m instanceof Gs?n=jt(jt([],Pt(n)),Pt(m.errors)):n.push(m)}}}catch(m){i={error:m}}finally{try{p&&!p.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}}if(n)throw new Gs(n)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)Ia(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&xr(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&xr(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}(),La=Fi.EMPTY;function Ra(r){return r instanceof Fi||r&&"closed"in r&&de(r.remove)&&de(r.add)&&de(r.unsubscribe)}function Ia(r){de(r)?r():r.unsubscribe()}var Na={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Fs={setTimeout:function(r,e){for(var t=[],i=2;i<arguments.length;i++)t[i-2]=arguments[i];var s=Fs.delegate;return s!=null&&s.setTimeout?s.setTimeout.apply(s,jt([r,e],Pt(t))):setTimeout.apply(void 0,jt([r,e],Pt(t)))},clearTimeout:function(r){var e=Fs.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(r)},delegate:void 0};function Da(r){Fs.setTimeout(function(){throw r})}function Pr(){}function Ar(r){r()}var Hs=function(r){pt(e,r);function e(t){var i=r.call(this)||this;return i.isStopped=!1,t?(i.destination=t,Ra(t)&&t.add(i)):i.destination=nu,i}return e.create=function(t,i,s){return new $s(t,i,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,r.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}(Fi),iu=Function.prototype.bind;function Bs(r,e){return iu.call(r,e)}var ru=function(){function r(e){this.partialObserver=e}return r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(i){Or(i)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(i){Or(i)}else Or(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Or(t)}},r}(),$s=function(r){pt(e,r);function e(t,i,s){var n=r.call(this)||this,a;if(de(t)||!t)a={next:t??void 0,error:i??void 0,complete:s??void 0};else{var o;n&&Na.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 ru(a),n}return e}(Hs);function Or(r){Da(r)}function su(r){throw r}var nu={closed:!0,next:Pr,error:su,complete:Pr},Vs=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Hi(r){return r}function au(r){return r.length===0?Hi:r.length===1?r[0]:function(t){return r.reduce(function(i,s){return s(i)},t)}}var ie=function(){function r(e){e&&(this._subscribe=e)}return r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,i){var s=this,n=hu(e)?e:new $s(e,t,i);return Ar(function(){var a=s,o=a.operator,l=a.source;n.add(o?o.call(n,l):l?s._subscribe(n):s._trySubscribe(n))}),n},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var i=this;return t=Ga(t),new t(function(s,n){var a=new $s({next:function(o){try{e(o)}catch(l){n(l),a.unsubscribe()}},error:n,complete:s});i.subscribe(a)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[Vs]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return au(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=Ga(e),new e(function(i,s){var n;t.subscribe(function(a){return n=a},function(a){return s(a)},function(){return i(n)})})},r.create=function(e){return new r(e)},r}();function Ga(r){var e;return(e=r??Na.Promise)!==null&&e!==void 0?e:Promise}function ou(r){return r&&de(r.next)&&de(r.error)&&de(r.complete)}function hu(r){return r&&r instanceof Hs||ou(r)&&Ra(r)}function lu(r){return de(r==null?void 0:r.lift)}function Be(r){return function(e){if(lu(e))return e.lift(function(t){try{return r(t,this)}catch(i){this.error(i)}});throw new TypeError("Unable to lift unknown Observable type")}}function Pe(r,e,t,i,s){return new du(r,e,t,i,s)}var du=function(r){pt(e,r);function e(t,i,s,n,a,o){var l=r.call(this,t)||this;return l.onFinalize=a,l.shouldUnsubscribe=o,l._next=i?function(h){try{i(h)}catch(d){t.error(d)}}:r.prototype._next,l._error=n?function(h){try{n(h)}catch(d){t.error(d)}finally{this.unsubscribe()}}:r.prototype._error,l._complete=s?function(){try{s()}catch(h){t.error(h)}finally{this.unsubscribe()}}:r.prototype._complete,l}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var i=this.closed;r.prototype.unsubscribe.call(this),!i&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(Hs),uu=Ds(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),B=function(r){pt(e,r);function e(){var t=r.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 i=new Fa(this,this);return i.operator=t,i},e.prototype._throwIfClosed=function(){if(this.closed)throw new uu},e.prototype.next=function(t){var i=this;Ar(function(){var s,n;if(i._throwIfClosed(),!i.isStopped){i.currentObservers||(i.currentObservers=Array.from(i.observers));try{for(var a=oi(i.currentObservers),o=a.next();!o.done;o=a.next()){var l=o.value;l.next(t)}}catch(h){s={error:h}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(s)throw s.error}}}})},e.prototype.error=function(t){var i=this;Ar(function(){if(i._throwIfClosed(),!i.isStopped){i.hasError=i.isStopped=!0,i.thrownError=t;for(var s=i.observers;s.length;)s.shift().error(t)}})},e.prototype.complete=function(){var t=this;Ar(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var i=t.observers;i.length;)i.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(),r.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 i=this,s=this,n=s.hasError,a=s.isStopped,o=s.observers;return n||a?La:(this.currentObservers=null,o.push(t),new Fi(function(){i.currentObservers=null,xr(o,t)}))},e.prototype._checkFinalizedStatuses=function(t){var i=this,s=i.hasError,n=i.thrownError,a=i.isStopped;s?t.error(n):a&&t.complete()},e.prototype.asObservable=function(){var t=new ie;return t.source=this,t},e.create=function(t,i){return new Fa(t,i)},e}(ie),Fa=function(r){pt(e,r);function e(t,i){var s=r.call(this)||this;return s.destination=t,s.source=i,s}return e.prototype.next=function(t){var i,s;(s=(i=this.destination)===null||i===void 0?void 0:i.next)===null||s===void 0||s.call(i,t)},e.prototype.error=function(t){var i,s;(s=(i=this.destination)===null||i===void 0?void 0:i.error)===null||s===void 0||s.call(i,t)},e.prototype.complete=function(){var t,i;(i=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||i===void 0||i.call(t)},e.prototype._subscribe=function(t){var i,s;return(s=(i=this.source)===null||i===void 0?void 0:i.subscribe(t))!==null&&s!==void 0?s:La},e}(B),li=function(r){pt(e,r);function e(t){var i=r.call(this)||this;return i._value=t,i}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(t){var i=r.prototype._subscribe.call(this,t);return!i.closed&&t.next(this._value),i},e.prototype.getValue=function(){var t=this,i=t.hasError,s=t.thrownError,n=t._value;if(i)throw s;return this._throwIfClosed(),n},e.prototype.next=function(t){r.prototype.next.call(this,this._value=t)},e}(B),Ha={now:function(){return(Ha.delegate||Date).now()},delegate:void 0},cu=function(r){pt(e,r);function e(t,i){return r.call(this)||this}return e.prototype.schedule=function(t,i){return this},e}(Fi),Mr={setInterval:function(r,e){for(var t=[],i=2;i<arguments.length;i++)t[i-2]=arguments[i];var s=Mr.delegate;return s!=null&&s.setInterval?s.setInterval.apply(s,jt([r,e],Pt(t))):setInterval.apply(void 0,jt([r,e],Pt(t)))},clearInterval:function(r){var e=Mr.delegate;return((e==null?void 0:e.clearInterval)||clearInterval)(r)},delegate:void 0},fu=function(r){pt(e,r);function e(t,i){var s=r.call(this,t,i)||this;return s.scheduler=t,s.work=i,s.pending=!1,s}return e.prototype.schedule=function(t,i){var s;if(i===void 0&&(i=0),this.closed)return this;this.state=t;var n=this.id,a=this.scheduler;return n!=null&&(this.id=this.recycleAsyncId(a,n,i)),this.pending=!0,this.delay=i,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(a,this.id,i),this},e.prototype.requestAsyncId=function(t,i,s){return s===void 0&&(s=0),Mr.setInterval(t.flush.bind(t,this),s)},e.prototype.recycleAsyncId=function(t,i,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return i;i!=null&&Mr.clearInterval(i)},e.prototype.execute=function(t,i){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(t,i);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,i){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,i=t.id,s=t.scheduler,n=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,xr(n,this),i!=null&&(this.id=this.recycleAsyncId(s,i,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},e}(cu),Ba=function(){function r(e,t){t===void 0&&(t=r.now),this.schedulerActionCtor=e,this.now=t}return r.prototype.schedule=function(e,t,i){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(i,t)},r.now=Ha.now,r}(),pu=function(r){pt(e,r);function e(t,i){i===void 0&&(i=Ba.now);var s=r.call(this,t,i)||this;return s.actions=[],s._active=!1,s}return e.prototype.flush=function(t){var i=this.actions;if(this._active){i.push(t);return}var s;this._active=!0;do if(s=t.execute(t.state,t.delay))break;while(t=i.shift());if(this._active=!1,s){for(;t=i.shift();)t.unsubscribe();throw s}},e}(Ba),Lr=new pu(fu),mu=Lr,gu=new ie(function(r){return r.complete()});function $a(r){return r&&de(r.schedule)}function Va(r){return r[r.length-1]}function za(r){return de(Va(r))?r.pop():void 0}function zs(r){return $a(Va(r))?r.pop():void 0}var Ws=function(r){return r&&typeof r.length=="number"&&typeof r!="function"};function Wa(r){return de(r==null?void 0:r.then)}function Ua(r){return de(r[Vs])}function Za(r){return Symbol.asyncIterator&&de(r==null?void 0:r[Symbol.asyncIterator])}function ja(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function vu(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Xa=vu();function qa(r){return de(r==null?void 0:r[Xa])}function Ya(r){return eu(this,arguments,function(){var t,i,s,n;return Ma(this,function(a){switch(a.label){case 0:t=r.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,hi(t.read())];case 3:return i=a.sent(),s=i.value,n=i.done,n?[4,hi(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,hi(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 Ka(r){return de(r==null?void 0:r.getReader)}function Ye(r){if(r instanceof ie)return r;if(r!=null){if(Ua(r))return yu(r);if(Ws(r))return bu(r);if(Wa(r))return _u(r);if(Za(r))return Ja(r);if(qa(r))return wu(r);if(Ka(r))return Su(r)}throw ja(r)}function yu(r){return new ie(function(e){var t=r[Vs]();if(de(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function bu(r){return new ie(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()})}function _u(r){return new ie(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,Da)})}function wu(r){return new ie(function(e){var t,i;try{for(var s=oi(r),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&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}e.complete()})}function Ja(r){return new ie(function(e){Tu(r,e).catch(function(t){return e.error(t)})})}function Su(r){return Ja(Ya(r))}function Tu(r,e){var t,i,s,n;return Qd(this,void 0,void 0,function(){var a,o;return Ma(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),t=tu(r),l.label=1;case 1:return[4,t.next()];case 2:if(i=l.sent(),!!i.done)return[3,4];if(a=i.value,e.next(a),e.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return o=l.sent(),s={error:o},[3,11];case 6:return l.trys.push([6,,9,10]),i&&!i.done&&(n=t.return)?[4,n.call(t)]:[3,8];case 7:l.sent(),l.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 mt(r,e,t,i,s){i===void 0&&(i=0),s===void 0&&(s=!1);var n=e.schedule(function(){t(),s?r.add(this.schedule(null,i)):this.unsubscribe()},i);if(r.add(n),!s)return n}function Qa(r,e){return e===void 0&&(e=0),Be(function(t,i){t.subscribe(Pe(i,function(s){return mt(i,r,function(){return i.next(s)},e)},function(){return mt(i,r,function(){return i.complete()},e)},function(s){return mt(i,r,function(){return i.error(s)},e)}))})}function eo(r,e){return e===void 0&&(e=0),Be(function(t,i){i.add(r.schedule(function(){return t.subscribe(i)},e))})}function Cu(r,e){return Ye(r).pipe(eo(e),Qa(e))}function Eu(r,e){return Ye(r).pipe(eo(e),Qa(e))}function ku(r,e){return new ie(function(t){var i=0;return e.schedule(function(){i===r.length?t.complete():(t.next(r[i++]),t.closed||this.schedule())})})}function xu(r,e){return new ie(function(t){var i;return mt(t,e,function(){i=r[Xa](),mt(t,e,function(){var s,n,a;try{s=i.next(),n=s.value,a=s.done}catch(o){t.error(o);return}a?t.complete():t.next(n)},0,!0)}),function(){return de(i==null?void 0:i.return)&&i.return()}})}function to(r,e){if(!r)throw new Error("Iterable cannot be null");return new ie(function(t){mt(t,e,function(){var i=r[Symbol.asyncIterator]();mt(t,e,function(){i.next().then(function(s){s.done?t.complete():t.next(s.value)})},0,!0)})})}function Pu(r,e){return to(Ya(r),e)}function Au(r,e){if(r!=null){if(Ua(r))return Cu(r,e);if(Ws(r))return ku(r,e);if(Wa(r))return Eu(r,e);if(Za(r))return to(r,e);if(qa(r))return xu(r,e);if(Ka(r))return Pu(r,e)}throw ja(r)}function Bi(r,e){return e?Au(r,e):Ye(r)}function Se(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=zs(r);return Bi(r,t)}function io(r,e){var t=de(r)?r:function(){return r},i=function(s){return s.error(t())};return new ie(e?function(s){return e.schedule(i,0,s)}:i)}var ro=Ds(function(r){return function(){r(this),this.name="EmptyError",this.message="no elements in sequence"}});function Ou(r){return r instanceof Date&&!isNaN(r)}function ke(r,e){return Be(function(t,i){var s=0;t.subscribe(Pe(i,function(n){i.next(r.call(e,n,s++))}))})}var Mu=Array.isArray;function Lu(r,e){return Mu(e)?r.apply(void 0,jt([],Pt(e))):r(e)}function Us(r){return ke(function(e){return Lu(r,e)})}var Ru=Array.isArray,Iu=Object.getPrototypeOf,Nu=Object.prototype,Du=Object.keys;function so(r){if(r.length===1){var e=r[0];if(Ru(e))return{args:e,keys:null};if(Gu(e)){var t=Du(e);return{args:t.map(function(i){return e[i]}),keys:t}}}return{args:r,keys:null}}function Gu(r){return r&&typeof r=="object"&&Iu(r)===Nu}function no(r,e){return r.reduce(function(t,i,s){return t[i]=e[s],t},{})}function Fu(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=zs(r),i=za(r),s=so(r),n=s.args,a=s.keys;if(n.length===0)return Bi([],t);var o=new ie(Hu(n,t,a?function(l){return no(a,l)}:Hi));return i?o.pipe(Us(i)):o}function Hu(r,e,t){return t===void 0&&(t=Hi),function(i){ao(e,function(){for(var s=r.length,n=new Array(s),a=s,o=s,l=function(d){ao(e,function(){var u=Bi(r[d],e),c=!1;u.subscribe(Pe(i,function(p){n[d]=p,c||(c=!0,o--),o||i.next(t(n.slice()))},function(){--a||i.complete()}))},i)},h=0;h<s;h++)l(h)},i)}}function ao(r,e,t){r?mt(t,r,e):e()}function Bu(r,e,t,i,s,n,a,o){var l=[],h=0,d=0,u=!1,c=function(){u&&!l.length&&!h&&e.complete()},p=function(m){return h<i?f(m):l.push(m)},f=function(m){n&&e.next(m),h++;var g=!1;Ye(t(m,d++)).subscribe(Pe(e,function(_){s==null||s(_),n?p(_):e.next(_)},function(){g=!0},void 0,function(){if(g)try{h--;for(var _=function(){var w=l.shift();a?mt(e,a,function(){return f(w)}):f(w)};l.length&&h<i;)_();c()}catch(w){e.error(w)}}))};return r.subscribe(Pe(e,p,function(){u=!0,c()})),function(){o==null||o()}}function Rr(r,e,t){return t===void 0&&(t=1/0),de(e)?Rr(function(i,s){return ke(function(n,a){return e(i,n,s,a)})(Ye(r(i,s)))},t):(typeof e=="number"&&(t=e),Be(function(i,s){return Bu(i,s,r,t)}))}function $u(r){return r===void 0&&(r=1/0),Rr(Hi,r)}function Vu(){return $u(1)}function zu(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return Vu()(Bi(r,zs(r)))}function Wu(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=za(r),i=so(r),s=i.args,n=i.keys,a=new ie(function(o){var l=s.length;if(!l){o.complete();return}for(var h=new Array(l),d=l,u=l,c=function(f){var m=!1;Ye(s[f]).subscribe(Pe(o,function(g){m||(m=!0,u--),h[f]=g},function(){return d--},void 0,function(){(!d||!m)&&(u||o.next(n?no(n,h):h),o.complete())}))},p=0;p<l;p++)c(p)});return t?a.pipe(Us(t)):a}var Uu=["addListener","removeListener"],Zu=["addEventListener","removeEventListener"],ju=["on","off"];function be(r,e,t,i){if(de(t)&&(i=t,t=void 0),i)return be(r,e,t).pipe(Us(i));var s=Pt(Yu(r)?Zu.map(function(o){return function(l){return r[o](e,l,t)}}):Xu(r)?Uu.map(oo(r,e)):qu(r)?ju.map(oo(r,e)):[],2),n=s[0],a=s[1];if(!n&&Ws(r))return Rr(function(o){return be(o,e,t)})(Ye(r));if(!n)throw new TypeError("Invalid event target");return new ie(function(o){var l=function(){for(var h=[],d=0;d<arguments.length;d++)h[d]=arguments[d];return o.next(1<h.length?h:h[0])};return n(l),function(){return a(l)}})}function oo(r,e){return function(t){return function(i){return r[t](e,i)}}}function Xu(r){return de(r.addListener)&&de(r.removeListener)}function qu(r){return de(r.on)&&de(r.off)}function Yu(r){return de(r.addEventListener)&&de(r.removeEventListener)}function ho(r,e,t){r===void 0&&(r=0),t===void 0&&(t=mu);var i=-1;return e!=null&&($a(e)?t=e:i=e),new ie(function(s){var n=Ou(r)?+r-t.now():r;n<0&&(n=0);var a=0;return t.schedule(function(){s.closed||(s.next(a++),0<=i?this.schedule(void 0,i):s.complete())},n)})}function Ku(r,e){return r===void 0&&(r=0),e===void 0&&(e=Lr),r<0&&(r=0),ho(r,r,e)}function ze(r,e){return Be(function(t,i){var s=0;t.subscribe(Pe(i,function(n){return r.call(e,n,s++)&&i.next(n)}))})}function di(r){return Be(function(e,t){var i=null,s=!1,n;i=e.subscribe(Pe(t,void 0,void 0,function(a){n=Ye(r(a,di(r)(e))),i?(i.unsubscribe(),i=null,n.subscribe(t)):s=!0})),s&&(i.unsubscribe(),i=null,n.subscribe(t))})}function lo(r,e){return e===void 0&&(e=Lr),Be(function(t,i){var s=null,n=null,a=null,o=function(){if(s){s.unsubscribe(),s=null;var h=n;n=null,i.next(h)}};function l(){var h=a+r,d=e.now();if(d<h){s=this.schedule(void 0,h-d),i.add(s);return}o()}t.subscribe(Pe(i,function(h){n=h,a=e.now(),s||(s=e.schedule(l,r),i.add(s))},function(){o(),i.complete()},void 0,function(){n=s=null}))})}function Ju(r){return Be(function(e,t){var i=!1;e.subscribe(Pe(t,function(s){i=!0,t.next(s)},function(){i||t.next(r),t.complete()}))})}function We(r){return r<=0?function(){return gu}:Be(function(e,t){var i=0;e.subscribe(Pe(t,function(s){++i<=r&&(t.next(s),r<=i&&t.complete())}))})}function Qu(){return Be(function(r,e){r.subscribe(Pe(e,Pr))})}function ec(r){return ke(function(){return r})}function uo(r,e){return e?function(t){return zu(e.pipe(We(1),Qu()),t.pipe(uo(r)))}:Rr(function(t,i){return Ye(r(t,i)).pipe(We(1),ec(t))})}function tc(r,e){e===void 0&&(e=Lr);var t=ho(r,e);return uo(function(){return t})}function ic(r){return r===void 0&&(r=rc),Be(function(e,t){var i=!1;e.subscribe(Pe(t,function(s){i=!0,t.next(s)},function(){return i?t.complete():t.error(r())}))})}function rc(){return new ro}function ui(r,e){var t=arguments.length>=2;return function(i){return i.pipe(r?ze(function(s,n){return r(s,n,i)}):Hi,We(1),t?Ju(e):ic(function(){return new ro}))}}function sc(r,e){return Be(function(t,i){var s=null,n=0,a=!1,o=function(){return a&&!s&&i.complete()};t.subscribe(Pe(i,function(l){s==null||s.unsubscribe();var h=0,d=n++;Ye(r(l,d)).subscribe(s=Pe(i,function(u){return i.next(e?e(l,u,d,h++):u)},function(){s=null,o()}))},function(){a=!0,o()}))})}function k(r){return Be(function(e,t){Ye(r).subscribe(Pe(t,function(){return t.complete()},Pr)),!t.closed&&e.subscribe(t)})}class co{constructor(e){this.onChange$=new B,this.style=e}get style(){return this._style}set style(e){this._style={...this._style,...e},this.onChange$.next(this._style)}}function $e(r){r&&(r.closed||(r.next(),r.complete()))}function Zs(...r){r.forEach(e=>{$e(e)})}function nc(r){r&&(r.closed||r.complete())}function Xt(...r){r.forEach(e=>{nc(e)})}function ci(...r){r.forEach(e=>{ac(e)})}function ac(r){r&&(r.closed||r.unsubscribe())}const fi=(r,e)=>({...e,...r,style:{...e.style,...r.style}});class Ke{constructor(e){this.onDestroy$=new B,this.config=e,this.styleAdapter=new co(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(),$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}}const Ft=class Ft{};Ft.POSITION_TOP_LEFT={x:0,y:0},Ft.DIMENSION_ZERO={width:0,height:0},Ft.GOLDEN_RATIO=1.61,Ft.TIMELINE_ZOOM_EASED_DURATION_MS=800,Ft.TIMELINE_SCROLL_EASED_DURATION_MS=200,Ft.MIME_TYPE_VND_APPLE_MPEGURL="application/vnd.apple.mpegurl";let $=Ft;var ne;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const n={};for(const a of s)n[a]=a;return n},r.getValidEnumValues=s=>{const n=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of n)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(n){return s[n]}),r.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},r.find=(s,n)=>{for(const a of s)if(n(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function i(s,n=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(n)}r.joinValues=i,r.jsonStringifyReplacer=(s,n)=>typeof n=="bigint"?n.toString():n})(ne||(ne={}));const N=ne.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),At=r=>{switch(typeof r){case"undefined":return N.undefined;case"string":return N.string;case"number":return isNaN(r)?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(r)?N.array:r===null?N.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?N.promise:typeof Map<"u"&&r instanceof Map?N.map:typeof Set<"u"&&r instanceof Set?N.set:typeof Date<"u"&&r instanceof Date?N.date:N.object;default:return N.unknown}},M=ne.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"]),oc=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class st extends Error{constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};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},i={_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)i._errors.push(t(a));else{let o=i,l=0;for(;l<a.path.length;){const h=a.path[l];l===a.path.length-1?(o[h]=o[h]||{_errors:[]},o[h]._errors.push(t(a))):o[h]=o[h]||{_errors:[]},o=o[h],l++}}};return s(this),i}toString(){return this.message}get message(){return JSON.stringify(this.issues,ne.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},i=[];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))):i.push(e(s));return{formErrors:i,fieldErrors:t}}get formErrors(){return this.flatten()}}st.create=r=>new st(r);const $i=(r,e)=>{let t;switch(r.code){case M.invalid_type:r.received===N.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,ne.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${ne.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${ne.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${ne.joinValues(r.options)}, received '${r.received}'`;break;case M.invalid_arguments:t="Invalid function arguments";break;case M.invalid_return_type:t="Invalid function return type";break;case M.invalid_date:t="Invalid date";break;case M.invalid_string:typeof r.validation=="object"?"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:ne.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case M.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(r.minimum)}`:t="Invalid input";break;case M.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(r.maximum)}`:t="Invalid input";break;case M.custom:t="Invalid input";break;case M.invalid_intersection_types:t="Intersection results could not be merged";break;case M.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case M.not_finite:t="Number must be finite";break;default:t=e.defaultError,ne.assertNever(r)}return{message:t}};let fo=$i;function hc(r){fo=r}function Ir(){return fo}const Nr=r=>{const{data:e,path:t,errorMaps:i,issueData:s}=r,n=[...t,...s.path||[]],a={...s,path:n};let o="";const l=i.filter(h=>!!h).slice().reverse();for(const h of l)o=h(a,{data:e,defaultError:o}).message;return{...s,path:n,message:s.message||o}},lc=[];function H(r,e){const t=Nr({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ir(),$i].filter(i=>!!i)});r.common.issues.push(t)}class Re{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const i=[];for(const s of t){if(s.status==="aborted")return Y;s.status==="dirty"&&e.dirty(),i.push(s.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,t){const i=[];for(const s of t)i.push({key:await s.key,value:await s.value});return Re.mergeObjectSync(e,i)}static mergeObjectSync(e,t){const i={};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)&&(i[n.value]=a.value)}return{status:e.value,value:i}}}const Y=Object.freeze({status:"aborted"}),po=r=>({status:"dirty",value:r}),Ae=r=>({status:"valid",value:r}),js=r=>r.status==="aborted",Xs=r=>r.status==="dirty",Dr=r=>r.status==="valid",Gr=r=>typeof Promise<"u"&&r instanceof Promise;var ee;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ee||(ee={}));class nt{constructor(e,t,i,s){this.parent=e,this.data=t,this._path=i,this._key=s}get path(){return this._path.concat(this._key)}}const mo=(r,e)=>{if(Dr(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,error:new st(r.common.issues)}};function J(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:i,description:s}=r;if(e&&(t||i))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:i??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 At(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Re,ctx:{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Gr(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 i=this.safeParse(e,t);if(i.success)return i.data;throw i.error}safeParse(e,t){var i;const s={common:{issues:[],async:(i=t==null?void 0:t.async)!==null&&i!==void 0?i:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:At(e)},n=this._parseSync({data:e,path:s.path,parent:s});return mo(s,n)}async parseAsync(e,t){const i=await this.safeParseAsync(e,t);if(i.success)return i.data;throw i.error}async safeParseAsync(e,t){const i={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:At(e)},s=this._parse({data:e,path:i.path,parent:i}),n=await(Gr(s)?s:Promise.resolve(s));return mo(i,n)}refine(e,t){const i=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:M.custom,...i(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((i,s)=>e(i)?!0:(s.addIssue(typeof t=="function"?t(i,s):t),!1))}_refinement(e){return new Qe({schema:this,typeName:X.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return yt.create(this,this._def)}nullable(){return Jt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Je.create(this,this._def)}promise(){return vi.create(this,this._def)}or(e){return Zi.create([this,e],this._def)}and(e){return ji.create(this,e,this._def)}transform(e){return new Qe({...J(this._def),schema:this,typeName:X.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ji({...J(this._def),innerType:this,defaultValue:t,typeName:X.ZodDefault})}brand(){return new vo({typeName:X.ZodBranded,type:this,...J(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Wr({...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 Qi.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const dc=/^c[^\s-]{8,}$/i,uc=/^[a-z][a-z0-9]*$/,cc=/^([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,fc=/^(([^<>()[\]\\.,;:\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,}))$/,pc=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.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$"):r.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,i)=>this.refinement(s=>e.test(s),{validation:t,code:M.invalid_string,...ee.errToObj(i)}),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 H(n,{code:M.invalid_type,expected:N.string,received:n.parsedType}),Y}const i=new Re;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:M.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:M.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.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?H(s,{code:M.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):o&&H(s,{code:M.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),i.dirty())}else if(n.kind==="email")fc.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"email",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="uuid")cc.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"uuid",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid")dc.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"cuid",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid2")uc.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"cuid2",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),H(s,{validation:"url",code:M.invalid_string,message:n.message}),i.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"regex",code:M.invalid_string,message:n.message}),i.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),H(s,{code:M.invalid_string,validation:{startsWith:n.value},message:n.message}),i.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),H(s,{code:M.invalid_string,validation:{endsWith:n.value},message:n.message}),i.dirty()):n.kind==="datetime"?pc(n).test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{code:M.invalid_string,validation:"datetime",message:n.message}),i.dirty()):ne.assertNever(n);return{status:i.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=r=>{var e;return new gt({checks:[],typeName:X.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...J(r)})};function mc(r,e){const t=(r.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,s=t>i?t:i,n=parseInt(r.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 H(n,{code:M.invalid_type,expected:N.number,received:n.parsedType}),Y}let i;const s=new Re;for(const n of this._def.checks)n.kind==="int"?ne.isInteger(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:M.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.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)&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?mc(e.data,n.value)!==0&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:M.not_finite,message:n.message}),s.dirty()):ne.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,i,s){return new Ot({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,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"&&ne.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(t===null||i.value>t)&&(t=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Ot.create=r=>new Ot({checks:[],typeName:X.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...J(r)});class Vi extends Q{_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==N.bigint){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:N.bigint,received:i.parsedType}),Y}return Ae(e.data)}}Vi.create=r=>{var e;return new Vi({typeName:X.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...J(r)})};class zi extends Q{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==N.boolean){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:N.boolean,received:i.parsedType}),Y}return Ae(e.data)}}zi.create=r=>new zi({typeName:X.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...J(r)});class qt 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 H(n,{code:M.invalid_type,expected:N.date,received:n.parsedType}),Y}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return H(n,{code:M.invalid_date}),Y}const i=new Re;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:M.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),i.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:M.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),i.dirty()):ne.assertNever(n);return{status:i.value,value:new Date(e.data.getTime())}}_addCheck(e){return new qt({...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}}qt.create=r=>new qt({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:X.ZodDate,...J(r)});class Fr extends Q{_parse(e){if(this._getType(e)!==N.symbol){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:N.symbol,received:i.parsedType}),Y}return Ae(e.data)}}Fr.create=r=>new Fr({typeName:X.ZodSymbol,...J(r)});class Wi extends Q{_parse(e){if(this._getType(e)!==N.undefined){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:N.undefined,received:i.parsedType}),Y}return Ae(e.data)}}Wi.create=r=>new Wi({typeName:X.ZodUndefined,...J(r)});class Ui extends Q{_parse(e){if(this._getType(e)!==N.null){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:N.null,received:i.parsedType}),Y}return Ae(e.data)}}Ui.create=r=>new Ui({typeName:X.ZodNull,...J(r)});class pi extends Q{constructor(){super(...arguments),this._any=!0}_parse(e){return Ae(e.data)}}pi.create=r=>new pi({typeName:X.ZodAny,...J(r)});class Yt extends Q{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ae(e.data)}}Yt.create=r=>new Yt({typeName:X.ZodUnknown,...J(r)});class vt extends Q{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:M.invalid_type,expected:N.never,received:t.parsedType}),Y}}vt.create=r=>new vt({typeName:X.ZodNever,...J(r)});class Hr extends Q{_parse(e){if(this._getType(e)!==N.undefined){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:N.void,received:i.parsedType}),Y}return Ae(e.data)}}Hr.create=r=>new Hr({typeName:X.ZodVoid,...J(r)});class Je extends Q{_parse(e){const{ctx:t,status:i}=this._processInputParams(e),s=this._def;if(t.parsedType!==N.array)return H(t,{code:M.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)&&(H(t,{code:a?M.too_big:M.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}),i.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(H(t,{code:M.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),i.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(H(t,{code:M.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),i.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new nt(t,a,t.path,o)))).then(a=>Re.mergeArray(i,a));const n=[...t.data].map((a,o)=>s.type._parseSync(new nt(t,a,t.path,o)));return Re.mergeArray(i,n)}get element(){return this._def.type}min(e,t){return new Je({...this._def,minLength:{value:e,message:ee.toString(t)}})}max(e,t){return new Je({...this._def,maxLength:{value:e,message:ee.toString(t)}})}length(e,t){return new Je({...this._def,exactLength:{value:e,message:ee.toString(t)}})}nonempty(e){return this.min(1,e)}}Je.create=(r,e)=>new Je({type:r,minLength:null,maxLength:null,exactLength:null,typeName:X.ZodArray,...J(e)});var Br;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Br||(Br={}));function mi(r){if(r instanceof me){const e={};for(const t in r.shape){const i=r.shape[t];e[t]=yt.create(mi(i))}return new me({...r._def,shape:()=>e})}else return r instanceof Je?Je.create(mi(r.element)):r instanceof yt?yt.create(mi(r.unwrap())):r instanceof Jt?Jt.create(mi(r.unwrap())):r instanceof at?at.create(r.items.map(e=>mi(e))):r}class me 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=ne.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==N.object){const h=this._getOrReturnCtx(e);return H(h,{code:M.invalid_type,expected:N.object,received:h.parsedType}),Y}const{status:i,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof vt&&this._def.unknownKeys==="strip"))for(const h in s.data)a.includes(h)||o.push(h);const l=[];for(const h of a){const d=n[h],u=s.data[h];l.push({key:{status:"valid",value:h},value:d._parse(new nt(s,u,s.path,h)),alwaysSet:h in s.data})}if(this._def.catchall instanceof vt){const h=this._def.unknownKeys;if(h==="passthrough")for(const d of o)l.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(h==="strict")o.length>0&&(H(s,{code:M.unrecognized_keys,keys:o}),i.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const h=this._def.catchall;for(const d of o){const u=s.data[d];l.push({key:{status:"valid",value:d},value:h._parse(new nt(s,u,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const h=[];for(const d of l){const u=await d.key;h.push({key:u,value:await d.value,alwaysSet:d.alwaysSet})}return h}).then(h=>Re.mergeObjectSync(i,h)):Re.mergeObjectSync(i,l)}get shape(){return this._def.shape()}strict(e){return ee.errToObj,new me({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,i)=>{var s,n,a,o;const l=(a=(n=(s=this._def).errorMap)===null||n===void 0?void 0:n.call(s,t,i).message)!==null&&a!==void 0?a:i.defaultError;return t.code==="unrecognized_keys"?{message:(o=ee.errToObj(e).message)!==null&&o!==void 0?o:l}:{message:l}}}:{}})}strip(){return new me({...this._def,unknownKeys:"strip"})}passthrough(){return new me({...this._def,unknownKeys:"passthrough"})}extend(e){return new me({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new me({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>Br.mergeShapes(this._def.shape(),e._def.shape()),typeName:X.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new me({...this._def,catchall:e})}pick(e){const t={};return ne.objectKeys(e).forEach(i=>{e[i]&&this.shape[i]&&(t[i]=this.shape[i])}),new me({...this._def,shape:()=>t})}omit(e){const t={};return ne.objectKeys(this.shape).forEach(i=>{e[i]||(t[i]=this.shape[i])}),new me({...this._def,shape:()=>t})}deepPartial(){return mi(this)}partial(e){const t={};return ne.objectKeys(this.shape).forEach(i=>{const s=this.shape[i];e&&!e[i]?t[i]=s:t[i]=s.optional()}),new me({...this._def,shape:()=>t})}required(e){const t={};return ne.objectKeys(this.shape).forEach(i=>{if(e&&!e[i])t[i]=this.shape[i];else{let n=this.shape[i];for(;n instanceof yt;)n=n._def.innerType;t[i]=n}}),new me({...this._def,shape:()=>t})}keyof(){return go(ne.objectKeys(this.shape))}}me.create=(r,e)=>new me({shape:()=>r,unknownKeys:"strip",catchall:vt.create(),typeName:X.ZodObject,...J(e)}),me.strictCreate=(r,e)=>new me({shape:()=>r,unknownKeys:"strict",catchall:vt.create(),typeName:X.ZodObject,...J(e)}),me.lazycreate=(r,e)=>new me({shape:r,unknownKeys:"strip",catchall:vt.create(),typeName:X.ZodObject,...J(e)});class Zi extends Q{_parse(e){const{ctx:t}=this._processInputParams(e),i=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 H(t,{code:M.invalid_union,unionErrors:a}),Y}if(t.common.async)return Promise.all(i.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 l of i){const h={...t,common:{...t.common,issues:[]},parent:null},d=l._parseSync({data:t.data,path:t.path,parent:h});if(d.status==="valid")return d;d.status==="dirty"&&!n&&(n={result:d,ctx:h}),h.common.issues.length&&a.push(h.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const o=a.map(l=>new st(l));return H(t,{code:M.invalid_union,unionErrors:o}),Y}}get options(){return this._def.options}}Zi.create=(r,e)=>new Zi({options:r,typeName:X.ZodUnion,...J(e)});const $r=r=>r instanceof qi?$r(r.schema):r instanceof Qe?$r(r.innerType()):r instanceof Yi?[r.value]:r instanceof Mt?r.options:r instanceof Ki?Object.keys(r.enum):r instanceof Ji?$r(r._def.innerType):r instanceof Wi?[void 0]:r instanceof Ui?[null]:null;class Vr extends Q{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.object)return H(t,{code:M.invalid_type,expected:N.object,received:t.parsedType}),Y;const i=this.discriminator,s=t.data[i],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}):(H(t,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),Y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,i){const s=new Map;for(const n of t){const a=$r(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 Vr({typeName:X.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...J(i)})}}function qs(r,e){const t=At(r),i=At(e);if(r===e)return{valid:!0,data:r};if(t===N.object&&i===N.object){const s=ne.objectKeys(e),n=ne.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of n){const l=qs(r[o],e[o]);if(!l.valid)return{valid:!1};a[o]=l.data}return{valid:!0,data:a}}else if(t===N.array&&i===N.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let n=0;n<r.length;n++){const a=r[n],o=e[n],l=qs(a,o);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return t===N.date&&i===N.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ji extends Q{_parse(e){const{status:t,ctx:i}=this._processInputParams(e),s=(n,a)=>{if(js(n)||js(a))return Y;const o=qs(n.value,a.value);return o.valid?((Xs(n)||Xs(a))&&t.dirty(),{status:t.value,value:o.data}):(H(i,{code:M.invalid_intersection_types}),Y)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([n,a])=>s(n,a)):s(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}ji.create=(r,e,t)=>new ji({left:r,right:e,typeName:X.ZodIntersection,...J(t)});class at extends Q{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==N.array)return H(i,{code:M.invalid_type,expected:N.array,received:i.parsedType}),Y;if(i.data.length<this._def.items.length)return H(i,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Y;!this._def.rest&&i.data.length>this._def.items.length&&(H(i,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...i.data].map((a,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new nt(i,a,i.path,o)):null}).filter(a=>!!a);return i.common.async?Promise.all(n).then(a=>Re.mergeArray(t,a)):Re.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new at({...this._def,rest:e})}}at.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new at({items:r,typeName:X.ZodTuple,rest:null,...J(e)})};class Xi extends Q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==N.object)return H(i,{code:M.invalid_type,expected:N.object,received:i.parsedType}),Y;const s=[],n=this._def.keyType,a=this._def.valueType;for(const o in i.data)s.push({key:n._parse(new nt(i,o,i.path,o)),value:a._parse(new nt(i,i.data[o],i.path,o))});return i.common.async?Re.mergeObjectAsync(t,s):Re.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,i){return t instanceof Q?new Xi({keyType:e,valueType:t,typeName:X.ZodRecord,...J(i)}):new Xi({keyType:gt.create(),valueType:e,typeName:X.ZodRecord,...J(t)})}}class zr extends Q{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==N.map)return H(i,{code:M.invalid_type,expected:N.map,received:i.parsedType}),Y;const s=this._def.keyType,n=this._def.valueType,a=[...i.data.entries()].map(([o,l],h)=>({key:s._parse(new nt(i,o,i.path,[h,"key"])),value:n._parse(new nt(i,l,i.path,[h,"value"]))}));if(i.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of a){const h=await l.key,d=await l.value;if(h.status==="aborted"||d.status==="aborted")return Y;(h.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(h.value,d.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const l of a){const h=l.key,d=l.value;if(h.status==="aborted"||d.status==="aborted")return Y;(h.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(h.value,d.value)}return{status:t.value,value:o}}}}zr.create=(r,e,t)=>new zr({valueType:e,keyType:r,typeName:X.ZodMap,...J(t)});class Kt extends Q{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==N.set)return H(i,{code:M.invalid_type,expected:N.set,received:i.parsedType}),Y;const s=this._def;s.minSize!==null&&i.data.size<s.minSize.value&&(H(i,{code:M.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&i.data.size>s.maxSize.value&&(H(i,{code:M.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(l){const h=new Set;for(const d of l){if(d.status==="aborted")return Y;d.status==="dirty"&&t.dirty(),h.add(d.value)}return{status:t.value,value:h}}const o=[...i.data.values()].map((l,h)=>n._parse(new nt(i,l,i.path,h)));return i.common.async?Promise.all(o).then(l=>a(l)):a(o)}min(e,t){return new Kt({...this._def,minSize:{value:e,message:ee.toString(t)}})}max(e,t){return new Kt({...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)}}Kt.create=(r,e)=>new Kt({valueType:r,minSize:null,maxSize:null,typeName:X.ZodSet,...J(e)});class gi extends Q{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.function)return H(t,{code:M.invalid_type,expected:N.function,received:t.parsedType}),Y;function i(o,l){return Nr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ir(),$i].filter(h=>!!h),issueData:{code:M.invalid_arguments,argumentsError:l}})}function s(o,l){return Nr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ir(),$i].filter(h=>!!h),issueData:{code:M.invalid_return_type,returnTypeError:l}})}const n={errorMap:t.common.contextualErrorMap},a=t.data;return this._def.returns instanceof vi?Ae(async(...o)=>{const l=new st([]),h=await this._def.args.parseAsync(o,n).catch(c=>{throw l.addIssue(i(o,c)),l}),d=await a(...h);return await this._def.returns._def.type.parseAsync(d,n).catch(c=>{throw l.addIssue(s(d,c)),l})}):Ae((...o)=>{const l=this._def.args.safeParse(o,n);if(!l.success)throw new st([i(o,l.error)]);const h=a(...l.data),d=this._def.returns.safeParse(h,n);if(!d.success)throw new st([s(h,d.error)]);return d.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new gi({...this._def,args:at.create(e).rest(Yt.create())})}returns(e){return new gi({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,i){return new gi({args:e||at.create([]).rest(Yt.create()),returns:t||Yt.create(),typeName:X.ZodFunction,...J(i)})}}class qi 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})}}qi.create=(r,e)=>new qi({getter:r,typeName:X.ZodLazy,...J(e)});class Yi extends Q{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),Y}return{status:"valid",value:e.data}}get value(){return this._def.value}}Yi.create=(r,e)=>new Yi({value:r,typeName:X.ZodLiteral,...J(e)});function go(r,e){return new Mt({values:r,typeName:X.ZodEnum,...J(e)})}class Mt extends Q{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),i=this._def.values;return H(t,{expected:ne.joinValues(i),received:t.parsedType,code:M.invalid_type}),Y}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),i=this._def.values;return H(t,{received:t.data,code:M.invalid_enum_value,options:i}),Y}return Ae(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 Mt.create(e)}exclude(e){return Mt.create(this.options.filter(t=>!e.includes(t)))}}Mt.create=go;class Ki extends Q{_parse(e){const t=ne.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==N.string&&i.parsedType!==N.number){const s=ne.objectValues(t);return H(i,{expected:ne.joinValues(s),received:i.parsedType,code:M.invalid_type}),Y}if(t.indexOf(e.data)===-1){const s=ne.objectValues(t);return H(i,{received:i.data,code:M.invalid_enum_value,options:s}),Y}return Ae(e.data)}get enum(){return this._def.values}}Ki.create=(r,e)=>new Ki({values:r,typeName:X.ZodNativeEnum,...J(e)});class vi 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 H(t,{code:M.invalid_type,expected:N.promise,received:t.parsedType}),Y;const i=t.parsedType===N.promise?t.data:Promise.resolve(t.data);return Ae(i.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}vi.create=(r,e)=>new vi({type:r,typeName:X.ZodPromise,...J(e)});class Qe 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:i}=this._processInputParams(e),s=this._def.effect||null;if(s.type==="preprocess"){const a=s.transform(i.data);return i.common.async?Promise.resolve(a).then(o=>this._def.schema._parseAsync({data:o,path:i.path,parent:i})):this._def.schema._parseSync({data:a,path:i.path,parent:i})}const n={addIssue:a=>{H(i,a),a.fatal?t.abort():t.dirty()},get path(){return i.path}};if(n.addIssue=n.addIssue.bind(n),s.type==="refinement"){const a=o=>{const l=s.refinement(o,n);if(i.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(i.common.async===!1){const o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});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:i.data,path:i.path,parent:i}).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(i.common.async===!1){const a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});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:i.data,path:i.path,parent:i}).then(a=>Dr(a)?Promise.resolve(s.transform(a.value,n)).then(o=>({status:t.value,value:o})):a);ne.assertNever(s)}}Qe.create=(r,e,t)=>new Qe({schema:r,typeName:X.ZodEffects,effect:e,...J(t)}),Qe.createWithPreprocess=(r,e,t)=>new Qe({schema:e,effect:{type:"preprocess",transform:r},typeName:X.ZodEffects,...J(t)});class yt extends Q{_parse(e){return this._getType(e)===N.undefined?Ae(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}yt.create=(r,e)=>new yt({innerType:r,typeName:X.ZodOptional,...J(e)});class Jt extends Q{_parse(e){return this._getType(e)===N.null?Ae(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Jt.create=(r,e)=>new Jt({innerType:r,typeName:X.ZodNullable,...J(e)});class Ji extends Q{_parse(e){const{ctx:t}=this._processInputParams(e);let i=t.data;return t.parsedType===N.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ji.create=(r,e)=>new Ji({innerType:r,typeName:X.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...J(e)});class Wr extends Q{_parse(e){const{ctx:t}=this._processInputParams(e),i=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t,common:{...t.common,issues:[]}}});return Gr(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue()})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue()}}removeCatch(){return this._def.innerType}}Wr.create=(r,e)=>new Wr({innerType:r,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 i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:N.nan,received:i.parsedType}),Y}return{status:"valid",value:e.data}}}Ur.create=r=>new Ur({typeName:X.ZodNaN,...J(r)});const gc=Symbol("zod_brand");class vo extends Q{_parse(e){const{ctx:t}=this._processInputParams(e),i=t.data;return this._def.type._parse({data:i,path:t.path,parent:t})}unwrap(){return this._def.type}}class Qi extends Q{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?Y:n.status==="dirty"?(t.dirty(),po(n.value)):this._def.out._parseAsync({data:n.value,path:i.path,parent:i})})();{const s=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return s.status==="aborted"?Y:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:i.path,parent:i})}}static create(e,t){return new Qi({in:e,out:t,typeName:X.ZodPipeline})}}const yo=(r,e={},t)=>r?pi.create().superRefine((i,s)=>{if(!r(i)){const n=typeof e=="function"?e(i):e,a=typeof n=="string"?{message:n}:n;s.addIssue({code:"custom",...a,fatal:t})}}):pi.create(),vc={object:me.lazycreate};var X;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline"})(X||(X={}));const yc=(r,e={message:`Input not instance of ${r.name}`})=>yo(t=>t instanceof r,e,!0),bo=gt.create,_o=Ot.create,bc=Ur.create,_c=Vi.create,wo=zi.create,wc=qt.create,Sc=Fr.create,Tc=Wi.create,Cc=Ui.create,Ec=pi.create,kc=Yt.create,xc=vt.create,Pc=Hr.create,Ac=Je.create,Oc=me.create,Mc=me.strictCreate,Lc=Zi.create,Rc=Vr.create,Ic=ji.create,Nc=at.create,Dc=Xi.create,Gc=zr.create,Fc=Kt.create,Hc=gi.create,Bc=qi.create,$c=Yi.create,Vc=Mt.create,zc=Ki.create,Wc=vi.create,So=Qe.create,Uc=yt.create,Zc=Jt.create,jc=Qe.createWithPreprocess,Xc=Qi.create;var _e=Object.freeze({__proto__:null,defaultErrorMap:$i,setErrorMap:hc,getErrorMap:Ir,makeIssue:Nr,EMPTY_PATH:lc,addIssueToContext:H,ParseStatus:Re,INVALID:Y,DIRTY:po,OK:Ae,isAborted:js,isDirty:Xs,isValid:Dr,isAsync:Gr,get util(){return ne},ZodParsedType:N,getParsedType:At,ZodType:Q,ZodString:gt,ZodNumber:Ot,ZodBigInt:Vi,ZodBoolean:zi,ZodDate:qt,ZodSymbol:Fr,ZodUndefined:Wi,ZodNull:Ui,ZodAny:pi,ZodUnknown:Yt,ZodNever:vt,ZodVoid:Hr,ZodArray:Je,get objectUtil(){return Br},ZodObject:me,ZodUnion:Zi,ZodDiscriminatedUnion:Vr,ZodIntersection:ji,ZodTuple:at,ZodRecord:Xi,ZodMap:zr,ZodSet:Kt,ZodFunction:gi,ZodLazy:qi,ZodLiteral:Yi,ZodEnum:Mt,ZodNativeEnum:Ki,ZodPromise:vi,ZodEffects:Qe,ZodTransformer:Qe,ZodOptional:yt,ZodNullable:Jt,ZodDefault:Ji,ZodCatch:Wr,ZodNaN:Ur,BRAND:gc,ZodBranded:vo,ZodPipeline:Qi,custom:yo,Schema:Q,ZodSchema:Q,late:vc,get ZodFirstPartyTypeKind(){return X},coerce:{string:r=>gt.create({...r,coerce:!0}),number:r=>Ot.create({...r,coerce:!0}),boolean:r=>zi.create({...r,coerce:!0}),bigint:r=>Vi.create({...r,coerce:!0}),date:r=>qt.create({...r,coerce:!0})},any:Ec,array:Ac,bigint:_c,boolean:wo,date:wc,discriminatedUnion:Rc,effect:So,enum:Vc,function:Hc,instanceof:yc,intersection:Ic,lazy:Bc,literal:$c,map:Gc,nan:bc,nativeEnum:zc,never:xc,null:Cc,nullable:Zc,number:_o,object:Oc,oboolean:()=>wo().optional(),onumber:()=>_o().optional(),optional:Uc,ostring:()=>bo().optional(),pipeline:Xc,preprocess:jc,promise:Wc,record:Dc,set:Fc,strictObject:Mc,string:bo,symbol:Sc,transformer:So,tuple:Nc,undefined:Tc,union:Lc,unknown:kc,void:Pc,NEVER:Y,ZodIssueCode:M,quotelessJson:oc,ZodError:st});class yi{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 bt{constructor(){this.onChange$=new li(void 0)}static instance(){return bt._instance||(bt._instance=new bt),bt._instance}get styles(){return this._styles}set styles(e){this._styles={...this._styles,...e},this.onChange$.next(this._styles)}}const er={height:80,backgroundFill:"#ffffff",backgroundOpacity:1,descriptionTextFill:"#1c1c1c",descriptionFontSize:15,leftBackgroundFill:"#ffffff",leftBackgroundOpacity:1};class tr extends Ke{constructor(e){super(e),this.stylesProvider=bt.instance(),this.id=yi.id()(this.config.id),this.description=yi.description()(this.config.description)}createCanvasNode(){return this.bodyGroup=new O.Group({...this.timelinePosition,width:this.timeline.getBodyGroupRect().width,height:this.styleAdapter.style.height}),this.bodyBackground=new O.Rect({...$.POSITION_TOP_LEFT,...this.bodyGroup.getSize(),fill:this.styleAdapter.style.backgroundFill,opacity:this.styleAdapter.style.backgroundOpacity,listening:!1}),this.leftGroup=new O.Group({...$.POSITION_TOP_LEFT,width:this.timeline.getLeftPanelRect().width,listening:!1}),this.leftBackground=new O.Rect({...$.POSITION_TOP_LEFT,...this.leftGroup.getSize(),fill:this.styleAdapter.style.leftBackgroundFill,opacity:this.styleAdapter.style.leftBackgroundOpacity,listening:!1}),this.leftPanelText=new O.Text({...$.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$),ze(e=>!!e)).subscribe(e=>{this.onStylesProviderChange()}),this.styleAdapter.onChange$.pipe(k(this.onDestroy$),ze(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 To={color:"rgba(255,73,145)",renderType:"lane",symbolType:"square"};class Co extends Ke{constructor(e){super(e),this.onChange$=new B,this.onClick$=new B,this.onMouseEnter$=new B,this.onMouseLeave$=new B,this.id=yi.id()(this.config.id),this.description=yi.description()(this.config.description),this.editable=yi.boolean()(this.config.editable),this.observation=this.config.observation}createCanvasNode(){return this.group=new O.Group({...$.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$];Xt(...e),ci(...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 ot{static resetCursorStyle(){this.cursor("default")}static cursor(e){document.body.style.cursor=e}}const Eo={color:"#ff6c6c",markerRenderType:"lane",markerSymbolType:"square",lineStrokeWidth:1,lineOpacity:.7};class ko extends Ke{constructor(e,t,i){super(e),this.onDrag=s=>{},this.onDragEnd=s=>{},this.markerLane=t,this.timeline=i,this.x=this.config.x,this.editable=this.config.editable}createCanvasNode(){let e=this.getVerticalMeasurement();return this.group=new O.Group({x:this.x,y:e.y,draggable:this.editable}),this.line=new O.Line({stroke:this.style.color,strokeWidth:this.style.lineStrokeWidth,opacity:this.style.lineOpacity,points:[0,0,0,e.height],listening:!1}),this.handleGroup=new O.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}),ot.cursor("grab"))}),this.handleGroup.on("mouseleave",()=>{this.editable&&(this.handleGroup.to({scaleX:1,scaleY:1,duration:.1}),ot.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=>{ot.cursor("grabbing");let i=this.timeline.constrainTimelinePosition(this.group.getPosition().x);this.group.setAttrs({x:i,y:e.y}),this.onDrag(this.group)}),this.group.on("dragend",t=>{let i=this.timeline.constrainTimelinePosition(this.group.getPosition().x);this.group.setAttrs({x:i,y:e.y}),this.onDragEnd(this.group),ot.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 yi=9e15,Lt=1e9,qs="0123456789abcdef",Ur="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Zr="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Ys={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-yi,maxE:yi,crypto:!1},xo,_t,q=!0,jr="[DecimalError] ",Rt=jr+"Invalid argument: ",Po=jr+"Precision limit exceeded",Ao=jr+"crypto unavailable",Mo="[object Decimal]",Me=Math.floor,Te=Math.pow,jc=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Xc=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,qc=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Oo=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Qe=1e7,Z=7,Yc=9007199254740991,Kc=Ur.length-1,Ks=Zr.length-1,C={toStringTag:Mo};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,l=n.s,h=i.s;if(!a||!o)return!l||!h?NaN:l!==h?l:a===o?0:!a^l<0?1:-1;if(!a[0]||!o[0])return a[0]?l:o[0]?-h:0;if(l!==h)return l;if(n.e!==i.e)return n.e>i.e^l<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]^l<0?1:-1;return r===s?0:r>s^l<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())+Z,r.rounding=1,t=Jc(r,Go(r,t)),r.precision=i,r.rounding=e,z(_t==2||_t==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,l,h,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=Me((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,l=o.times(o).times(o),h=l.plus(d),r=ce(h.plus(d).times(o),h.plus(l),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-Me(this.e/Z))*Z,i=e[i],i)for(;i%10==0;i/=10)t--;t<0&&(t=0)}return t},C.dividedBy=C.div=function(i){return ce(this,new this.constructor(i))},C.dividedToIntegerBy=C.divToInt=function(i){var e=this,t=e.constructor;return z(ce(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/Kr(4,i)).toString()):(i=16,e="2.3283064365386962890625e-10"),n=bi(a,1,n.times(e),new a(1),!0);for(var l,h=i,d=new a(8);h--;)l=n.times(n),n=o.minus(l.times(d.minus(l.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=bi(n,2,s,s,!0);else{i=1.4*Math.sqrt(r),i=i>16?16:i|0,s=s.times(1/Kr(5,i)),s=bi(n,2,s,s,!0);for(var a,o=new n(5),l=new n(16),h=new n(20);i--;)a=s.times(s),s=s.times(o.plus(a.times(l.times(a).plus(h))))}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,ce(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()?et(t,s,n):new t(0):new t(NaN):e.isZero()?et(t,s+4,n).times(.5):(t.precision=s+6,t.rounding=1,e=e.asin(),i=et(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=ce(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=et(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,l,h=this,d=h.constructor,u=d.precision,c=d.rounding;if(h.isFinite()){if(h.isZero())return new d(h);if(h.abs().eq(1)&&u+4<=Ks)return a=et(d,u+4,c).times(.25),a.s=h.s,a}else{if(!h.s)return new d(NaN);if(u+4<=Ks)return a=et(d,u+4,c).times(.5),a.s=h.s,a}for(d.precision=o=u+10,d.rounding=1,t=Math.min(28,o/Z+2|0),i=t;i;--i)h=h.div(h.times(h).plus(1).sqrt().plus(1));for(q=!1,e=Math.ceil(o/Z),r=1,l=h.times(h),a=new d(h),s=h;i!==-1;)if(s=s.times(l),n=a.minus(s.div(r+=2)),s=s.times(l),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&&Me(this.e/Z)>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,l,h=this,d=h.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=h.d,h.s<0||!t||!t[0]||h.eq(1))return new d(t&&!t[0]?-1/0:h.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=Nt(h,o),r=e?Yr(d,o+10):Nt(i,o),l=ce(a,r,o,1),tr(l.d,s=u,c))do if(o+=10,a=Nt(h,o),r=e?Yr(d,o+10):Nt(i,o),l=ce(a,r,o,1),!n){+xe(l.d).slice(s+1,s+15)+1==1e14&&(l=z(l,u+1,0));break}while(tr(l.d,s+=10,c));return q=!0,z(l,u,c)},C.minus=C.sub=function(i){var e,t,r,s,n,a,o,l,h,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(h=p.d,c=i.d,o=f.precision,l=f.rounding,!h[0]||!c[0]){if(c[0])i.s=-i.s;else if(h[0])i=new f(p);else return new f(l===3?-0:0);return q?z(i,o,l):i}if(t=Me(i.e/Z),d=Me(p.e/Z),h=h.slice(),n=d-t,n){for(u=n<0,u?(e=h,n=-n,a=c.length):(e=c,t=d,a=h.length),r=Math.max(Math.ceil(o/Z),a)+2,n>r&&(n=r,e.length=1),e.reverse(),r=n;r--;)e.push(0);e.reverse()}else{for(r=h.length,a=c.length,u=r<a,u&&(a=r),r=0;r<a;r++)if(h[r]!=c[r]){u=h[r]<c[r];break}n=0}for(u&&(e=h,h=c,c=e,i.s=-i.s),a=h.length,r=c.length-a;r>0;--r)h[a++]=0;for(r=c.length;r>n;){if(h[--r]<c[r]){for(s=r;s&&h[--s]===0;)h[s]=Qe-1;--h[s],h[r]+=Qe}h[r]-=c[r]}for(;h[--a]===0;)h.pop();for(;h[0]===0;h.shift())--t;return h[0]?(i.d=h,i.e=qr(h,t),q?z(i,o,l):i):new f(l===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=ce(t,i.abs(),0,3,1),e.s*=i.s):e=ce(t,i,0,r.modulo,1),e=e.times(i),q=!0,t.minus(e))},C.naturalExponential=C.exp=function(){return Js(this)},C.naturalLogarithm=C.ln=function(){return Nt(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,l,h,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(h=u.d,d=i.d,o=c.precision,l=c.rounding,!h[0]||!d[0])return d[0]||(i=new c(u)),q?z(i,o,l):i;if(n=Me(u.e/Z),r=Me(i.e/Z),h=h.slice(),s=n-r,s){for(s<0?(t=h,s=-s,a=d.length):(t=d,r=n,a=h.length),n=Math.ceil(o/Z),a=n>a?n+1:a+1,s>a&&(s=a,t.length=1),t.reverse();s--;)t.push(0);t.reverse()}for(a=h.length,s=d.length,a-s<0&&(s=a,t=d,d=h,h=t),e=0;s;)e=(h[--s]=h[s]+d[s]+e)/Qe|0,h[s]%=Qe;for(e&&(h.unshift(e),++r),a=h.length;h[--a]==0;)h.pop();return i.d=h,i.e=qr(h,r),q?z(i,o,l):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=Lo(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())+Z,r.rounding=1,t=ef(r,Go(r,t)),r.precision=i,r.rounding=e,z(_t>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,l=a.e,h=a.s,d=a.constructor;if(h!==1||!o||!o[0])return new d(!h||h<0&&(!o||o[0])?NaN:o?a:1/0);for(q=!1,h=Math.sqrt(+a),h==0||h==1/0?(e=xe(o),(e.length+l)%2==0&&(e+="0"),h=Math.sqrt(e),l=Me((l+1)/2)-(l<0||l%2),h==1/0?e="5e"+l:(e=h.toExponential(),e=e.slice(0,e.indexOf("e")+1)+l),r=new d(e)):r=new d(h.toString()),t=(l=d.precision)+3;;)if(n=r,r=n.plus(ce(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,l+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,l+1,1),i=!r.times(r).eq(a));break}return q=!0,z(r,l,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=ce(t,new r(1).minus(t.times(t)).sqrt(),i+10,0),r.precision=i,r.rounding=e,z(_t==2||_t==4?t.neg():t,i,e,!0)):new r(NaN)},C.times=C.mul=function(i){var e,t,r,s,n,a,o,l,h,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=Me(d.e/Z)+Me(i.e/Z),l=c.length,h=p.length,l<h&&(n=c,c=p,p=n,a=l,l=h,h=a),n=[],a=l+h,r=a;r--;)n.push(0);for(r=h;--r>=0;){for(e=0,s=l+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=qr(n,t),q?z(i,u.precision,u.rounding):i},C.toBinary=function(i,e){return en(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,Lt),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,Lt),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,Lt),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,l,h,d,u,c,p=this,f=p.d,m=p.constructor;if(!f)return new m(p);if(h=t=new m(1),r=l=new m(0),e=new m(r),n=e.e=Lo(f)-p.e-1,a=n%Z,e.d[0]=Te(10,a<0?Z+a:a),i==null)i=n>0?e:h;else{if(o=new m(i),!o.isInt()||o.lt(h))throw Error(Rt+o);i=o.gt(e)?n>0?e:h:o}for(q=!1,o=new m(xe(f)),d=m.precision,m.precision=n=f.length*Z*2;u=ce(o,e,0,1,1),s=t.plus(u.times(r)),s.cmp(i)!=1;)t=r,r=s,s=h,h=l.plus(u.times(s)),l=s,s=e,e=o.minus(u.times(s)),o=s;return s=ce(i.minus(t),r,0,1,1),l=l.plus(s.times(h)),t=t.plus(s.times(r)),l.s=h.s=p.s,c=ce(h,r,n,1).minus(p).abs().cmp(ce(l,t,n,1).minus(p).abs())<1?[h,r]:[l,t],m.precision=d,q=!0,c},C.toHexadecimal=C.toHex=function(i,e){return en(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=ce(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 en(this,8,i,e)},C.toPower=C.pow=function(i){var e,t,r,s,n,a,o=this,l=o.constructor,h=+(i=new l(i));if(!o.d||!i.d||!o.d[0]||!i.d[0])return new l(Te(+o,h));if(o=new l(o),o.eq(1))return o;if(r=l.precision,n=l.rounding,i.eq(1))return z(o,r,n);if(e=Me(i.e/Z),e>=i.d.length-1&&(t=h<0?-h:h)<=Yc)return s=Ro(l,o,t,r),i.s<0?new l(1).div(s):z(s,r,n);if(a=o.s,a<0){if(e<i.d.length-1)return new l(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,h),e=t==0||!isFinite(t)?Me(h*(Math.log("0."+xe(o.d))/Math.LN10+o.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?a/0:0):(q=!1,l.rounding=o.s=1,t=Math.min(12,(e+"").length),s=Js(i.times(Nt(o,r+t)),r),s.d&&(s=z(s,r+5,1),tr(s.d,r,n)&&(e=r+10,s=z(Js(i.times(Nt(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,l.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,Lt),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,Lt),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=Z-r.length,t&&(n+=It(t)),n+=r;a=i[e],r=a+"",t=Z-r.length,t&&(n+=It(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 tr(i,e,t,r){var s,n,a,o;for(n=i[0];n>=10;n/=10)--e;return--e<0?(e+=Z,s=0):(s=Math.ceil((e+1)/Z),e%=Z),n=Te(10,Z-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 Xr(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]+=qs.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 Jc(i,e){var t,r,s;if(e.isZero())return e;r=e.d.length,r<32?(t=Math.ceil(r/3),s=(1/Kr(4,t)).toString()):(t=16,s="2.3283064365386962890625e-10"),i.precision+=t,e=bi(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 ce=function(){function i(r,s,n){var a,o=0,l=r.length;for(r=r.slice();l--;)a=r[l]*s+o,r[l]=a%n|0,o=a/n|0;return o&&r.unshift(o),r}function e(r,s,n,a){var o,l;if(n!=a)l=n>a?1:-1;else for(o=l=0;o<n;o++)if(r[o]!=s[o]){l=r[o]>s[o]?1:-1;break}return l}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,l){var h,d,u,c,p,f,m,g,_,w,b,T,L,A,G,R,H,V,I,K,W=r.constructor,he=r.s==s.s?1:-1,ae=r.d,U=s.d;if(!ae||!ae[0]||!U||!U[0])return new W(!r.s||!s.s||(ae?U&&ae[0]==U[0]:!U)?NaN:ae&&ae[0]==0||!U?he*0:he/0);for(l?(p=1,d=r.e-s.e):(l=Qe,p=Z,d=Me(r.e/p)-Me(s.e/p)),I=U.length,H=ae.length,_=new W(he),w=_.d=[],u=0;U[u]==(ae[u]||0);u++);if(U[u]>(ae[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++)G=c*l+(ae[u]||0),w[u]=G/U|0,c=G%U|0;f=c||u<H}else{for(c=l/(U[0]+1)|0,c>1&&(U=i(U,c,l),ae=i(ae,c,l),I=U.length,H=ae.length),R=I,b=ae.slice(0,I),T=b.length;T<I;)b[T++]=0;K=U.slice(),K.unshift(0),V=U[0],U[1]>=l/2&&++V;do c=0,h=e(U,b,I,T),h<0?(L=b[0],I!=T&&(L=L*l+(b[1]||0)),c=L/V|0,c>1?(c>=l&&(c=l-1),m=i(U,c,l),g=m.length,T=b.length,h=e(m,b,g,T),h==1&&(c--,t(m,I<g?K:U,g,l))):(c==0&&(h=c=1),m=U.slice()),g=m.length,g<T&&m.unshift(0),t(b,m,T,l),h==-1&&(T=b.length,h=e(U,b,I,T),h<1&&(c++,t(b,I<T?K:U,T,l))),T=b.length):h===0&&(c++,b=[0]),w[u++]=c,h&&b[0]?b[T++]=ae[R]||0:(b=[ae[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,xo=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,l,h,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+=Z,a=e,d=u[c=0],l=d/Te(10,s-a-1)%10|0;else if(c=Math.ceil((n+1)/Z),o=u.length,c>=o)if(r){for(;o++<=c;)u.push(0);d=l=0,s=1,n%=Z,a=n-Z+1}else break e;else{for(d=o=u[c],s=1;o>=10;o/=10)s++;n%=Z,a=n-Z+s,l=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)),h=t<4?(l||r)&&(t==0||t==(i.s<0?3:2)):l>5||l==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,h?(e-=i.e+1,u[0]=Te(10,(Z-e%Z)%Z),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,Z-n),u[c]=a>0?(d/Te(10,s-a)%Te(10,a)|0)*o:0),h)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 Do(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)+It(r):a>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(i.e<0?"e":"e+")+i.e):s<0?(n="0."+It(-s-1)+n,t&&(r=t-a)>0&&(n+=It(r))):s>=a?(n+=It(s+1-a),t&&(r=t-s-1)>0&&(n=n+"."+It(r))):((r=s+1)<a&&(n=n.slice(0,r)+"."+n.slice(r)),t&&(r=t-a)>0&&(s+1===a&&(n+="."),n+=It(r))),n}function qr(i,e){var t=i[0];for(e*=Z;t>=10;t/=10)e++;return e}function Yr(i,e,t){if(e>Kc)throw q=!0,t&&(i.precision=t),Error(Po);return z(new i(Ur),e,1,!0)}function et(i,e,t){if(e>Ks)throw Error(Po);return z(new i(Zr),e,t,!0)}function Lo(i){var e=i.length-1,t=e*Z+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 It(i){for(var e="";i--;)e+="0";return e}function Ro(i,e,t,r){var s,n=new i(1),a=Math.ceil(r/Z+4);for(q=!1;;){if(t%2&&(n=n.times(e),Fo(n.d,a)&&(s=!0)),t=Me(t/2),t===0){t=n.d.length-1,s&&n.d[t]===0&&++n.d[t];break}e=e.times(e),Fo(e.d,a)}return q=!0,n}function Io(i){return i.d[i.d.length-1]&1}function No(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 Js(i,e){var t,r,s,n,a,o,l,h=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,l=f):l=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,l+=r,t=n=a=new c(1),c.precision=l;;){if(n=z(n.times(i),l,1),t=t.times(++d),o=a.plus(ce(n,t,l,1)),xe(o.d).slice(0,l)===xe(a.d).slice(0,l)){for(s=u;s--;)a=z(a.times(a),l,1);if(e==null)if(h<3&&tr(a.d,l-r,p,h))c.precision=l+=10,t=n=o=new c(1),d=0,h++;else return z(a,c.precision=f,p,q=!0);else return c.precision=f,a}a=o}}function Nt(i,e){var t,r,s,n,a,o,l,h,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 h=Yr(_,d+2,b).times(n+""),m=Nt(new _(r+"."+t.slice(1)),d-f).plus(h),_.precision=b,e==null?z(m,b,w,q=!0):m;for(u=m,l=a=m=ce(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),h=l.plus(ce(a,new _(s),d,1)),xe(h.d).slice(0,d)===xe(l.d).slice(0,d))if(l=l.times(2),n!==0&&(l=l.plus(Yr(_,d+2,b).times(n+""))),l=ce(l,new _(p),d,1),e==null)if(tr(l.d,d-f,w,o))_.precision=d+=f,h=a=m=ce(u.minus(1),u.plus(1),d,1),c=z(m.times(m),d,1),s=o=1;else return z(l,_.precision=b,w,q=!0);else return _.precision=b,l;l=h,s+=2}}function Do(i){return String(i.s*i.s/0)}function Qs(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)%Z,t<0&&(r+=Z),r<s){for(r&&i.d.push(+e.slice(0,r)),s-=Z;r<s;)i.d.push(+e.slice(r,r+=Z));e=e.slice(r),r=Z-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 Qc(i,e){var t,r,s,n,a,o,l,h,d;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Oo.test(e))return Qs(i,e)}else if(e==="Infinity"||e==="NaN")return+e||(i.s=NaN),i.e=NaN,i.d=null,i;if(Xc.test(e))t=16,e=e.toLowerCase();else if(jc.test(e))t=2;else if(qc.test(e))t=8;else throw Error(Rt+e);for(n=e.search(/p/i),n>0?(l=+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=Ro(r,new r(t),n,n*2)),h=Xr(e,t,Qe),d=h.length-1,n=d;h[n]===0;--n)h.pop();return n<0?new r(i.s*0):(i.e=qr(h,d),i.d=h,q=!1,a&&(i=ce(i,s,o*4)),l&&(i=i.times(Math.abs(l)<54?Te(2,l):j.pow(2,l))),q=!0,i)}function ef(i,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:bi(i,2,e,e);t=1.4*Math.sqrt(r),t=t>16?16:t|0,e=e.times(1/Kr(5,t)),e=bi(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 bi(i,e,t,r,s){var n,a,o,l,h=i.precision,d=Math.ceil(h/Z);for(q=!1,l=t.times(t),o=new i(r);;){if(a=ce(o.times(l),new i(e++*e++),h,1),o=s?r.plus(a):r.minus(a),r=ce(a.times(l),new i(e++*e++),h,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 Kr(i,e){for(var t=i;--e;)t*=i;return t}function Go(i,e){var t,r=e.s<0,s=et(i,i.precision,1),n=s.times(.5);if(e=e.abs(),e.lte(n))return _t=r?4:1,e;if(t=e.divToInt(s),t.isZero())_t=r?3:2;else{if(e=e.minus(t.times(s)),e.lte(n))return _t=Io(t)?r?2:3:r?4:1,e;_t=Io(t)?r?1:4:r?3:2}return e.minus(s).abs()}function en(i,e,t,r){var s,n,a,o,l,h,d,u,c,p=i.constructor,f=t!==void 0;if(f?(Ne(t,1,Lt),r===void 0?r=p.rounding:Ne(r,0,8)):(t=p.precision,r=p.rounding),!i.isFinite())d=Do(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=Xr(ot(c),10,s),c.e=c.d.length),u=Xr(d,10,s),n=l=u.length;u[--l]==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=ce(i,c,t,r,0,s),u=i.d,n=i.e,h=xo),a=u[t],o=s/2,h=h||u[t+1]!==void 0,h=r<4?(a!==void 0||h)&&(r===0||r===(i.s<0?3:2)):a>o||a===o&&(r===4||h||r===6&&u[t-1]&1||r===(i.s<0?8:7)),u.length=t,h)for(;++u[--t]>s-1;)u[t]=0,t||(++n,u.unshift(1));for(l=u.length;!u[l-1];--l);for(a=0,d="";a<l;a++)d+=qs.charAt(u[a]);if(f){if(l>1)if(e==16||e==8){for(a=e==16?4:3,--l;l%a;l++)d+="0";for(u=Xr(d,s,e),l=u.length;!u[l-1];--l);for(a=1,d="1.";a<l;a++)d+=qs.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>l)for(n-=l;n--;)d+="0";else n<l&&(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 Fo(i,e){if(i.length>e)return i.length=e,!0}function tf(i){return new this(i).abs()}function rf(i){return new this(i).acos()}function sf(i){return new this(i).acosh()}function nf(i,e){return new this(i).plus(e)}function af(i){return new this(i).asin()}function of(i){return new this(i).asinh()}function hf(i){return new this(i).atan()}function lf(i){return new this(i).atanh()}function df(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=et(this,n,1).times(e.s>0?.25:.75),t.s=i.s):!e.d||i.isZero()?(t=e.s<0?et(this,r,s):new this(0),t.s=i.s):!i.d||e.isZero()?(t=et(this,n,1).times(.5),t.s=i.s):e.s<0?(this.precision=n,this.rounding=1,t=this.atan(ce(i,e,n,1)),e=et(this,n,1),this.precision=r,this.rounding=s,t=i.s<0?t.minus(e):t.plus(e)):t=this.atan(ce(i,e,n,1)),t}function uf(i){return new this(i).cbrt()}function cf(i){return z(i=new this(i),i.e+1,2)}function ff(i,e,t){return new this(i).clamp(e,t)}function pf(i){if(!i||typeof i!="object")throw Error(jr+"Object expected");var e,t,r,s=i.defaults===!0,n=["precision",1,Lt,"rounding",0,8,"toExpNeg",-yi,0,"toExpPos",0,yi,"maxE",0,yi,"minE",-yi,0,"modulo",0,9];for(e=0;e<n.length;e+=3)if(t=n[e],s&&(this[t]=Ys[t]),(r=i[t])!==void 0)if(Me(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]=Ys[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(Ao);else this[t]=!1;else throw Error(Rt+t+": "+r);return this}function mf(i){return new this(i).cos()}function gf(i){return new this(i).cosh()}function Ho(i){var e,t,r;function s(n){var a,o,l,h=this;if(!(h instanceof s))return new s(n);if(h.constructor=s,Bo(n)){h.s=n.s,q?!n.d||n.e>s.maxE?(h.e=NaN,h.d=null):n.e<s.minE?(h.e=0,h.d=[0]):(h.e=n.e,h.d=n.d.slice()):(h.e=n.e,h.d=n.d?n.d.slice():n.d);return}if(l=typeof n,l==="number"){if(n===0){h.s=1/n<0?-1:1,h.e=0,h.d=[0];return}if(n<0?(n=-n,h.s=-1):h.s=1,n===~~n&&n<1e7){for(a=0,o=n;o>=10;o/=10)a++;q?a>s.maxE?(h.e=NaN,h.d=null):a<s.minE?(h.e=0,h.d=[0]):(h.e=a,h.d=[n]):(h.e=a,h.d=[n]);return}else if(n*0!==0){n||(h.s=NaN),h.e=NaN,h.d=null;return}return Qs(h,n.toString())}else if(l!=="string")throw Error(Rt+n);return(o=n.charCodeAt(0))===45?(n=n.slice(1),h.s=-1):(o===43&&(n=n.slice(1)),h.s=1),Oo.test(n)?Qs(h,n):Qc(h,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=pf,s.clone=Ho,s.isDecimal=Bo,s.abs=tf,s.acos=rf,s.acosh=sf,s.add=nf,s.asin=af,s.asinh=of,s.atan=hf,s.atanh=lf,s.atan2=df,s.cbrt=uf,s.ceil=cf,s.clamp=ff,s.cos=mf,s.cosh=gf,s.div=vf,s.exp=yf,s.floor=bf,s.hypot=_f,s.ln=wf,s.log=Sf,s.log10=Cf,s.log2=Tf,s.max=Ef,s.min=kf,s.mod=xf,s.mul=Pf,s.pow=Af,s.random=Mf,s.round=Of,s.sign=Lf,s.sin=Rf,s.sinh=If,s.sqrt=Nf,s.sub=Df,s.sum=Gf,s.tan=Ff,s.tanh=Hf,s.trunc=Bf,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 vf(i,e){return new this(i).div(e)}function yf(i){return new this(i).exp()}function bf(i){return z(i=new this(i),i.e+1,3)}function _f(){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 Bo(i){return i instanceof j||i&&i.toStringTag===Mo||!1}function wf(i){return new this(i).ln()}function Sf(i,e){return new this(i).log(e)}function Tf(i){return new this(i).log(2)}function Cf(i){return new this(i).log(10)}function Ef(){return No(this,arguments,"lt")}function kf(){return No(this,arguments,"gt")}function xf(i,e){return new this(i).mod(e)}function Pf(i,e){return new this(i).mul(e)}function Af(i,e){return new this(i).pow(e)}function Mf(i){var e,t,r,s,n=0,a=new this(1),o=[];if(i===void 0?i=this.precision:Ne(i,1,Lt),r=Math.ceil(i/Z),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(Ao);else for(;n<r;)o[n++]=Math.random()*1e7|0;for(r=o[--n],i%=Z,r&&i&&(s=Te(10,Z-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-=Z)o.shift();for(r=1,s=o[0];s>=10;s/=10)r++;r<Z&&(t-=Z-r)}return a.e=t,a.d=o,a}function Of(i){return z(i=new this(i),i.e+1,this.rounding)}function Lf(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Rf(i){return new this(i).sin()}function If(i){return new this(i).sinh()}function Nf(i){return new this(i).sqrt()}function Df(i,e){return new this(i).sub(e)}function Gf(){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 Ff(i){return new this(i).tan()}function Hf(i){return new this(i).tanh()}function Bf(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 j=C.constructor=Ho(Ys);Ur=new j(Ur),Zr=new j(Zr);function ir(i){return i==null}const $o={editable:!0,style:{...Eo,markerSymbolSize:20,periodMarkerHandleType:"start"}};class Vo extends ko{constructor(e,t,r){super({...$o,...e,style:{...$o.style,...e.style}},t,r)}createSymbol(){switch(this.style.markerSymbolType){case"triangle":let t=j.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 zo={editable:!0,style:{...To,selectedAreaOpacity:.2,markerHandleAreaOpacity:.7}};class Wo extends Co{constructor(e){super({...zo,...e,style:{...zo.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),!ir(this.observation.end)&&!ir(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 Vo({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 Vo({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&&!ir(this.observation.start)}hasEnd(){return this.observation&&!ir(this.observation.end)}}const Uo={editable:!0,style:{...Eo,markerSymbolSize:20}};class $f extends ko{constructor(e,t,r){super({...Uo,...e,style:{...Uo.style,...e.style}},t,r)}createSymbol(){switch(this.style.markerSymbolType){case"triangle":let t=j.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 Zo={description:"",editable:!0,style:{...To}};class jo extends Co{constructor(e){super({...Zo,...e,style:{...Zo.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 $f({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 Vf={...Qi};class tn extends er{constructor(e){super({...e,style:{...Vf,...e.style}}),this.onMarkerFocus$=new $,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 jo(e))}createPeriodMarker(e){return this.addMarker(new Wo(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 zf{static randomHexColor(){return`#${Math.floor(Math.random()*16777215).toString(16)}`}}class _i{static createGoldenRatioWedge(e){let t=new j(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:zf.randomHexColor(),opacity:1})}}function Xo(i,e){return function(){return i.apply(e,arguments)}}const{toString:qo}=Object.prototype,{getPrototypeOf:rn}=Object,sn=(i=>e=>{const t=qo.call(e);return i[t]||(i[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),wt=i=>(i=i.toLowerCase(),e=>sn(e)===i),Jr=i=>e=>typeof e===i,{isArray:wi}=Array,rr=Jr("undefined");function Wf(i){return i!==null&&!rr(i)&&i.constructor!==null&&!rr(i.constructor)&&Dt(i.constructor.isBuffer)&&i.constructor.isBuffer(i)}const Yo=wt("ArrayBuffer");function Uf(i){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(i):e=i&&i.buffer&&Yo(i.buffer),e}const Zf=Jr("string"),Dt=Jr("function"),Ko=Jr("number"),nn=i=>i!==null&&typeof i=="object",jf=i=>i===!0||i===!1,Qr=i=>{if(sn(i)!=="object")return!1;const e=rn(i);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in i)&&!(Symbol.iterator in i)},Xf=wt("Date"),qf=wt("File"),Yf=wt("Blob"),Kf=wt("FileList"),Jf=i=>nn(i)&&Dt(i.pipe),Qf=i=>{const e="[object FormData]";return i&&(typeof FormData=="function"&&i instanceof FormData||qo.call(i)===e||Dt(i.toString)&&i.toString()===e)},ep=wt("URLSearchParams"),tp=i=>i.trim?i.trim():i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function sr(i,e,{allOwnKeys:t=!1}={}){if(i===null||typeof i>"u")return;let r,s;if(typeof i!="object"&&(i=[i]),wi(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 Jo(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 Qo=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),eh=i=>!rr(i)&&i!==Qo;function an(){const{caseless:i}=eh(this)&&this||{},e={},t=(r,s)=>{const n=i&&Jo(e,s)||s;Qr(e[n])&&Qr(r)?e[n]=an(e[n],r):Qr(r)?e[n]=an({},r):wi(r)?e[n]=r.slice():e[n]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&sr(arguments[r],t);return e}const ip=(i,e,t,{allOwnKeys:r}={})=>(sr(e,(s,n)=>{t&&Dt(s)?i[n]=Xo(s,t):i[n]=s},{allOwnKeys:r}),i),rp=i=>(i.charCodeAt(0)===65279&&(i=i.slice(1)),i),sp=(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)},np=(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&&rn(i)}while(i&&(!t||t(i,e))&&i!==Object.prototype);return e},ap=(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},op=i=>{if(!i)return null;if(wi(i))return i;let e=i.length;if(!Ko(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=i[e];return t},hp=(i=>e=>i&&e instanceof i)(typeof Uint8Array<"u"&&rn(Uint8Array)),lp=(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])}},dp=(i,e)=>{let t;const r=[];for(;(t=i.exec(e))!==null;)r.push(t);return r},up=wt("HTMLFormElement"),cp=i=>i.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,s){return r.toUpperCase()+s}),th=(({hasOwnProperty:i})=>(e,t)=>i.call(e,t))(Object.prototype),fp=wt("RegExp"),ih=(i,e)=>{const t=Object.getOwnPropertyDescriptors(i),r={};sr(t,(s,n)=>{e(s,n,i)!==!1&&(r[n]=s)}),Object.defineProperties(i,r)},pp=i=>{ih(i,(e,t)=>{if(Dt(i)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const r=i[t];if(Dt(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+"'")})}})},mp=(i,e)=>{const t={},r=s=>{s.forEach(n=>{t[n]=!0})};return wi(i)?r(i):r(String(i).split(e)),t},gp=()=>{},vp=(i,e)=>(i=+i,Number.isFinite(i)?i:e),on="abcdefghijklmnopqrstuvwxyz",rh="0123456789",sh={DIGIT:rh,ALPHA:on,ALPHA_DIGIT:on+on.toUpperCase()+rh},yp=(i=16,e=sh.ALPHA_DIGIT)=>{let t="";const{length:r}=e;for(;i--;)t+=e[Math.random()*r|0];return t};function bp(i){return!!(i&&Dt(i.append)&&i[Symbol.toStringTag]==="FormData"&&i[Symbol.iterator])}const S={isArray:wi,isArrayBuffer:Yo,isBuffer:Wf,isFormData:Qf,isArrayBufferView:Uf,isString:Zf,isNumber:Ko,isBoolean:jf,isObject:nn,isPlainObject:Qr,isUndefined:rr,isDate:Xf,isFile:qf,isBlob:Yf,isRegExp:fp,isFunction:Dt,isStream:Jf,isURLSearchParams:ep,isTypedArray:hp,isFileList:Kf,forEach:sr,merge:an,extend:ip,trim:tp,stripBOM:rp,inherits:sp,toFlatObject:np,kindOf:sn,kindOfTest:wt,endsWith:ap,toArray:op,forEachEntry:lp,matchAll:dp,isHTMLForm:up,hasOwnProperty:th,hasOwnProp:th,reduceDescriptors:ih,freezeMethods:pp,toObjectSet:mp,toCamelCase:cp,noop:gp,toFiniteNumber:vp,findKey:Jo,global:Qo,isContextDefined:eh,ALPHABET:sh,generateString:yp,isSpecCompliantForm:bp,toJSONObject:i=>{const e=new Array(10),t=(r,s)=>{if(nn(r)){if(e.indexOf(r)>=0)return;if(!("toJSON"in r)){e[s]=r;const n=wi(r)?[]:{};return sr(r,(a,o)=>{const l=t(a,s+1);!rr(l)&&(n[o]=l)}),e[s]=void 0,n}}return r};return t(i,0)}};function re(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(re,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 nh=re.prototype,ah={};["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=>{ah[i]={value:i}}),Object.defineProperties(re,ah),Object.defineProperty(nh,"isAxiosError",{value:!0}),re.from=(i,e,t,r,s,n)=>{const a=Object.create(nh);return S.toFlatObject(i,a,function(l){return l!==Error.prototype},o=>o!=="isAxiosError"),re.call(a,i.message,e,t,r,s),a.cause=i,a.name=i.name,n&&Object.assign(a,n),a};const _p=null;function hn(i){return S.isPlainObject(i)||S.isArray(i)}function oh(i){return S.endsWith(i,"[]")?i.slice(0,-2):i}function hh(i,e,t){return i?i.concat(e).map(function(s,n){return s=oh(s),!t&&n?"["+s+"]":s}).join(t?".":""):e}function wp(i){return S.isArray(i)&&!i.some(hn)}const Sp=S.toFlatObject(S,{},null,function(e){return/^is[A-Z]/.test(e)});function es(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,l=(t.Blob||typeof Blob<"u"&&Blob)&&S.isSpecCompliantForm(e);if(!S.isFunction(s))throw new TypeError("visitor must be a function");function h(f){if(f===null)return"";if(S.isDate(f))return f.toISOString();if(!l&&S.isBlob(f))throw new re("Blob is not supported. Use a Buffer instead.");return S.isArrayBuffer(f)||S.isTypedArray(f)?l&&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)&&wp(f)||(S.isFileList(f)||S.endsWith(m,"[]"))&&(_=S.toArray(f)))return m=oh(m),_.forEach(function(b,T){!(S.isUndefined(b)||b===null)&&e.append(a===!0?hh([m],T,n):a===null?m:m+"[]",h(b))}),!1}return hn(f)?!0:(e.append(hh(g,m,n),h(f)),!1)}const u=[],c=Object.assign(Sp,{defaultVisitor:d,convertValue:h,isVisitable:hn});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 lh(i){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(i).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function ln(i,e){this._pairs=[],i&&es(i,this,e)}const dh=ln.prototype;dh.append=function(e,t){this._pairs.push([e,t])},dh.toString=function(e){const t=e?function(r){return e.call(this,r,lh)}:lh;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function Tp(i){return encodeURIComponent(i).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function uh(i,e,t){if(!e)return i;const r=t&&t.encode||Tp,s=t&&t.serialize;let n;if(s?n=s(e,t):n=S.isURLSearchParams(e)?e.toString():new ln(e,t).toString(r),n){const a=i.indexOf("#");a!==-1&&(i=i.slice(0,a)),i+=(i.indexOf("?")===-1?"?":"&")+n}return i}class Cp{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 ch=Cp,fh={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ep=typeof URLSearchParams<"u"?URLSearchParams:ln,kp=typeof FormData<"u"?FormData:null,xp=(()=>{let i;return typeof navigator<"u"&&((i=navigator.product)==="ReactNative"||i==="NativeScript"||i==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Pp=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),ht={isBrowser:!0,classes:{URLSearchParams:Ep,FormData:kp,Blob},isStandardBrowserEnv:xp,isStandardBrowserWebWorkerEnv:Pp,protocols:["http","https","file","blob","url","data"]};function Ap(i,e){return es(i,new ht.classes.URLSearchParams,Object.assign({visitor:function(t,r,s,n){return ht.isNode&&S.isBuffer(t)?(this.append(r,t.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},e))}function Mp(i){return S.matchAll(/\w+|\[(\w*)]/g,i).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Op(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 ph(i){function e(t,r,s,n){let a=t[n++];const o=Number.isFinite(+a),l=n>=t.length;return a=!a&&S.isArray(s)?s.length:a,l?(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]=Op(s[a])),!o)}if(S.isFormData(i)&&S.isFunction(i.entries)){const t={};return S.forEachEntry(i,(r,s)=>{e(Mp(r),s,t,0)}),t}return null}const Lp={"Content-Type":void 0};function Rp(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 ts={transitional:fh,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(ph(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 Ap(e,this.formSerializer).toString();if((o=S.isFileList(e))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return es(o?{"files[]":e}:e,l&&new l,this.formSerializer)}}return n||s?(t.setContentType("application/json",!1),Rp(e)):e}],transformResponse:[function(e){const t=this.transitional||ts.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"?re.from(o,re.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:ht.classes.FormData,Blob:ht.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};S.forEach(["delete","get","head"],function(e){ts.headers[e]={}}),S.forEach(["post","put","patch"],function(e){ts.headers[e]=S.merge(Lp)});const dn=ts,Ip=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"]),Np=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]&&Ip[t])&&(t==="set-cookie"?e[t]?e[t].push(r):e[t]=[r]:e[t]=e[t]?e[t]+", "+r:r)}),e},mh=Symbol("internals");function nr(i){return i&&String(i).trim().toLowerCase()}function is(i){return i===!1||i==null?i:S.isArray(i)?i.map(is):String(i)}function Dp(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 Gp(i){return/^[-_a-zA-Z]+$/.test(i.trim())}function un(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 Fp(i){return i.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}function Hp(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 rs{constructor(e){e&&this.set(e)}set(e,t,r){const s=this;function n(o,l,h){const d=nr(l);if(!d)throw new Error("header name must be a non-empty string");const u=S.findKey(s,d);(!u||s[u]===void 0||h===!0||h===void 0&&s[u]!==!1)&&(s[u||l]=is(o))}const a=(o,l)=>S.forEach(o,(h,d)=>n(h,d,l));return S.isPlainObject(e)||e instanceof this.constructor?a(e,t):S.isString(e)&&(e=e.trim())&&!Gp(e)?a(Np(e),t):e!=null&&n(t,e,r),this}get(e,t){if(e=nr(e),e){const r=S.findKey(this,e);if(r){const s=this[r];if(!t)return s;if(t===!0)return Dp(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=nr(e),e){const r=S.findKey(this,e);return!!(r&&this[r]!==void 0&&(!t||un(this,this[r],r,t)))}return!1}delete(e,t){const r=this;let s=!1;function n(a){if(a=nr(a),a){const o=S.findKey(r,a);o&&(!t||un(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||un(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]=is(s),delete t[n];return}const o=e?Fp(n):String(n).trim();o!==n&&delete t[n],t[o]=is(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[mh]=this[mh]={accessors:{}}).accessors,s=this.prototype;function n(a){const o=nr(a);r[o]||(Hp(s,a),r[o]=!0)}return S.isArray(e)?e.forEach(n):n(e),this}}rs.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),S.freezeMethods(rs.prototype),S.freezeMethods(rs);const St=rs;function cn(i,e){const t=this||dn,r=e||t,s=St.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 gh(i){return!!(i&&i.__CANCEL__)}function ar(i,e,t){re.call(this,i??"canceled",re.ERR_CANCELED,e,t),this.name="CanceledError"}S.inherits(ar,re,{__CANCEL__:!0});function Bp(i,e,t){const r=t.config.validateStatus;!t.status||!r||r(t.status)?i(t):e(new re("Request failed with status code "+t.status,[re.ERR_BAD_REQUEST,re.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}const $p=ht.isStandardBrowserEnv?function(){return{write:function(t,r,s,n,a,o){const l=[];l.push(t+"="+encodeURIComponent(r)),S.isNumber(s)&&l.push("expires="+new Date(s).toGMTString()),S.isString(n)&&l.push("path="+n),S.isString(a)&&l.push("domain="+a),o===!0&&l.push("secure"),document.cookie=l.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 Vp(i){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(i)}function zp(i,e){return e?i.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):i}function vh(i,e){return i&&!Vp(e)?zp(i,e):e}const Wp=ht.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 Up(i){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(i);return e&&e[1]||""}function Zp(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(l){const h=Date.now(),d=r[n];a||(a=h),t[s]=l,r[s]=h;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),h-a<e)return;const p=d&&h-d;return p?Math.round(c*1e3/p):void 0}}function yh(i,e){let t=0;const r=Zp(50,250);return s=>{const n=s.loaded,a=s.lengthComputable?s.total:void 0,o=n-t,l=r(o),h=n<=a;t=n;const d={loaded:n,total:a,progress:a?n/a:void 0,bytes:o,rate:l||void 0,estimated:l&&a&&h?(a-n)/l:void 0,event:s};d[e?"download":"upload"]=!0,i(d)}}const ss={http:_p,xhr:typeof XMLHttpRequest<"u"&&function(i){return new Promise(function(t,r){let s=i.data;const n=St.from(i.headers).normalize(),a=i.responseType;let o;function l(){i.cancelToken&&i.cancelToken.unsubscribe(o),i.signal&&i.signal.removeEventListener("abort",o)}S.isFormData(s)&&(ht.isStandardBrowserEnv||ht.isStandardBrowserWebWorkerEnv)&&n.setContentType(!1);let h=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=vh(i.baseURL,i.url);h.open(i.method.toUpperCase(),uh(d,i.params,i.paramsSerializer),!0),h.timeout=i.timeout;function u(){if(!h)return;const p=St.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),m={data:!a||a==="text"||a==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:p,config:i,request:h};Bp(function(_){t(_),l()},function(_){r(_),l()},m),h=null}if("onloadend"in h?h.onloadend=u:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(u)},h.onabort=function(){h&&(r(new re("Request aborted",re.ECONNABORTED,i,h)),h=null)},h.onerror=function(){r(new re("Network Error",re.ERR_NETWORK,i,h)),h=null},h.ontimeout=function(){let f=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const m=i.transitional||fh;i.timeoutErrorMessage&&(f=i.timeoutErrorMessage),r(new re(f,m.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,i,h)),h=null},ht.isStandardBrowserEnv){const p=(i.withCredentials||Wp(d))&&i.xsrfCookieName&&$p.read(i.xsrfCookieName);p&&n.set(i.xsrfHeaderName,p)}s===void 0&&n.setContentType(null),"setRequestHeader"in h&&S.forEach(n.toJSON(),function(f,m){h.setRequestHeader(m,f)}),S.isUndefined(i.withCredentials)||(h.withCredentials=!!i.withCredentials),a&&a!=="json"&&(h.responseType=i.responseType),typeof i.onDownloadProgress=="function"&&h.addEventListener("progress",yh(i.onDownloadProgress,!0)),typeof i.onUploadProgress=="function"&&h.upload&&h.upload.addEventListener("progress",yh(i.onUploadProgress)),(i.cancelToken||i.signal)&&(o=p=>{h&&(r(!p||p.type?new ar(null,i,h):p),h.abort(),h=null)},i.cancelToken&&i.cancelToken.subscribe(o),i.signal&&(i.signal.aborted?o():i.signal.addEventListener("abort",o)));const c=Up(d);if(c&&ht.protocols.indexOf(c)===-1){r(new re("Unsupported protocol "+c+":",re.ERR_BAD_REQUEST,i));return}h.send(s||null)})}};S.forEach(ss,(i,e)=>{if(i){try{Object.defineProperty(i,"name",{value:e})}catch{}Object.defineProperty(i,"adapterName",{value:e})}});const jp={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)?ss[t.toLowerCase()]:t));s++);if(!r)throw r===!1?new re(`Adapter ${t} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(S.hasOwnProp(ss,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:ss};function fn(i){if(i.cancelToken&&i.cancelToken.throwIfRequested(),i.signal&&i.signal.aborted)throw new ar(null,i)}function bh(i){return fn(i),i.headers=St.from(i.headers),i.data=cn.call(i,i.transformRequest),["post","put","patch"].indexOf(i.method)!==-1&&i.headers.setContentType("application/x-www-form-urlencoded",!1),jp.getAdapter(i.adapter||dn.adapter)(i).then(function(r){return fn(i),r.data=cn.call(i,i.transformResponse,r),r.headers=St.from(r.headers),r},function(r){return gh(r)||(fn(i),r&&r.response&&(r.response.data=cn.call(i,i.transformResponse,r.response),r.response.headers=St.from(r.response.headers))),Promise.reject(r)})}const _h=i=>i instanceof St?i.toJSON():i;function Si(i,e){e=e||{};const t={};function r(h,d,u){return S.isPlainObject(h)&&S.isPlainObject(d)?S.merge.call({caseless:u},h,d):S.isPlainObject(d)?S.merge({},d):S.isArray(d)?d.slice():d}function s(h,d,u){if(S.isUndefined(d)){if(!S.isUndefined(h))return r(void 0,h,u)}else return r(h,d,u)}function n(h,d){if(!S.isUndefined(d))return r(void 0,d)}function a(h,d){if(S.isUndefined(d)){if(!S.isUndefined(h))return r(void 0,h)}else return r(void 0,d)}function o(h,d,u){if(u in e)return r(h,d);if(u in i)return r(void 0,h)}const l={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:(h,d)=>s(_h(h),_h(d),!0)};return S.forEach(Object.keys(i).concat(Object.keys(e)),function(d){const u=l[d]||s,c=u(i[d],e[d],d);S.isUndefined(c)&&u!==o||(t[d]=c)}),t}const wh="1.3.3",pn={};["object","boolean","number","function","string","symbol"].forEach((i,e)=>{pn[i]=function(r){return typeof r===i||"a"+(e<1?"n ":" ")+i}});const Sh={};pn.transitional=function(e,t,r){function s(n,a){return"[Axios v"+wh+"] Transitional option '"+n+"'"+a+(r?". "+r:"")}return(n,a,o)=>{if(e===!1)throw new re(s(a," has been removed"+(t?" in "+t:"")),re.ERR_DEPRECATED);return t&&!Sh[a]&&(Sh[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 Xp(i,e,t){if(typeof i!="object")throw new re("options must be an object",re.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],l=o===void 0||a(o,n,i);if(l!==!0)throw new re("option "+n+" must be "+l,re.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new re("Unknown option "+n,re.ERR_BAD_OPTION)}}const mn={assertOptions:Xp,validators:pn},Gt=mn.validators;class ns{constructor(e){this.defaults=e,this.interceptors={request:new ch,response:new ch}}request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Si(this.defaults,t);const{transitional:r,paramsSerializer:s,headers:n}=t;r!==void 0&&mn.assertOptions(r,{silentJSONParsing:Gt.transitional(Gt.boolean),forcedJSONParsing:Gt.transitional(Gt.boolean),clarifyTimeoutError:Gt.transitional(Gt.boolean)},!1),s!==void 0&&mn.assertOptions(s,{encode:Gt.function,serialize:Gt.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=St.concat(a,n);const o=[];let l=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(l=l&&m.synchronous,o.unshift(m.fulfilled,m.rejected))});const h=[];this.interceptors.response.forEach(function(m){h.push(m.fulfilled,m.rejected)});let d,u=0,c;if(!l){const f=[bh.bind(this),void 0];for(f.unshift.apply(f,o),f.push.apply(f,h),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=bh.call(this,p)}catch(f){return Promise.reject(f)}for(u=0,c=h.length;u<c;)d=d.then(h[u++],h[u++]);return d}getUri(e){e=Si(this.defaults,e);const t=vh(e.baseURL,e.url);return uh(t,e.params,e.paramsSerializer)}}S.forEach(["delete","get","head","options"],function(e){ns.prototype[e]=function(t,r){return this.request(Si(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(Si(o||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:n,data:a}))}}ns.prototype[e]=t(),ns.prototype[e+"Form"]=t(!0)});const as=ns;class gn{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 gn(function(s){e=s}),cancel:e}}}const qp=gn;function Yp(i){return function(t){return i.apply(null,t)}}function Kp(i){return S.isObject(i)&&i.isAxiosError===!0}const vn={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(vn).forEach(([i,e])=>{vn[e]=i});const Jp=vn;function Th(i){const e=new as(i),t=Xo(as.prototype.request,e);return S.extend(t,as.prototype,e,{allOwnKeys:!0}),S.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return Th(Si(i,s))},t}const Ce=Th(dn);Ce.Axios=as,Ce.CanceledError=ar,Ce.CancelToken=qp,Ce.isCancel=gh,Ce.VERSION=wh,Ce.toFormData=es,Ce.AxiosError=re,Ce.Cancel=Ce.CanceledError,Ce.all=function(e){return Promise.all(e)},Ce.spread=Yp,Ce.isAxiosError=Kp,Ce.mergeConfig=Si,Ce.AxiosHeaders=St,Ce.formToJSON=i=>ph(S.isHTMLForm(i)?new FormData(i):i),Ce.HttpStatusCode=Jp,Ce.default=Ce;const Ch=Ce;function Qp(i,e){return ir(e)?Ch.get(i):Ch.get(i,e)}function Ue(i,e){this.message=i,this.error=e}Ue.prototype=Object.create(Error.prototype);const yn=/([0-9]+)?:?([0-9]{2}):([0-9]{2}\.[0-9]{2,3})/;function em(i,e){e||(e={});const{meta:t=!1,strict:r=!0}=e;if(typeof i!="string")throw new Ue("Input must be a string");i=i.trim(),i=i.replace(/\r\n/g,`
13
- `),i=i.replace(/\r/g,`
14
- `);const s=i.split(`
10
+ */var bi=9e15,Lt=1e9,Ys="0123456789abcdef",Zr="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",jr="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Ks={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-bi,maxE:bi,crypto:!1},xo,_t,q=!0,Xr="[DecimalError] ",Rt=Xr+"Invalid argument: ",Po=Xr+"Precision limit exceeded",Ao=Xr+"crypto unavailable",Oo="[object Decimal]",Oe=Math.floor,Te=Math.pow,qc=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Yc=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Kc=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Mo=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,et=1e7,Z=7,Jc=9007199254740991,Qc=Zr.length-1,Js=jr.length-1,C={toStringTag:Oo};C.absoluteValue=C.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),z(r)},C.ceil=function(){return z(new this.constructor(this),this.e+1,2)},C.clampedTo=C.clamp=function(r,e){var t,i=this,s=i.constructor;if(r=new s(r),e=new s(e),!r.s||!e.s)return new s(NaN);if(r.gt(e))throw Error(Rt+e);return t=i.cmp(r),t<0?r:i.cmp(e)>0?e:new s(i)},C.comparedTo=C.cmp=function(r){var e,t,i,s,n=this,a=n.d,o=(r=new n.constructor(r)).d,l=n.s,h=r.s;if(!a||!o)return!l||!h?NaN:l!==h?l:a===o?0:!a^l<0?1:-1;if(!a[0]||!o[0])return a[0]?l:o[0]?-h:0;if(l!==h)return l;if(n.e!==r.e)return n.e>r.e^l<0?1:-1;for(i=a.length,s=o.length,e=0,t=i<s?i:s;e<t;++e)if(a[e]!==o[e])return a[e]>o[e]^l<0?1:-1;return i===s?0:i>s^l<0?1:-1},C.cosine=C.cos=function(){var r,e,t=this,i=t.constructor;return t.d?t.d[0]?(r=i.precision,e=i.rounding,i.precision=r+Math.max(t.e,t.sd())+Z,i.rounding=1,t=ef(i,Go(i,t)),i.precision=r,i.rounding=e,z(_t==2||_t==3?t.neg():t,r,e,!0)):new i(1):new i(NaN)},C.cubeRoot=C.cbrt=function(){var r,e,t,i,s,n,a,o,l,h,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),r=d.e,(n=(r-t.length+1)%3)&&(t+=n==1||n==-2?"0":"00"),n=Te(t,1/3),r=Oe((r+1)/3)-(r%3==(r<0?-1:2)),n==1/0?t="5e"+r:(t=n.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),i=new u(t),i.s=d.s):i=new u(n.toString()),a=(r=u.precision)+3;;)if(o=i,l=o.times(o).times(o),h=l.plus(d),i=ce(h.plus(d).times(o),h.plus(l),a+2,1),xe(o.d).slice(0,a)===(t=xe(i.d)).slice(0,a))if(t=t.slice(a-3,a+1),t=="9999"||!s&&t=="4999"){if(!s&&(z(o,r+1,0),o.times(o).times(o).eq(d))){i=o;break}a+=4,s=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(z(i,r+1,1),e=!i.times(i).times(i).eq(d));break}return q=!0,z(i,r,u.rounding,e)},C.decimalPlaces=C.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-Oe(this.e/Z))*Z,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t},C.dividedBy=C.div=function(r){return ce(this,new this.constructor(r))},C.dividedToIntegerBy=C.divToInt=function(r){var e=this,t=e.constructor;return z(ce(e,new t(r),0,1,1),t.precision,t.rounding)},C.equals=C.eq=function(r){return this.cmp(r)===0},C.floor=function(){return z(new this.constructor(this),this.e+1,3)},C.greaterThan=C.gt=function(r){return this.cmp(r)>0},C.greaterThanOrEqualTo=C.gte=function(r){var e=this.cmp(r);return e==1||e===0},C.hyperbolicCosine=C.cosh=function(){var r,e,t,i,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,i=a.rounding,a.precision=t+Math.max(n.e,n.sd())+4,a.rounding=1,s=n.d.length,s<32?(r=Math.ceil(s/3),e=(1/Jr(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),n=_i(a,1,n.times(e),new a(1),!0);for(var l,h=r,d=new a(8);h--;)l=n.times(n),n=o.minus(l.times(d.minus(l.times(d))));return z(n,a.precision=t,a.rounding=i,!0)},C.hyperbolicSine=C.sinh=function(){var r,e,t,i,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,i=s.d.length,i<3)s=_i(n,2,s,s,!0);else{r=1.4*Math.sqrt(i),r=r>16?16:r|0,s=s.times(1/Jr(5,r)),s=_i(n,2,s,s,!0);for(var a,o=new n(5),l=new n(16),h=new n(20);r--;)a=s.times(s),s=s.times(o.plus(a.times(l.times(a).plus(h))))}return n.precision=e,n.rounding=t,z(s,e,t,!0)},C.hyperbolicTangent=C.tanh=function(){var r,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(r=i.precision,e=i.rounding,i.precision=r+7,i.rounding=1,ce(t.sinh(),t.cosh(),i.precision=r,i.rounding=e)):new i(t.s)},C.inverseCosine=C.acos=function(){var r,e=this,t=e.constructor,i=e.abs().cmp(1),s=t.precision,n=t.rounding;return i!==-1?i===0?e.isNeg()?tt(t,s,n):new t(0):new t(NaN):e.isZero()?tt(t,s+4,n).times(.5):(t.precision=s+6,t.rounding=1,e=e.asin(),r=tt(t,s+4,n).times(.5),t.precision=s,t.rounding=n,r.minus(e))},C.inverseHyperbolicCosine=C.acosh=function(){var r,e,t=this,i=t.constructor;return t.lte(1)?new i(t.eq(1)?0:NaN):t.isFinite()?(r=i.precision,e=i.rounding,i.precision=r+Math.max(Math.abs(t.e),t.sd())+4,i.rounding=1,q=!1,t=t.times(t).minus(1).sqrt().plus(t),q=!0,i.precision=r,i.rounding=e,t.ln()):new i(t)},C.inverseHyperbolicSine=C.asinh=function(){var r,e,t=this,i=t.constructor;return!t.isFinite()||t.isZero()?new i(t):(r=i.precision,e=i.rounding,i.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,i.rounding=1,q=!1,t=t.times(t).plus(1).sqrt().plus(t),q=!0,i.precision=r,i.rounding=e,t.ln())},C.inverseHyperbolicTangent=C.atanh=function(){var r,e,t,i,s=this,n=s.constructor;return s.isFinite()?s.e>=0?new n(s.abs().eq(1)?s.s/0:s.isZero()?s:NaN):(r=n.precision,e=n.rounding,i=s.sd(),Math.max(i,r)<2*-s.e-1?z(new n(s),r,e,!0):(n.precision=t=i-s.e,s=ce(s.plus(1),new n(1).minus(s),t+r,1),n.precision=r+4,n.rounding=1,s=s.ln(),n.precision=r,n.rounding=e,s.times(.5))):new n(NaN)},C.inverseSine=C.asin=function(){var r,e,t,i,s=this,n=s.constructor;return s.isZero()?new n(s):(e=s.abs().cmp(1),t=n.precision,i=n.rounding,e!==-1?e===0?(r=tt(n,t+4,i).times(.5),r.s=s.s,r):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=i,s.times(2)))},C.inverseTangent=C.atan=function(){var r,e,t,i,s,n,a,o,l,h=this,d=h.constructor,u=d.precision,c=d.rounding;if(h.isFinite()){if(h.isZero())return new d(h);if(h.abs().eq(1)&&u+4<=Js)return a=tt(d,u+4,c).times(.25),a.s=h.s,a}else{if(!h.s)return new d(NaN);if(u+4<=Js)return a=tt(d,u+4,c).times(.5),a.s=h.s,a}for(d.precision=o=u+10,d.rounding=1,t=Math.min(28,o/Z+2|0),r=t;r;--r)h=h.div(h.times(h).plus(1).sqrt().plus(1));for(q=!1,e=Math.ceil(o/Z),i=1,l=h.times(h),a=new d(h),s=h;r!==-1;)if(s=s.times(l),n=a.minus(s.div(i+=2)),s=s.times(l),a=n.plus(s.div(i+=2)),a.d[e]!==void 0)for(r=e;a.d[r]===n.d[r]&&r--;);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/Z)>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(r){return this.cmp(r)<0},C.lessThanOrEqualTo=C.lte=function(r){return this.cmp(r)<1},C.logarithm=C.log=function(r){var e,t,i,s,n,a,o,l,h=this,d=h.constructor,u=d.precision,c=d.rounding,p=5;if(r==null)r=new d(10),e=!0;else{if(r=new d(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new d(NaN);e=r.eq(10)}if(t=h.d,h.s<0||!t||!t[0]||h.eq(1))return new d(t&&!t[0]?-1/0:h.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=Nt(h,o),i=e?Kr(d,o+10):Nt(r,o),l=ce(a,i,o,1),ir(l.d,s=u,c))do if(o+=10,a=Nt(h,o),i=e?Kr(d,o+10):Nt(r,o),l=ce(a,i,o,1),!n){+xe(l.d).slice(s+1,s+15)+1==1e14&&(l=z(l,u+1,0));break}while(ir(l.d,s+=10,c));return q=!0,z(l,u,c)},C.minus=C.sub=function(r){var e,t,i,s,n,a,o,l,h,d,u,c,p=this,f=p.constructor;if(r=new f(r),!p.d||!r.d)return!p.s||!r.s?r=new f(NaN):p.d?r.s=-r.s:r=new f(r.d||p.s!==r.s?p:NaN),r;if(p.s!=r.s)return r.s=-r.s,p.plus(r);if(h=p.d,c=r.d,o=f.precision,l=f.rounding,!h[0]||!c[0]){if(c[0])r.s=-r.s;else if(h[0])r=new f(p);else return new f(l===3?-0:0);return q?z(r,o,l):r}if(t=Oe(r.e/Z),d=Oe(p.e/Z),h=h.slice(),n=d-t,n){for(u=n<0,u?(e=h,n=-n,a=c.length):(e=c,t=d,a=h.length),i=Math.max(Math.ceil(o/Z),a)+2,n>i&&(n=i,e.length=1),e.reverse(),i=n;i--;)e.push(0);e.reverse()}else{for(i=h.length,a=c.length,u=i<a,u&&(a=i),i=0;i<a;i++)if(h[i]!=c[i]){u=h[i]<c[i];break}n=0}for(u&&(e=h,h=c,c=e,r.s=-r.s),a=h.length,i=c.length-a;i>0;--i)h[a++]=0;for(i=c.length;i>n;){if(h[--i]<c[i]){for(s=i;s&&h[--s]===0;)h[s]=et-1;--h[s],h[i]+=et}h[i]-=c[i]}for(;h[--a]===0;)h.pop();for(;h[0]===0;h.shift())--t;return h[0]?(r.d=h,r.e=Yr(h,t),q?z(r,o,l):r):new f(l===3?-0:0)},C.modulo=C.mod=function(r){var e,t=this,i=t.constructor;return r=new i(r),!t.d||!r.s||r.d&&!r.d[0]?new i(NaN):!r.d||t.d&&!t.d[0]?z(new i(t),i.precision,i.rounding):(q=!1,i.modulo==9?(e=ce(t,r.abs(),0,3,1),e.s*=r.s):e=ce(t,r,0,i.modulo,1),e=e.times(r),q=!0,t.minus(e))},C.naturalExponential=C.exp=function(){return Qs(this)},C.naturalLogarithm=C.ln=function(){return Nt(this)},C.negated=C.neg=function(){var r=new this.constructor(this);return r.s=-r.s,z(r)},C.plus=C.add=function(r){var e,t,i,s,n,a,o,l,h,d,u=this,c=u.constructor;if(r=new c(r),!u.d||!r.d)return!u.s||!r.s?r=new c(NaN):u.d||(r=new c(r.d||u.s===r.s?u:NaN)),r;if(u.s!=r.s)return r.s=-r.s,u.minus(r);if(h=u.d,d=r.d,o=c.precision,l=c.rounding,!h[0]||!d[0])return d[0]||(r=new c(u)),q?z(r,o,l):r;if(n=Oe(u.e/Z),i=Oe(r.e/Z),h=h.slice(),s=n-i,s){for(s<0?(t=h,s=-s,a=d.length):(t=d,i=n,a=h.length),n=Math.ceil(o/Z),a=n>a?n+1:a+1,s>a&&(s=a,t.length=1),t.reverse();s--;)t.push(0);t.reverse()}for(a=h.length,s=d.length,a-s<0&&(s=a,t=d,d=h,h=t),e=0;s;)e=(h[--s]=h[s]+d[s]+e)/et|0,h[s]%=et;for(e&&(h.unshift(e),++i),a=h.length;h[--a]==0;)h.pop();return r.d=h,r.e=Yr(h,i),q?z(r,o,l):r},C.precision=C.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(Rt+r);return t.d?(e=Lo(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e},C.round=function(){var r=this,e=r.constructor;return z(new e(r),r.e+1,e.rounding)},C.sine=C.sin=function(){var r,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(r=i.precision,e=i.rounding,i.precision=r+Math.max(t.e,t.sd())+Z,i.rounding=1,t=rf(i,Go(i,t)),i.precision=r,i.rounding=e,z(_t>2?t.neg():t,r,e,!0)):new i(NaN)},C.squareRoot=C.sqrt=function(){var r,e,t,i,s,n,a=this,o=a.d,l=a.e,h=a.s,d=a.constructor;if(h!==1||!o||!o[0])return new d(!h||h<0&&(!o||o[0])?NaN:o?a:1/0);for(q=!1,h=Math.sqrt(+a),h==0||h==1/0?(e=xe(o),(e.length+l)%2==0&&(e+="0"),h=Math.sqrt(e),l=Oe((l+1)/2)-(l<0||l%2),h==1/0?e="5e"+l:(e=h.toExponential(),e=e.slice(0,e.indexOf("e")+1)+l),i=new d(e)):i=new d(h.toString()),t=(l=d.precision)+3;;)if(n=i,i=n.plus(ce(a,n,t+2,1)).times(.5),xe(n.d).slice(0,t)===(e=xe(i.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!s&&e=="4999"){if(!s&&(z(n,l+1,0),n.times(n).eq(a))){i=n;break}t+=4,s=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(z(i,l+1,1),r=!i.times(i).eq(a));break}return q=!0,z(i,l,d.rounding,r)},C.tangent=C.tan=function(){var r,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(r=i.precision,e=i.rounding,i.precision=r+10,i.rounding=1,t=t.sin(),t.s=1,t=ce(t,new i(1).minus(t.times(t)).sqrt(),r+10,0),i.precision=r,i.rounding=e,z(_t==2||_t==4?t.neg():t,r,e,!0)):new i(NaN)},C.times=C.mul=function(r){var e,t,i,s,n,a,o,l,h,d=this,u=d.constructor,c=d.d,p=(r=new u(r)).d;if(r.s*=d.s,!c||!c[0]||!p||!p[0])return new u(!r.s||c&&!c[0]&&!p||p&&!p[0]&&!c?NaN:!c||!p?r.s/0:r.s*0);for(t=Oe(d.e/Z)+Oe(r.e/Z),l=c.length,h=p.length,l<h&&(n=c,c=p,p=n,a=l,l=h,h=a),n=[],a=l+h,i=a;i--;)n.push(0);for(i=h;--i>=0;){for(e=0,s=l+i;s>i;)o=n[s]+p[i]*c[s-i-1]+e,n[s--]=o%et|0,e=o/et|0;n[s]=(n[s]+e)%et|0}for(;!n[--a];)n.pop();return e?++t:n.shift(),r.d=n,r.e=Yr(n,t),q?z(r,u.precision,u.rounding):r},C.toBinary=function(r,e){return tn(this,2,r,e)},C.toDecimalPlaces=C.toDP=function(r,e){var t=this,i=t.constructor;return t=new i(t),r===void 0?t:(Ne(r,0,Lt),e===void 0?e=i.rounding:Ne(e,0,8),z(t,r+t.e+1,e))},C.toExponential=function(r,e){var t,i=this,s=i.constructor;return r===void 0?t=ht(i,!0):(Ne(r,0,Lt),e===void 0?e=s.rounding:Ne(e,0,8),i=z(new s(i),r+1,e),t=ht(i,!0,r+1)),i.isNeg()&&!i.isZero()?"-"+t:t},C.toFixed=function(r,e){var t,i,s=this,n=s.constructor;return r===void 0?t=ht(s):(Ne(r,0,Lt),e===void 0?e=n.rounding:Ne(e,0,8),i=z(new n(s),r+s.e+1,e),t=ht(i,!1,r+i.e+1)),s.isNeg()&&!s.isZero()?"-"+t:t},C.toFraction=function(r){var e,t,i,s,n,a,o,l,h,d,u,c,p=this,f=p.d,m=p.constructor;if(!f)return new m(p);if(h=t=new m(1),i=l=new m(0),e=new m(i),n=e.e=Lo(f)-p.e-1,a=n%Z,e.d[0]=Te(10,a<0?Z+a:a),r==null)r=n>0?e:h;else{if(o=new m(r),!o.isInt()||o.lt(h))throw Error(Rt+o);r=o.gt(e)?n>0?e:h:o}for(q=!1,o=new m(xe(f)),d=m.precision,m.precision=n=f.length*Z*2;u=ce(o,e,0,1,1),s=t.plus(u.times(i)),s.cmp(r)!=1;)t=i,i=s,s=h,h=l.plus(u.times(s)),l=s,s=e,e=o.minus(u.times(s)),o=s;return s=ce(r.minus(t),i,0,1,1),l=l.plus(s.times(h)),t=t.plus(s.times(i)),l.s=h.s=p.s,c=ce(h,i,n,1).minus(p).abs().cmp(ce(l,t,n,1).minus(p).abs())<1?[h,i]:[l,t],m.precision=d,q=!0,c},C.toHexadecimal=C.toHex=function(r,e){return tn(this,16,r,e)},C.toNearest=function(r,e){var t=this,i=t.constructor;if(t=new i(t),r==null){if(!t.d)return t;r=new i(1),e=i.rounding}else{if(r=new i(r),e===void 0?e=i.rounding:Ne(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(q=!1,t=ce(t,r,0,e,1).times(r),q=!0,z(t)):(r.s=t.s,t=r),t},C.toNumber=function(){return+this},C.toOctal=function(r,e){return tn(this,8,r,e)},C.toPower=C.pow=function(r){var e,t,i,s,n,a,o=this,l=o.constructor,h=+(r=new l(r));if(!o.d||!r.d||!o.d[0]||!r.d[0])return new l(Te(+o,h));if(o=new l(o),o.eq(1))return o;if(i=l.precision,n=l.rounding,r.eq(1))return z(o,i,n);if(e=Oe(r.e/Z),e>=r.d.length-1&&(t=h<0?-h:h)<=Jc)return s=Ro(l,o,t,i),r.s<0?new l(1).div(s):z(s,i,n);if(a=o.s,a<0){if(e<r.d.length-1)return new l(NaN);if(r.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,h),e=t==0||!isFinite(t)?Oe(h*(Math.log("0."+xe(o.d))/Math.LN10+o.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?a/0:0):(q=!1,l.rounding=o.s=1,t=Math.min(12,(e+"").length),s=Qs(r.times(Nt(o,i+t)),i),s.d&&(s=z(s,i+5,1),ir(s.d,i,n)&&(e=i+10,s=z(Qs(r.times(Nt(o,e+t)),e),e+5,1),+xe(s.d).slice(i+1,i+15)+1==1e14&&(s=z(s,i+1,0)))),s.s=a,q=!0,l.rounding=n,z(s,i,n))},C.toPrecision=function(r,e){var t,i=this,s=i.constructor;return r===void 0?t=ht(i,i.e<=s.toExpNeg||i.e>=s.toExpPos):(Ne(r,1,Lt),e===void 0?e=s.rounding:Ne(e,0,8),i=z(new s(i),r,e),t=ht(i,r<=i.e||i.e<=s.toExpNeg,r)),i.isNeg()&&!i.isZero()?"-"+t:t},C.toSignificantDigits=C.toSD=function(r,e){var t=this,i=t.constructor;return r===void 0?(r=i.precision,e=i.rounding):(Ne(r,1,Lt),e===void 0?e=i.rounding:Ne(e,0,8)),z(new i(t),r,e)},C.toString=function(){var r=this,e=r.constructor,t=ht(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t},C.truncated=C.trunc=function(){return z(new this.constructor(this),this.e+1,1)},C.valueOf=C.toJSON=function(){var r=this,e=r.constructor,t=ht(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function xe(r){var e,t,i,s=r.length-1,n="",a=r[0];if(s>0){for(n+=a,e=1;e<s;e++)i=r[e]+"",t=Z-i.length,t&&(n+=It(t)),n+=i;a=r[e],i=a+"",t=Z-i.length,t&&(n+=It(t))}else if(a===0)return"0";for(;a%10===0;)a/=10;return n+a}function Ne(r,e,t){if(r!==~~r||r<e||r>t)throw Error(Rt+r)}function ir(r,e,t,i){var s,n,a,o;for(n=r[0];n>=10;n/=10)--e;return--e<0?(e+=Z,s=0):(s=Math.ceil((e+1)/Z),e%=Z),n=Te(10,Z-e),o=r[s]%n|0,i==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)&&(r[s+1]/n/100|0)==Te(10,e-2)-1||(o==n/2||o==0)&&(r[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=(i||t<4)&&o==9999||!i&&t>3&&o==4999):a=((i||t<4)&&o+1==n||!i&&t>3&&o+1==n/2)&&(r[s+1]/n/1e3|0)==Te(10,e-3)-1,a}function qr(r,e,t){for(var i,s=[0],n,a=0,o=r.length;a<o;){for(n=s.length;n--;)s[n]*=e;for(s[0]+=Ys.indexOf(r.charAt(a++)),i=0;i<s.length;i++)s[i]>t-1&&(s[i+1]===void 0&&(s[i+1]=0),s[i+1]+=s[i]/t|0,s[i]%=t)}return s.reverse()}function ef(r,e){var t,i,s;if(e.isZero())return e;i=e.d.length,i<32?(t=Math.ceil(i/3),s=(1/Jr(4,t)).toString()):(t=16,s="2.3283064365386962890625e-10"),r.precision+=t,e=_i(r,1,e.times(s),new r(1));for(var n=t;n--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return r.precision-=t,e}var ce=function(){function r(i,s,n){var a,o=0,l=i.length;for(i=i.slice();l--;)a=i[l]*s+o,i[l]=a%n|0,o=a/n|0;return o&&i.unshift(o),i}function e(i,s,n,a){var o,l;if(n!=a)l=n>a?1:-1;else for(o=l=0;o<n;o++)if(i[o]!=s[o]){l=i[o]>s[o]?1:-1;break}return l}function t(i,s,n,a){for(var o=0;n--;)i[n]-=o,o=i[n]<s[n]?1:0,i[n]=o*a+i[n]-s[n];for(;!i[0]&&i.length>1;)i.shift()}return function(i,s,n,a,o,l){var h,d,u,c,p,f,m,g,_,w,b,T,L,A,G,R,F,V,I,K,W=i.constructor,he=i.s==s.s?1:-1,ae=i.d,U=s.d;if(!ae||!ae[0]||!U||!U[0])return new W(!i.s||!s.s||(ae?U&&ae[0]==U[0]:!U)?NaN:ae&&ae[0]==0||!U?he*0:he/0);for(l?(p=1,d=i.e-s.e):(l=et,p=Z,d=Oe(i.e/p)-Oe(s.e/p)),I=U.length,F=ae.length,_=new W(he),w=_.d=[],u=0;U[u]==(ae[u]||0);u++);if(U[u]>(ae[u]||0)&&d--,n==null?(A=n=W.precision,a=W.rounding):o?A=n+(i.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<F||c)&&A--;u++)G=c*l+(ae[u]||0),w[u]=G/U|0,c=G%U|0;f=c||u<F}else{for(c=l/(U[0]+1)|0,c>1&&(U=r(U,c,l),ae=r(ae,c,l),I=U.length,F=ae.length),R=I,b=ae.slice(0,I),T=b.length;T<I;)b[T++]=0;K=U.slice(),K.unshift(0),V=U[0],U[1]>=l/2&&++V;do c=0,h=e(U,b,I,T),h<0?(L=b[0],I!=T&&(L=L*l+(b[1]||0)),c=L/V|0,c>1?(c>=l&&(c=l-1),m=r(U,c,l),g=m.length,T=b.length,h=e(m,b,g,T),h==1&&(c--,t(m,I<g?K:U,g,l))):(c==0&&(h=c=1),m=U.slice()),g=m.length,g<T&&m.unshift(0),t(b,m,T,l),h==-1&&(T=b.length,h=e(U,b,I,T),h<1&&(c++,t(b,I<T?K:U,T,l))),T=b.length):h===0&&(c++,b=[0]),w[u++]=c,h&&b[0]?b[T++]=ae[R]||0:(b=[ae[R]],T=1);while((R++<F||b[0]!==void 0)&&A--);f=b[0]!==void 0}w[0]||w.shift()}if(p==1)_.e=d,xo=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(r,e,t,i){var s,n,a,o,l,h,d,u,c,p=r.constructor;e:if(e!=null){if(u=r.d,!u)return r;for(s=1,o=u[0];o>=10;o/=10)s++;if(n=e-s,n<0)n+=Z,a=e,d=u[c=0],l=d/Te(10,s-a-1)%10|0;else if(c=Math.ceil((n+1)/Z),o=u.length,c>=o)if(i){for(;o++<=c;)u.push(0);d=l=0,s=1,n%=Z,a=n-Z+1}else break e;else{for(d=o=u[c],s=1;o>=10;o/=10)s++;n%=Z,a=n-Z+s,l=a<0?0:d/Te(10,s-a-1)%10|0}if(i=i||e<0||u[c+1]!==void 0||(a<0?d:d%Te(10,s-a-1)),h=t<4?(l||i)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||i||t==6&&(n>0?a>0?d/Te(10,s-a):0:u[c-1])%10&1||t==(r.s<0?8:7)),e<1||!u[0])return u.length=0,h?(e-=r.e+1,u[0]=Te(10,(Z-e%Z)%Z),r.e=-e||0):u[0]=r.e=0,r;if(n==0?(u.length=c,o=1,c--):(u.length=c+1,o=Te(10,Z-n),u[c]=a>0?(d/Te(10,s-a)%Te(10,a)|0)*o:0),h)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&&(r.e++,u[0]==et&&(u[0]=1));break}else{if(u[c]+=o,u[c]!=et)break;u[c--]=0,o=1}for(n=u.length;u[--n]===0;)u.pop()}return q&&(r.e>p.maxE?(r.d=null,r.e=NaN):r.e<p.minE&&(r.e=0,r.d=[0])),r}function ht(r,e,t){if(!r.isFinite())return Do(r);var i,s=r.e,n=xe(r.d),a=n.length;return e?(t&&(i=t-a)>0?n=n.charAt(0)+"."+n.slice(1)+It(i):a>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(r.e<0?"e":"e+")+r.e):s<0?(n="0."+It(-s-1)+n,t&&(i=t-a)>0&&(n+=It(i))):s>=a?(n+=It(s+1-a),t&&(i=t-s-1)>0&&(n=n+"."+It(i))):((i=s+1)<a&&(n=n.slice(0,i)+"."+n.slice(i)),t&&(i=t-a)>0&&(s+1===a&&(n+="."),n+=It(i))),n}function Yr(r,e){var t=r[0];for(e*=Z;t>=10;t/=10)e++;return e}function Kr(r,e,t){if(e>Qc)throw q=!0,t&&(r.precision=t),Error(Po);return z(new r(Zr),e,1,!0)}function tt(r,e,t){if(e>Js)throw Error(Po);return z(new r(jr),e,t,!0)}function Lo(r){var e=r.length-1,t=e*Z+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}function It(r){for(var e="";r--;)e+="0";return e}function Ro(r,e,t,i){var s,n=new r(1),a=Math.ceil(i/Z+4);for(q=!1;;){if(t%2&&(n=n.times(e),Fo(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),Fo(e.d,a)}return q=!0,n}function Io(r){return r.d[r.d.length-1]&1}function No(r,e,t){for(var i,s=new r(e[0]),n=0;++n<e.length;)if(i=new r(e[n]),i.s)s[t](i)&&(s=i);else{s=i;break}return s}function Qs(r,e){var t,i,s,n,a,o,l,h=0,d=0,u=0,c=r.constructor,p=c.rounding,f=c.precision;if(!r.d||!r.d[0]||r.e>17)return new c(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:0/0);for(e==null?(q=!1,l=f):l=e,o=new c(.03125);r.e>-2;)r=r.times(o),u+=5;for(i=Math.log(Te(2,u))/Math.LN10*2+5|0,l+=i,t=n=a=new c(1),c.precision=l;;){if(n=z(n.times(r),l,1),t=t.times(++d),o=a.plus(ce(n,t,l,1)),xe(o.d).slice(0,l)===xe(a.d).slice(0,l)){for(s=u;s--;)a=z(a.times(a),l,1);if(e==null)if(h<3&&ir(a.d,l-i,p,h))c.precision=l+=10,t=n=o=new c(1),d=0,h++;else return z(a,c.precision=f,p,q=!0);else return c.precision=f,a}a=o}}function Nt(r,e){var t,i,s,n,a,o,l,h,d,u,c,p=1,f=10,m=r,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),i=t.charAt(0),Math.abs(n=m.e)<15e14){for(;i<7&&i!=1||i==1&&t.charAt(1)>3;)m=m.times(r),t=xe(m.d),i=t.charAt(0),p++;n=m.e,i>1?(m=new _("0."+t),n++):m=new _(i+"."+t.slice(1))}else return h=Kr(_,d+2,b).times(n+""),m=Nt(new _(i+"."+t.slice(1)),d-f).plus(h),_.precision=b,e==null?z(m,b,w,q=!0):m;for(u=m,l=a=m=ce(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),h=l.plus(ce(a,new _(s),d,1)),xe(h.d).slice(0,d)===xe(l.d).slice(0,d))if(l=l.times(2),n!==0&&(l=l.plus(Kr(_,d+2,b).times(n+""))),l=ce(l,new _(p),d,1),e==null)if(ir(l.d,d-f,w,o))_.precision=d+=f,h=a=m=ce(u.minus(1),u.plus(1),d,1),c=z(m.times(m),d,1),s=o=1;else return z(l,_.precision=b,w,q=!0);else return _.precision=b,l;l=h,s+=2}}function Do(r){return String(r.s*r.s/0)}function en(r,e){var t,i,s;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(t<0&&(t=i),t+=+e.slice(i+1),e=e.substring(0,i)):t<0&&(t=e.length),i=0;e.charCodeAt(i)===48;i++);for(s=e.length;e.charCodeAt(s-1)===48;--s);if(e=e.slice(i,s),e){if(s-=i,r.e=t=t-i-1,r.d=[],i=(t+1)%Z,t<0&&(i+=Z),i<s){for(i&&r.d.push(+e.slice(0,i)),s-=Z;i<s;)r.d.push(+e.slice(i,i+=Z));e=e.slice(i),i=Z-e.length}else i-=s;for(;i--;)e+="0";r.d.push(+e),q&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function tf(r,e){var t,i,s,n,a,o,l,h,d;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Mo.test(e))return en(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(Yc.test(e))t=16,e=e.toLowerCase();else if(qc.test(e))t=2;else if(Kc.test(e))t=8;else throw Error(Rt+e);for(n=e.search(/p/i),n>0?(l=+e.slice(n+1),e=e.substring(2,n)):e=e.slice(2),n=e.indexOf("."),a=n>=0,i=r.constructor,a&&(e=e.replace(".",""),o=e.length,n=o-n,s=Ro(i,new i(t),n,n*2)),h=qr(e,t,et),d=h.length-1,n=d;h[n]===0;--n)h.pop();return n<0?new i(r.s*0):(r.e=Yr(h,d),r.d=h,q=!1,a&&(r=ce(r,s,o*4)),l&&(r=r.times(Math.abs(l)<54?Te(2,l):j.pow(2,l))),q=!0,r)}function rf(r,e){var t,i=e.d.length;if(i<3)return e.isZero()?e:_i(r,2,e,e);t=1.4*Math.sqrt(i),t=t>16?16:t|0,e=e.times(1/Jr(5,t)),e=_i(r,2,e,e);for(var s,n=new r(5),a=new r(16),o=new r(20);t--;)s=e.times(e),e=e.times(n.plus(s.times(a.times(s).minus(o))));return e}function _i(r,e,t,i,s){var n,a,o,l,h=r.precision,d=Math.ceil(h/Z);for(q=!1,l=t.times(t),o=new r(i);;){if(a=ce(o.times(l),new r(e++*e++),h,1),o=s?i.plus(a):i.minus(a),i=ce(a.times(l),new r(e++*e++),h,1),a=o.plus(i),a.d[d]!==void 0){for(n=d;a.d[n]===o.d[n]&&n--;);if(n==-1)break}n=o,o=i,i=a,a=n}return q=!0,a.d.length=d+1,a}function Jr(r,e){for(var t=r;--e;)t*=r;return t}function Go(r,e){var t,i=e.s<0,s=tt(r,r.precision,1),n=s.times(.5);if(e=e.abs(),e.lte(n))return _t=i?4:1,e;if(t=e.divToInt(s),t.isZero())_t=i?3:2;else{if(e=e.minus(t.times(s)),e.lte(n))return _t=Io(t)?i?2:3:i?4:1,e;_t=Io(t)?i?1:4:i?3:2}return e.minus(s).abs()}function tn(r,e,t,i){var s,n,a,o,l,h,d,u,c,p=r.constructor,f=t!==void 0;if(f?(Ne(t,1,Lt),i===void 0?i=p.rounding:Ne(i,0,8)):(t=p.precision,i=p.rounding),!r.isFinite())d=Do(r);else{for(d=ht(r),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=qr(ht(c),10,s),c.e=c.d.length),u=qr(d,10,s),n=l=u.length;u[--l]==0;)u.pop();if(!u[0])d=f?"0p+0":"0";else{if(a<0?n--:(r=new p(r),r.d=u,r.e=n,r=ce(r,c,t,i,0,s),u=r.d,n=r.e,h=xo),a=u[t],o=s/2,h=h||u[t+1]!==void 0,h=i<4?(a!==void 0||h)&&(i===0||i===(r.s<0?3:2)):a>o||a===o&&(i===4||h||i===6&&u[t-1]&1||i===(r.s<0?8:7)),u.length=t,h)for(;++u[--t]>s-1;)u[t]=0,t||(++n,u.unshift(1));for(l=u.length;!u[l-1];--l);for(a=0,d="";a<l;a++)d+=Ys.charAt(u[a]);if(f){if(l>1)if(e==16||e==8){for(a=e==16?4:3,--l;l%a;l++)d+="0";for(u=qr(d,s,e),l=u.length;!u[l-1];--l);for(a=1,d="1.";a<l;a++)d+=Ys.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>l)for(n-=l;n--;)d+="0";else n<l&&(d=d.slice(0,n)+"."+d.slice(n))}d=(e==16?"0x":e==2?"0b":e==8?"0o":"")+d}return r.s<0?"-"+d:d}function Fo(r,e){if(r.length>e)return r.length=e,!0}function sf(r){return new this(r).abs()}function nf(r){return new this(r).acos()}function af(r){return new this(r).acosh()}function of(r,e){return new this(r).plus(e)}function hf(r){return new this(r).asin()}function lf(r){return new this(r).asinh()}function df(r){return new this(r).atan()}function uf(r){return new this(r).atanh()}function cf(r,e){r=new this(r),e=new this(e);var t,i=this.precision,s=this.rounding,n=i+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=tt(this,n,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?tt(this,i,s):new this(0),t.s=r.s):!r.d||e.isZero()?(t=tt(this,n,1).times(.5),t.s=r.s):e.s<0?(this.precision=n,this.rounding=1,t=this.atan(ce(r,e,n,1)),e=tt(this,n,1),this.precision=i,this.rounding=s,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(ce(r,e,n,1)),t}function ff(r){return new this(r).cbrt()}function pf(r){return z(r=new this(r),r.e+1,2)}function mf(r,e,t){return new this(r).clamp(e,t)}function gf(r){if(!r||typeof r!="object")throw Error(Xr+"Object expected");var e,t,i,s=r.defaults===!0,n=["precision",1,Lt,"rounding",0,8,"toExpNeg",-bi,0,"toExpPos",0,bi,"maxE",0,bi,"minE",-bi,0,"modulo",0,9];for(e=0;e<n.length;e+=3)if(t=n[e],s&&(this[t]=Ks[t]),(i=r[t])!==void 0)if(Oe(i)===i&&i>=n[e+1]&&i<=n[e+2])this[t]=i;else throw Error(Rt+t+": "+i);if(t="crypto",s&&(this[t]=Ks[t]),(i=r[t])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Ao);else this[t]=!1;else throw Error(Rt+t+": "+i);return this}function vf(r){return new this(r).cos()}function yf(r){return new this(r).cosh()}function Ho(r){var e,t,i;function s(n){var a,o,l,h=this;if(!(h instanceof s))return new s(n);if(h.constructor=s,Bo(n)){h.s=n.s,q?!n.d||n.e>s.maxE?(h.e=NaN,h.d=null):n.e<s.minE?(h.e=0,h.d=[0]):(h.e=n.e,h.d=n.d.slice()):(h.e=n.e,h.d=n.d?n.d.slice():n.d);return}if(l=typeof n,l==="number"){if(n===0){h.s=1/n<0?-1:1,h.e=0,h.d=[0];return}if(n<0?(n=-n,h.s=-1):h.s=1,n===~~n&&n<1e7){for(a=0,o=n;o>=10;o/=10)a++;q?a>s.maxE?(h.e=NaN,h.d=null):a<s.minE?(h.e=0,h.d=[0]):(h.e=a,h.d=[n]):(h.e=a,h.d=[n]);return}else if(n*0!==0){n||(h.s=NaN),h.e=NaN,h.d=null;return}return en(h,n.toString())}else if(l!=="string")throw Error(Rt+n);return(o=n.charCodeAt(0))===45?(n=n.slice(1),h.s=-1):(o===43&&(n=n.slice(1)),h.s=1),Mo.test(n)?en(h,n):tf(h,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=gf,s.clone=Ho,s.isDecimal=Bo,s.abs=sf,s.acos=nf,s.acosh=af,s.add=of,s.asin=hf,s.asinh=lf,s.atan=df,s.atanh=uf,s.atan2=cf,s.cbrt=ff,s.ceil=pf,s.clamp=mf,s.cos=vf,s.cosh=yf,s.div=bf,s.exp=_f,s.floor=wf,s.hypot=Sf,s.ln=Tf,s.log=Cf,s.log10=kf,s.log2=Ef,s.max=xf,s.min=Pf,s.mod=Af,s.mul=Of,s.pow=Mf,s.random=Lf,s.round=Rf,s.sign=If,s.sin=Nf,s.sinh=Df,s.sqrt=Gf,s.sub=Ff,s.sum=Hf,s.tan=Bf,s.tanh=$f,s.trunc=Vf,r===void 0&&(r={}),r&&r.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<i.length;)r.hasOwnProperty(t=i[e++])||(r[t]=this[t]);return s.config(r),s}function bf(r,e){return new this(r).div(e)}function _f(r){return new this(r).exp()}function wf(r){return z(r=new this(r),r.e+1,3)}function Sf(){var r,e,t=new this(0);for(q=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),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 Bo(r){return r instanceof j||r&&r.toStringTag===Oo||!1}function Tf(r){return new this(r).ln()}function Cf(r,e){return new this(r).log(e)}function Ef(r){return new this(r).log(2)}function kf(r){return new this(r).log(10)}function xf(){return No(this,arguments,"lt")}function Pf(){return No(this,arguments,"gt")}function Af(r,e){return new this(r).mod(e)}function Of(r,e){return new this(r).mul(e)}function Mf(r,e){return new this(r).pow(e)}function Lf(r){var e,t,i,s,n=0,a=new this(1),o=[];if(r===void 0?r=this.precision:Ne(r,1,Lt),i=Math.ceil(r/Z),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(i));n<i;)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(i*=4);n<i;)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=i/4}else throw Error(Ao);else for(;n<i;)o[n++]=Math.random()*1e7|0;for(i=o[--n],r%=Z,i&&r&&(s=Te(10,Z-r),o[n]=(i/s|0)*s);o[n]===0;n--)o.pop();if(n<0)t=0,o=[0];else{for(t=-1;o[0]===0;t-=Z)o.shift();for(i=1,s=o[0];s>=10;s/=10)i++;i<Z&&(t-=Z-i)}return a.e=t,a.d=o,a}function Rf(r){return z(r=new this(r),r.e+1,this.rounding)}function If(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function Nf(r){return new this(r).sin()}function Df(r){return new this(r).sinh()}function Gf(r){return new this(r).sqrt()}function Ff(r,e){return new this(r).sub(e)}function Hf(){var r=0,e=arguments,t=new this(e[r]);for(q=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return q=!0,z(t,this.precision,this.rounding)}function Bf(r){return new this(r).tan()}function $f(r){return new this(r).tanh()}function Vf(r){return z(r=new this(r),r.e+1,1)}C[Symbol.for("nodejs.util.inspect.custom")]=C.toString,C[Symbol.toStringTag]="Decimal";var j=C.constructor=Ho(Ks);Zr=new j(Zr),jr=new j(jr);function rr(r){return r==null}const $o={editable:!0,style:{...Eo,markerSymbolSize:20,periodMarkerHandleType:"start"}};class Vo extends ko{constructor(e,t,i){super({...$o,...e,style:{...$o.style,...e.style}},t,i)}createSymbol(){switch(this.style.markerSymbolType){case"triangle":let t=j.sqrt(2).mul(this.style.markerSymbolSize).toNumber()/2;return new O.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 O.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 O.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 zo={editable:!0,style:{...To,selectedAreaOpacity:.2,markerHandleAreaOpacity:.7}};class Wo extends Co{constructor(e){super({...zo,...e,style:{...zo.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),!rr(this.observation.end)&&!rr(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),i=this.timeline.timeToTimelinePosition(this.observation.end);this.selectedAreaRect=new O.Rect({x:t,y:e.y,width:i-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 O.Rect({x:t,y:e.y+s.y-s.height/2,width:i-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 Vo({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 i=this.timeline.timelinePositionToTime(t.x());this.setTimeObservation({...this.observation,start:i}),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 Vo({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 i=this.timeline.timelinePositionToTime(t.x());this.setTimeObservation({...this.observation,end:i}),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&&!rr(this.observation.start)}hasEnd(){return this.observation&&!rr(this.observation.end)}}const Uo={editable:!0,style:{...Eo,markerSymbolSize:20}};class zf extends ko{constructor(e,t,i){super({...Uo,...e,style:{...Uo.style,...e.style}},t,i)}createSymbol(){switch(this.style.markerSymbolType){case"triangle":let t=j.sqrt(2).mul(this.style.markerSymbolSize).toNumber()/2;return new O.Line({points:[-t,0,t,0,0,t],fill:this.style.color,closed:!0,offsetY:t/2});case"circle":return new O.Circle({fill:this.style.color,radius:this.style.markerSymbolSize/2});case"square":return new O.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 Zo={description:"",editable:!0,style:{...To}};class jo extends Co{constructor(e){super({...Zo,...e,style:{...Zo.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 zf({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 i=this.timeline.timelinePositionToTime(t.x());this.setTimeObservation({...this.observation,time:i})}},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 Wf={...er};class rn extends tr{constructor(e){super({...e,style:{...Wf,...e.style}}),this.onMarkerFocus$=new B,this.markers=[],this.markersMap=new Map}createCanvasNode(){return super.createCanvasNode(),this.markersGroup=new O.Group({...$.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 jo(e))}createPeriodMarker(e){return this.addMarker(new Wo(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(i=>i.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 Uf{static randomHexColor(){return`#${Math.floor(Math.random()*16777215).toString(16)}`}}class wi{static createGoldenRatioWedge(e){let t=new j(e.height).div($.GOLDEN_RATIO+1).toDecimalPlaces(2).toNumber(),i=e.height-t,s=i/2;return new O.Line({points:[e.x-s,e.y,e.x+s,e.y,e.x+s,e.y+i,e.x,e.y+i+t,e.x-s,e.y+i],fill:e.color,stroke:e.color,closed:!0,listening:!1})}static createTriangle(e){let t=e.height/2;return new O.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 O.Rect({...$.POSITION_TOP_LEFT,opacity:0,listening:!0,...e})}static createDebugRect(){return new O.Rect({...$.POSITION_TOP_LEFT,width:100,height:100,fill:Uf.randomHexColor(),opacity:1})}}function Xo(r,e){return function(){return r.apply(e,arguments)}}const{toString:qo}=Object.prototype,{getPrototypeOf:sn}=Object,nn=(r=>e=>{const t=qo.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),wt=r=>(r=r.toLowerCase(),e=>nn(e)===r),Qr=r=>e=>typeof e===r,{isArray:Si}=Array,sr=Qr("undefined");function Zf(r){return r!==null&&!sr(r)&&r.constructor!==null&&!sr(r.constructor)&&Dt(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const Yo=wt("ArrayBuffer");function jf(r){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&Yo(r.buffer),e}const Xf=Qr("string"),Dt=Qr("function"),Ko=Qr("number"),an=r=>r!==null&&typeof r=="object",qf=r=>r===!0||r===!1,es=r=>{if(nn(r)!=="object")return!1;const e=sn(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in r)&&!(Symbol.iterator in r)},Yf=wt("Date"),Kf=wt("File"),Jf=wt("Blob"),Qf=wt("FileList"),ep=r=>an(r)&&Dt(r.pipe),tp=r=>{const e="[object FormData]";return r&&(typeof FormData=="function"&&r instanceof FormData||qo.call(r)===e||Dt(r.toString)&&r.toString()===e)},ip=wt("URLSearchParams"),rp=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function nr(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let i,s;if(typeof r!="object"&&(r=[r]),Si(r))for(i=0,s=r.length;i<s;i++)e.call(null,r[i],i,r);else{const n=t?Object.getOwnPropertyNames(r):Object.keys(r),a=n.length;let o;for(i=0;i<a;i++)o=n[i],e.call(null,r[o],o,r)}}function Jo(r,e){e=e.toLowerCase();const t=Object.keys(r);let i=t.length,s;for(;i-- >0;)if(s=t[i],e===s.toLowerCase())return s;return null}const Qo=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),eh=r=>!sr(r)&&r!==Qo;function on(){const{caseless:r}=eh(this)&&this||{},e={},t=(i,s)=>{const n=r&&Jo(e,s)||s;es(e[n])&&es(i)?e[n]=on(e[n],i):es(i)?e[n]=on({},i):Si(i)?e[n]=i.slice():e[n]=i};for(let i=0,s=arguments.length;i<s;i++)arguments[i]&&nr(arguments[i],t);return e}const sp=(r,e,t,{allOwnKeys:i}={})=>(nr(e,(s,n)=>{t&&Dt(s)?r[n]=Xo(s,t):r[n]=s},{allOwnKeys:i}),r),np=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),ap=(r,e,t,i)=>{r.prototype=Object.create(e.prototype,i),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:e.prototype}),t&&Object.assign(r.prototype,t)},op=(r,e,t,i)=>{let s,n,a;const o={};if(e=e||{},r==null)return e;do{for(s=Object.getOwnPropertyNames(r),n=s.length;n-- >0;)a=s[n],(!i||i(a,r,e))&&!o[a]&&(e[a]=r[a],o[a]=!0);r=t!==!1&&sn(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},hp=(r,e,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;const i=r.indexOf(e,t);return i!==-1&&i===t},lp=r=>{if(!r)return null;if(Si(r))return r;let e=r.length;if(!Ko(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},dp=(r=>e=>r&&e instanceof r)(typeof Uint8Array<"u"&&sn(Uint8Array)),up=(r,e)=>{const i=(r&&r[Symbol.iterator]).call(r);let s;for(;(s=i.next())&&!s.done;){const n=s.value;e.call(r,n[0],n[1])}},cp=(r,e)=>{let t;const i=[];for(;(t=r.exec(e))!==null;)i.push(t);return i},fp=wt("HTMLFormElement"),pp=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,i,s){return i.toUpperCase()+s}),th=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),mp=wt("RegExp"),ih=(r,e)=>{const t=Object.getOwnPropertyDescriptors(r),i={};nr(t,(s,n)=>{e(s,n,r)!==!1&&(i[n]=s)}),Object.defineProperties(r,i)},gp=r=>{ih(r,(e,t)=>{if(Dt(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const i=r[t];if(Dt(i)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},vp=(r,e)=>{const t={},i=s=>{s.forEach(n=>{t[n]=!0})};return Si(r)?i(r):i(String(r).split(e)),t},yp=()=>{},bp=(r,e)=>(r=+r,Number.isFinite(r)?r:e),hn="abcdefghijklmnopqrstuvwxyz",rh="0123456789",sh={DIGIT:rh,ALPHA:hn,ALPHA_DIGIT:hn+hn.toUpperCase()+rh},_p=(r=16,e=sh.ALPHA_DIGIT)=>{let t="";const{length:i}=e;for(;r--;)t+=e[Math.random()*i|0];return t};function wp(r){return!!(r&&Dt(r.append)&&r[Symbol.toStringTag]==="FormData"&&r[Symbol.iterator])}const S={isArray:Si,isArrayBuffer:Yo,isBuffer:Zf,isFormData:tp,isArrayBufferView:jf,isString:Xf,isNumber:Ko,isBoolean:qf,isObject:an,isPlainObject:es,isUndefined:sr,isDate:Yf,isFile:Kf,isBlob:Jf,isRegExp:mp,isFunction:Dt,isStream:ep,isURLSearchParams:ip,isTypedArray:dp,isFileList:Qf,forEach:nr,merge:on,extend:sp,trim:rp,stripBOM:np,inherits:ap,toFlatObject:op,kindOf:nn,kindOfTest:wt,endsWith:hp,toArray:lp,forEachEntry:up,matchAll:cp,isHTMLForm:fp,hasOwnProperty:th,hasOwnProp:th,reduceDescriptors:ih,freezeMethods:gp,toObjectSet:vp,toCamelCase:pp,noop:yp,toFiniteNumber:bp,findKey:Jo,global:Qo,isContextDefined:eh,ALPHABET:sh,generateString:_p,isSpecCompliantForm:wp,toJSONObject:r=>{const e=new Array(10),t=(i,s)=>{if(an(i)){if(e.indexOf(i)>=0)return;if(!("toJSON"in i)){e[s]=i;const n=Si(i)?[]:{};return nr(i,(a,o)=>{const l=t(a,s+1);!sr(l)&&(n[o]=l)}),e[s]=void 0,n}}return i};return t(r,0)}};function re(r,e,t,i,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),i&&(this.request=i),s&&(this.response=s)}S.inherits(re,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 nh=re.prototype,ah={};["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(r=>{ah[r]={value:r}}),Object.defineProperties(re,ah),Object.defineProperty(nh,"isAxiosError",{value:!0}),re.from=(r,e,t,i,s,n)=>{const a=Object.create(nh);return S.toFlatObject(r,a,function(l){return l!==Error.prototype},o=>o!=="isAxiosError"),re.call(a,r.message,e,t,i,s),a.cause=r,a.name=r.name,n&&Object.assign(a,n),a};const Sp=null;function ln(r){return S.isPlainObject(r)||S.isArray(r)}function oh(r){return S.endsWith(r,"[]")?r.slice(0,-2):r}function hh(r,e,t){return r?r.concat(e).map(function(s,n){return s=oh(s),!t&&n?"["+s+"]":s}).join(t?".":""):e}function Tp(r){return S.isArray(r)&&!r.some(ln)}const Cp=S.toFlatObject(S,{},null,function(e){return/^is[A-Z]/.test(e)});function ts(r,e,t){if(!S.isObject(r))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 i=t.metaTokens,s=t.visitor||d,n=t.dots,a=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&S.isSpecCompliantForm(e);if(!S.isFunction(s))throw new TypeError("visitor must be a function");function h(f){if(f===null)return"";if(S.isDate(f))return f.toISOString();if(!l&&S.isBlob(f))throw new re("Blob is not supported. Use a Buffer instead.");return S.isArrayBuffer(f)||S.isTypedArray(f)?l&&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=i?m:m.slice(0,-2),f=JSON.stringify(f);else if(S.isArray(f)&&Tp(f)||(S.isFileList(f)||S.endsWith(m,"[]"))&&(_=S.toArray(f)))return m=oh(m),_.forEach(function(b,T){!(S.isUndefined(b)||b===null)&&e.append(a===!0?hh([m],T,n):a===null?m:m+"[]",h(b))}),!1}return ln(f)?!0:(e.append(hh(g,m,n),h(f)),!1)}const u=[],c=Object.assign(Cp,{defaultVisitor:d,convertValue:h,isVisitable:ln});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(r))throw new TypeError("data must be an object");return p(r),e}function lh(r){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(i){return e[i]})}function dn(r,e){this._pairs=[],r&&ts(r,this,e)}const dh=dn.prototype;dh.append=function(e,t){this._pairs.push([e,t])},dh.toString=function(e){const t=e?function(i){return e.call(this,i,lh)}:lh;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function Ep(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function uh(r,e,t){if(!e)return r;const i=t&&t.encode||Ep,s=t&&t.serialize;let n;if(s?n=s(e,t):n=S.isURLSearchParams(e)?e.toString():new dn(e,t).toString(i),n){const a=r.indexOf("#");a!==-1&&(r=r.slice(0,a)),r+=(r.indexOf("?")===-1?"?":"&")+n}return r}class kp{constructor(){this.handlers=[]}use(e,t,i){return this.handlers.push({fulfilled:e,rejected:t,synchronous:i?i.synchronous:!1,runWhen:i?i.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(i){i!==null&&e(i)})}}const ch=kp,fh={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},xp=typeof URLSearchParams<"u"?URLSearchParams:dn,Pp=typeof FormData<"u"?FormData:null,Ap=(()=>{let r;return typeof navigator<"u"&&((r=navigator.product)==="ReactNative"||r==="NativeScript"||r==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Op=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),lt={isBrowser:!0,classes:{URLSearchParams:xp,FormData:Pp,Blob},isStandardBrowserEnv:Ap,isStandardBrowserWebWorkerEnv:Op,protocols:["http","https","file","blob","url","data"]};function Mp(r,e){return ts(r,new lt.classes.URLSearchParams,Object.assign({visitor:function(t,i,s,n){return lt.isNode&&S.isBuffer(t)?(this.append(i,t.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},e))}function Lp(r){return S.matchAll(/\w+|\[(\w*)]/g,r).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Rp(r){const e={},t=Object.keys(r);let i;const s=t.length;let n;for(i=0;i<s;i++)n=t[i],e[n]=r[n];return e}function ph(r){function e(t,i,s,n){let a=t[n++];const o=Number.isFinite(+a),l=n>=t.length;return a=!a&&S.isArray(s)?s.length:a,l?(S.hasOwnProp(s,a)?s[a]=[s[a],i]:s[a]=i,!o):((!s[a]||!S.isObject(s[a]))&&(s[a]=[]),e(t,i,s[a],n)&&S.isArray(s[a])&&(s[a]=Rp(s[a])),!o)}if(S.isFormData(r)&&S.isFunction(r.entries)){const t={};return S.forEachEntry(r,(i,s)=>{e(Lp(i),s,t,0)}),t}return null}const Ip={"Content-Type":void 0};function Np(r,e,t){if(S.isString(r))try{return(e||JSON.parse)(r),S.trim(r)}catch(i){if(i.name!=="SyntaxError")throw i}return(t||JSON.stringify)(r)}const is={transitional:fh,adapter:["xhr","http"],transformRequest:[function(e,t){const i=t.getContentType()||"",s=i.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(ph(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(i.indexOf("application/x-www-form-urlencoded")>-1)return Mp(e,this.formSerializer).toString();if((o=S.isFileList(e))||i.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return ts(o?{"files[]":e}:e,l&&new l,this.formSerializer)}}return n||s?(t.setContentType("application/json",!1),Np(e)):e}],transformResponse:[function(e){const t=this.transitional||is.transitional,i=t&&t.forcedJSONParsing,s=this.responseType==="json";if(e&&S.isString(e)&&(i&&!this.responseType||s)){const a=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e)}catch(o){if(a)throw o.name==="SyntaxError"?re.from(o,re.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:lt.classes.FormData,Blob:lt.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};S.forEach(["delete","get","head"],function(e){is.headers[e]={}}),S.forEach(["post","put","patch"],function(e){is.headers[e]=S.merge(Ip)});const un=is,Dp=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"]),Gp=r=>{const e={};let t,i,s;return r&&r.split(`
11
+ `).forEach(function(a){s=a.indexOf(":"),t=a.substring(0,s).trim().toLowerCase(),i=a.substring(s+1).trim(),!(!t||e[t]&&Dp[t])&&(t==="set-cookie"?e[t]?e[t].push(i):e[t]=[i]:e[t]=e[t]?e[t]+", "+i:i)}),e},mh=Symbol("internals");function ar(r){return r&&String(r).trim().toLowerCase()}function rs(r){return r===!1||r==null?r:S.isArray(r)?r.map(rs):String(r)}function Fp(r){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=t.exec(r);)e[i[1]]=i[2];return e}function Hp(r){return/^[-_a-zA-Z]+$/.test(r.trim())}function cn(r,e,t,i,s){if(S.isFunction(i))return i.call(this,e,t);if(s&&(e=t),!!S.isString(e)){if(S.isString(i))return e.indexOf(i)!==-1;if(S.isRegExp(i))return i.test(e)}}function Bp(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,i)=>t.toUpperCase()+i)}function $p(r,e){const t=S.toCamelCase(" "+e);["get","set","has"].forEach(i=>{Object.defineProperty(r,i+t,{value:function(s,n,a){return this[i].call(this,e,s,n,a)},configurable:!0})})}class ss{constructor(e){e&&this.set(e)}set(e,t,i){const s=this;function n(o,l,h){const d=ar(l);if(!d)throw new Error("header name must be a non-empty string");const u=S.findKey(s,d);(!u||s[u]===void 0||h===!0||h===void 0&&s[u]!==!1)&&(s[u||l]=rs(o))}const a=(o,l)=>S.forEach(o,(h,d)=>n(h,d,l));return S.isPlainObject(e)||e instanceof this.constructor?a(e,t):S.isString(e)&&(e=e.trim())&&!Hp(e)?a(Gp(e),t):e!=null&&n(t,e,i),this}get(e,t){if(e=ar(e),e){const i=S.findKey(this,e);if(i){const s=this[i];if(!t)return s;if(t===!0)return Fp(s);if(S.isFunction(t))return t.call(this,s,i);if(S.isRegExp(t))return t.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ar(e),e){const i=S.findKey(this,e);return!!(i&&this[i]!==void 0&&(!t||cn(this,this[i],i,t)))}return!1}delete(e,t){const i=this;let s=!1;function n(a){if(a=ar(a),a){const o=S.findKey(i,a);o&&(!t||cn(i,i[o],o,t))&&(delete i[o],s=!0)}}return S.isArray(e)?e.forEach(n):n(e),s}clear(e){const t=Object.keys(this);let i=t.length,s=!1;for(;i--;){const n=t[i];(!e||cn(this,this[n],n,e,!0))&&(delete this[n],s=!0)}return s}normalize(e){const t=this,i={};return S.forEach(this,(s,n)=>{const a=S.findKey(i,n);if(a){t[a]=rs(s),delete t[n];return}const o=e?Bp(n):String(n).trim();o!==n&&delete t[n],t[o]=rs(s),i[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return S.forEach(this,(i,s)=>{i!=null&&i!==!1&&(t[s]=e&&S.isArray(i)?i.join(", "):i)}),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 i=new this(e);return t.forEach(s=>i.set(s)),i}static accessor(e){const i=(this[mh]=this[mh]={accessors:{}}).accessors,s=this.prototype;function n(a){const o=ar(a);i[o]||($p(s,a),i[o]=!0)}return S.isArray(e)?e.forEach(n):n(e),this}}ss.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),S.freezeMethods(ss.prototype),S.freezeMethods(ss);const St=ss;function fn(r,e){const t=this||un,i=e||t,s=St.from(i.headers);let n=i.data;return S.forEach(r,function(o){n=o.call(t,n,s.normalize(),e?e.status:void 0)}),s.normalize(),n}function gh(r){return!!(r&&r.__CANCEL__)}function or(r,e,t){re.call(this,r??"canceled",re.ERR_CANCELED,e,t),this.name="CanceledError"}S.inherits(or,re,{__CANCEL__:!0});function Vp(r,e,t){const i=t.config.validateStatus;!t.status||!i||i(t.status)?r(t):e(new re("Request failed with status code "+t.status,[re.ERR_BAD_REQUEST,re.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}const zp=lt.isStandardBrowserEnv?function(){return{write:function(t,i,s,n,a,o){const l=[];l.push(t+"="+encodeURIComponent(i)),S.isNumber(s)&&l.push("expires="+new Date(s).toGMTString()),S.isString(n)&&l.push("path="+n),S.isString(a)&&l.push("domain="+a),o===!0&&l.push("secure"),document.cookie=l.join("; ")},read:function(t){const i=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return i?decodeURIComponent(i[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Wp(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Up(r,e){return e?r.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):r}function vh(r,e){return r&&!Wp(e)?Up(r,e):e}const Zp=lt.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let i;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 i=s(window.location.href),function(a){const o=S.isString(a)?s(a):a;return o.protocol===i.protocol&&o.host===i.host}}():function(){return function(){return!0}}();function jp(r){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return e&&e[1]||""}function Xp(r,e){r=r||10;const t=new Array(r),i=new Array(r);let s=0,n=0,a;return e=e!==void 0?e:1e3,function(l){const h=Date.now(),d=i[n];a||(a=h),t[s]=l,i[s]=h;let u=n,c=0;for(;u!==s;)c+=t[u++],u=u%r;if(s=(s+1)%r,s===n&&(n=(n+1)%r),h-a<e)return;const p=d&&h-d;return p?Math.round(c*1e3/p):void 0}}function yh(r,e){let t=0;const i=Xp(50,250);return s=>{const n=s.loaded,a=s.lengthComputable?s.total:void 0,o=n-t,l=i(o),h=n<=a;t=n;const d={loaded:n,total:a,progress:a?n/a:void 0,bytes:o,rate:l||void 0,estimated:l&&a&&h?(a-n)/l:void 0,event:s};d[e?"download":"upload"]=!0,r(d)}}const ns={http:Sp,xhr:typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(t,i){let s=r.data;const n=St.from(r.headers).normalize(),a=r.responseType;let o;function l(){r.cancelToken&&r.cancelToken.unsubscribe(o),r.signal&&r.signal.removeEventListener("abort",o)}S.isFormData(s)&&(lt.isStandardBrowserEnv||lt.isStandardBrowserWebWorkerEnv)&&n.setContentType(!1);let h=new XMLHttpRequest;if(r.auth){const p=r.auth.username||"",f=r.auth.password?unescape(encodeURIComponent(r.auth.password)):"";n.set("Authorization","Basic "+btoa(p+":"+f))}const d=vh(r.baseURL,r.url);h.open(r.method.toUpperCase(),uh(d,r.params,r.paramsSerializer),!0),h.timeout=r.timeout;function u(){if(!h)return;const p=St.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),m={data:!a||a==="text"||a==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:p,config:r,request:h};Vp(function(_){t(_),l()},function(_){i(_),l()},m),h=null}if("onloadend"in h?h.onloadend=u:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(u)},h.onabort=function(){h&&(i(new re("Request aborted",re.ECONNABORTED,r,h)),h=null)},h.onerror=function(){i(new re("Network Error",re.ERR_NETWORK,r,h)),h=null},h.ontimeout=function(){let f=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const m=r.transitional||fh;r.timeoutErrorMessage&&(f=r.timeoutErrorMessage),i(new re(f,m.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,r,h)),h=null},lt.isStandardBrowserEnv){const p=(r.withCredentials||Zp(d))&&r.xsrfCookieName&&zp.read(r.xsrfCookieName);p&&n.set(r.xsrfHeaderName,p)}s===void 0&&n.setContentType(null),"setRequestHeader"in h&&S.forEach(n.toJSON(),function(f,m){h.setRequestHeader(m,f)}),S.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),a&&a!=="json"&&(h.responseType=r.responseType),typeof r.onDownloadProgress=="function"&&h.addEventListener("progress",yh(r.onDownloadProgress,!0)),typeof r.onUploadProgress=="function"&&h.upload&&h.upload.addEventListener("progress",yh(r.onUploadProgress)),(r.cancelToken||r.signal)&&(o=p=>{h&&(i(!p||p.type?new or(null,r,h):p),h.abort(),h=null)},r.cancelToken&&r.cancelToken.subscribe(o),r.signal&&(r.signal.aborted?o():r.signal.addEventListener("abort",o)));const c=jp(d);if(c&&lt.protocols.indexOf(c)===-1){i(new re("Unsupported protocol "+c+":",re.ERR_BAD_REQUEST,r));return}h.send(s||null)})}};S.forEach(ns,(r,e)=>{if(r){try{Object.defineProperty(r,"name",{value:e})}catch{}Object.defineProperty(r,"adapterName",{value:e})}});const qp={getAdapter:r=>{r=S.isArray(r)?r:[r];const{length:e}=r;let t,i;for(let s=0;s<e&&(t=r[s],!(i=S.isString(t)?ns[t.toLowerCase()]:t));s++);if(!i)throw i===!1?new re(`Adapter ${t} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(S.hasOwnProp(ns,t)?`Adapter '${t}' is not available in the build`:`Unknown adapter '${t}'`);if(!S.isFunction(i))throw new TypeError("adapter is not a function");return i},adapters:ns};function pn(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new or(null,r)}function bh(r){return pn(r),r.headers=St.from(r.headers),r.data=fn.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),qp.getAdapter(r.adapter||un.adapter)(r).then(function(i){return pn(r),i.data=fn.call(r,r.transformResponse,i),i.headers=St.from(i.headers),i},function(i){return gh(i)||(pn(r),i&&i.response&&(i.response.data=fn.call(r,r.transformResponse,i.response),i.response.headers=St.from(i.response.headers))),Promise.reject(i)})}const _h=r=>r instanceof St?r.toJSON():r;function Ti(r,e){e=e||{};const t={};function i(h,d,u){return S.isPlainObject(h)&&S.isPlainObject(d)?S.merge.call({caseless:u},h,d):S.isPlainObject(d)?S.merge({},d):S.isArray(d)?d.slice():d}function s(h,d,u){if(S.isUndefined(d)){if(!S.isUndefined(h))return i(void 0,h,u)}else return i(h,d,u)}function n(h,d){if(!S.isUndefined(d))return i(void 0,d)}function a(h,d){if(S.isUndefined(d)){if(!S.isUndefined(h))return i(void 0,h)}else return i(void 0,d)}function o(h,d,u){if(u in e)return i(h,d);if(u in r)return i(void 0,h)}const l={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:(h,d)=>s(_h(h),_h(d),!0)};return S.forEach(Object.keys(r).concat(Object.keys(e)),function(d){const u=l[d]||s,c=u(r[d],e[d],d);S.isUndefined(c)&&u!==o||(t[d]=c)}),t}const wh="1.3.3",mn={};["object","boolean","number","function","string","symbol"].forEach((r,e)=>{mn[r]=function(i){return typeof i===r||"a"+(e<1?"n ":" ")+r}});const Sh={};mn.transitional=function(e,t,i){function s(n,a){return"[Axios v"+wh+"] Transitional option '"+n+"'"+a+(i?". "+i:"")}return(n,a,o)=>{if(e===!1)throw new re(s(a," has been removed"+(t?" in "+t:"")),re.ERR_DEPRECATED);return t&&!Sh[a]&&(Sh[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 Yp(r,e,t){if(typeof r!="object")throw new re("options must be an object",re.ERR_BAD_OPTION_VALUE);const i=Object.keys(r);let s=i.length;for(;s-- >0;){const n=i[s],a=e[n];if(a){const o=r[n],l=o===void 0||a(o,n,r);if(l!==!0)throw new re("option "+n+" must be "+l,re.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new re("Unknown option "+n,re.ERR_BAD_OPTION)}}const gn={assertOptions:Yp,validators:mn},Gt=gn.validators;class as{constructor(e){this.defaults=e,this.interceptors={request:new ch,response:new ch}}request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Ti(this.defaults,t);const{transitional:i,paramsSerializer:s,headers:n}=t;i!==void 0&&gn.assertOptions(i,{silentJSONParsing:Gt.transitional(Gt.boolean),forcedJSONParsing:Gt.transitional(Gt.boolean),clarifyTimeoutError:Gt.transitional(Gt.boolean)},!1),s!==void 0&&gn.assertOptions(s,{encode:Gt.function,serialize:Gt.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=St.concat(a,n);const o=[];let l=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(l=l&&m.synchronous,o.unshift(m.fulfilled,m.rejected))});const h=[];this.interceptors.response.forEach(function(m){h.push(m.fulfilled,m.rejected)});let d,u=0,c;if(!l){const f=[bh.bind(this),void 0];for(f.unshift.apply(f,o),f.push.apply(f,h),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=bh.call(this,p)}catch(f){return Promise.reject(f)}for(u=0,c=h.length;u<c;)d=d.then(h[u++],h[u++]);return d}getUri(e){e=Ti(this.defaults,e);const t=vh(e.baseURL,e.url);return uh(t,e.params,e.paramsSerializer)}}S.forEach(["delete","get","head","options"],function(e){as.prototype[e]=function(t,i){return this.request(Ti(i||{},{method:e,url:t,data:(i||{}).data}))}}),S.forEach(["post","put","patch"],function(e){function t(i){return function(n,a,o){return this.request(Ti(o||{},{method:e,headers:i?{"Content-Type":"multipart/form-data"}:{},url:n,data:a}))}}as.prototype[e]=t(),as.prototype[e+"Form"]=t(!0)});const os=as;class vn{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 i=this;this.promise.then(s=>{if(!i._listeners)return;let n=i._listeners.length;for(;n-- >0;)i._listeners[n](s);i._listeners=null}),this.promise.then=s=>{let n;const a=new Promise(o=>{i.subscribe(o),n=o}).then(s);return a.cancel=function(){i.unsubscribe(n)},a},e(function(n,a,o){i.reason||(i.reason=new or(n,a,o),t(i.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 vn(function(s){e=s}),cancel:e}}}const Kp=vn;function Jp(r){return function(t){return r.apply(null,t)}}function Qp(r){return S.isObject(r)&&r.isAxiosError===!0}const yn={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(yn).forEach(([r,e])=>{yn[e]=r});const em=yn;function Th(r){const e=new os(r),t=Xo(os.prototype.request,e);return S.extend(t,os.prototype,e,{allOwnKeys:!0}),S.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return Th(Ti(r,s))},t}const Ce=Th(un);Ce.Axios=os,Ce.CanceledError=or,Ce.CancelToken=Kp,Ce.isCancel=gh,Ce.VERSION=wh,Ce.toFormData=ts,Ce.AxiosError=re,Ce.Cancel=Ce.CanceledError,Ce.all=function(e){return Promise.all(e)},Ce.spread=Jp,Ce.isAxiosError=Qp,Ce.mergeConfig=Ti,Ce.AxiosHeaders=St,Ce.formToJSON=r=>ph(S.isHTMLForm(r)?new FormData(r):r),Ce.HttpStatusCode=em,Ce.default=Ce;const Ch=Ce;function tm(r,e){return rr(e)?Ch.get(r):Ch.get(r,e)}function Eh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Ue(r,e){this.message=r,this.error=e}Ue.prototype=Object.create(Error.prototype);const bn=/([0-9]+)?:?([0-9]{2}):([0-9]{2}\.[0-9]{2,3})/;function im(r,e){e||(e={});const{meta:t=!1,strict:i=!0}=e;if(typeof r!="string")throw new Ue("Input must be a string");r=r.trim(),r=r.replace(/\r\n/g,`
13
+ `),r=r.replace(/\r/g,`
14
+ `);const s=r.split(`
15
15
 
16
16
  `),n=s.shift();if(!n.startsWith("WEBVTT"))throw new Ue('Must start with "WEBVTT"');const a=n.split(`
17
- `),o=a[0].replace("WEBVTT","");if(o.length>0&&o[0]!==" "&&o[0]!==" ")throw new Ue("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 Ue("Missing blank line after signature");const{cues:l,errors:h}=im(s,r);if(r&&h.length>0)throw h[0];const d=t?tm(a):null,u={valid:h.length===0,strict:r,cues:l,errors:h};return t&&(u.meta=d),u}function tm(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 im(i,e){const t=[];return{cues:i.map((s,n)=>{try{return rm(s,n,e)}catch(a){return t.push(a),null}}).filter(Boolean),errors:t}}function rm(i,e,t){let r="",s=0,n=.01,a="",o="";const l=i.split(`
18
- `).filter(Boolean);if(l.length>0&&l[0].trim().startsWith("NOTE"))return null;if(l.length===1&&!l[0].includes("-->"))throw new Ue(`Cue identifier cannot be standalone (cue #${e})`);if(l.length>1&&!(l[0].includes("-->")||l[1].includes("-->"))){const d=`Cue identifier needs to be followed by timestamp (cue #${e})`;throw new Ue(d)}l.length>1&&l[1].includes("-->")&&(r=l.shift());const h=typeof l[0]=="string"&&l[0].split(" --> ");if(h.length!==2||!Eh(h[0])||!Eh(h[1]))throw new Ue(`Invalid cue timestamp (cue #${e})`);if(s=kh(h[0]),n=kh(h[1]),t){if(s>n)throw new Ue(`Start timestamp greater than end (cue #${e})`);if(n<=s)throw new Ue(`End must be greater than start (cue #${e})`)}if(!t&&n<s)throw new Ue(`End must be greater or equal to start when not strict (cue #${e})`);return o=h[1].replace(yn,"").trim(),l.shift(),a=l.join(`
19
- `),a?{identifier:r,start:s,end:n,text:a,styles:o}:!1}function Eh(i){return yn.test(i)}function kh(i){const e=i.match(yn);let t=parseFloat(e[1]||0)*60*60;return t+=parseFloat(e[2])*60,t+=parseFloat(e[3]),t}var xh={ParserError:Ue,parse:em};function Oe(i,e){this.message=i,this.error=e}Oe.prototype=Object.create(Error.prototype);function sm(i){if(!i)throw new Oe("Input must be non-null");if(typeof i!="object")throw new Oe("Input must be an object");if(Array.isArray(i))throw new Oe("Input cannot be array");if(!i.valid)throw new Oe("Input must be valid");let e=`WEBVTT
20
- `;if(i.meta){if(typeof i.meta!="object"||Array.isArray(i.meta))throw new Oe("Metadata must be an object");Object.entries(i.meta).forEach(r=>{if(typeof r[1]!="string")throw new Oe(`Metadata value for "${r[0]}" must be string`);e+=`${r[0]}: ${r[1]}
21
- `})}let t=null;return i.cues.forEach((r,s)=>{if(t&&t>r.start)throw new Oe(`Cue number ${s} is not in chronological order`);t=r.start,e+=`
22
- `,e+=nm(r),e+=`
23
- `}),e}function nm(i){if(typeof i!="object")throw new Oe("Cue malformed: not of type object");if(typeof i.identifier!="string"&&typeof i.identifier!="number"&&i.identifier!==null)throw new Oe(`Cue malformed: identifier value is not a string.
24
- ${JSON.stringify(i)}`);if(isNaN(i.start))throw new Oe(`Cue malformed: null start value.
25
- ${JSON.stringify(i)}`);if(isNaN(i.end))throw new Oe(`Cue malformed: null end value.
26
- ${JSON.stringify(i)}`);if(i.start>=i.end)throw new Oe(`Cue malformed: start timestamp greater than end
27
- ${JSON.stringify(i)}`);if(typeof i.text!="string")throw new Oe(`Cue malformed: null text value.
28
- ${JSON.stringify(i)}`);if(typeof i.styles!="string")throw new Oe(`Cue malformed: null styles value.
29
- ${JSON.stringify(i)}`);let e="";i.identifier.length>0&&(e+=`${i.identifier}
30
- `);const t=Ph(i.start),r=Ph(i.end);return e+=`${t} --> ${r}`,e+=i.styles?` ${i.styles}`:"",e+=`
31
- ${i.text}`,e}function Ph(i){const e=os(am(i),2),t=os(om(i),2),r=os(hm(i),2),s=os(lm(i),3);return`${e}:${t}:${r}.${s}`}function os(i,e){let t=`${i}`;for(;t.length<e;)t=`0${t}`;return t}function am(i){return Math.floor(i/60/60)}function om(i){return Math.floor(i/60)%60}function hm(i){return Math.floor(i%60)}function lm(i){return Math.floor((i%1).toFixed(4)*1e3)}var dm={CompilerError:Oe,compile:sm};const um=xh.parse;function cm(i,e){e=e||10;const t=um(i),r=[];let s=[],n=null,a=0,o=0;return t.cues.forEach((l,h)=>{const d=h===0,u=h===t.cues.length-1,c=l.start,p=l.end,f=u?1/0:t.cues[h+1].start,m=d?p:p-c,g=d?0:c-t.cues[h-1].end;a=a+m+g,`${h}`,r.length+1,n&&(s.push(n),a+=n.end-o,n=null),s.push(l);let _=f-p<e&&g<e&&a>e;if(fm(o,e,f,g)){const w=pm(u,p,e,a,o);r.push({duration:w,cues:s}),o+=w,a=0,s=[]}else _=!1;_&&(n=l)}),r}function fm(i,e,t,r){const s=Ah(r,e);return(r<=e||s+i<t)&&t-i>=e}function pm(i,e,t,r,s){let n=t;return r>t&&(n=Ah(r-t,t)),i?n=parseFloat((e-s).toFixed(2)):n=Math.round(n),n}function Ah(i,e){return i+=e-i%e,i}function lg(i){}var Mh={segment:cm};const Oh=Mh.segment;function mm(i,e,t){typeof t>"u"&&(t="900000");const r=Oh(i,e),s=[];return r.forEach((n,a)=>{const o=`WEBVTT
17
+ `),o=a[0].replace("WEBVTT","");if(o.length>0&&o[0]!==" "&&o[0]!==" ")throw new Ue("Header comment must start with space or tab");if(s.length===0&&a.length===1)return{valid:!0,strict:i,cues:[],errors:[]};if(!t&&a.length>1&&a[1]!=="")throw new Ue("Missing blank line after signature");const{cues:l,errors:h}=sm(s,i);if(i&&h.length>0)throw h[0];const d=t?rm(a):null,u={valid:h.length===0,strict:i,cues:l,errors:h};return t&&(u.meta=d),u}function rm(r){const e={};return r.slice(1).forEach(t=>{const i=t.indexOf(":"),s=t.slice(0,i).trim(),n=t.slice(i+1).trim();e[s]=n}),Object.keys(e).length>0?e:null}function sm(r,e){const t=[];return{cues:r.map((s,n)=>{try{return nm(s,n,e)}catch(a){return t.push(a),null}}).filter(Boolean),errors:t}}function nm(r,e,t){let i="",s=0,n=.01,a="",o="";const l=r.split(`
18
+ `).filter(Boolean);if(l.length>0&&l[0].trim().startsWith("NOTE"))return null;if(l.length===1&&!l[0].includes("-->"))throw new Ue(`Cue identifier cannot be standalone (cue #${e})`);if(l.length>1&&!(l[0].includes("-->")||l[1].includes("-->"))){const d=`Cue identifier needs to be followed by timestamp (cue #${e})`;throw new Ue(d)}l.length>1&&l[1].includes("-->")&&(i=l.shift());const h=typeof l[0]=="string"&&l[0].split(" --> ");if(h.length!==2||!kh(h[0])||!kh(h[1]))throw new Ue(`Invalid cue timestamp (cue #${e})`);if(s=xh(h[0]),n=xh(h[1]),t){if(s>n)throw new Ue(`Start timestamp greater than end (cue #${e})`);if(n<=s)throw new Ue(`End must be greater than start (cue #${e})`)}if(!t&&n<s)throw new Ue(`End must be greater or equal to start when not strict (cue #${e})`);return o=h[1].replace(bn,"").trim(),l.shift(),a=l.join(`
19
+ `),a?{identifier:i,start:s,end:n,text:a,styles:o}:!1}function kh(r){return bn.test(r)}function xh(r){const e=r.match(bn);let t=parseFloat(e[1]||0)*60*60;return t+=parseFloat(e[2])*60,t+=parseFloat(e[3]),t}var Ph={ParserError:Ue,parse:im};function Me(r,e){this.message=r,this.error=e}Me.prototype=Object.create(Error.prototype);function am(r){if(!r)throw new Me("Input must be non-null");if(typeof r!="object")throw new Me("Input must be an object");if(Array.isArray(r))throw new Me("Input cannot be array");if(!r.valid)throw new Me("Input must be valid");let e=`WEBVTT
20
+ `;if(r.meta){if(typeof r.meta!="object"||Array.isArray(r.meta))throw new Me("Metadata must be an object");Object.entries(r.meta).forEach(i=>{if(typeof i[1]!="string")throw new Me(`Metadata value for "${i[0]}" must be string`);e+=`${i[0]}: ${i[1]}
21
+ `})}let t=null;return r.cues.forEach((i,s)=>{if(t&&t>i.start)throw new Me(`Cue number ${s} is not in chronological order`);t=i.start,e+=`
22
+ `,e+=om(i),e+=`
23
+ `}),e}function om(r){if(typeof r!="object")throw new Me("Cue malformed: not of type object");if(typeof r.identifier!="string"&&typeof r.identifier!="number"&&r.identifier!==null)throw new Me(`Cue malformed: identifier value is not a string.
24
+ ${JSON.stringify(r)}`);if(isNaN(r.start))throw new Me(`Cue malformed: null start value.
25
+ ${JSON.stringify(r)}`);if(isNaN(r.end))throw new Me(`Cue malformed: null end value.
26
+ ${JSON.stringify(r)}`);if(r.start>=r.end)throw new Me(`Cue malformed: start timestamp greater than end
27
+ ${JSON.stringify(r)}`);if(typeof r.text!="string")throw new Me(`Cue malformed: null text value.
28
+ ${JSON.stringify(r)}`);if(typeof r.styles!="string")throw new Me(`Cue malformed: null styles value.
29
+ ${JSON.stringify(r)}`);let e="";r.identifier.length>0&&(e+=`${r.identifier}
30
+ `);const t=Ah(r.start),i=Ah(r.end);return e+=`${t} --> ${i}`,e+=r.styles?` ${r.styles}`:"",e+=`
31
+ ${r.text}`,e}function Ah(r){const e=hs(hm(r),2),t=hs(lm(r),2),i=hs(dm(r),2),s=hs(um(r),3);return`${e}:${t}:${i}.${s}`}function hs(r,e){let t=`${r}`;for(;t.length<e;)t=`0${t}`;return t}function hm(r){return Math.floor(r/60/60)}function lm(r){return Math.floor(r/60)%60}function dm(r){return Math.floor(r%60)}function um(r){return Math.floor((r%1).toFixed(4)*1e3)}var cm={CompilerError:Me,compile:am};const fm=Ph.parse;function pm(r,e){e=e||10;const t=fm(r),i=[];let s=[],n=null,a=0,o=0;return t.cues.forEach((l,h)=>{const d=h===0,u=h===t.cues.length-1,c=l.start,p=l.end,f=u?1/0:t.cues[h+1].start,m=d?p:p-c,g=d?0:c-t.cues[h-1].end;a=a+m+g,`${h}`,i.length+1,n&&(s.push(n),a+=n.end-o,n=null),s.push(l);let _=f-p<e&&g<e&&a>e;if(mm(o,e,f,g)){const w=gm(u,p,e,a,o);i.push({duration:w,cues:s}),o+=w,a=0,s=[]}else _=!1;_&&(n=l)}),i}function mm(r,e,t,i){const s=Oh(i,e);return(i<=e||s+r<t)&&t-r>=e}function gm(r,e,t,i,s){let n=t;return i>t&&(n=Oh(i-t,t)),r?n=parseFloat((e-s).toFixed(2)):n=Math.round(n),n}function Oh(r,e){return r+=e-r%e,r}function fg(r){}var Mh={segment:pm};const Lh=Mh.segment;function vm(r,e,t){typeof t>"u"&&(t="900000");const i=Lh(r,e),s=[];return i.forEach((n,a)=>{const o=`WEBVTT
32
32
  X-TIMESTAMP-MAP=MPEGTS:${t},LOCAL:00:00:00.000
33
33
 
34
- ${bm(n.cues)}
35
- `,l=Lh(a);s.push({filename:l,content:o})}),s}function gm(i,e){const t=Oh(i,e),r=vm(t);return`#EXTM3U
36
- #EXT-X-TARGETDURATION:${Math.round(ym(t))}
34
+ ${wm(n.cues)}
35
+ `,l=Rh(a);s.push({filename:l,content:o})}),s}function ym(r,e){const t=Lh(r,e),i=bm(t);return`#EXTM3U
36
+ #EXT-X-TARGETDURATION:${Math.round(_m(t))}
37
37
  #EXT-X-VERSION:3
38
38
  #EXT-X-MEDIA-SEQUENCE:0
39
39
  #EXT-X-PLAYLIST-TYPE:VOD
40
- ${r}
40
+ ${i}
41
41
  #EXT-X-ENDLIST
42
- `}function hs(i,e){return`${"0".repeat(Math.max(0,e-i.toString().length))}${i}`}function Lh(i){return`${i}.vtt`}function vm(i){const e=[];return i.forEach((t,r)=>{e.push(`#EXTINF:${t.duration.toFixed(5)},
43
- ${Lh(r)}`)}),e.join(`
44
- `)}function ym(i){let e=0;return i.forEach(t=>{t.duration>e&&(e=t.duration)}),e}function bm(i){const e=[];return i.forEach(t=>{e.push(_m(t))}),e.join(`
42
+ `}function ls(r,e){return`${"0".repeat(Math.max(0,e-r.toString().length))}${r}`}function Rh(r){return`${r}.vtt`}function bm(r){const e=[];return r.forEach((t,i)=>{e.push(`#EXTINF:${t.duration.toFixed(5)},
43
+ ${Rh(i)}`)}),e.join(`
44
+ `)}function _m(r){let e=0;return r.forEach(t=>{t.duration>e&&(e=t.duration)}),e}function wm(r){const e=[];return r.forEach(t=>{e.push(Sm(t))}),e.join(`
45
45
 
46
- `)}function _m(i){const e=[];i.identifier&&e.push(i.identifier);const t=Rh(i.start),r=Rh(i.end),s=i.styles?`${i.styles}`:"";return e.push(`${t} --> ${r} ${s}`),e.push(i.text),e.join(`
47
- `)}function Rh(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`${`${hs(t,2)}:`}${hs(r,2)}:${hs(s,2)}.${hs(e*1e3,3)}`}var wm={hlsSegment:mm,hlsSegmentPlaylist:gm};const Sm=xh.parse,Tm=dm.compile,Cm=Mh.segment;var Em={parse:Sm,compile:Tm,segment:Cm,hls:wm};class bn{constructor(e,t){this.cues=new Map,this.cuesKeysSorted=[],this.url=e,this.axiosConfig=t}fetch(){return Hi(Qp(this.getUrl(),this.axiosConfig)).pipe(ke(e=>{let t=e.data;try{return Em.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 _n extends bn{constructor(e,t){super(e,t)}static create(e,t){let r=new _n(e,t);return r.fetch().pipe(ke(s=>r))}mapCue(e){return{id:e.identifier,startTime:new j(e.start).toDecimalPlaces(3).toNumber(),endTime:new j(e.end).toDecimalPlaces(3).toNumber(),text:e.text}}}const Ih={listening:!0,style:{height:20,fill:"rgba(255,73,145)",opacity:1,visible:!0}};class km extends Ye{constructor(e,t){super({...Ih,...e,style:{...Ih.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 xm={...Qi,height:40,paddingTop:0,paddingBottom:0,subtitlesLaneItemOpacity:.9,subtitlesLaneItemFill:"rgba(255,73,145)"};class wn extends er{constructor(e){super({...e,style:{...xm,...e.style}}),this.subtitlesLaneItemsMap=new Map,this.onSettleLayout$=new $,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=_i.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 km({...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(We(1)).subscribe(e=>{this.subtitlesVttFile=e,this.createEntities()})}fetchSubtitlesVttFile(e){return e?_n.create(e).pipe(ke(t=>t),li((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 Pm={listening:!1,style:{...F.POSITION_TOP_LEFT,...F.DIMENSION_ZERO,stroke:"rgba(255,73,145)",strokeWidth:5,visible:!1}};class Sn extends Ye{constructor(e){super(ci(e,Pm)),this.onClick$=new $,this.onMouseOver$=new $,this.onMouseMove$=new $,this.onMouseOut$=new $,this.onMouseLeave$=new $,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$];jt(...e),ui(...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 bn{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 j(e.start).toDecimalPlaces(3).toNumber(),endTime:new j(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 Tt{static createKonvaImage(e){return new ie(t=>{M.Image.fromURL(e,r=>{t.next(r),t.complete()},r=>{console.error(r),t.error(r)})})}static createKonvaImageSizedByWidth(e,t){return Tt.createKonvaImage(e).pipe(ke(r=>(r.setAttrs({width:t,height:Tt.calculateProportionalHeight(t,r)}),r)))}static createKonvaImageSizedByHeight(e,t){return Tt.createKonvaImage(e).pipe(ke(r=>(r.setAttrs({width:Tt.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 Am={...Qi,thumbnailHeight:40,thumbnailStroke:"rgba(121,0,255,0.9)",thumbnailStrokeWidth:0,thumbnailHoverScale:1.5,thumbnailHoverStroke:"rgba(0,255,188,0.9)",thumbnailHoverStrokeWidth:5};class Tn extends er{constructor(e){super({...e,style:{...Am,...e.style}}),this.thumbnailsMap=new Map,this.thumbnailsVisibleSet=new Set,this.onSettleLayout$=new $,this.eventStreamBreaker$=new $,this.onClick$=new $,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=_i.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 Sn({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(lo(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 $}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),Tt.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 Sn({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 Tt.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 l=this.getRect().y+this.thumbnailsGroup.y()+e.getDimension().height/2-this.thumbnailHover.getDimension().height/2;return{x:s,y:l}}fetchAndCreateThumbnails(){this.fetchThumbnailVttFile(this._thumbnailVttUrl,this._axiosConfig,this.style.thumbnailHeight).pipe(We(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(ic(s=>{let n=s.getCues()[0];return Tt.createKonvaImageSizedByHeight(n.url,r).pipe(ke(a=>{let o=a.getSize().width;return{thumbnailVttFile:s,thumbnailWidth:o}}))}),li((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 Cn extends bn{constructor(e,t){super(e,t)}static create(e,t){let r=new Cn(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 j(e.start).toDecimalPlaces(3).toNumber(),endTime:new j(e.end).toDecimalPlaces(3).toNumber(),text:e.text,minSample:r,maxSample:s}}}const Nh={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 Mm extends Ye{constructor(e){super({...Nh,...e,style:{...Nh.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 j(this.audioVttCue.maxSample).mul(this.style.height/2).toDecimalPlaces(2).toNumber()}resolveMinSampleBarHeight(){return new j(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 Om={...Qi,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 Dh extends er{constructor(e){super({...e,style:{...Om,...e.style}}),this.audioTrackLaneItemsMap=new Map,this.onSettleLayout$=new $,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=_i.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()}),Du([this.onSettleLayout$,this.timeline.onScroll$]).pipe(k(this.onDestroy$),lo(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 j(t+this.style.itemMinPadding).div(this.style.itemWidth+this.style.itemMinPadding).floor().toNumber(),this.itemPadding=new j(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),l=new Mm({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,l),this.audioTrackLaneItemsGroup.add(l.initCanvasNode())}}resolveNumOfCuesPerInterpolation(e){return new j(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),l=n;n=l+o;let h=e.slice(l,n),d=e[l],u=e[n-1],c=0,p=0;h.forEach(m=>{c+=m.minSample,p+=m.maxSample});let f={id:`${a}`,text:"",minSample:new j(c).div(o).toDecimalPlaces(3).toNumber(),maxSample:new j(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(We(1)).subscribe(e=>{this.audioVttFile=e,this.createEntities()})}fetchAudioTrackVttFile(e){return e?Cn.create(e).pipe(ke(t=>t),li((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,$e(this.onSettleLayout$),super.destroy()}}function En(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 Lm={...F.POSITION_TOP_LEFT,width:0,zoomMax:1500,scrollStepNumberOfDivisions:10,style:{height:20,backgroundFill:"#000000",backgroundFillOpacity:.3,handleBarFill:"#01a6f0",handleBarOpacity:1,handleOpacity:1}};class Rm extends Ye{constructor(e){super(ci(e,Lm)),this.onScroll$=new $,this.onZoom$=new $,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$),ze(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}),at.cursor("ew-resize")}),this.leftZoomHandle.on("mouseout",n=>{this.leftZoomHandle.to({...t}),at.cursor("default")}),this.rightZoomHandle.on("mouseover",n=>{this.rightZoomHandle.to({...e}),at.cursor("ew-resize")}),this.rightZoomHandle.on("mouseout",n=>{this.rightZoomHandle.to({...t}),at.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);En({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 j(this.group.width()).mul(100).div(e).toNumber()}getZoomPercent(){return this.group.width()===this.handleBar.width()?100:new j(this.group.width()).mul(100).div(this.handleBar.width()).toNumber()}getScrollHandlePercent(){return this.handleBar.x()===0?0:new j(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 Im={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 Nm extends Ye{constructor(e,t){super(ci(e,Im)),this.stylesProvider=bt.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(ze(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 Dm={style:{visible:!0,fill:"#f43530",lineWidth:2,symbolHeight:15,scrubberHeight:15,backgroundFill:"#ffffff",backgroundOpacity:0,playProgressFill:"#008cbc",playProgressOpacity:.5,bufferedFill:"#a2a2a2",bufferedOpacity:1}};class Gm extends Ye{constructor(e,t,r){super(ci(e,Dm)),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=_i.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),l=this.timeline.timeToTimelinePosition(a.end);s.setAttrs({x:o,width:l-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 Fm={style:{...F.POSITION_TOP_LEFT,width:150,height:20,textFontSize:20,textFill:"#0d0f05",visible:!0}};class Gh extends Ye{constructor(e,t){super(ci(e,Fm)),this.stylesProvider=bt.instance(),this.videoEventStreamBreaker$=new $,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(ze(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.text.setAttrs({fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily})}),this.videoController.onVideoLoaded$.pipe(ze(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.onVideoLoadedEvent(e)})}onMeasurementsChange(){this.group.width(this.style.width)}fireVideoEventStreamBreaker(){$e(this.videoEventStreamBreaker$),this.videoEventStreamBreaker$=new $}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 Hm={...Qi,height:60,tickDivisor:5,tickDivisionMinWidth:18,tickFill:"#0d0f05",tickHeight:12,divisionTickFill:"#000000",divisionTickHeight:12*F.GOLDEN_RATIO,timecodeShowFirst:!0,timecodeFontSize:11,timecodeFill:"#0d0f05"};class Bm extends er{constructor(e,t){super({...e,style:{...Hm,...e.style}}),this.onClick$=new $,this.onMouseEnter$=new $,this.onMouseOver$=new $,this.onMouseMove$=new $,this.onMouseOut$=new $,this.onMouseLeave$=new $,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=_i.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 Gh({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$];jt(...e),ui(...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 j(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 l=0,h=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:l}),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+h:f?L-R.width-d:L-R.width/2,V=b-R.height;G.setAttrs({x:H,y:V});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 j(e).div(s).floor().greaterThan(t)?this.resolveTimeDivisionWidth(e,t,r,s*r):new j(e).div(s/r).toNumber()}}const $m={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}},Fh="omakase_scrubber_lane";class Vm extends Ye{constructor(e,t){super(ci(e,$m)),this.scrollWithPlayhead=!0,this.syncTimelineWithPlayheadInProgress=!1,this.mouseWheelEnabled=!1,this.leftPanelVisible=!0,this.videoEventBreaker$=new $,this.onScroll$=new $,this.onZoom$=new $,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=_i.createEventCatcher(),this.thumbnailHover=new Sn({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 Rm({style:{height:this.style.scrollbarHeight}}),this.rightPanel.add(this.scrollbar.initCanvasNode()),this.playhead=new Gm({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 Nm({},this),[this.playhead,this.playheadHover].forEach(t=>{this.addToTimecodedSurfaceGroup(t.initCanvasNode())}),this.headerTimecodeDisplay=new Gh({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 Bm({id:Fh,description:""},this.videoController),this.addLanes([this.scrubberLane]),this.stage}afterCanvasNodeInit(){this.videoController.onVideoLoading$.pipe(ze(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.clearContent()}),this.videoController.onVideoLoaded$.pipe(ze(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=>{at.cursor("grabbing")}),this.timecodedGroup.on("dragend",e=>{at.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 Tt.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 l=this.scrubberLane.getRect();return{x:n,y:l.y+l.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 j(this.getTimecodedContainerDimension().width-this.getTimecodedGroupDimension().width).abs();return new j(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 j(e).mul(e).div(t).round().toNumber(),x:new j(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 ie(t=>{let r=this.getTimecodedGroupPosition().x;En({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 ie(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 j(r.width-t.width);return new j(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 j(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 ie(e=>{this.zoomStep("IN",this.timecodedGroup.getRelativePointerPosition().x),e.next(this.getZoomPercent()),e.complete()})}zoomOut(){return new ie(e=>{this.zoomStep("OUT",this.timecodedGroup.getRelativePointerPosition().x),e.next(this.getZoomPercent()),e.complete()})}zoomToEased(e){return new ie(t=>{e=this.getConstrainedZoomPercent(e);let r=this.getTimecodedGroupDimension().width,s=this.calculateWidthFromZoomRatioPercent(e);En({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 j(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(l=>{l.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 l=new j(t).div(s);if(l.greaterThanOrEqualTo(0)&&l.lessThanOrEqualTo(1)){let h=e-s,d=l.mul(h).abs().round().toNumber(),u=r+d*(a==="IN"?-1:1);o=u<0?u:0}}if(e>n.width){let l=n.x+n.width;o+e<=l&&(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 j(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 $}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(Fh)}getMarkerLane(e){let t=this.getLane(e);return t instanceof tn?t:void 0}getThumbnailLane(e){let t=this.getLane(e);return t instanceof Tn?t:void 0}getSubtitlesLane(e){let t=this.getLane(e);return t instanceof wn?t:void 0}getAudioTrackLane(e){let t=this.getLane(e);return t instanceof Dh?t:void 0}createMarkerLane(e){let t=new tn(e);return this.addLane(t),t}createThumbnailLane(e){let t=new Tn(e);return this.addLane(t),t}createSubtitlesLane(e){let t=new wn(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 j(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 j(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)),li((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,Us(this.videoEventBreaker$);let e=[this.onScroll$,this.onZoom$];jt(...e),ui(...e),[this.scrollbar,this.playheadHover,this.playhead,...this.timelineLanes,this.thumbnailHover,this.headerTimecodeDisplay].forEach(r=>{r&&r.destroy()}),super.destroy()}}class kn{static timeToFrame(e,t){return t.mul(e).floor().toNumber()}static frameToTime(e,t){return new j(e).dividedBy(t).toNumber()}}class Ti{constructor(){this.resolveUserAgent()}static instance(){return Ti._instance||(Ti._instance=new Ti),Ti._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 lt=class{static formatVideoTimestamp(i,e){if(i<=0)return lt.VIDEO_ZERO_TIMESTAMP;const t=Math.floor(i/3600),r=Math.floor(i%3600/60),s=Math.floor(i%60);let n=new j(kn.timeToFrame(i,e)).mod(e).toNumber();return`${lt.padZero(t)}:${lt.padZero(r)}:${lt.padZero(s)}:${lt.padZero(n)}`}static padZero(i,e=2){return i.toString().padStart(e,"0")}};let xn=lt;xn.VIDEO_ZERO_TIMESTAMP=`${lt.padZero(0)}:${lt.padZero(0)}:${lt.padZero(0)}:${lt.padZero(0)}`;class zm{constructor(){this._state={playing:!1,paused:!0,waiting:!1,seeking:!1,buffering:!1,ended:!1},this.onChange$=new hi(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 Hh(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 Wm(i){return{errorMap:(e,t)=>({message:i})}}const Ze={PAUSE:"pause",WAITING:"waiting",PLAYING:"playing",TIMEUPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",LOADEDDATA:"loadeddata",LOADEDMETEDATA:"loadedmetadata",ENDED:"ended",PROGRESS:"progress"};class Um{constructor(e,t){if(this.browserProvider=Ti.instance(),this.helpMenuGroups=[],this._isVideoLoaded=!1,this.frameDurationSpillOverCorrection=.001,this.syncLoopMaxIterations=20,this.seekInProgress=!1,this.videoStalledCheckIntervalMs=700,this.videoFrameCallback$=new hi(null),this.videoEventBreaker$=new $,this.onDestroy$=new $,this.seekBreaker$=new $,this.onVideoLoaded$=new hi(void 0),this.onVideoLoading$=new $,this.onPlay$=new $,this.onPause$=new $,this.onVideoTimeChange$=new $,this.onSeeking$=new $,this.onSeeked$=new $,this.onBuffering$=new $,this.onEnded$=new $,this.onAudioSwitched$=new $,this.onPlaybackState$=new $,this.onHelpMenuChange$=new hi(void 0),this.onVideoError$=new $,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=vi.url()(e),t=_e.coerce.number().min(0).max(100).parse(t,Wm("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 j(this.video.frameRate),this.syncStepCurrentTimeMediaTime=0,this.playbackStateMachine=new zm,this.initEventHandlers(),this.startVideoFrameCallback(),this._isVideoLoaded=!0,this.onVideoLoaded$.next({video:this.video});let n=Number.parseFloat(this.getDuration().toFixed(3));return Number.isInteger(Number.parseFloat((this.getDuration()*this.video.frameRate).toFixed(1)))&&(n=Number.parseFloat((n-this.frameDurationSpillOverCorrection).toFixed(3)),this.video.setCorrectedDuration(n)),this.getHls().on(Le.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}),li((s,n)=>{let a=Hh(s);return this.onVideoError$.next({type:"VIDEO_LOAD_ERROR",message:a}),io(()=>new Error(a))}))}catch(s){let n=Hh(s);return this.onVideoError$.next({type:"VIDEO_LOAD_ERROR",message:n}),io(()=>new Error(n))}}initEventHandlers(){be(this.videoElement,Ze.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,Ze.WAITING).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.waiting=!0}),be(this.videoElement,Ze.PLAYING).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setPlaying(),this.videoStalledCheckLastCurrentTime=void 0}),be(this.videoElement,Ze.PAUSE).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setPaused(),this.videoStalledCheckLastCurrentTime=void 0}),be(this.videoElement,Ze.PROGRESS).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.onBuffering$.next({bufferedTimespans:this.getBufferedTimespans()})}),be(this.videoElement,Ze.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}),qu(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 $,this.videoElement&&this.videoFrameCallbackHandle&&this.videoElement.cancelVideoFrameCallback(this.videoFrameCallbackHandle)}syncVideoFrames(e){return console.debug("syncFrames - START",e),new ie(t=>{let r=new hi(!1),s=new $,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=l=>{r.pipe(We(1)).subscribe(h=>{h?console.debug("%csyncFrames - seek skipped, breaker already triggered","color: gray"):this._seekTimeFireAndForget(l)})};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 l=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},h,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(l(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(h||(h=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(j.add(p,w).toNumber())}else{console.debug(`%csyncFrames - CORRECTION SEEK TO FRAME; syncConditions.seekToFrame[${e.seekToFrame}] !== currentTimeFrame[${f}] | seekToFrameTimeBaseline=${h}`,"color: red");let _=Math.abs(e.seekToFrame-f),w=_*this.video.frameDuration,T=(e.seekToFrame>=f?j.add(h,w):j.sub(h,w)).toNumber();h=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(j.add(p,this.syncStepCurrentTimeMediaTime).toNumber()):o(m+this.syncStepCurrentTimeMediaTime));console.debug("syncFrames.syncLoop - END")};this.videoFrameCallback$.pipe(Qu((e.seekToFrame,0)),k(s)).subscribe(u=>{console.debug("syncFrames.syncLoop - videoFrameCallback$ trigger",u),d(u)})}})}seekTimeAndSync(e,t={}){return new ie(r=>{this.seekInProgress&&($e(this.seekBreaker$),this.seekBreaker$=new $),this.seekInProgress=!0,isNaN(e)||(e=e<0?0:e>this.getDuration()?this.getDuration():e,be(this.videoElement,Ze.SEEKING).pipe(k(this.seekBreaker$),We(1)).subscribe(s=>{this.onSeeking$.next({newTime:e,currentTime:this.getCurrentTime()})}),be(this.videoElement,Ze.SEEKED).pipe(k(this.seekBreaker$),We(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$),We(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 ie(t=>{this.seekInProgress&&($e(this.seekBreaker$),this.seekBreaker$=new $),this.seekInProgress=!0,isNaN(e)||(e=e<0?0:e>this.getDuration()?this.getDuration():e,be(this.videoElement,Ze.SEEKING).pipe(k(this.seekBreaker$),We(1)).subscribe(r=>{this.onSeeking$.next({newTime:e,currentTime:this.getCurrentTime()})}),be(this.videoElement,Ze.SEEKED).pipe(k(this.seekBreaker$),We(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=j.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 ie(t=>{isNaN(e)||(e=e<0?0:e>this.getDuration()?this.getDuration():e,be(this.videoElement,Ze.SEEKED).pipe(di()).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=j.add(r,e).toNumber(),n;t.seekDirection?n=t.seekDirection:n=s===r?"NONE":s>r?"FORWARD":"BACKWARD";let a=j.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 j(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 kn.timeToFrame(e,this.getFrameRateDecimal())}calculateFrameToTime(e){return kn.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),xn.formatVideoTimestamp(e,this.getFrameRateDecimal())):xn.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(){Us(this.videoEventBreaker$,this.seekBreaker$),jt(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$];jt(...e),ui(...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 Zm{constructor(e,t,r,s){this._element=e,this._sourceUrl=t,this._frameRate=r,this._duration=s,this._totalFrames=new j(this._duration).mul(this._frameRate).ceil().toNumber(),this._frameDuration=new j(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 jm extends Um{constructor(e,t){super(e,t),Le.isSupported()?console.debug("video load with hls.js"):console.error("hls is not supported through MediaSource extensions");let r={...Le.DefaultConfig,enableWorker:!1};this.hls=new Le(r)}videoLoad(e,t,r){return new ie(s=>{this.hls.on(Le.Events.ERROR,function(l,h){h.type;let d=h.details;h.fatal,d.includes("audioTrackLoadError")||(s.error(`Error loading video. Hls error details: ${d}`),s.complete())});let n=new ie(l=>{this.hls.once(Le.Events.MEDIA_ATTACHED,function(h,d){console.debug("video element and hls.js are now bound together"),l.next(!0),l.complete()})}),a=new ie(l=>{this.hls.once(Le.Events.MANIFEST_PARSED,function(h,d){console.debug("manifest loaded, found "+d.levels.length+" quality level"),l.next(!0),l.complete()})}),o=be(this.videoElement,Ze.LOADEDDATA).pipe(di());Vu([n,a,o]).pipe(di()).subscribe(l=>{r=r&&_e.coerce.number().parse(r),r=r||this.videoElement.duration;let h=new Zm(this.videoElement,e,t,r);s.next(h),s.complete()}),this.hls.loadSource(e),this.hls.attachMedia(this.videoElement)})}initEventHandlers(){super.initEventHandlers(),this.hls.on(Le.Events.ERROR,function(e,t){t.type,t.details,t.fatal,console.error(e,t),t.details===Le.ErrorDetails.BUFFER_STALLED_ERROR||t.details===Le.ErrorDetails.BUFFER_APPEND_ERROR||(t.details,Le.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 Xm{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 qm extends Xm{constructor(e){super(e)}}class Pn{constructor(e){this.subtitlesTracks=new Map,this.onCreate$=new $,this.onRemove$=new $,this.onShow$=new $,this.onHide$=new $,this.videoController=e,this.videoController.onVideoLoaded$.pipe(ze(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 ie(t=>{let r=new qm({...e});this.subtitlesTracks.has(r.id)&&this.removeTrack(r.id),r.element=Pn.createHTMLTrackElement(r),be(r.element,"load").pipe(di()).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$];jt(...e),ui(...e),this.currentTrack=void 0,this.videoController=void 0}}var ds={},Ym={get exports(){return ds},set exports(i){ds=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(l,h,d){this.fn=l,this.context=h,this.once=d||!1}function n(l,h,d,u,c){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new s(d,u||l,c),f=t?t+h:h;return l._events[f]?l._events[f].fn?l._events[f]=[l._events[f],p]:l._events[f].push(p):(l._events[f]=p,l._eventsCount++),l}function a(l,h){--l._eventsCount===0?l._events=new r:delete l._events[h]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var h=[],d,u;if(this._eventsCount===0)return h;for(u in d=this._events)e.call(d,u)&&h.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(d)):h},o.prototype.listeners=function(h){var d=t?t+h:h,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(h){var d=t?t+h:h,u=this._events[d];return u?u.fn?1:u.length:0},o.prototype.emit=function(h,d,u,c,p,f){var m=t?t+h:h;if(!this._events[m])return!1;var g=this._events[m],_=arguments.length,w,b;if(g.fn){switch(g.once&&this.removeListener(h,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(h,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(h,d,u){return n(this,h,d,u,!1)},o.prototype.once=function(h,d,u){return n(this,h,d,u,!0)},o.prototype.removeListener=function(h,d,u,c){var p=t?t+h:h;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(h){var d;return h?(d=t?t+h:h,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})(Ym);const ug=ds,Km={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 Jm{constructor(e){this.onAudioSwitched$=new $,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 or{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 ge={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 Qm{constructor(e){this._playerHTMLElementId=e,this.divPlayer=this.getElementById(this._playerHTMLElementId),this.createDom()}createDom(){this.divPlayer.classList.add(`${ge.player}`),this.divPlayer.innerHTML=`<div class="${ge.playerWrapper}">
46
+ `)}function Sm(r){const e=[];r.identifier&&e.push(r.identifier);const t=Ih(r.start),i=Ih(r.end),s=r.styles?`${r.styles}`:"";return e.push(`${t} --> ${i} ${s}`),e.push(r.text),e.join(`
47
+ `)}function Ih(r){const e=(r%1).toFixed(3);r=Math.round(r-e);const t=Math.floor(r/3600),i=Math.floor((r-t*3600)/60),s=r-t*3600-i*60;return`${`${ls(t,2)}:`}${ls(i,2)}:${ls(s,2)}.${ls(e*1e3,3)}`}var Tm={hlsSegment:vm,hlsSegmentPlaylist:ym};const Cm=Ph.parse,Em=cm.compile,km=Mh.segment;var xm={parse:Cm,compile:Em,segment:km,hls:Tm};const Pm=Eh(xm);class _n{constructor(e,t){this.cues=new Map,this.cuesKeysSorted=[],this.url=e,this.axiosConfig=t}fetch(){return Bi(tm(this.getUrl(),this.axiosConfig)).pipe(ke(e=>{let t=e.data;try{return Pm.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(i){return console.error(i),!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 i=this.findCueIndex(e),s=this.findCueIndex(t);return s===-1?[]:this.cuesKeysSorted.slice(i,s+1).map(n=>this.cues.get(n))}getCues(){return[...this.cues.values()]}findCueIndex(e){let t=0,i=this.cuesKeysSorted.length-1;for(;t<=i;){const s=Math.floor((t+i)/2);if(this.cuesKeysSorted[s]===e)return s;this.cuesKeysSorted[s]<e?t=s+1:i=s-1}return i===-1&&(i=0),i}}class wn extends _n{constructor(e,t){super(e,t)}static create(e,t){let i=new wn(e,t);return i.fetch().pipe(ke(s=>i))}mapCue(e){return{id:e.identifier,startTime:new j(e.start).toDecimalPlaces(3).toNumber(),endTime:new j(e.end).toDecimalPlaces(3).toNumber(),text:e.text}}}const Nh={listening:!0,style:{height:20,fill:"rgba(255,73,145)",opacity:1,visible:!0}};class Am extends Ke{constructor(e,t){super({...Nh,...e,style:{...Nh.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 i=this.subtitlesLane.resolveItemHorizontalMeasurement(this.getTextTrackCue());this.setHorizontalMeasurement(i)})}createCanvasNode(){return this.group=new O.Group({x:this.x,y:0,width:this.width,height:this.style.height,visible:this.style.visible,listening:this.listening}),this.backgroundRect=new O.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 Om={...er,height:40,paddingTop:0,paddingBottom:0,subtitlesLaneItemOpacity:.9,subtitlesLaneItemFill:"rgba(255,73,145)"};class Sn extends tr{constructor(e){super({...e,style:{...Om,...e.style}}),this.subtitlesLaneItemsMap=new Map,this.onSettleLayout$=new B,this._subtitlesVttUrl=this.config.subtitlesVttUrl}createCanvasNode(){return super.createCanvasNode(),this.timecodedGroup=new O.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 O.Group({...$.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 i=this.resolveItemHorizontalMeasurement(t),s=new Am({...i,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)),i=this.timeline.constrainTimelinePosition(this.timeline.timeToTimelinePosition(e.endTime));return{x:t,width:i-t}}fetchAndCreateSubtitles(){this.fetchSubtitlesVttFile(this._subtitlesVttUrl).pipe(We(1)).subscribe(e=>{this.subtitlesVttFile=e,this.createEntities()})}fetchSubtitlesVttFile(e){return e?wn.create(e).pipe(ke(t=>t),di((t,i)=>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 Mm={listening:!1,style:{...$.POSITION_TOP_LEFT,...$.DIMENSION_ZERO,stroke:"rgba(255,73,145)",strokeWidth:5,visible:!1}};class Tn extends Ke{constructor(e){super(fi(e,Mm)),this.onClick$=new B,this.onMouseOver$=new B,this.onMouseMove$=new B,this.onMouseOut$=new B,this.onMouseLeave$=new B,this.listening=this.config.listening}createCanvasNode(){return this.group=new O.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 O.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$];Xt(...e),ci(...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 ds extends _n{constructor(e,t){super(e,t)}static create(e,t){let i=new ds(e,t);return i.fetch().pipe(ke(s=>i))}mapCue(e){return{id:e.identifier,startTime:new j(e.start).toDecimalPlaces(3).toNumber(),endTime:new j(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 Tt{static createKonvaImage(e){return new ie(t=>{O.Image.fromURL(e,i=>{t.next(i),t.complete()},i=>{console.error(i),t.error(i)})})}static createKonvaImageSizedByWidth(e,t){return Tt.createKonvaImage(e).pipe(ke(i=>(i.setAttrs({width:t,height:Tt.calculateProportionalHeight(t,i)}),i)))}static createKonvaImageSizedByHeight(e,t){return Tt.createKonvaImage(e).pipe(ke(i=>(i.setAttrs({width:Tt.calculateProportionalWidth(t,i),height:t}),i)))}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 Lm={...er,thumbnailHeight:40,thumbnailStroke:"rgba(121,0,255,0.9)",thumbnailStrokeWidth:0,thumbnailHoverScale:1.5,thumbnailHoverStroke:"rgba(0,255,188,0.9)",thumbnailHoverStrokeWidth:5};class Cn extends tr{constructor(e){super({...e,style:{...Lm,...e.style}}),this.thumbnailsMap=new Map,this.thumbnailsVisibleSet=new Set,this.onSettleLayout$=new B,this.eventStreamBreaker$=new B,this.onClick$=new B,this._thumbnailVttUrl=this.config.thumbnailVttUrl,this._axiosConfig=this.config.axiosConfig}createCanvasNode(){return super.createCanvasNode(),this.timecodedGroup=new O.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 O.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 Tn({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(lo(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 B}createAndAdjustThumbnails(){this.isVttLoaded()&&(this.resolveVisibleTimestamps(),this.thumbnailVttFile.getCues().forEach(e=>{let t=this.timeline.timeToTimelinePosition(e.startTime),i=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(i,t)}else i&&(this.thumbnailsMap.set(e.startTime,null),Tt.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),i=this.thumbnailsVisibleSet.has(e.getThumbnailVttCue().startTime);e.setVisibleAndX(i,t)}}))}resolveVisibleTimestamps(){let e;this.thumbnailVttFile.getCues().forEach(i=>{let s=this.timeline.timeToTimelinePosition(i.startTime);this.timeline.constrainTimelinePosition(s)===s&&((e?s>=e:!0)?(e=s+this.thumbnailWidth,this.thumbnailsVisibleSet.add(i.startTime)):this.thumbnailsVisibleSet.delete(i.startTime))})}createThumbnail(e,t,i){let s=this.timeline.timeToTimelinePosition(e.startTime),n=new Tn({listening:!0,style:{x:s,y:0,visible:i,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 Tt.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(),i=this.thumbnailHover.getImage().getSize(),s=e.getPosition().x+e.getDimension().width/2-i.width/2,n=e.style.strokeWidth>0?e.style.strokeWidth/2:0;s=s-n<0?n:s+i.width+n>t.width?t.width-i.width-n:s;let l=this.getRect().y+this.thumbnailsGroup.y()+e.getDimension().height/2-this.thumbnailHover.getDimension().height/2;return{x:s,y:l}}fetchAndCreateThumbnails(){this.fetchThumbnailVttFile(this._thumbnailVttUrl,this._axiosConfig,this.style.thumbnailHeight).pipe(We(1)).subscribe(e=>{e&&(this.thumbnailVttFile=e.thumbnailVttFile,this.thumbnailWidth=e.thumbnailWidth,this.createAndAdjustThumbnails())})}fetchThumbnailVttFile(e,t,i){return e?ds.create(e,t).pipe(sc(s=>{let n=s.getCues()[0];return Tt.createKonvaImageSizedByHeight(n.url,i).pipe(ke(a=>{let o=a.getSize().width;return{thumbnailVttFile:s,thumbnailWidth:o}}))}),di((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 En extends _n{constructor(e,t){super(e,t)}static create(e,t){let i=new En(e,t);return i.fetch().pipe(ke(s=>i))}mapCue(e){let t=e.text.split(","),i=_e.coerce.number().min(-1).max(0).catch(0).parse(t[0]),s=_e.coerce.number().min(0).max(1).catch(0).parse(t[1]);return{id:e.identifier,startTime:new j(e.start).toDecimalPlaces(3).toNumber(),endTime:new j(e.end).toDecimalPlaces(3).toNumber(),text:e.text,minSample:i,maxSample:s}}}const Dh={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 Rm extends Ke{constructor(e){super({...Dh,...e,style:{...Dh.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 O.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(),i=this.resolveMinSampleBarHeight();return this.maxSampleBar=new O.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 O.Rect({x:0,width:this.group.width(),y:e,height:i,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 j(this.audioVttCue.maxSample).mul(this.style.height/2).toDecimalPlaces(2).toNumber()}resolveMinSampleBarHeight(){return new j(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(),i=this.resolveMinSampleBarHeight();this.minSampleBar.setAttrs({height:i}),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 Im={...er,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 Gh extends tr{constructor(e){super({...e,style:{...Im,...e.style}}),this.audioTrackLaneItemsMap=new Map,this.onSettleLayout$=new B,this._audioVttFileUrl=this.config.audioVttFileUrl}createCanvasNode(){return super.createCanvasNode(),this.timecodedGroup=new O.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 O.Group({...$.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()}),Fu([this.onSettleLayout$,this.timeline.onScroll$]).pipe(k(this.onDestroy$),lo(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 j(t+this.style.itemMinPadding).div(this.style.itemWidth+this.style.itemMinPadding).floor().toNumber(),this.itemPadding=new j(t-this.numOfInterpolations*this.style.itemWidth).div(this.numOfInterpolations-1).toNumber();let i=this.resolveNumOfCuesPerInterpolation(e.length),s=this.resolveCuesInterpolations(e,i);for(let n=0;n<this.numOfInterpolations;n++){let a=s.get(n),o=this.resolveInterpolatedItemPosition(n),l=new Rm({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,l),this.audioTrackLaneItemsGroup.add(l.initCanvasNode())}}resolveNumOfCuesPerInterpolation(e){return new j(e).div(this.numOfInterpolations).floor().toNumber()}resolveCuesInterpolations(e,t){let i=e.length-t*this.numOfInterpolations,s=new Map,n=0;for(let a=0;a<this.numOfInterpolations;a++){let o=t+(a<i?1:0),l=n;n=l+o;let h=e.slice(l,n),d=e[l],u=e[n-1],c=0,p=0;h.forEach(m=>{c+=m.minSample,p+=m.maxSample});let f={id:`${a}`,text:"",minSample:new j(c).div(o).toDecimalPlaces(3).toNumber(),maxSample:new j(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),i=this.resolveCuesInterpolations(e,t);for(let s=0;s<this.numOfInterpolations;s++){let n=i.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),i=this.timeline.timeToTimelinePosition(t.getAudioVttCue().startTime);t.setPosition({x:i})}}fetchAndCreateAudioTrack(){this.fetchAudioTrackVttFile(this._audioVttFileUrl).pipe(We(1)).subscribe(e=>{this.audioVttFile=e,this.createEntities()})}fetchAudioTrackVttFile(e){return e?En.create(e).pipe(ke(t=>t),di((t,i)=>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,$e(this.onSettleLayout$),super.destroy()}}function kn(r){if(r.from===r.to)return;let e=r.from<r.to,t=e?r.to-r.from:r.from-r.to,i=new O.Animation(s=>{let n=O.Easings.StrongEaseInOut(s.time,0,t,r.duration);if(n>=t)r.onUpdateHandler(s,r.to),i.stop(),r.onCompleteHandler&&(r.onCompleteHandler(s,r.to),i=null);else{let a=r.from+n*(e?1:-1);r.onUpdateHandler(s,a)}},r.layer);i.start()}const Nm={...$.POSITION_TOP_LEFT,width:0,zoomMax:1500,scrollStepNumberOfDivisions:10,style:{height:20,backgroundFill:"#000000",backgroundFillOpacity:.3,handleBarFill:"#01a6f0",handleBarOpacity:1,handleOpacity:1}};class Dm extends Ke{constructor(e){super(fi(e,Nm)),this.onScroll$=new B,this.onZoom$=new B,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 O.Group({x:this.x,y:this.y,width:this.width,height:this.style.height}),this.background=new O.Rect({...$.POSITION_TOP_LEFT,width:this.group.width(),height:this.style.height,fill:this.style.backgroundFill,opacity:this.style.backgroundFillOpacity}),this.handleGroup=new O.Group({...$.POSITION_TOP_LEFT,width:this.group.width(),height:this.style.height}),this.handleBar=new O.Rect({...$.POSITION_TOP_LEFT,width:this.handleGroup.width(),height:this.style.height,fill:this.style.handleBarFill,opacity:this.style.handleBarOpacity,draggable:!0}),this.leftZoomHandle=new O.Circle({...$.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 O.Circle({...$.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$),ze(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}),ot.cursor("ew-resize")}),this.leftZoomHandle.on("mouseout",n=>{this.leftZoomHandle.to({...t}),ot.cursor("default")}),this.rightZoomHandle.on("mouseover",n=>{this.rightZoomHandle.to({...e}),ot.cursor("ew-resize")}),this.rightZoomHandle.on("mouseout",n=>{this.rightZoomHandle.to({...t}),ot.cursor("default")});let i=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=i(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 i=this.handleBar.x()>e,s=this.handleBar.x()+t*(i?-1:1);i?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(),i=this.getConstrainedHandleBarX(e);kn({layer:this.handleGroup.getLayer(),duration:$.TIMELINE_SCROLL_EASED_DURATION_MS,from:t,to:i,onUpdateHandler:(s,n)=>{this.scrollTo(n)}})}calculateHandleBarWidthFromZoomRatioPercent(e){return new j(this.group.width()).mul(100).div(e).toNumber()}getZoomPercent(){return this.group.width()===this.handleBar.width()?100:new j(this.group.width()).mul(100).div(this.handleBar.width()).toNumber()}getScrollHandlePercent(){return this.handleBar.x()===0?0:new j(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 Gm={style:{...$.POSITION_TOP_LEFT,height:100,fill:"#737373",fillSnapped:"#ffd500",lineWidth:2,symbolY:0,symbolHeight:15,textFontSize:12,textFill:"#0d0f05",textSnappedFill:"#f43530",visible:!1}};class Fm extends Ke{constructor(e,t){super(fi(e,Gm)),this.stylesProvider=bt.instance(),this.timeline=t}createCanvasNode(){return this.group=new O.Group({x:this.style.x,y:this.style.y,visible:this.style.visible,listening:!1}),this.line=new O.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 O.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 O.Label({...$.POSITION_TOP_LEFT,listening:!1}),this.text=new O.Text({fontSize:this.style.textFontSize,fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily,fill:this.style.textFill,...$.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(ze(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 i=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(i),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 Hm={style:{visible:!0,fill:"#f43530",lineWidth:2,symbolHeight:15,scrubberHeight:15,backgroundFill:"#ffffff",backgroundOpacity:0,playProgressFill:"#008cbc",playProgressOpacity:.5,bufferedFill:"#a2a2a2",bufferedOpacity:1}};class Bm extends Ke{constructor(e,t,i){super(fi(e,Hm)),this.timeline=t,this.videoController=i}createCanvasNode(){return this.group=new O.Group({...$.POSITION_TOP_LEFT,listening:!1}),this.background=new O.Rect({...$.POSITION_TOP_LEFT,height:this.style.scrubberHeight,fill:this.style.backgroundFill,opacity:this.style.backgroundOpacity,listening:!1}),this.playProgressBackground=new O.Rect({...$.POSITION_TOP_LEFT,height:this.style.scrubberHeight,fill:this.style.playProgressFill,opacity:this.style.playProgressOpacity,listening:!1}),this.playheadGroup=new O.Group({...$.POSITION_TOP_LEFT,visible:this.style.visible,listening:!1}),this.playheadLine=new O.Line({points:[0,0,0,0],stroke:this.style.fill,strokeWidth:this.style.lineWidth,listening:!1}),this.playheadSymbol=wi.createTriangle({...$.POSITION_TOP_LEFT,height:this.style.symbolHeight,color:this.style.fill}),this.bufferedGroup=new O.Group({...$.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,i=this.bufferedGroup.getChildren().length;t===i?this.bufferedGroup.getChildren().forEach((s,n)=>{let a=e[n],o=this.timeline.timeToTimelinePosition(a.start),l=this.timeline.timeToTimelinePosition(a.end);s.setAttrs({x:o,width:l-o})}):(this.bufferedGroup.getChildren().forEach(s=>s.destroy()),this.createBuffers(e))}else this.createBuffers(e)}createBuffers(e){e.forEach(t=>{let i=this.timeline.timeToTimelinePosition(t.start),s=this.timeline.timeToTimelinePosition(t.end),n=new O.Rect({x:i,y:0,width:s-i,height:this.style.scrubberHeight,fill:this.style.bufferedFill,opacity:this.style.bufferedOpacity,listening:!1});this.bufferedGroup.add(n)})}}const $m={style:{...$.POSITION_TOP_LEFT,width:150,height:20,textFontSize:20,textFill:"#0d0f05",visible:!0}};class Fh extends Ke{constructor(e,t){super(fi(e,$m)),this.stylesProvider=bt.instance(),this.videoEventStreamBreaker$=new B,this.videoController=t}createCanvasNode(){return this.group=new O.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 O.Text({...$.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(ze(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.text.setAttrs({fontFamily:this.stylesProvider.styles.omakasePlayerStyle.fontFamily})}),this.videoController.onVideoLoaded$.pipe(ze(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.onVideoLoadedEvent(e)})}onMeasurementsChange(){this.group.width(this.style.width)}fireVideoEventStreamBreaker(){$e(this.videoEventStreamBreaker$),this.videoEventStreamBreaker$=new B}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 Vm={...er,height:60,tickDivisor:5,tickDivisionMinWidth:18,tickFill:"#0d0f05",tickHeight:12,divisionTickFill:"#000000",divisionTickHeight:12*$.GOLDEN_RATIO,timecodeShowFirst:!0,timecodeFontSize:11,timecodeFill:"#0d0f05"};class zm extends tr{constructor(e,t){super({...e,style:{...Vm,...e.style}}),this.onClick$=new B,this.onMouseEnter$=new B,this.onMouseOver$=new B,this.onMouseMove$=new B,this.onMouseOut$=new B,this.onMouseLeave$=new B,this.videoController=t}createCanvasNode(){return super.createCanvasNode(),this.timecodedGroup=new O.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 O.Group({...$.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 Fh({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$];Xt(...e),ci(...e),super.destroy()}clearContent(){this.ticksGroup.destroyChildren()}refreshTimeDivisions(e=!1){if(!this.isTimelineReady())return;let t=this.style.tickDivisor,i=this.style.tickDivisionMinWidth,s=this.timeline.getTimecodedGroupRect().width,n=this.resolveTimeDivisionWidth(s,i,t,t),a=new j(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 l=0,h=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 O.Group({x:g,y:l}),L=0,A=new O.Line({points:[L,w,L,w+_],stroke:this.style.tickFill,strokeWidth:1,listening:!1});T.add(A);let G=new O.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(),F=p?L+h:f?L-R.width-d:L-R.width/2,V=b-R.height;G.setAttrs({x:F,y:V});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,i,s){return new j(e).div(s).floor().greaterThan(t)?this.resolveTimeDivisionWidth(e,t,i,s*i):new j(e).div(s/i).toNumber()}}const Wm={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}},Hh="omakase_scrubber_lane";class Um extends Ke{constructor(e,t){super(fi(e,Wm)),this.scrollWithPlayhead=!0,this.syncTimelineWithPlayheadInProgress=!1,this.mouseWheelEnabled=!1,this.leftPanelVisible=!0,this.videoEventBreaker$=new B,this.onScroll$=new B,this.onZoom$=new B,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 O.Stage({container:this.timelineHTMLElementId,...e}),this.layer=new O.Layer,this.stage.add(this.layer),this.layoutGroup=new O.Group({...$.POSITION_TOP_LEFT}),this.layer.add(this.layoutGroup),this.layoutBackground=new O.Rect({...$.POSITION_TOP_LEFT,fill:this.style.backgroundFill}),this.headerGroup=new O.Group({...$.POSITION_TOP_LEFT}),this.headerBackground=new O.Rect({...$.POSITION_TOP_LEFT,fill:this.style.headerBackgroundFill}),this.footerGroup=new O.Group({...$.POSITION_TOP_LEFT}),this.footerBackground=new O.Rect({...$.POSITION_TOP_LEFT,fill:this.style.footerBackgroundFill}),this.bodyGroup=new O.Group({...$.POSITION_TOP_LEFT}),this.bodyContentGroup=new O.Group({...$.POSITION_TOP_LEFT}),this.leftPanel=new O.Group({...$.POSITION_TOP_LEFT}),this.rightPanel=new O.Group({...$.POSITION_TOP_LEFT}),this.timecodedContainer=new O.Group({...$.POSITION_TOP_LEFT}),this.timecodedGroup=new O.Group({...$.POSITION_TOP_LEFT,draggable:!0}),this.timecodedBaseGroup=new O.Group({...$.POSITION_TOP_LEFT,name:"timecodedBaseGroup"}),this.timecodedThumbnailsGroup=new O.Group({...$.POSITION_TOP_LEFT,name:"timecodedThumbnailsGroup"}),this.timecodedSubtitlesGroup=new O.Group({...$.POSITION_TOP_LEFT,name:"timecodedSubtitlesGroup"}),this.timecodedAudioGroup=new O.Group({...$.POSITION_TOP_LEFT,name:"timecodedAudioGroup"}),this.timecodedMarkersGroup=new O.Group({...$.POSITION_TOP_LEFT,name:"timecodedMarkersGroup"}),this.timecodedSurfaceGroup=new O.Group({...$.POSITION_TOP_LEFT,name:"timecodedSurfaceGroup"}),this.timecodedBackground=new O.Rect({...$.POSITION_TOP_LEFT,fill:"yellow",opacity:0,listening:!1}),this.timecodedEventCatcher=wi.createEventCatcher(),this.thumbnailHover=new Tn({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 Dm({style:{height:this.style.scrollbarHeight}}),this.rightPanel.add(this.scrollbar.initCanvasNode()),this.playhead=new Bm({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 Fm({},this),[this.playhead,this.playheadHover].forEach(t=>{this.addToTimecodedSurfaceGroup(t.initCanvasNode())}),this.headerTimecodeDisplay=new Fh({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 zm({id:Hh,description:""},this.videoController),this.addLanes([this.scrubberLane]),this.stage}afterCanvasNodeInit(){this.videoController.onVideoLoading$.pipe(ze(e=>!!e),k(this.onDestroy$)).subscribe(e=>{this.clearContent()}),this.videoController.onVideoLoaded$.pipe(ze(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 i=e.evt;i.preventDefault();let s=i.deltaY>0?"IN":"OUT";i.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({...$.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=>{ot.cursor("grabbing")}),this.timecodedGroup.on("dragend",e=>{ot.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,i=this.timelinePositionToTime(t);if(this.thumbnailVttFile){let s=this.thumbnailVttFile.findCue(i);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(i=>i.getDimension().height).reduce((i,s)=>i+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 Tt.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(),i=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>i.width?i.width-s.width-a:n;let l=this.scrubberLane.getRect();return{x:n,y:l.y+l.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 j(this.getTimecodedContainerDimension().width-this.getTimecodedGroupDimension().width).abs();return new j(this.getTimecodedGroupPosition().x).abs().mul(100).div(e).toNumber()}}setHorizontalScrollPercent(e){this.setTimelinePosition(this.calculateTimelineXFromScrollPercent(e))}getScrollHandleHorizontalMeasurement(e){let t=this.getTimecodedGroupDimension().width,i=this.getTimecodedGroupPosition().x,s;return t<=e?s={width:e,x:0}:s={width:new j(e).mul(e).div(t).round().toNumber(),x:new j(i).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 ie(t=>{let i=this.getTimecodedGroupPosition().x;kn({layer:this.timecodedGroup.getLayer(),duration:$.TIMELINE_SCROLL_EASED_DURATION_MS,from:i,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,i=this.isInVisiblePositionRange(e);this.scrollWithPlayhead=i&&!t}syncTimelineWithPlayhead(){return new ie(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(),i=this.getTimecodedContainerDimension();if(t.width>i.width){let s=new j(i.width-t.width);return new j(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 j(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 ie(e=>{this.zoomStep("IN",this.timecodedGroup.getRelativePointerPosition().x),e.next(this.getZoomPercent()),e.complete()})}zoomOut(){return new ie(e=>{this.zoomStep("OUT",this.timecodedGroup.getRelativePointerPosition().x),e.next(this.getZoomPercent()),e.complete()})}zoomToEased(e){return new ie(t=>{e=this.getConstrainedZoomPercent(e);let i=this.getTimecodedGroupDimension().width,s=this.calculateWidthFromZoomRatioPercent(e);kn({layer:this.timecodedGroup.getLayer(),duration:$.TIMELINE_ZOOM_EASED_DURATION_MS,from:i,to:s,onUpdateHandler:(n,a)=>{this.zoomByWidth(a,this.resolveZoomFocus())},onCompleteHandler:(n,a)=>{t.next(this.getZoomPercent()),t.complete()}})})}zoomStep(e,t){let i=new j(this.getTimecodedGroupDimension().width),s=(e==="IN"?i.mul(this.zoomScale):i.div(this.zoomScale)).round().toNumber();this.zoomByWidth(s,t)}zoomByPercent(e,t=!0){e=this.getConstrainedZoomPercent(e);let i=this.calculateWidthFromZoomRatioPercent(e);return this.zoomByWidth(i,this.resolveZoomFocus(),t),this.getZoomPercent()}zoomByWidth(e,t,i=!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(l=>{l.width(e)}),(this.getTimecodedGroupDimension().width!==n||this.getTimecodedGroupPosition().x!==s)&&(i?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 i=this.getTimecodedGroupPosition().x,s=this.getTimecodedGroupDimension().width,n=this.getTimecodedContainerRect(),a=e>s?"IN":"OUT",o=i;if(e===n.width)o=0;else if(e>n.width){if(t>0){let l=new j(t).div(s);if(l.greaterThanOrEqualTo(0)&&l.lessThanOrEqualTo(1)){let h=e-s,d=l.mul(h).abs().round().toNumber(),u=i+d*(a==="IN"?-1:1);o=u<0?u:0}}if(e>n.width){let l=n.x+n.width;o+e<=l&&(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 j(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 i=this.resolvePlayheadSyncPosition();e>i-this.playheadHoverSnapArea&&e<i+this.playheadHoverSnapArea&&(e=i,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 B}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,i={...$.POSITION_TOP_LEFT};t||(i.y=this.timelineLanes.map(s=>s.getRect().height).reduce((s,n)=>s+n,0)),e.setTimeline(this),e.setVideoController(this.videoController),e.setTimelinePosition(i),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 i={...$.POSITION_TOP_LEFT};this.timelineLanes.forEach(s=>{s.setTimelinePosition({...i}),i.y=i.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(Hh)}getMarkerLane(e){let t=this.getLane(e);return t instanceof rn?t:void 0}getThumbnailLane(e){let t=this.getLane(e);return t instanceof Cn?t:void 0}getSubtitlesLane(e){let t=this.getLane(e);return t instanceof Sn?t:void 0}getAudioTrackLane(e){let t=this.getLane(e);return t instanceof Gh?t:void 0}createMarkerLane(e){let t=new rn(e);return this.addLane(t),t}createThumbnailLane(e){let t=new Cn(e);return this.addLane(t),t}createSubtitlesLane(e){let t=new Sn(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 j(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 j(e).mul(this.getTimecodedGroupDimension().width).div(this.videoController.getDuration()).toNumber()}getConstrainedTimelineX(e){let t=this.getTimecodedGroupDimension(),i=this.getTimecodedContainerDimension();if(t.width<=i.width)return 0;{let s=i.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),i=this.timelinePositionToTime(e.end);return{start:t,end:i}}getZoomBaseline(){return this.zoomBaseline}getZoomMax(){return this.zoomMax}fetchThumbnailVttFile(){return this.thumbnailVttUrl?ds.create(this.thumbnailVttUrl,this.axiosConfig).pipe(ke(e=>(this.thumbnailVttFile=e,e)),di((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,Zs(this.videoEventBreaker$);let e=[this.onScroll$,this.onZoom$];Xt(...e),ci(...e),[this.scrollbar,this.playheadHover,this.playhead,...this.timelineLanes,this.thumbnailHover,this.headerTimecodeDisplay].forEach(i=>{i&&i.destroy()}),super.destroy()}}class xn{static timeToFrame(e,t){return t.mul(e).floor().toNumber()}static frameToTime(e,t){return new j(e).dividedBy(t).toNumber()}}class Ci{constructor(){this.resolveUserAgent()}static instance(){return Ci._instance||(Ci._instance=new Ci),Ci._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 je=class je{static formatVideoTimestamp(e,t){if(e<=0)return je.VIDEO_ZERO_TIMESTAMP;const i=Math.floor(e/3600),s=Math.floor(e%3600/60),n=Math.floor(e%60);let a=new j(xn.timeToFrame(e,t)).mod(t).toNumber();return`${je.padZero(i)}:${je.padZero(s)}:${je.padZero(n)}:${je.padZero(a)}`}static padZero(e,t=2){return e.toString().padStart(t,"0")}};je.VIDEO_ZERO_TIMESTAMP=`${je.padZero(0)}:${je.padZero(0)}:${je.padZero(0)}:${je.padZero(0)}`;let us=je;class Zm{constructor(){this._state={playing:!1,paused:!0,waiting:!1,seeking:!1,buffering:!1,ended:!1},this.onChange$=new li(this._state)}updateState(e){let t={...this._state,...e},i=this.compare(this._state,t)===0;this._state=t,i||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 Bh(r){let e;return typeof r=="string"?e=r:r instanceof st?(console.log(r),e=r.errors.map(t=>t.message).join(". ")):r instanceof Error?e=r.message:e="Unexpected error",e}function jm(r){return{errorMap:(e,t)=>({message:r})}}const Ze={PAUSE:"pause",WAITING:"waiting",PLAYING:"playing",TIMEUPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",LOADEDDATA:"loadeddata",LOADEDMETEDATA:"loadedmetadata",ENDED:"ended",PROGRESS:"progress"};class Xm{constructor(e,t){if(this.browserProvider=Ci.instance(),this.helpMenuGroups=[],this._isVideoLoaded=!1,this.frameDurationSpillOverCorrection=.001,this.syncLoopMaxIterations=20,this.seekInProgress=!1,this.videoStalledCheckIntervalMs=700,this.videoFrameCallback$=new li(null),this.videoEventBreaker$=new B,this.onDestroy$=new B,this.seekBreaker$=new B,this.onVideoLoaded$=new li(void 0),this.onVideoLoading$=new B,this.onPlay$=new B,this.onPause$=new B,this.onVideoTimeChange$=new B,this.onSeeking$=new B,this.onSeeked$=new B,this.onBuffering$=new B,this.onEnded$=new B,this.onAudioSwitched$=new B,this.onPlaybackState$=new B,this.onHelpMenuChange$=new li(void 0),this.onVideoError$=new B,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(i=>{i&&(this.seekInProgress||(this.isPlaying()?this.videoTimeChangeHandlerExecutor():this.isPaused()))})}loadVideo(e,t,i){try{return e=yi.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,i).pipe(ke(s=>{this.video=s,this.frameRateDecimal=new j(this.video.frameRate),this.syncStepCurrentTimeMediaTime=0,this.playbackStateMachine=new Zm,this.initEventHandlers(),this.startVideoFrameCallback(),this._isVideoLoaded=!0,this.onVideoLoaded$.next({video:this.video});let n=Number.parseFloat(this.getDuration().toFixed(3));return Number.isInteger(Number.parseFloat((this.getDuration()*this.video.frameRate).toFixed(1)))&&(n=Number.parseFloat((n-this.frameDurationSpillOverCorrection).toFixed(3)),this.video.setCorrectedDuration(n)),this.getHls().on(Le.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}),di((s,n)=>{let a=Bh(s);return this.onVideoError$.next({type:"VIDEO_LOAD_ERROR",message:a}),io(()=>new Error(a))}))}catch(s){let n=Bh(s);return this.onVideoError$.next({type:"VIDEO_LOAD_ERROR",message:n}),io(()=>new Error(n))}}initEventHandlers(){be(this.videoElement,Ze.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,Ze.WAITING).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.waiting=!0}),be(this.videoElement,Ze.PLAYING).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setPlaying(),this.videoStalledCheckLastCurrentTime=void 0}),be(this.videoElement,Ze.PAUSE).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.playbackStateMachine.setPaused(),this.videoStalledCheckLastCurrentTime=void 0}),be(this.videoElement,Ze.PROGRESS).pipe(k(this.videoEventBreaker$)).subscribe(e=>{this.onBuffering$.next({bufferedTimespans:this.getBufferedTimespans()})}),be(this.videoElement,Ze.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}),Ku(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 i=this.videoStalledCheckIntervalMs*.8/1e3*this.getPlaybackRate(),s=this.videoStalledCheckLastCurrentTime+i,n=t<s;this.playbackStateMachine.waiting=n,this.videoStalledCheckLastCurrentTime=t}})}getBufferedTimespans(){if(!this.isVideoLoaded())return[];let e=[],t=this.videoElement.buffered;for(let i=0;i<t.length;i++)e.push({start:t.start(i),end:t.end(i)});return e}startVideoFrameCallback(){let e=()=>{this.videoElement?this.videoFrameCallbackHandle=this.videoElement.requestVideoFrameCallback((i,s)=>{t({now:i,metadata:s})}):console.debug("Cannot call requestVideoFrameCallback, videoElement not found")},t=i=>{this.videoFrameCallback$.next(i),e()};e()}detachVideoEventListeners(){$e(this.videoEventBreaker$),this.videoEventBreaker$=new B,this.videoElement&&this.videoFrameCallbackHandle&&this.videoElement.cancelVideoFrameCallback(this.videoFrameCallbackHandle)}syncVideoFrames(e){return console.debug("syncFrames - START",e),new ie(t=>{let i=new li(!1),s=new B,n=this.syncLoopMaxIterations;this.seekBreaker$.pipe(k(s)).subscribe(()=>{console.debug("%csyncFrames - seek breaker triggered","color: gray"),i.next(!0),a()});let a=()=>{$e(s),t.next(!0),t.complete(),console.debug("%csyncFrames - END","color: gray")},o=l=>{i.pipe(We(1)).subscribe(h=>{h?console.debug("%csyncFrames - seek skipped, breaker already triggered","color: gray"):this._seekTimeFireAndForget(l)})};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 l=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},h,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(l(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(h||(h=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(j.add(p,w).toNumber())}else{console.debug(`%csyncFrames - CORRECTION SEEK TO FRAME; syncConditions.seekToFrame[${e.seekToFrame}] !== currentTimeFrame[${f}] | seekToFrameTimeBaseline=${h}`,"color: red");let _=Math.abs(e.seekToFrame-f),w=_*this.video.frameDuration,T=(e.seekToFrame>=f?j.add(h,w):j.sub(h,w)).toNumber();h=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(j.add(p,this.syncStepCurrentTimeMediaTime).toNumber()):o(m+this.syncStepCurrentTimeMediaTime));console.debug("syncFrames.syncLoop - END")};this.videoFrameCallback$.pipe(tc((e.seekToFrame,0)),k(s)).subscribe(u=>{console.debug("syncFrames.syncLoop - videoFrameCallback$ trigger",u),d(u)})}})}seekTimeAndSync(e,t={}){return new ie(i=>{this.seekInProgress&&($e(this.seekBreaker$),this.seekBreaker$=new B),this.seekInProgress=!0,isNaN(e)||(e=e<0?0:e>this.getDuration()?this.getDuration():e,be(this.videoElement,Ze.SEEKING).pipe(k(this.seekBreaker$),We(1)).subscribe(s=>{this.onSeeking$.next({newTime:e,currentTime:this.getCurrentTime()})}),be(this.videoElement,Ze.SEEKED).pipe(k(this.seekBreaker$),We(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,i.next(!0),i.complete(),this.videoTimeChangeHandlerExecutor()};this.getCurrentTime()>this.getCorrectedDuration()?this.seekTimeWithoutSync(this.getCorrectedDuration()).pipe(k(this.seekBreaker$),We(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 ie(t=>{this.seekInProgress&&($e(this.seekBreaker$),this.seekBreaker$=new B),this.seekInProgress=!0,isNaN(e)||(e=e<0?0:e>this.getDuration()?this.getDuration():e,be(this.videoElement,Ze.SEEKING).pipe(k(this.seekBreaker$),We(1)).subscribe(i=>{this.onSeeking$.next({newTime:e,currentTime:this.getCurrentTime()})}),be(this.videoElement,Ze.SEEKED).pipe(k(this.seekBreaker$),We(1)).subscribe(i=>{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 i=e===t?"NONE":e>t?"FORWARD":"BACKWARD",s=j.sub(t,e).abs();console.debug(`Seeking from currentTime[${t}] to newTime[${e}], direction: ${i} ${s.toNumber()}`),this.setCurrentTime(e)}}_seekTimeAndSyncNoEmitEvents(e){return this.isPlaying()?Se(!1):new ie(t=>{isNaN(e)||(e=e<0?0:e>this.getDuration()?this.getDuration():e,be(this.videoElement,Ze.SEEKED).pipe(ui()).subscribe(i=>{this.syncVideoFrames({}).subscribe(s=>{t.next(!0),t.complete(),this.videoTimeChangeHandlerExecutor()})}),console.debug(`Seeking ${e}`),this.setCurrentTime(e))})}seekFromCurrentTimeAndSync(e,t={}){let i=this.getCurrentTime();t.currentTime&&(i=t.currentTime);let s=j.add(i,e).toNumber(),n;t.seekDirection?n=t.seekDirection:n=s===i?"NONE":s>i?"FORWARD":"BACKWARD";let a=j.sub(i,s).abs().toNumber();return console.debug(`Seeking from currentTime ${i} 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 j(this.frameDurationSpillOverCorrection).toNumber(),i=this.calculateTimeToFrame(t);return i!==e&&e!=this.getCorrectedDuration()*this.getFrameRate()?(console.error(`Frame numbers don't match. Wanted: ${e}, calculated: ${i}`),Se(!1)):this.seekTimeAndSync(t,{seekToFrame:e,seekToTimestamp:t,currentTime:this.getCurrentTime()}).pipe(ke(s=>s))}}}_seekFromCurrentFrame(e){let t=this.getCurrentFrame(),i=t+e;if(console.debug(`seekFromCurrentFrame - Current frame: ${t}, wanted frame: ${i}`),t!==i){if(i<=0)return this._seekToFrame(0);if(i>=this.getTotalFrames()||i>=this.getCorrectedDuration()*this.getFrameRate()&&!this.playbackStateMachine.state.ended)return this._seekToFrame(this.getCorrectedDuration()*this.getFrameRate());if(i>=this.getTotalFrames()||i>=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:i,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 xn.timeToFrame(e,this.getFrameRateDecimal())}calculateFrameToTime(e){return xn.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),us.formatVideoTimestamp(e,this.getFrameRateDecimal())):us.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(){Zs(this.videoEventBreaker$,this.seekBreaker$),Xt(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$];Xt(...e),ci(...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 qm{constructor(e,t,i,s){this._element=e,this._sourceUrl=t,this._frameRate=i,this._duration=s,this._totalFrames=new j(this._duration).mul(this._frameRate).ceil().toNumber(),this._frameDuration=new j(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 Ym extends Xm{constructor(e,t){super(e,t),Le.isSupported()?console.debug("video load with hls.js"):console.error("hls is not supported through MediaSource extensions");let i={...Le.DefaultConfig,enableWorker:!1};this.hls=new Le(i)}videoLoad(e,t,i){return new ie(s=>{this.hls.on(Le.Events.ERROR,function(l,h){h.type;let d=h.details;h.fatal,d.includes("audioTrackLoadError")||(s.error(`Error loading video. Hls error details: ${d}`),s.complete())});let n=new ie(l=>{this.hls.once(Le.Events.MEDIA_ATTACHED,function(h,d){console.debug("video element and hls.js are now bound together"),l.next(!0),l.complete()})}),a=new ie(l=>{this.hls.once(Le.Events.MANIFEST_PARSED,function(h,d){console.debug("manifest loaded, found "+d.levels.length+" quality level"),l.next(!0),l.complete()})}),o=be(this.videoElement,Ze.LOADEDDATA).pipe(ui());Wu([n,a,o]).pipe(ui()).subscribe(l=>{i=i&&_e.coerce.number().parse(i),i=i||this.videoElement.duration;let h=new qm(this.videoElement,e,t,i);s.next(h),s.complete()}),this.hls.loadSource(e),this.hls.attachMedia(this.videoElement)})}initEventHandlers(){super.initEventHandlers(),this.hls.on(Le.Events.ERROR,function(e,t){t.type,t.details,t.fatal,console.error(e,t),t.details===Le.ErrorDetails.BUFFER_STALLED_ERROR||t.details===Le.ErrorDetails.BUFFER_APPEND_ERROR||(t.details,Le.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 i=this.hls.audioTrack;i>=0&&t!==i&&this.onAudioSwitched$.next({audioTrack:this.getCurrentAudioTrack()})}getHls(){return this.hls}}class Km{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 Jm extends Km{constructor(e){super(e)}}class Pn{constructor(e){this.subtitlesTracks=new Map,this.onCreate$=new B,this.onRemove$=new B,this.onShow$=new B,this.onHide$=new B,this.videoController=e,this.videoController.onVideoLoaded$.pipe(ze(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(i=>{i.getAttribute("id")===e.id&&i.parentElement.removeChild(i)}),!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 ie(t=>{let i=new Jm({...e});this.subtitlesTracks.has(i.id)&&this.removeTrack(i.id),i.element=Pn.createHTMLTrackElement(i),be(i.element,"load").pipe(ui()).subscribe(n=>{this.subtitlesTracks.set(i.id,i),t.next(i),t.complete(),this.onCreate$.next({textTrack:i})}),this.videoController.getHTMLVideoElement().appendChild(i.element);let s=this.getDomTextTrack(i);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 i=this.getDomTextTrack(t);if(i){for(let s=0;s<this.videoController.getHTMLVideoElement().textTracks.length;s++){let n=this.videoController.getHTMLVideoElement().textTracks[s];n.mode="hidden"}i.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 i=this.getDomTextTrack(t);i&&(i.mode="hidden",t.hidden=!0,this.onHide$.next({}))}}destroy(){this.removeAllTracks();let e=[this.onCreate$,this.onRemove$,this.onShow$,this.onHide$];Xt(...e),ci(...e),this.currentTrack=void 0,this.videoController=void 0}}var $h={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(l,h,d){this.fn=l,this.context=h,this.once=d||!1}function n(l,h,d,u,c){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new s(d,u||l,c),f=t?t+h:h;return l._events[f]?l._events[f].fn?l._events[f]=[l._events[f],p]:l._events[f].push(p):(l._events[f]=p,l._eventsCount++),l}function a(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var h=[],d,u;if(this._eventsCount===0)return h;for(u in d=this._events)e.call(d,u)&&h.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(d)):h},o.prototype.listeners=function(h){var d=t?t+h:h,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(h){var d=t?t+h:h,u=this._events[d];return u?u.fn?1:u.length:0},o.prototype.emit=function(h,d,u,c,p,f){var m=t?t+h:h;if(!this._events[m])return!1;var g=this._events[m],_=arguments.length,w,b;if(g.fn){switch(g.once&&this.removeListener(h,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(h,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(h,d,u){return n(this,h,d,u,!1)},o.prototype.once=function(h,d,u){return n(this,h,d,u,!0)},o.prototype.removeListener=function(h,d,u,c){var p=t?t+h:h;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(h){var d;return h?(d=t?t+h:h,this._events[d]&&a(this,d)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,r.exports=o})($h);var Qm=$h.exports;const eg=Eh(Qm),tg={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 ig{constructor(e){this.onAudioSwitched$=new B,this.videoController=e}getAudioTracks(){return this.videoController.getAudioTracks()}getCurrentAudioTrack(){return this.videoController.getCurrentAudioTrack()}setAudioTrack(e){let t=this.getCurrentAudioTrack();this.videoController.setAudioTrack(e);let i=this.getCurrentAudioTrack();t!==i&&this.onAudioSwitched$.next({audioTrack:i})}destroy(){}}class hr{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 i=e??document.documentElement,s=i.requestFullscreen||i.webkitRequestFullscreen||i.webkitRequestFullScreen||i.mozRequestFullScreen||i.msRequestFullscreen;if(!s)throw new Error("Unsupported");return s.call(i,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 ge={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 rg{constructor(e){this._playerHTMLElementId=e,this.divPlayer=this.getElementById(this._playerHTMLElementId),this.createDom()}createDom(){this.divPlayer.classList.add(`${ge.player}`),this.divPlayer.innerHTML=`<div class="${ge.playerWrapper}">
48
48
  <video class="${ge.video}"></video>
49
49
 
50
50
  <div class="${ge.help} d-none">
@@ -67,9 +67,9 @@ ${Lh(r)}`)}),e.join(`
67
67
 
68
68
  <div class="${ge.errorMessage} d-none">
69
69
  </div>
70
- </div>`,this._videoElement=this.getPlayerElement(ge.video),this.divPlayerWrapper=this.getPlayerElement(ge.playerWrapper),this.divButtonPlay=this.getPlayerElement(ge.buttonPlay),this.divButtonPause=this.getPlayerElement(ge.buttonPause),this.divButtonLoading=this.getPlayerElement(ge.buttonLoading),this.divButtonError=this.getPlayerElement(ge.buttonError),this.divButtonReplay=this.getPlayerElement(ge.buttonReplay),this.divButtonHelp=this.getPlayerElement(ge.buttonHelp),this.divHelp=this.getPlayerElement(ge.help),this.divHelpMenu=this.getPlayerElement(ge.helpMenu),this.divErrorMessage=this.getPlayerElement(ge.errorMessage)}getElementById(e){return document.getElementById(e)}getPlayerElement(e){return this.getPlayerElements(e)[0]}getPlayerElements(e){return Array.from(this.getElementById(this._playerHTMLElementId).querySelectorAll(`.${e}`))}showElements(...e){return e.forEach(t=>{t.classList.remove("d-none"),t.classList.add("d-block")}),this}isShown(e){return e.classList.contains("d-block")}hideElements(...e){return e.forEach(t=>{t.classList.remove("d-block"),t.classList.add("d-none")}),this}helpChangeHandler(){this._videoController.getHelpMenuGroups().length>0?(this.showElements(this.divHelp),this.divHelpMenu.innerHTML=this._videoController.getHelpMenuGroups().map(t=>{let r=`${t.items.map(s=>`<div class="omakase-help-item"><span class="float-start">${s.name}</span><span class="float-end">${s.description}</span></div>`).join("")}`;return`<div class="omakase-help-group">
70
+ </div>`,this._videoElement=this.getPlayerElement(ge.video),this.divPlayerWrapper=this.getPlayerElement(ge.playerWrapper),this.divButtonPlay=this.getPlayerElement(ge.buttonPlay),this.divButtonPause=this.getPlayerElement(ge.buttonPause),this.divButtonLoading=this.getPlayerElement(ge.buttonLoading),this.divButtonError=this.getPlayerElement(ge.buttonError),this.divButtonReplay=this.getPlayerElement(ge.buttonReplay),this.divButtonHelp=this.getPlayerElement(ge.buttonHelp),this.divHelp=this.getPlayerElement(ge.help),this.divHelpMenu=this.getPlayerElement(ge.helpMenu),this.divErrorMessage=this.getPlayerElement(ge.errorMessage)}getElementById(e){return document.getElementById(e)}getPlayerElement(e){return this.getPlayerElements(e)[0]}getPlayerElements(e){return Array.from(this.getElementById(this._playerHTMLElementId).querySelectorAll(`.${e}`))}showElements(...e){return e.forEach(t=>{t.classList.remove("d-none"),t.classList.add("d-block")}),this}isShown(e){return e.classList.contains("d-block")}hideElements(...e){return e.forEach(t=>{t.classList.remove("d-block"),t.classList.add("d-none")}),this}helpChangeHandler(){this._videoController.getHelpMenuGroups().length>0?(this.showElements(this.divHelp),this.divHelpMenu.innerHTML=this._videoController.getHelpMenuGroups().map(t=>{let i=`${t.items.map(s=>`<div class="omakase-help-item"><span class="float-start">${s.name}</span><span class="float-end">${s.description}</span></div>`).join("")}`;return`<div class="omakase-help-group">
71
71
  <span class="omakase-help-group-title">${t.name}</span>
72
- ${r}
72
+ ${i}
73
73
  </div>
74
- `}).join("")):this.hideElements(this.divHelp)}isFullscreen(){return or.isFullscreenEnabled()?or.isFullscreen():!1}toggleFullscreen(e){try{or.isFullscreenEnabled()&&(this.isFullscreen()?or.exitFullscreen().then(()=>{}):or.requestFullscreen(e).then(()=>{}))}catch(t){console.trace(t)}}set videoController(e){this._videoController=e,$e(this.videoEventBreaker$),this.videoEventBreaker$=new $;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(){Us(this.videoEventBreaker$),this.divPlayer&&this.divPlayer.replaceChildren(),this._videoController=null,this._videoElement=null,this._timeline=null,this._timelineElement=null}}const cg="",An={fontFamily:"Arial"},Bh={playerHTMLElementId:"omakase-player",crossorigin:"anonymous",style:{...An}};class eg{constructor(e){this.stylesProvider=bt.instance(),this.eventEmitter=new ds,this.onDestroy$=new $,this.config={...Bh,...e,style:{...Bh.style,...e.style}},this.styleAdapter=new co({...An,...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 Qm(this.playerHTMLElementId),this.videoController=new jm(this.domController,this.config.crossorigin),this.audioController=new Jm(this.videoController),this.subtitlesController=new Pn(this.videoController),this.domController.videoController=this.videoController,this.bindEventHandlers()}loadVideo(e,t,r){return new ie(s=>{this.videoController.loadVideo(e,t,r).pipe(di()).subscribe({next:n=>{s.next(n),s.complete()},error:n=>{s.error(n),s.complete()}})})}createTimeline(e){return new ie(t=>{let r=()=>{console.debug("Creating timeline"),this._timeline=new Vm(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(ze(s=>!!s),di()).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$),ze(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 Km}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$)}}Ie.AudioTrackLane=Dh,Ie.MarkerLane=tn,Ie.MomentMarker=jo,Ie.OMAKASE_PLAYER_STYLE_DEFAULT=An,Ie.OmakasePlayer=eg,Ie.PeriodMarker=Wo,Ie.SubtitlesLane=wn,Ie.ThumbnailLane=Tn,Object.defineProperty(Ie,Symbol.toStringTag,{value:"Module"})});
74
+ `}).join("")):this.hideElements(this.divHelp)}isFullscreen(){return hr.isFullscreenEnabled()?hr.isFullscreen():!1}toggleFullscreen(e){try{hr.isFullscreenEnabled()&&(this.isFullscreen()?hr.exitFullscreen().then(()=>{}):hr.requestFullscreen(e).then(()=>{}))}catch(t){console.trace(t)}}set videoController(e){this._videoController=e,$e(this.videoEventBreaker$),this.videoEventBreaker$=new B;let t=[this.divButtonPlay,this.divButtonPause,this.divButtonLoading,this.divButtonReplay,this.divButtonError],i=()=>{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;i(),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=>{i(),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(){Zs(this.videoEventBreaker$),this.divPlayer&&this.divPlayer.replaceChildren(),this._videoController=null,this._videoElement=null,this._timeline=null,this._timelineElement=null}}const mg="",An={fontFamily:"Arial"},Vh={playerHTMLElementId:"omakase-player",crossorigin:"anonymous",style:{...An}};class sg{constructor(e){this.stylesProvider=bt.instance(),this.eventEmitter=new eg,this.onDestroy$=new B,this.config={...Vh,...e,style:{...Vh.style,...e.style}},this.styleAdapter=new co({...An,...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 rg(this.playerHTMLElementId),this.videoController=new Ym(this.domController,this.config.crossorigin),this.audioController=new ig(this.videoController),this.subtitlesController=new Pn(this.videoController),this.domController.videoController=this.videoController,this.bindEventHandlers()}loadVideo(e,t,i){return new ie(s=>{this.videoController.loadVideo(e,t,i).pipe(ui()).subscribe({next:n=>{s.next(n),s.complete()},error:n=>{s.error(n),s.complete()}})})}createTimeline(e){return new ie(t=>{let i=()=>{console.debug("Creating timeline"),this._timeline=new Um(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"),i(),t.next(this._timeline),t.complete()):(console.debug("Waiting video to load.."),this.videoController.onVideoLoaded$.pipe(ze(s=>!!s),ui()).subscribe(s=>{console.debug("Video just loaded"),i(),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$),ze(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 tg}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$)}}Ie.AudioTrackLane=Gh,Ie.MarkerLane=rn,Ie.MomentMarker=jo,Ie.OMAKASE_PLAYER_STYLE_DEFAULT=An,Ie.OmakasePlayer=sg,Ie.PeriodMarker=Wo,Ie.SubtitlesLane=Sn,Ie.ThumbnailLane=Cn,Object.defineProperty(Ie,Symbol.toStringTag,{value:"Module"})});
75
75
  //# sourceMappingURL=omakase-player.umd.js.map