From 9ef407a191d20b24f605fe1935227db9f41e9d45 Mon Sep 17 00:00:00 2001 From: tillvit Date: Mon, 1 Jan 2024 03:34:39 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tillvit/?= =?UTF-8?q?smeditor@ccffc5f13692b788f2039fdd50f97ec3c6fd811d=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...er-b5a8bd39.js => ChartManager-bba9ffde.js | 52 +++++++++--------- ...b249bb9f.js => NodeFileHandler-32fac6e8.js | 2 +- app.js | 2 +- app/index.html | 2 +- assets/analyze-576bdc06.mp4 | Bin 3326754 -> 0 bytes assets/analyze-738fe825.mp4 | Bin 0 -> 1682720 bytes ...ader-f4f83111.js => downloader-a9f86f42.js | 2 +- embed.js | 2 +- embed/index.html | 2 +- index.html | 2 +- memory-ba8edfa0.js => memory-e7c5df82.js | 2 +- sw.js | 2 +- workbox-6db16f92.js | 1 + workbox-fa446783.js | 1 - 14 files changed, 36 insertions(+), 36 deletions(-) rename ChartManager-b5a8bd39.js => ChartManager-bba9ffde.js (93%) rename NodeFileHandler-b249bb9f.js => NodeFileHandler-32fac6e8.js (99%) delete mode 100644 assets/analyze-576bdc06.mp4 create mode 100644 assets/analyze-738fe825.mp4 rename downloader-f4f83111.js => downloader-a9f86f42.js (97%) rename memory-ba8edfa0.js => memory-e7c5df82.js (98%) create mode 100644 workbox-6db16f92.js delete mode 100644 workbox-fa446783.js diff --git a/ChartManager-b5a8bd39.js b/ChartManager-bba9ffde.js similarity index 93% rename from ChartManager-b5a8bd39.js rename to ChartManager-bba9ffde.js index fa1aba83..9127443d 100644 --- a/ChartManager-b5a8bd39.js +++ b/ChartManager-bba9ffde.js @@ -1,15 +1,15 @@ -var Og=Object.defineProperty;var Fg=(r,e,t)=>e in r?Og(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Ms=(r,e,t)=>(Fg(r,typeof e!="symbol"?e+"":e,t),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const n of s)if(n.type==="childList")for(const a of n.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const n={};return s.integrity&&(n.integrity=s.integrity),s.referrerPolicy&&(n.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?n.credentials="include":s.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(s){if(s.ep)return;s.ep=!0;const n=t(s);fetch(s.href,n)}})();var _s=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(_s||{}),Jp=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Jp||{}),_h=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(_h||{}),Ee=(r=>(r[r.NORMAL=0]="NORMAL",r[r.ADD=1]="ADD",r[r.MULTIPLY=2]="MULTIPLY",r[r.SCREEN=3]="SCREEN",r[r.OVERLAY=4]="OVERLAY",r[r.DARKEN=5]="DARKEN",r[r.LIGHTEN=6]="LIGHTEN",r[r.COLOR_DODGE=7]="COLOR_DODGE",r[r.COLOR_BURN=8]="COLOR_BURN",r[r.HARD_LIGHT=9]="HARD_LIGHT",r[r.SOFT_LIGHT=10]="SOFT_LIGHT",r[r.DIFFERENCE=11]="DIFFERENCE",r[r.EXCLUSION=12]="EXCLUSION",r[r.HUE=13]="HUE",r[r.SATURATION=14]="SATURATION",r[r.COLOR=15]="COLOR",r[r.LUMINOSITY=16]="LUMINOSITY",r[r.NORMAL_NPM=17]="NORMAL_NPM",r[r.ADD_NPM=18]="ADD_NPM",r[r.SCREEN_NPM=19]="SCREEN_NPM",r[r.NONE=20]="NONE",r[r.SRC_OVER=0]="SRC_OVER",r[r.SRC_IN=21]="SRC_IN",r[r.SRC_OUT=22]="SRC_OUT",r[r.SRC_ATOP=23]="SRC_ATOP",r[r.DST_OVER=24]="DST_OVER",r[r.DST_IN=25]="DST_IN",r[r.DST_OUT=26]="DST_OUT",r[r.DST_ATOP=27]="DST_ATOP",r[r.ERASE=26]="ERASE",r[r.SUBTRACT=28]="SUBTRACT",r[r.XOR=29]="XOR",r))(Ee||{}),Ni=(r=>(r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r))(Ni||{}),re=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(re||{}),$s=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))($s||{}),we=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(we||{}),ce=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(ce||{}),er=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(er||{}),Pr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Pr||{}),Xt=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(Xt||{}),Lt=(r=>(r[r.NPM=0]="NPM",r[r.UNPACK=1]="UNPACK",r[r.PMA=2]="PMA",r[r.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",r[r.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",r[r.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",r))(Lt||{}),Li=(r=>(r[r.NO=0]="NO",r[r.YES=1]="YES",r[r.AUTO=2]="AUTO",r[r.BLEND=0]="BLEND",r[r.CLEAR=1]="CLEAR",r[r.BLIT=2]="BLIT",r))(Li||{}),Pc=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(Pc||{}),ai=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(ai||{}),pt=(r=>(r[r.NONE=0]="NONE",r[r.SCISSOR=1]="SCISSOR",r[r.STENCIL=2]="STENCIL",r[r.SPRITE=3]="SPRITE",r[r.COLOR=4]="COLOR",r))(pt||{}),ut=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(ut||{}),Gi=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Gi||{});const Ng={createCanvas:(r,e)=>{const t=document.createElement("canvas");return t.width=r,t.height=e,t},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,e)=>fetch(r,e),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")},de={ADAPTER:Ng,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Al=/iPhone/i,wd=/iPod/i,xd=/iPad/i,_d=/\biOS-universal(?:.+)Mac\b/i,wl=/\bAndroid(?:.+)Mobile\b/i,Ed=/Android/i,Is=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Aa=/Silk/i,Xi=/Windows Phone/i,Td=/\bWindows(?:.+)ARM\b/i,Sd=/BlackBerry/i,Cd=/BB10/i,Md=/Opera Mini/i,Id=/\b(CriOS|Chrome)(?:.+)Mobile/i,kd=/Mobile(?:.+)Firefox\b/i,Bd=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function Ug(r){return function(e){return e.test(r)}}function Pd(r){var e={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?e.userAgent=r:r&&r.userAgent&&(e={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var s=Ug(t),n={apple:{phone:s(Al)&&!s(Xi),ipod:s(wd),tablet:!s(Al)&&(s(xd)||Bd(e))&&!s(Xi),universal:s(_d),device:(s(Al)||s(wd)||s(xd)||s(_d)||Bd(e))&&!s(Xi)},amazon:{phone:s(Is),tablet:!s(Is)&&s(Aa),device:s(Is)||s(Aa)},android:{phone:!s(Xi)&&s(Is)||!s(Xi)&&s(wl),tablet:!s(Xi)&&!s(Is)&&!s(wl)&&(s(Aa)||s(Ed)),device:!s(Xi)&&(s(Is)||s(Aa)||s(wl)||s(Ed))||s(/\bokhttp\b/i)},windows:{phone:s(Xi),tablet:s(Td),device:s(Xi)||s(Td)},other:{blackberry:s(Sd),blackberry10:s(Cd),opera:s(Md),firefox:s(kd),chrome:s(Id),device:s(Sd)||s(Cd)||s(Md)||s(kd)||s(Id)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const Gg=Pd.default??Pd,tr=Gg(globalThis.navigator);de.RETINA_PREFIX=/@([0-9\.]+)x/;de.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var si=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function da(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Hg(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),t}var Zp={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,c,u){this.fn=l,this.context=c,this.once=u||!1}function n(l,c,u,h,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var p=new s(u,h||l,d),f=t?t+c:c;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,c){--l._eventsCount===0?l._events=new i:delete l._events[c]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],u,h;if(this._eventsCount===0)return c;for(h in u=this._events)e.call(u,h)&&c.push(t?h.slice(1):h);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},o.prototype.listeners=function(c){var u=t?t+c:c,h=this._events[u];if(!h)return[];if(h.fn)return[h.fn];for(var d=0,p=h.length,f=new Array(p);d80*t){o=c=r[0],l=u=r[1];for(var f=t;fc&&(c=h),d>u&&(u=d);p=Math.max(c-o,u-l),p=p!==0?32767/p:0}return ta(n,a,t,o,l,p,0),a}function ef(r,e,t,i,s){var n,a;if(s===Sh(r,e,t,i)>0)for(n=e;n=e;n-=i)a=Rd(n,r[n],r[n+1],a);return a&&qo(a,a.next)&&(ra(a),a=a.next),a}function vs(r,e){if(!r)return r;e||(e=r);var t=r,i;do if(i=!1,!t.steiner&&(qo(t,t.next)||at(t.prev,t,t.next)===0)){if(ra(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function ta(r,e,t,i,s,n,a){if(r){!a&&n&&Jg(r,i,s,n);for(var o=r,l,c;r.prev!==r.next;){if(l=r.prev,c=r.next,n?zg(r,i,s,n):Vg(r)){e.push(l.i/t|0),e.push(r.i/t|0),e.push(c.i/t|0),ra(r),r=c.next,o=c.next;continue}if(r=c,r===o){a?a===1?(r=jg(vs(r),e,t),ta(r,e,t,i,s,n,2)):a===2&&Yg(r,e,t,i,s,n):ta(vs(r),e,t,i,s,n,1);break}}}}function Vg(r){var e=r.prev,t=r,i=r.next;if(at(e,t,i)>=0)return!1;for(var s=e.x,n=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=sn?s>a?s:a:n>a?n:a,p=o>l?o>c?o:c:l>c?l:c,f=i.next;f!==e;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Xs(s,o,n,l,a,c,f.x,f.y)&&at(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function zg(r,e,t,i){var s=r.prev,n=r,a=r.next;if(at(s,n,a)>=0)return!1;for(var o=s.x,l=n.x,c=a.x,u=s.y,h=n.y,d=a.y,p=ol?o>c?o:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,y=Eh(p,f,e,t,i),b=Eh(m,g,e,t,i),A=r.prevZ,v=r.nextZ;A&&A.z>=y&&v&&v.z<=b;){if(A.x>=p&&A.x<=m&&A.y>=f&&A.y<=g&&A!==s&&A!==a&&Xs(o,u,l,h,c,d,A.x,A.y)&&at(A.prev,A,A.next)>=0||(A=A.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==s&&v!==a&&Xs(o,u,l,h,c,d,v.x,v.y)&&at(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;A&&A.z>=y;){if(A.x>=p&&A.x<=m&&A.y>=f&&A.y<=g&&A!==s&&A!==a&&Xs(o,u,l,h,c,d,A.x,A.y)&&at(A.prev,A,A.next)>=0)return!1;A=A.prevZ}for(;v&&v.z<=b;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==s&&v!==a&&Xs(o,u,l,h,c,d,v.x,v.y)&&at(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function jg(r,e,t){var i=r;do{var s=i.prev,n=i.next.next;!qo(s,n)&&tf(s,i,i.next,n)&&ia(s,n)&&ia(n,s)&&(e.push(s.i/t|0),e.push(i.i/t|0),e.push(n.i/t|0),ra(i),ra(i.next),i=r=n),i=i.next}while(i!==r);return vs(i)}function Yg(r,e,t,i,s,n){var a=r;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&t0(a,o)){var l=rf(a,o);a=vs(a,a.next),l=vs(l,l.next),ta(a,e,t,i,s,n,0),ta(l,e,t,i,s,n,0);return}o=o.next}a=a.next}while(a!==r)}function Xg(r,e,t,i){var s=[],n,a,o,l,c;for(n=0,a=e.length;n=t.next.y&&t.next.y!==t.y){var o=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(o<=i&&o>n&&(n=o,a=t.x=t.x&&t.x>=c&&i!==t.x&&Xs(sa.x||t.x===a.x&&$g(a,t)))&&(a=t,h=d)),t=t.next;while(t!==l);return a}function $g(r,e){return at(r.prev,r,e.prev)<0&&at(e.next,r,r.next)<0}function Jg(r,e,t,i){var s=r;do s.z===0&&(s.z=Eh(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,Zg(s)}function Zg(r){var e,t,i,s,n,a,o,l,c=1;do{for(t=r,r=null,n=null,a=0;t;){for(a++,i=t,o=0,e=0;e0||l>0&&i;)o!==0&&(l===0||!i||t.z<=i.z)?(s=t,t=t.nextZ,o--):(s=i,i=i.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;t=i}n.nextZ=null,c*=2}while(a>1);return r}function Eh(r,e,t,i,s){return r=(r-t)*s|0,e=(e-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function e0(r){var e=r,t=r;do(e.x=(r-a)*(n-o)&&(r-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(n-o)>=(s-a)*(i-o)}function t0(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!i0(r,e)&&(ia(r,e)&&ia(e,r)&&r0(r,e)&&(at(r.prev,r,e.prev)||at(r,e.prev,e))||qo(r,e)&&at(r.prev,r,r.next)>0&&at(e.prev,e,e.next)>0)}function at(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function qo(r,e){return r.x===e.x&&r.y===e.y}function tf(r,e,t,i){var s=xa(at(r,e,t)),n=xa(at(r,e,i)),a=xa(at(t,i,r)),o=xa(at(t,i,e));return!!(s!==n&&a!==o||s===0&&wa(r,t,e)||n===0&&wa(r,i,e)||a===0&&wa(t,r,i)||o===0&&wa(t,e,i))}function wa(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function xa(r){return r>0?1:r<0?-1:0}function i0(r,e){var t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&tf(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function ia(r,e){return at(r.prev,r,r.next)<0?at(r,e,r.next)>=0&&at(r,r.prev,e)>=0:at(r,e,r.prev)<0||at(r,r.next,e)<0}function r0(r,e){var t=r,i=!1,s=(r.x+e.x)/2,n=(r.y+e.y)/2;do t.y>n!=t.next.y>n&&t.next.y!==t.y&&s<(t.next.x-t.x)*(n-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==r);return i}function rf(r,e){var t=new Th(r.i,r.x,r.y),i=new Th(e.i,e.x,e.y),s=r.next,n=e.prev;return r.next=e,e.prev=r,t.next=s,s.prev=t,i.next=t,t.prev=i,n.next=i,i.prev=n,i}function Rd(r,e,t,i){var s=new Th(r,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function ra(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Th(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Ko.deviation=function(r,e,t,i){var s=e&&e.length,n=s?e[0]*t:r.length,a=Math.abs(Sh(r,0,n,t));if(s)for(var o=0,l=e.length;o0&&(i+=r[s-1].length,t.holes.push(i))}return t};var s0=Rc.exports;const n0=da(s0);var bo={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */bo.exports;(function(r,e){(function(t){var i=e&&!e.nodeType&&e,s=r&&!r.nodeType&&r,n=typeof si=="object"&&si;(n.global===n||n.window===n||n.self===n)&&(t=n);var a,o=2147483647,l=36,c=1,u=26,h=38,d=700,p=72,f=128,m="-",g=/^xn--/,y=/[^\x20-\x7E]/,b=/[\x2E\u3002\uFF0E\uFF61]/g,A={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=l-c,E=Math.floor,C=String.fromCharCode,M;function P(G){throw new RangeError(A[G])}function k(G,D){for(var O=G.length,ee=[];O--;)ee[O]=D(G[O]);return ee}function N(G,D){var O=G.split("@"),ee="";O.length>1&&(ee=O[0]+"@",G=O[1]),G=G.replace(b,".");var Q=G.split("."),K=k(Q,D).join(".");return ee+K}function H(G){for(var D=[],O=0,ee=G.length,Q,K;O=55296&&Q<=56319&&O65535&&(D-=65536,O+=C(D>>>10&1023|55296),D=56320|D&1023),O+=C(D),O}).join("")}function S(G){return G-48<10?G-22:G-65<26?G-65:G-97<26?G-97:l}function w(G,D){return G+22+75*(G<26)-((D!=0)<<5)}function F(G,D,O){var ee=0;for(G=O?E(G/d):G>>1,G+=E(G/D);G>v*u>>1;ee+=l)G=E(G/v);return E(ee+(v+1)*G/(G+h))}function z(G){var D=[],O=G.length,ee,Q=0,K=f,ge=p,Te,he,pe,be,oe,ue,ve,x,j;for(Te=G.lastIndexOf(m),Te<0&&(Te=0),he=0;he=128&&P("not-basic"),D.push(G.charCodeAt(he));for(pe=Te>0?Te+1:0;pe=O&&P("invalid-input"),ve=S(G.charCodeAt(pe++)),(ve>=l||ve>E((o-Q)/oe))&&P("overflow"),Q+=ve*oe,x=ue<=ge?c:ue>=ge+u?u:ue-ge,!(veE(o/j)&&P("overflow"),oe*=j;ee=D.length+1,ge=F(Q-be,ee,be==0),E(Q/ee)>o-K&&P("overflow"),K+=E(Q/ee),Q%=ee,D.splice(Q++,0,K)}return T(D)}function L(G){var D,O,ee,Q,K,ge,Te,he,pe,be,oe,ue=[],ve,x,j,V;for(G=H(G),ve=G.length,D=f,O=0,K=p,ge=0;ge=D&&oeE((o-O)/x)&&P("overflow"),O+=(Te-D)*x,D=Te,ge=0;geo&&P("overflow"),oe==D){for(he=O,pe=l;be=pe<=K?c:pe>=K+u?u:pe-K,!(he"u"||!At?Oe:At(Uint8Array),ds={"%AggregateError%":typeof AggregateError>"u"?Oe:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Oe:ArrayBuffer,"%ArrayIteratorPrototype%":ks&&At?At([][Symbol.iterator]()):Oe,"%AsyncFromSyncIteratorPrototype%":Oe,"%AsyncFunction%":Fs,"%AsyncGenerator%":Fs,"%AsyncGeneratorFunction%":Fs,"%AsyncIteratorPrototype%":Fs,"%Atomics%":typeof Atomics>"u"?Oe:Atomics,"%BigInt%":typeof BigInt>"u"?Oe:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Oe:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Oe:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Oe:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?Oe:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Oe:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Oe:FinalizationRegistry,"%Function%":nf,"%GeneratorFunction%":Fs,"%Int8Array%":typeof Int8Array>"u"?Oe:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Oe:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Oe:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":ks&&At?At(At([][Symbol.iterator]())):Oe,"%JSON%":typeof JSON=="object"?JSON:Oe,"%Map%":typeof Map>"u"?Oe:Map,"%MapIteratorPrototype%":typeof Map>"u"||!ks||!At?Oe:At(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Oe:Promise,"%Proxy%":typeof Proxy>"u"?Oe:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?Oe:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Oe:Set,"%SetIteratorPrototype%":typeof Set>"u"||!ks||!At?Oe:At(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Oe:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":ks&&At?At(""[Symbol.iterator]()):Oe,"%Symbol%":ks?Symbol:Oe,"%SyntaxError%":nn,"%ThrowTypeError%":v0,"%TypedArray%":A0,"%TypeError%":Js,"%Uint8Array%":typeof Uint8Array>"u"?Oe:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Oe:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Oe:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Oe:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?Oe:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Oe:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Oe:WeakSet};if(At)try{null.error}catch(r){var w0=At(At(r));ds["%Error.prototype%"]=w0}var x0=function r(e){var t;if(e==="%AsyncFunction%")t=El("async function () {}");else if(e==="%GeneratorFunction%")t=El("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=El("async function* () {}");else if(e==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(t=i.prototype)}else if(e==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&At&&(t=At(s.prototype))}return ds[e]=t,t},Fd={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ua=sf,Ao=y0,_0=ua.call(Function.call,Array.prototype.concat),E0=ua.call(Function.apply,Array.prototype.splice),Nd=ua.call(Function.call,String.prototype.replace),wo=ua.call(Function.call,String.prototype.slice),T0=ua.call(Function.call,RegExp.prototype.exec),S0=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,C0=/\\(\\)?/g,M0=function(e){var t=wo(e,0,1),i=wo(e,-1);if(t==="%"&&i!=="%")throw new nn("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&t!=="%")throw new nn("invalid intrinsic syntax, expected opening `%`");var s=[];return Nd(e,S0,function(n,a,o,l){s[s.length]=o?Nd(l,C0,"$1"):a||n}),s},I0=function(e,t){var i=e,s;if(Ao(Fd,i)&&(s=Fd[i],i="%"+s[0]+"%"),Ao(ds,i)){var n=ds[i];if(n===Fs&&(n=x0(i)),typeof n>"u"&&!t)throw new Js("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new nn("intrinsic "+e+" does not exist!")},Dc=function(e,t){if(typeof e!="string"||e.length===0)throw new Js("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Js('"allowMissing" argument must be a boolean');if(T0(/^%?[^%]*%?$/,e)===null)throw new nn("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=M0(e),s=i.length>0?i[0]:"",n=I0("%"+s+"%",t),a=n.name,o=n.value,l=!1,c=n.alias;c&&(s=c[0],E0(i,_0([0,1],c)));for(var u=1,h=!0;u=i.length){var m=cs(o,d);h=!!m,h&&"get"in m&&!("originalValue"in m.get)?o=m.get:o=o[d]}else h=Ao(o,d),o=o[d];h&&!l&&(ds[a]=o)}}return o},af={exports:{}};(function(r){var e=sf,t=Dc,i=t("%Function.prototype.apply%"),s=t("%Function.prototype.call%"),n=t("%Reflect.apply%",!0)||e.call(s,i),a=t("%Object.getOwnPropertyDescriptor%",!0),o=t("%Object.defineProperty%",!0),l=t("%Math.max%");if(o)try{o({},"a",{value:1})}catch{o=null}r.exports=function(h){var d=n(e,s,arguments);if(a&&o){var p=a(d,"length");p.configurable&&o(d,"length",{value:1+l(0,h.length-(arguments.length-1))})}return d};var c=function(){return n(e,i,arguments)};o?o(r.exports,"apply",{value:c}):r.exports.apply=c})(af);var k0=af.exports,of=Dc,lf=k0,B0=lf(of("String.prototype.indexOf")),P0=function(e,t){var i=of(e,!!t);return typeof i=="function"&&B0(e,".prototype.")>-1?lf(i):i};const R0={},D0=Object.freeze(Object.defineProperty({__proto__:null,default:R0},Symbol.toStringTag,{value:"Module"})),L0=Hg(D0);var Lc=typeof Map=="function"&&Map.prototype,Sl=Object.getOwnPropertyDescriptor&&Lc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,xo=Lc&&Sl&&typeof Sl.get=="function"?Sl.get:null,Ud=Lc&&Map.prototype.forEach,Oc=typeof Set=="function"&&Set.prototype,Cl=Object.getOwnPropertyDescriptor&&Oc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,_o=Oc&&Cl&&typeof Cl.get=="function"?Cl.get:null,Gd=Oc&&Set.prototype.forEach,O0=typeof WeakMap=="function"&&WeakMap.prototype,Xn=O0?WeakMap.prototype.has:null,F0=typeof WeakSet=="function"&&WeakSet.prototype,Kn=F0?WeakSet.prototype.has:null,N0=typeof WeakRef=="function"&&WeakRef.prototype,Hd=N0?WeakRef.prototype.deref:null,U0=Boolean.prototype.valueOf,G0=Object.prototype.toString,H0=Function.prototype.toString,W0=String.prototype.match,Fc=String.prototype.slice,Ir=String.prototype.replace,V0=String.prototype.toUpperCase,Wd=String.prototype.toLowerCase,hf=RegExp.prototype.test,Vd=Array.prototype.concat,Oi=Array.prototype.join,z0=Array.prototype.slice,zd=Math.floor,Ch=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ml=Object.getOwnPropertySymbols,Mh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,an=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Ct=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===an||"symbol")?Symbol.toStringTag:null,cf=Object.prototype.propertyIsEnumerable,jd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Yd(r,e){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||hf.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-zd(-r):zd(r);if(i!==r){var s=String(i),n=Fc.call(e,s.length+1);return Ir.call(s,t,"$&_")+"."+Ir.call(Ir.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Ir.call(e,t,"$&_")}var Ih=L0,Xd=Ih.custom,Kd=uf(Xd)?Xd:null,j0=function r(e,t,i,s){var n=t||{};if(wr(n,"quoteStyle")&&n.quoteStyle!=="single"&&n.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(wr(n,"maxStringLength")&&(typeof n.maxStringLength=="number"?n.maxStringLength<0&&n.maxStringLength!==1/0:n.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=wr(n,"customInspect")?n.customInspect:!0;if(typeof a!="boolean"&&a!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(wr(n,"indent")&&n.indent!==null&&n.indent!==" "&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(wr(n,"numericSeparator")&&typeof n.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var o=n.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return ff(e,n);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return o?Yd(e,l):l}if(typeof e=="bigint"){var c=String(e)+"n";return o?Yd(e,c):c}var u=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=u&&u>0&&typeof e=="object")return kh(e)?"[Array]":"[Object]";var h=hy(n,i);if(typeof s>"u")s=[];else if(pf(s,e)>=0)return"[Circular]";function d(S,w,F){if(w&&(s=z0.call(s),s.push(w)),F){var z={depth:n.depth};return wr(n,"quoteStyle")&&(z.quoteStyle=n.quoteStyle),r(S,z,i+1,s)}return r(S,n,i+1,s)}if(typeof e=="function"&&!qd(e)){var p=ey(e),f=_a(e,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(f.length>0?" { "+Oi.call(f,", ")+" }":"")}if(uf(e)){var m=an?Ir.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):Mh.call(e);return typeof e=="object"&&!an?Tn(m):m}if(ay(e)){for(var g="<"+Wd.call(String(e.nodeName)),y=e.attributes||[],b=0;b",g}if(kh(e)){if(e.length===0)return"[]";var A=_a(e,d);return h&&!ly(A)?"["+Bh(A,h)+"]":"[ "+Oi.call(A,", ")+" ]"}if(K0(e)){var v=_a(e,d);return!("cause"in Error.prototype)&&"cause"in e&&!cf.call(e,"cause")?"{ ["+String(e)+"] "+Oi.call(Vd.call("[cause]: "+d(e.cause),v),", ")+" }":v.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Oi.call(v,", ")+" }"}if(typeof e=="object"&&a){if(Kd&&typeof e[Kd]=="function"&&Ih)return Ih(e,{depth:u-i});if(a!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(ty(e)){var E=[];return Ud&&Ud.call(e,function(S,w){E.push(d(w,e,!0)+" => "+d(S,e))}),Qd("Map",xo.call(e),E,h)}if(sy(e)){var C=[];return Gd&&Gd.call(e,function(S){C.push(d(S,e))}),Qd("Set",_o.call(e),C,h)}if(iy(e))return Il("WeakMap");if(ny(e))return Il("WeakSet");if(ry(e))return Il("WeakRef");if(Q0(e))return Tn(d(Number(e)));if(J0(e))return Tn(d(Ch.call(e)));if($0(e))return Tn(U0.call(e));if(q0(e))return Tn(d(String(e)));if(!X0(e)&&!qd(e)){var M=_a(e,d),P=jd?jd(e)===Object.prototype:e instanceof Object||e.constructor===Object,k=e instanceof Object?"":"null prototype",N=!P&&Ct&&Object(e)===e&&Ct in e?Fc.call(Gr(e),8,-1):k?"Object":"",H=P||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",T=H+(N||k?"["+Oi.call(Vd.call([],N||[],k||[]),": ")+"] ":"");return M.length===0?T+"{}":h?T+"{"+Bh(M,h)+"}":T+"{ "+Oi.call(M,", ")+" }"}return String(e)};function df(r,e,t){var i=(t.quoteStyle||e)==="double"?'"':"'";return i+r+i}function Y0(r){return Ir.call(String(r),/"/g,""")}function kh(r){return Gr(r)==="[object Array]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function X0(r){return Gr(r)==="[object Date]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function qd(r){return Gr(r)==="[object RegExp]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function K0(r){return Gr(r)==="[object Error]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function q0(r){return Gr(r)==="[object String]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function Q0(r){return Gr(r)==="[object Number]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function $0(r){return Gr(r)==="[object Boolean]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function uf(r){if(an)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Mh)return!1;try{return Mh.call(r),!0}catch{}return!1}function J0(r){if(!r||typeof r!="object"||!Ch)return!1;try{return Ch.call(r),!0}catch{}return!1}var Z0=Object.prototype.hasOwnProperty||function(r){return r in this};function wr(r,e){return Z0.call(r,e)}function Gr(r){return G0.call(r)}function ey(r){if(r.name)return r.name;var e=W0.call(H0.call(r),/^function\s*([\w$]+)/);return e?e[1]:null}function pf(r,e){if(r.indexOf)return r.indexOf(e);for(var t=0,i=r.length;te.maxStringLength){var t=r.length-e.maxStringLength,i="... "+t+" more character"+(t>1?"s":"");return ff(Fc.call(r,0,e.maxStringLength),e)+i}var s=Ir.call(Ir.call(r,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,oy);return df(s,"single",e)}function oy(r){var e=r.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+V0.call(e.toString(16))}function Tn(r){return"Object("+r+")"}function Il(r){return r+" { ? }"}function Qd(r,e,t,i){var s=i?Bh(t,i):Oi.call(t,", ");return r+" ("+e+") {"+s+"}"}function ly(r){for(var e=0;ee in r?Og(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Ms=(r,e,t)=>(Fg(r,typeof e!="symbol"?e+"":e,t),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const n of s)if(n.type==="childList")for(const a of n.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const n={};return s.integrity&&(n.integrity=s.integrity),s.referrerPolicy&&(n.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?n.credentials="include":s.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(s){if(s.ep)return;s.ep=!0;const n=t(s);fetch(s.href,n)}})();var _s=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(_s||{}),Jp=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Jp||{}),_h=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(_h||{}),Ee=(r=>(r[r.NORMAL=0]="NORMAL",r[r.ADD=1]="ADD",r[r.MULTIPLY=2]="MULTIPLY",r[r.SCREEN=3]="SCREEN",r[r.OVERLAY=4]="OVERLAY",r[r.DARKEN=5]="DARKEN",r[r.LIGHTEN=6]="LIGHTEN",r[r.COLOR_DODGE=7]="COLOR_DODGE",r[r.COLOR_BURN=8]="COLOR_BURN",r[r.HARD_LIGHT=9]="HARD_LIGHT",r[r.SOFT_LIGHT=10]="SOFT_LIGHT",r[r.DIFFERENCE=11]="DIFFERENCE",r[r.EXCLUSION=12]="EXCLUSION",r[r.HUE=13]="HUE",r[r.SATURATION=14]="SATURATION",r[r.COLOR=15]="COLOR",r[r.LUMINOSITY=16]="LUMINOSITY",r[r.NORMAL_NPM=17]="NORMAL_NPM",r[r.ADD_NPM=18]="ADD_NPM",r[r.SCREEN_NPM=19]="SCREEN_NPM",r[r.NONE=20]="NONE",r[r.SRC_OVER=0]="SRC_OVER",r[r.SRC_IN=21]="SRC_IN",r[r.SRC_OUT=22]="SRC_OUT",r[r.SRC_ATOP=23]="SRC_ATOP",r[r.DST_OVER=24]="DST_OVER",r[r.DST_IN=25]="DST_IN",r[r.DST_OUT=26]="DST_OUT",r[r.DST_ATOP=27]="DST_ATOP",r[r.ERASE=26]="ERASE",r[r.SUBTRACT=28]="SUBTRACT",r[r.XOR=29]="XOR",r))(Ee||{}),Ni=(r=>(r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r))(Ni||{}),re=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(re||{}),$s=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))($s||{}),we=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(we||{}),ce=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(ce||{}),er=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(er||{}),Rr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Rr||{}),Xt=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(Xt||{}),Lt=(r=>(r[r.NPM=0]="NPM",r[r.UNPACK=1]="UNPACK",r[r.PMA=2]="PMA",r[r.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",r[r.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",r[r.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",r))(Lt||{}),Li=(r=>(r[r.NO=0]="NO",r[r.YES=1]="YES",r[r.AUTO=2]="AUTO",r[r.BLEND=0]="BLEND",r[r.CLEAR=1]="CLEAR",r[r.BLIT=2]="BLIT",r))(Li||{}),Pc=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(Pc||{}),ai=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(ai||{}),pt=(r=>(r[r.NONE=0]="NONE",r[r.SCISSOR=1]="SCISSOR",r[r.STENCIL=2]="STENCIL",r[r.SPRITE=3]="SPRITE",r[r.COLOR=4]="COLOR",r))(pt||{}),ut=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(ut||{}),Gi=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Gi||{});const Ng={createCanvas:(r,e)=>{const t=document.createElement("canvas");return t.width=r,t.height=e,t},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,e)=>fetch(r,e),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")},de={ADAPTER:Ng,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Al=/iPhone/i,wd=/iPod/i,xd=/iPad/i,_d=/\biOS-universal(?:.+)Mac\b/i,wl=/\bAndroid(?:.+)Mobile\b/i,Ed=/Android/i,Is=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Aa=/Silk/i,Xi=/Windows Phone/i,Td=/\bWindows(?:.+)ARM\b/i,Sd=/BlackBerry/i,Cd=/BB10/i,Md=/Opera Mini/i,Id=/\b(CriOS|Chrome)(?:.+)Mobile/i,kd=/Mobile(?:.+)Firefox\b/i,Bd=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function Ug(r){return function(e){return e.test(r)}}function Pd(r){var e={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?e.userAgent=r:r&&r.userAgent&&(e={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var s=Ug(t),n={apple:{phone:s(Al)&&!s(Xi),ipod:s(wd),tablet:!s(Al)&&(s(xd)||Bd(e))&&!s(Xi),universal:s(_d),device:(s(Al)||s(wd)||s(xd)||s(_d)||Bd(e))&&!s(Xi)},amazon:{phone:s(Is),tablet:!s(Is)&&s(Aa),device:s(Is)||s(Aa)},android:{phone:!s(Xi)&&s(Is)||!s(Xi)&&s(wl),tablet:!s(Xi)&&!s(Is)&&!s(wl)&&(s(Aa)||s(Ed)),device:!s(Xi)&&(s(Is)||s(Aa)||s(wl)||s(Ed))||s(/\bokhttp\b/i)},windows:{phone:s(Xi),tablet:s(Td),device:s(Xi)||s(Td)},other:{blackberry:s(Sd),blackberry10:s(Cd),opera:s(Md),firefox:s(kd),chrome:s(Id),device:s(Sd)||s(Cd)||s(Md)||s(kd)||s(Id)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const Gg=Pd.default??Pd,tr=Gg(globalThis.navigator);de.RETINA_PREFIX=/@([0-9\.]+)x/;de.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var si=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function da(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Hg(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),t}var Zp={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,c,u){this.fn=l,this.context=c,this.once=u||!1}function n(l,c,u,h,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var p=new s(u,h||l,d),f=t?t+c:c;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,c){--l._eventsCount===0?l._events=new i:delete l._events[c]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],u,h;if(this._eventsCount===0)return c;for(h in u=this._events)e.call(u,h)&&c.push(t?h.slice(1):h);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},o.prototype.listeners=function(c){var u=t?t+c:c,h=this._events[u];if(!h)return[];if(h.fn)return[h.fn];for(var d=0,p=h.length,f=new Array(p);d80*t){o=c=r[0],l=u=r[1];for(var f=t;fc&&(c=h),d>u&&(u=d);p=Math.max(c-o,u-l),p=p!==0?32767/p:0}return ta(n,a,t,o,l,p,0),a}function ef(r,e,t,i,s){var n,a;if(s===Sh(r,e,t,i)>0)for(n=e;n=e;n-=i)a=Rd(n,r[n],r[n+1],a);return a&&qo(a,a.next)&&(ra(a),a=a.next),a}function vs(r,e){if(!r)return r;e||(e=r);var t=r,i;do if(i=!1,!t.steiner&&(qo(t,t.next)||at(t.prev,t,t.next)===0)){if(ra(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function ta(r,e,t,i,s,n,a){if(r){!a&&n&&Jg(r,i,s,n);for(var o=r,l,c;r.prev!==r.next;){if(l=r.prev,c=r.next,n?zg(r,i,s,n):Vg(r)){e.push(l.i/t|0),e.push(r.i/t|0),e.push(c.i/t|0),ra(r),r=c.next,o=c.next;continue}if(r=c,r===o){a?a===1?(r=jg(vs(r),e,t),ta(r,e,t,i,s,n,2)):a===2&&Yg(r,e,t,i,s,n):ta(vs(r),e,t,i,s,n,1);break}}}}function Vg(r){var e=r.prev,t=r,i=r.next;if(at(e,t,i)>=0)return!1;for(var s=e.x,n=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=sn?s>a?s:a:n>a?n:a,p=o>l?o>c?o:c:l>c?l:c,f=i.next;f!==e;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Xs(s,o,n,l,a,c,f.x,f.y)&&at(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function zg(r,e,t,i){var s=r.prev,n=r,a=r.next;if(at(s,n,a)>=0)return!1;for(var o=s.x,l=n.x,c=a.x,u=s.y,h=n.y,d=a.y,p=ol?o>c?o:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,y=Eh(p,f,e,t,i),b=Eh(m,g,e,t,i),A=r.prevZ,v=r.nextZ;A&&A.z>=y&&v&&v.z<=b;){if(A.x>=p&&A.x<=m&&A.y>=f&&A.y<=g&&A!==s&&A!==a&&Xs(o,u,l,h,c,d,A.x,A.y)&&at(A.prev,A,A.next)>=0||(A=A.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==s&&v!==a&&Xs(o,u,l,h,c,d,v.x,v.y)&&at(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;A&&A.z>=y;){if(A.x>=p&&A.x<=m&&A.y>=f&&A.y<=g&&A!==s&&A!==a&&Xs(o,u,l,h,c,d,A.x,A.y)&&at(A.prev,A,A.next)>=0)return!1;A=A.prevZ}for(;v&&v.z<=b;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==s&&v!==a&&Xs(o,u,l,h,c,d,v.x,v.y)&&at(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function jg(r,e,t){var i=r;do{var s=i.prev,n=i.next.next;!qo(s,n)&&tf(s,i,i.next,n)&&ia(s,n)&&ia(n,s)&&(e.push(s.i/t|0),e.push(i.i/t|0),e.push(n.i/t|0),ra(i),ra(i.next),i=r=n),i=i.next}while(i!==r);return vs(i)}function Yg(r,e,t,i,s,n){var a=r;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&t0(a,o)){var l=rf(a,o);a=vs(a,a.next),l=vs(l,l.next),ta(a,e,t,i,s,n,0),ta(l,e,t,i,s,n,0);return}o=o.next}a=a.next}while(a!==r)}function Xg(r,e,t,i){var s=[],n,a,o,l,c;for(n=0,a=e.length;n=t.next.y&&t.next.y!==t.y){var o=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(o<=i&&o>n&&(n=o,a=t.x=t.x&&t.x>=c&&i!==t.x&&Xs(sa.x||t.x===a.x&&$g(a,t)))&&(a=t,h=d)),t=t.next;while(t!==l);return a}function $g(r,e){return at(r.prev,r,e.prev)<0&&at(e.next,r,r.next)<0}function Jg(r,e,t,i){var s=r;do s.z===0&&(s.z=Eh(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,Zg(s)}function Zg(r){var e,t,i,s,n,a,o,l,c=1;do{for(t=r,r=null,n=null,a=0;t;){for(a++,i=t,o=0,e=0;e0||l>0&&i;)o!==0&&(l===0||!i||t.z<=i.z)?(s=t,t=t.nextZ,o--):(s=i,i=i.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;t=i}n.nextZ=null,c*=2}while(a>1);return r}function Eh(r,e,t,i,s){return r=(r-t)*s|0,e=(e-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function e0(r){var e=r,t=r;do(e.x=(r-a)*(n-o)&&(r-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(n-o)>=(s-a)*(i-o)}function t0(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!i0(r,e)&&(ia(r,e)&&ia(e,r)&&r0(r,e)&&(at(r.prev,r,e.prev)||at(r,e.prev,e))||qo(r,e)&&at(r.prev,r,r.next)>0&&at(e.prev,e,e.next)>0)}function at(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function qo(r,e){return r.x===e.x&&r.y===e.y}function tf(r,e,t,i){var s=xa(at(r,e,t)),n=xa(at(r,e,i)),a=xa(at(t,i,r)),o=xa(at(t,i,e));return!!(s!==n&&a!==o||s===0&&wa(r,t,e)||n===0&&wa(r,i,e)||a===0&&wa(t,r,i)||o===0&&wa(t,e,i))}function wa(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function xa(r){return r>0?1:r<0?-1:0}function i0(r,e){var t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&tf(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function ia(r,e){return at(r.prev,r,r.next)<0?at(r,e,r.next)>=0&&at(r,r.prev,e)>=0:at(r,e,r.prev)<0||at(r,r.next,e)<0}function r0(r,e){var t=r,i=!1,s=(r.x+e.x)/2,n=(r.y+e.y)/2;do t.y>n!=t.next.y>n&&t.next.y!==t.y&&s<(t.next.x-t.x)*(n-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==r);return i}function rf(r,e){var t=new Th(r.i,r.x,r.y),i=new Th(e.i,e.x,e.y),s=r.next,n=e.prev;return r.next=e,e.prev=r,t.next=s,s.prev=t,i.next=t,t.prev=i,n.next=i,i.prev=n,i}function Rd(r,e,t,i){var s=new Th(r,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function ra(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Th(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Ko.deviation=function(r,e,t,i){var s=e&&e.length,n=s?e[0]*t:r.length,a=Math.abs(Sh(r,0,n,t));if(s)for(var o=0,l=e.length;o0&&(i+=r[s-1].length,t.holes.push(i))}return t};var s0=Rc.exports;const n0=da(s0);var bo={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */bo.exports;(function(r,e){(function(t){var i=e&&!e.nodeType&&e,s=r&&!r.nodeType&&r,n=typeof si=="object"&&si;(n.global===n||n.window===n||n.self===n)&&(t=n);var a,o=2147483647,l=36,c=1,u=26,h=38,d=700,p=72,f=128,m="-",g=/^xn--/,y=/[^\x20-\x7E]/,b=/[\x2E\u3002\uFF0E\uFF61]/g,A={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=l-c,E=Math.floor,C=String.fromCharCode,M;function P(G){throw new RangeError(A[G])}function k(G,D){for(var O=G.length,ee=[];O--;)ee[O]=D(G[O]);return ee}function N(G,D){var O=G.split("@"),ee="";O.length>1&&(ee=O[0]+"@",G=O[1]),G=G.replace(b,".");var Q=G.split("."),K=k(Q,D).join(".");return ee+K}function H(G){for(var D=[],O=0,ee=G.length,Q,K;O=55296&&Q<=56319&&O65535&&(D-=65536,O+=C(D>>>10&1023|55296),D=56320|D&1023),O+=C(D),O}).join("")}function S(G){return G-48<10?G-22:G-65<26?G-65:G-97<26?G-97:l}function w(G,D){return G+22+75*(G<26)-((D!=0)<<5)}function F(G,D,O){var ee=0;for(G=O?E(G/d):G>>1,G+=E(G/D);G>v*u>>1;ee+=l)G=E(G/v);return E(ee+(v+1)*G/(G+h))}function z(G){var D=[],O=G.length,ee,Q=0,K=f,ge=p,Te,he,pe,be,oe,ue,ve,x,j;for(Te=G.lastIndexOf(m),Te<0&&(Te=0),he=0;he=128&&P("not-basic"),D.push(G.charCodeAt(he));for(pe=Te>0?Te+1:0;pe=O&&P("invalid-input"),ve=S(G.charCodeAt(pe++)),(ve>=l||ve>E((o-Q)/oe))&&P("overflow"),Q+=ve*oe,x=ue<=ge?c:ue>=ge+u?u:ue-ge,!(veE(o/j)&&P("overflow"),oe*=j;ee=D.length+1,ge=F(Q-be,ee,be==0),E(Q/ee)>o-K&&P("overflow"),K+=E(Q/ee),Q%=ee,D.splice(Q++,0,K)}return T(D)}function L(G){var D,O,ee,Q,K,ge,Te,he,pe,be,oe,ue=[],ve,x,j,V;for(G=H(G),ve=G.length,D=f,O=0,K=p,ge=0;ge=D&&oeE((o-O)/x)&&P("overflow"),O+=(Te-D)*x,D=Te,ge=0;geo&&P("overflow"),oe==D){for(he=O,pe=l;be=pe<=K?c:pe>=K+u?u:pe-K,!(he"u"||!At?Oe:At(Uint8Array),ds={"%AggregateError%":typeof AggregateError>"u"?Oe:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Oe:ArrayBuffer,"%ArrayIteratorPrototype%":ks&&At?At([][Symbol.iterator]()):Oe,"%AsyncFromSyncIteratorPrototype%":Oe,"%AsyncFunction%":Fs,"%AsyncGenerator%":Fs,"%AsyncGeneratorFunction%":Fs,"%AsyncIteratorPrototype%":Fs,"%Atomics%":typeof Atomics>"u"?Oe:Atomics,"%BigInt%":typeof BigInt>"u"?Oe:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Oe:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Oe:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Oe:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?Oe:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Oe:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Oe:FinalizationRegistry,"%Function%":nf,"%GeneratorFunction%":Fs,"%Int8Array%":typeof Int8Array>"u"?Oe:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Oe:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Oe:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":ks&&At?At(At([][Symbol.iterator]())):Oe,"%JSON%":typeof JSON=="object"?JSON:Oe,"%Map%":typeof Map>"u"?Oe:Map,"%MapIteratorPrototype%":typeof Map>"u"||!ks||!At?Oe:At(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Oe:Promise,"%Proxy%":typeof Proxy>"u"?Oe:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?Oe:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Oe:Set,"%SetIteratorPrototype%":typeof Set>"u"||!ks||!At?Oe:At(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Oe:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":ks&&At?At(""[Symbol.iterator]()):Oe,"%Symbol%":ks?Symbol:Oe,"%SyntaxError%":nn,"%ThrowTypeError%":v0,"%TypedArray%":A0,"%TypeError%":Js,"%Uint8Array%":typeof Uint8Array>"u"?Oe:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Oe:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Oe:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Oe:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?Oe:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Oe:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Oe:WeakSet};if(At)try{null.error}catch(r){var w0=At(At(r));ds["%Error.prototype%"]=w0}var x0=function r(e){var t;if(e==="%AsyncFunction%")t=El("async function () {}");else if(e==="%GeneratorFunction%")t=El("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=El("async function* () {}");else if(e==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(t=i.prototype)}else if(e==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&At&&(t=At(s.prototype))}return ds[e]=t,t},Fd={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ua=sf,Ao=y0,_0=ua.call(Function.call,Array.prototype.concat),E0=ua.call(Function.apply,Array.prototype.splice),Nd=ua.call(Function.call,String.prototype.replace),wo=ua.call(Function.call,String.prototype.slice),T0=ua.call(Function.call,RegExp.prototype.exec),S0=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,C0=/\\(\\)?/g,M0=function(e){var t=wo(e,0,1),i=wo(e,-1);if(t==="%"&&i!=="%")throw new nn("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&t!=="%")throw new nn("invalid intrinsic syntax, expected opening `%`");var s=[];return Nd(e,S0,function(n,a,o,l){s[s.length]=o?Nd(l,C0,"$1"):a||n}),s},I0=function(e,t){var i=e,s;if(Ao(Fd,i)&&(s=Fd[i],i="%"+s[0]+"%"),Ao(ds,i)){var n=ds[i];if(n===Fs&&(n=x0(i)),typeof n>"u"&&!t)throw new Js("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new nn("intrinsic "+e+" does not exist!")},Dc=function(e,t){if(typeof e!="string"||e.length===0)throw new Js("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Js('"allowMissing" argument must be a boolean');if(T0(/^%?[^%]*%?$/,e)===null)throw new nn("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=M0(e),s=i.length>0?i[0]:"",n=I0("%"+s+"%",t),a=n.name,o=n.value,l=!1,c=n.alias;c&&(s=c[0],E0(i,_0([0,1],c)));for(var u=1,h=!0;u=i.length){var m=cs(o,d);h=!!m,h&&"get"in m&&!("originalValue"in m.get)?o=m.get:o=o[d]}else h=Ao(o,d),o=o[d];h&&!l&&(ds[a]=o)}}return o},af={exports:{}};(function(r){var e=sf,t=Dc,i=t("%Function.prototype.apply%"),s=t("%Function.prototype.call%"),n=t("%Reflect.apply%",!0)||e.call(s,i),a=t("%Object.getOwnPropertyDescriptor%",!0),o=t("%Object.defineProperty%",!0),l=t("%Math.max%");if(o)try{o({},"a",{value:1})}catch{o=null}r.exports=function(h){var d=n(e,s,arguments);if(a&&o){var p=a(d,"length");p.configurable&&o(d,"length",{value:1+l(0,h.length-(arguments.length-1))})}return d};var c=function(){return n(e,i,arguments)};o?o(r.exports,"apply",{value:c}):r.exports.apply=c})(af);var k0=af.exports,of=Dc,lf=k0,B0=lf(of("String.prototype.indexOf")),P0=function(e,t){var i=of(e,!!t);return typeof i=="function"&&B0(e,".prototype.")>-1?lf(i):i};const R0={},D0=Object.freeze(Object.defineProperty({__proto__:null,default:R0},Symbol.toStringTag,{value:"Module"})),L0=Hg(D0);var Lc=typeof Map=="function"&&Map.prototype,Sl=Object.getOwnPropertyDescriptor&&Lc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,xo=Lc&&Sl&&typeof Sl.get=="function"?Sl.get:null,Ud=Lc&&Map.prototype.forEach,Oc=typeof Set=="function"&&Set.prototype,Cl=Object.getOwnPropertyDescriptor&&Oc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,_o=Oc&&Cl&&typeof Cl.get=="function"?Cl.get:null,Gd=Oc&&Set.prototype.forEach,O0=typeof WeakMap=="function"&&WeakMap.prototype,Xn=O0?WeakMap.prototype.has:null,F0=typeof WeakSet=="function"&&WeakSet.prototype,Kn=F0?WeakSet.prototype.has:null,N0=typeof WeakRef=="function"&&WeakRef.prototype,Hd=N0?WeakRef.prototype.deref:null,U0=Boolean.prototype.valueOf,G0=Object.prototype.toString,H0=Function.prototype.toString,W0=String.prototype.match,Fc=String.prototype.slice,kr=String.prototype.replace,V0=String.prototype.toUpperCase,Wd=String.prototype.toLowerCase,hf=RegExp.prototype.test,Vd=Array.prototype.concat,Oi=Array.prototype.join,z0=Array.prototype.slice,zd=Math.floor,Ch=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ml=Object.getOwnPropertySymbols,Mh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,an=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Ct=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===an||"symbol")?Symbol.toStringTag:null,cf=Object.prototype.propertyIsEnumerable,jd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Yd(r,e){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||hf.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-zd(-r):zd(r);if(i!==r){var s=String(i),n=Fc.call(e,s.length+1);return kr.call(s,t,"$&_")+"."+kr.call(kr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return kr.call(e,t,"$&_")}var Ih=L0,Xd=Ih.custom,Kd=uf(Xd)?Xd:null,j0=function r(e,t,i,s){var n=t||{};if(xr(n,"quoteStyle")&&n.quoteStyle!=="single"&&n.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(xr(n,"maxStringLength")&&(typeof n.maxStringLength=="number"?n.maxStringLength<0&&n.maxStringLength!==1/0:n.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=xr(n,"customInspect")?n.customInspect:!0;if(typeof a!="boolean"&&a!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(xr(n,"indent")&&n.indent!==null&&n.indent!==" "&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(xr(n,"numericSeparator")&&typeof n.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var o=n.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return ff(e,n);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return o?Yd(e,l):l}if(typeof e=="bigint"){var c=String(e)+"n";return o?Yd(e,c):c}var u=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=u&&u>0&&typeof e=="object")return kh(e)?"[Array]":"[Object]";var h=hy(n,i);if(typeof s>"u")s=[];else if(pf(s,e)>=0)return"[Circular]";function d(S,w,F){if(w&&(s=z0.call(s),s.push(w)),F){var z={depth:n.depth};return xr(n,"quoteStyle")&&(z.quoteStyle=n.quoteStyle),r(S,z,i+1,s)}return r(S,n,i+1,s)}if(typeof e=="function"&&!qd(e)){var p=ey(e),f=_a(e,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(f.length>0?" { "+Oi.call(f,", ")+" }":"")}if(uf(e)){var m=an?kr.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):Mh.call(e);return typeof e=="object"&&!an?Tn(m):m}if(ay(e)){for(var g="<"+Wd.call(String(e.nodeName)),y=e.attributes||[],b=0;b",g}if(kh(e)){if(e.length===0)return"[]";var A=_a(e,d);return h&&!ly(A)?"["+Bh(A,h)+"]":"[ "+Oi.call(A,", ")+" ]"}if(K0(e)){var v=_a(e,d);return!("cause"in Error.prototype)&&"cause"in e&&!cf.call(e,"cause")?"{ ["+String(e)+"] "+Oi.call(Vd.call("[cause]: "+d(e.cause),v),", ")+" }":v.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Oi.call(v,", ")+" }"}if(typeof e=="object"&&a){if(Kd&&typeof e[Kd]=="function"&&Ih)return Ih(e,{depth:u-i});if(a!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(ty(e)){var E=[];return Ud&&Ud.call(e,function(S,w){E.push(d(w,e,!0)+" => "+d(S,e))}),Qd("Map",xo.call(e),E,h)}if(sy(e)){var C=[];return Gd&&Gd.call(e,function(S){C.push(d(S,e))}),Qd("Set",_o.call(e),C,h)}if(iy(e))return Il("WeakMap");if(ny(e))return Il("WeakSet");if(ry(e))return Il("WeakRef");if(Q0(e))return Tn(d(Number(e)));if(J0(e))return Tn(d(Ch.call(e)));if($0(e))return Tn(U0.call(e));if(q0(e))return Tn(d(String(e)));if(!X0(e)&&!qd(e)){var M=_a(e,d),P=jd?jd(e)===Object.prototype:e instanceof Object||e.constructor===Object,k=e instanceof Object?"":"null prototype",N=!P&&Ct&&Object(e)===e&&Ct in e?Fc.call(Gr(e),8,-1):k?"Object":"",H=P||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",T=H+(N||k?"["+Oi.call(Vd.call([],N||[],k||[]),": ")+"] ":"");return M.length===0?T+"{}":h?T+"{"+Bh(M,h)+"}":T+"{ "+Oi.call(M,", ")+" }"}return String(e)};function df(r,e,t){var i=(t.quoteStyle||e)==="double"?'"':"'";return i+r+i}function Y0(r){return kr.call(String(r),/"/g,""")}function kh(r){return Gr(r)==="[object Array]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function X0(r){return Gr(r)==="[object Date]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function qd(r){return Gr(r)==="[object RegExp]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function K0(r){return Gr(r)==="[object Error]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function q0(r){return Gr(r)==="[object String]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function Q0(r){return Gr(r)==="[object Number]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function $0(r){return Gr(r)==="[object Boolean]"&&(!Ct||!(typeof r=="object"&&Ct in r))}function uf(r){if(an)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Mh)return!1;try{return Mh.call(r),!0}catch{}return!1}function J0(r){if(!r||typeof r!="object"||!Ch)return!1;try{return Ch.call(r),!0}catch{}return!1}var Z0=Object.prototype.hasOwnProperty||function(r){return r in this};function xr(r,e){return Z0.call(r,e)}function Gr(r){return G0.call(r)}function ey(r){if(r.name)return r.name;var e=W0.call(H0.call(r),/^function\s*([\w$]+)/);return e?e[1]:null}function pf(r,e){if(r.indexOf)return r.indexOf(e);for(var t=0,i=r.length;te.maxStringLength){var t=r.length-e.maxStringLength,i="... "+t+" more character"+(t>1?"s":"");return ff(Fc.call(r,0,e.maxStringLength),e)+i}var s=kr.call(kr.call(r,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,oy);return df(s,"single",e)}function oy(r){var e=r.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+V0.call(e.toString(16))}function Tn(r){return"Object("+r+")"}function Il(r){return r+" { ? }"}function Qd(r,e,t,i){var s=i?Bh(t,i):Oi.call(t,", ");return r+" ("+e+") {"+s+"}"}function ly(r){for(var e=0;e=0)return!1;return!0}function hy(r,e){var t;if(r.indent===" ")t=" ";else if(typeof r.indent=="number"&&r.indent>0)t=Oi.call(Array(r.indent+1)," ");else return null;return{base:t,prev:Oi.call(Array(e+1),t)}}function Bh(r,e){if(r.length===0)return"";var t=` `+e.prev+e.base;return t+Oi.call(r,","+t)+` -`+e.prev}function _a(r,e){var t=kh(r),i=[];if(t){i.length=r.length;for(var s=0;s1;){var t=e.pop(),i=t.obj[t.prop];if(rs(i)){for(var s=[],n=0;n=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||n===Ey.RFC1738&&(c===40||c===41)){o+=a.charAt(l);continue}if(c<128){o=o+Ii[c];continue}if(c<2048){o=o+(Ii[192|c>>6]+Ii[128|c&63]);continue}if(c<55296||c>=57344){o=o+(Ii[224|c>>12]+Ii[128|c>>6&63]+Ii[128|c&63]);continue}l+=1,c=65536+((c&1023)<<10|a.charCodeAt(l)&1023),o+=Ii[240|c>>18]+Ii[128|c>>12&63]+Ii[128|c>>6&63]+Ii[128|c&63]}return o},ky=function(e){for(var t=[{obj:{o:e},prop:"o"}],i=[],s=0;s"u"&&(A=0)}if(typeof l=="function"?y=l(t,y):y instanceof Date?y=h(y):i==="comma"&&Ji(y)&&(y=ao.maybeMap(y,function(z){return z instanceof Date?h(z):z})),y===null){if(n)return o&&!f?o(t,Tt.encoder,m,"key",d):t;y=""}if(Ny(y)||ao.isBuffer(y)){if(o){var C=f?t:o(t,Tt.encoder,m,"key",d);return[p(C)+"="+p(o(y,Tt.encoder,m,"value",d))]}return[p(t)+"="+p(String(y))]}var M=[];if(typeof y>"u")return M;var P;if(i==="comma"&&Ji(y))f&&o&&(y=ao.maybeMap(y,o)),P=[{value:y.length>0?y.join(",")||null:void 0}];else if(Ji(l))P=l;else{var k=Object.keys(y);P=c?k.sort(c):k}for(var N=s&&Ji(y)&&y.length===1?t+"[]":t,H=0;H"u"?Tt.allowDots:!!e.allowDots,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:Tt.charsetSentinel,delimiter:typeof e.delimiter>"u"?Tt.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:Tt.encode,encoder:typeof e.encoder=="function"?e.encoder:Tt.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:Tt.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:Tt.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:Tt.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:Tt.strictNullHandling}},Hy=function(r,e){var t=r,i=Gy(e),s,n;typeof i.filter=="function"?(n=i.filter,t=n("",t)):Ji(i.filter)&&(n=i.filter,s=n);var a=[];if(typeof t!="object"||t===null)return"";var o;e&&e.arrayFormat in $d?o=e.arrayFormat:e&&"indices"in e?o=e.indices?"indices":"repeat":o="indices";var l=$d[o];if(e&&"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var c=l==="comma"&&e&&e.commaRoundTrip;s||(s=Object.keys(t)),i.sort&&s.sort(i.sort);for(var u=yf(),h=0;h0?f+p:""},on=gf,Ph=Object.prototype.hasOwnProperty,Wy=Array.isArray,bt={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:on.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Vy=function(r){return r.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},bf=function(r,e){return r&&typeof r=="string"&&e.comma&&r.indexOf(",")>-1?r.split(","):r},zy="utf8=%26%2310003%3B",jy="utf8=%E2%9C%93",Yy=function(e,t){var i={__proto__:null},s=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,n=t.parameterLimit===1/0?void 0:t.parameterLimit,a=s.split(t.delimiter,n),o=-1,l,c=t.charset;if(t.charsetSentinel)for(l=0;l-1&&(f=Wy(f)?[f]:f),Ph.call(i,p)?i[p]=on.combine(i[p],f):i[p]=f}return i},Xy=function(r,e,t,i){for(var s=i?e:bf(e,t),n=r.length-1;n>=0;--n){var a,o=r[n];if(o==="[]"&&t.parseArrays)a=[].concat(s);else{a=t.plainObjects?Object.create(null):{};var l=o.charAt(0)==="["&&o.charAt(o.length-1)==="]"?o.slice(1,-1):o,c=parseInt(l,10);!t.parseArrays&&l===""?a={0:s}:!isNaN(c)&&o!==l&&String(c)===l&&c>=0&&t.parseArrays&&c<=t.arrayLimit?(a=[],a[c]=s):l!=="__proto__"&&(a[l]=s)}s=a}return s},Ky=function(e,t,i,s){if(e){var n=i.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,a=/(\[[^[\]]*])/,o=/(\[[^[\]]*])/g,l=i.depth>0&&a.exec(n),c=l?n.slice(0,l.index):n,u=[];if(c){if(!i.plainObjects&&Ph.call(Object.prototype,c)&&!i.allowPrototypes)return;u.push(c)}for(var h=0;i.depth>0&&(l=o.exec(n))!==null&&h"u"?bt.charset:e.charset;return{allowDots:typeof e.allowDots>"u"?bt.allowDots:!!e.allowDots,allowPrototypes:typeof e.allowPrototypes=="boolean"?e.allowPrototypes:bt.allowPrototypes,allowSparse:typeof e.allowSparse=="boolean"?e.allowSparse:bt.allowSparse,arrayLimit:typeof e.arrayLimit=="number"?e.arrayLimit:bt.arrayLimit,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:bt.charsetSentinel,comma:typeof e.comma=="boolean"?e.comma:bt.comma,decoder:typeof e.decoder=="function"?e.decoder:bt.decoder,delimiter:typeof e.delimiter=="string"||on.isRegExp(e.delimiter)?e.delimiter:bt.delimiter,depth:typeof e.depth=="number"||e.depth===!1?+e.depth:bt.depth,ignoreQueryPrefix:e.ignoreQueryPrefix===!0,interpretNumericEntities:typeof e.interpretNumericEntities=="boolean"?e.interpretNumericEntities:bt.interpretNumericEntities,parameterLimit:typeof e.parameterLimit=="number"?e.parameterLimit:bt.parameterLimit,parseArrays:e.parseArrays!==!1,plainObjects:typeof e.plainObjects=="boolean"?e.plainObjects:bt.plainObjects,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:bt.strictNullHandling}},Qy=function(r,e){var t=qy(e);if(r===""||r===null||typeof r>"u")return t.plainObjects?Object.create(null):{};for(var i=typeof r=="string"?Yy(r,t):r,s=t.plainObjects?Object.create(null):{},n=Object.keys(i),a=0;a",'"',"`"," ","\r",` +`+e.prev}function _a(r,e){var t=kh(r),i=[];if(t){i.length=r.length;for(var s=0;s1;){var t=e.pop(),i=t.obj[t.prop];if(rs(i)){for(var s=[],n=0;n=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||n===Ey.RFC1738&&(c===40||c===41)){o+=a.charAt(l);continue}if(c<128){o=o+Ii[c];continue}if(c<2048){o=o+(Ii[192|c>>6]+Ii[128|c&63]);continue}if(c<55296||c>=57344){o=o+(Ii[224|c>>12]+Ii[128|c>>6&63]+Ii[128|c&63]);continue}l+=1,c=65536+((c&1023)<<10|a.charCodeAt(l)&1023),o+=Ii[240|c>>18]+Ii[128|c>>12&63]+Ii[128|c>>6&63]+Ii[128|c&63]}return o},ky=function(e){for(var t=[{obj:{o:e},prop:"o"}],i=[],s=0;s"u"&&(A=0)}if(typeof l=="function"?y=l(t,y):y instanceof Date?y=h(y):i==="comma"&&Ji(y)&&(y=ao.maybeMap(y,function(z){return z instanceof Date?h(z):z})),y===null){if(n)return o&&!f?o(t,Tt.encoder,m,"key",d):t;y=""}if(Ny(y)||ao.isBuffer(y)){if(o){var C=f?t:o(t,Tt.encoder,m,"key",d);return[p(C)+"="+p(o(y,Tt.encoder,m,"value",d))]}return[p(t)+"="+p(String(y))]}var M=[];if(typeof y>"u")return M;var P;if(i==="comma"&&Ji(y))f&&o&&(y=ao.maybeMap(y,o)),P=[{value:y.length>0?y.join(",")||null:void 0}];else if(Ji(l))P=l;else{var k=Object.keys(y);P=c?k.sort(c):k}for(var N=s&&Ji(y)&&y.length===1?t+"[]":t,H=0;H"u"?Tt.allowDots:!!e.allowDots,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:Tt.charsetSentinel,delimiter:typeof e.delimiter>"u"?Tt.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:Tt.encode,encoder:typeof e.encoder=="function"?e.encoder:Tt.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:Tt.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:Tt.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:Tt.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:Tt.strictNullHandling}},Hy=function(r,e){var t=r,i=Gy(e),s,n;typeof i.filter=="function"?(n=i.filter,t=n("",t)):Ji(i.filter)&&(n=i.filter,s=n);var a=[];if(typeof t!="object"||t===null)return"";var o;e&&e.arrayFormat in $d?o=e.arrayFormat:e&&"indices"in e?o=e.indices?"indices":"repeat":o="indices";var l=$d[o];if(e&&"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var c=l==="comma"&&e&&e.commaRoundTrip;s||(s=Object.keys(t)),i.sort&&s.sort(i.sort);for(var u=yf(),h=0;h0?f+p:""},on=gf,Ph=Object.prototype.hasOwnProperty,Wy=Array.isArray,bt={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:on.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Vy=function(r){return r.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},bf=function(r,e){return r&&typeof r=="string"&&e.comma&&r.indexOf(",")>-1?r.split(","):r},zy="utf8=%26%2310003%3B",jy="utf8=%E2%9C%93",Yy=function(e,t){var i={__proto__:null},s=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,n=t.parameterLimit===1/0?void 0:t.parameterLimit,a=s.split(t.delimiter,n),o=-1,l,c=t.charset;if(t.charsetSentinel)for(l=0;l-1&&(f=Wy(f)?[f]:f),Ph.call(i,p)?i[p]=on.combine(i[p],f):i[p]=f}return i},Xy=function(r,e,t,i){for(var s=i?e:bf(e,t),n=r.length-1;n>=0;--n){var a,o=r[n];if(o==="[]"&&t.parseArrays)a=[].concat(s);else{a=t.plainObjects?Object.create(null):{};var l=o.charAt(0)==="["&&o.charAt(o.length-1)==="]"?o.slice(1,-1):o,c=parseInt(l,10);!t.parseArrays&&l===""?a={0:s}:!isNaN(c)&&o!==l&&String(c)===l&&c>=0&&t.parseArrays&&c<=t.arrayLimit?(a=[],a[c]=s):l!=="__proto__"&&(a[l]=s)}s=a}return s},Ky=function(e,t,i,s){if(e){var n=i.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,a=/(\[[^[\]]*])/,o=/(\[[^[\]]*])/g,l=i.depth>0&&a.exec(n),c=l?n.slice(0,l.index):n,u=[];if(c){if(!i.plainObjects&&Ph.call(Object.prototype,c)&&!i.allowPrototypes)return;u.push(c)}for(var h=0;i.depth>0&&(l=o.exec(n))!==null&&h"u"?bt.charset:e.charset;return{allowDots:typeof e.allowDots>"u"?bt.allowDots:!!e.allowDots,allowPrototypes:typeof e.allowPrototypes=="boolean"?e.allowPrototypes:bt.allowPrototypes,allowSparse:typeof e.allowSparse=="boolean"?e.allowSparse:bt.allowSparse,arrayLimit:typeof e.arrayLimit=="number"?e.arrayLimit:bt.arrayLimit,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:bt.charsetSentinel,comma:typeof e.comma=="boolean"?e.comma:bt.comma,decoder:typeof e.decoder=="function"?e.decoder:bt.decoder,delimiter:typeof e.delimiter=="string"||on.isRegExp(e.delimiter)?e.delimiter:bt.delimiter,depth:typeof e.depth=="number"||e.depth===!1?+e.depth:bt.depth,ignoreQueryPrefix:e.ignoreQueryPrefix===!0,interpretNumericEntities:typeof e.interpretNumericEntities=="boolean"?e.interpretNumericEntities:bt.interpretNumericEntities,parameterLimit:typeof e.parameterLimit=="number"?e.parameterLimit:bt.parameterLimit,parseArrays:e.parseArrays!==!1,plainObjects:typeof e.plainObjects=="boolean"?e.plainObjects:bt.plainObjects,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:bt.strictNullHandling}},Qy=function(r,e){var t=qy(e);if(r===""||r===null||typeof r>"u")return t.plainObjects?Object.create(null):{};for(var i=typeof r=="string"?Yy(r,t):r,s=t.plainObjects?Object.create(null):{},n=Object.keys(i),a=0;a",'"',"`"," ","\r",` `," "],av=["{","}","|","\\","^","`"].concat(nv),Rh=["'"].concat(av),Zd=["%","/","?",";","#"].concat(Rh),eu=["/","?","#"],ov=255,tu=/^[+a-z0-9A-Z_-]{0,63}$/,lv=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,hv={javascript:!0,"javascript:":!0},Dh={javascript:!0,"javascript:":!0},Zs={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},Lh=ev;function cv(r,e,t){if(r&&typeof r=="object"&&r instanceof nr)return r;var i=new nr;return i.parse(r,e,t),i}nr.prototype.parse=function(r,e,t){if(typeof r!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof r);var i=r.indexOf("?"),s=i!==-1&&i127?E+="x":E+=v[C];if(!E.match(tu)){var P=b.slice(0,p),k=b.slice(p+1),N=v.match(lv);N&&(P.push(N[1]),k.unshift(N[2])),k.length&&(o="/"+k.join(".")+o),this.hostname=P.join(".");break}}}this.hostname.length>ov?this.hostname="":this.hostname=this.hostname.toLowerCase(),y||(this.hostname=tv.toASCII(this.hostname));var H=this.port?":"+this.port:"",T=this.hostname||"";this.host=T+H,this.href+=this.host,y&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),o[0]!=="/"&&(o="/"+o))}if(!hv[u])for(var p=0,A=Rh.length;p0?t.host.split("@"):!1;E&&(t.auth=E.shift(),t.hostname=E.shift(),t.host=t.hostname)}return t.search=r.search,t.query=r.query,(t.pathname!==null||t.search!==null)&&(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.href=t.format(),t}if(!b.length)return t.pathname=null,t.search?t.path="/"+t.search:t.path=null,t.href=t.format(),t;for(var C=b.slice(-1)[0],M=(t.host||r.host||b.length>1)&&(C==="."||C==="..")||C==="",P=0,k=b.length;k>=0;k--)C=b[k],C==="."?b.splice(k,1):C===".."?(b.splice(k,1),P++):P&&(b.splice(k,1),P--);if(!g&&!y)for(;P--;P)b.unshift("..");g&&b[0]!==""&&(!b[0]||b[0].charAt(0)!=="/")&&b.unshift(""),M&&b.join("/").substr(-1)!=="/"&&b.push("");var N=b[0]===""||b[0]&&b[0].charAt(0)==="/";if(v){t.hostname=N?"":b.length?b.shift():"",t.host=t.hostname;var E=t.host&&t.host.indexOf("@")>0?t.host.split("@"):!1;E&&(t.auth=E.shift(),t.hostname=E.shift(),t.host=t.hostname)}return g=g||t.host&&b.length,g&&!N&&b.unshift(""),b.length>0?t.pathname=b.join("/"):(t.pathname=null,t.path=null),(t.pathname!==null||t.search!==null)&&(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.auth=r.auth||t.auth,t.slashes=t.slashes||r.slashes,t.href=t.format(),t};nr.prototype.parseHost=function(){var r=this.host,e=rv.exec(r);e&&(e=e[0],e!==":"&&(this.port=e.substr(1)),r=r.substr(0,r.length-e.length)),r&&(this.hostname=r)};const iu={};function Le(r,e,t=3){if(iu[e])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${e} Deprecated since v${r}`):(i=i.split(` `).splice(t).join(` `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${e} Deprecated since v${r}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${e} -Deprecated since v${r}`),console.warn(i))),iu[e]=!0}function fi(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function Sn(r){return r.split("?")[0].split("#")[0]}function dv(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function uv(r,e,t){return r.replace(new RegExp(dv(e),"g"),t)}function pv(r,e){let t="",i=0,s=-1,n=0,a=-1;for(let o=0;o<=r.length;++o){if(o2){const l=t.lastIndexOf("/");if(l!==t.length-1){l===-1?(t="",i=0):(t=t.slice(0,l),i=t.length-1-t.lastIndexOf("/")),s=o,n=0;continue}}else if(t.length===2||t.length===1){t="",i=0,s=o,n=0;continue}}e&&(t.length>0?t+="/..":t="..",i=2)}else t.length>0?t+=`/${r.slice(s+1,o)}`:t=r.slice(s+1,o),i=o-s-1;s=o,n=0}else a===46&&n!==-1?++n:n=-1}return t}const Bt={toPosix(r){return uv(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){fi(r),r=this.toPosix(r);const e=/^file:\/\/\//.exec(r);if(e)return e[0];const t=/^[^/:]+:\/{0,2}/.exec(r);return t?t[0]:""},toAbsolute(r,e,t){if(fi(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=Sn(this.toPosix(e??de.ADAPTER.getBaseUrl())),s=Sn(this.toPosix(t??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?Bt.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(fi(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let e="";const t=r.startsWith("/");this.hasProtocol(r)&&(e=this.rootname(r),r=r.slice(e.length));const i=r.endsWith("/");return r=pv(r,!1),r.length>0&&i&&(r+="/"),t?`/${r}`:e+r},isAbsolute(r){return fi(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let e;for(let t=0;t0)if(e===void 0)e=i;else{const s=r[t-1]??"";this.extname(s)?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(fi(r),r.length===0)return".";r=this.toPosix(r);let e=r.charCodeAt(0);const t=e===47;let i=-1,s=!0;const n=this.getProtocol(r),a=r;r=r.slice(n.length);for(let o=r.length-1;o>=1;--o)if(e=r.charCodeAt(o),e===47){if(!s){i=o;break}}else s=!1;return i===-1?t?"/":this.isUrl(a)?n+r:n:t&&i===1?"//":n+r.slice(0,i)},rootname(r){fi(r),r=this.toPosix(r);let e="";if(r.startsWith("/")?e="/":e=this.getProtocol(r),this.isUrl(r)){const t=r.indexOf("/",e.length);t!==-1?e=r.slice(0,t):e=r,e.endsWith("/")||(e+="/")}return e},basename(r,e){fi(r),e&&fi(e),r=Sn(this.toPosix(r));let t=0,i=-1,s=!0,n;if(e!==void 0&&e.length>0&&e.length<=r.length){if(e.length===r.length&&e===r)return"";let a=e.length-1,o=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!s){t=n+1;break}}else o===-1&&(s=!1,o=n+1),a>=0&&(l===e.charCodeAt(a)?--a===-1&&(i=n):(a=-1,i=o))}return t===i?i=o:i===-1&&(i=r.length),r.slice(t,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){t=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(t,i)},extname(r){fi(r),r=Sn(this.toPosix(r));let e=-1,t=0,i=-1,s=!0,n=0;for(let a=r.length-1;a>=0;--a){const o=r.charCodeAt(a);if(o===47){if(!s){t=a+1;break}continue}i===-1&&(s=!1,i=a+1),o===46?e===-1?e=a:n!==1&&(n=1):e!==-1&&(n=-1)}return e===-1||i===-1||n===0||n===1&&e===i-1&&e===t+1?"":r.slice(e,i)},parse(r){fi(r);const e={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return e;r=Sn(this.toPosix(r));let t=r.charCodeAt(0);const i=this.isAbsolute(r);let s;e.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,a=0,o=-1,l=!0,c=r.length-1,u=0;for(;c>=s;--c){if(t=r.charCodeAt(c),t===47){if(!l){a=c+1;break}continue}o===-1&&(l=!1,o=c+1),t===46?n===-1?n=c:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||o===-1||u===0||u===1&&n===o-1&&n===a+1?o!==-1&&(a===0&&i?e.base=e.name=r.slice(1,o):e.base=e.name=r.slice(a,o)):(a===0&&i?(e.name=r.slice(1,n),e.base=r.slice(1,o)):(e.name=r.slice(a,n),e.base=r.slice(a,o)),e.ext=r.slice(n,o)),e.dir=this.dirname(r),e},sep:"/",delimiter:":"};let Rl;async function fv(){return Rl??(Rl=(async()=>{const r=document.createElement("canvas").getContext("webgl");if(!r)return Lt.UNPACK;const e=await new Promise(n=>{const a=document.createElement("video");a.onloadeddata=()=>n(a),a.onerror=()=>n(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!e)return Lt.UNPACK;const t=r.createTexture();r.bindTexture(r.TEXTURE_2D,t);const i=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,t,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,e);const s=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.deleteFramebuffer(i),r.deleteTexture(t),r.getExtension("WEBGL_lose_context")?.loseContext(),s[0]<=s[3]?Lt.PMA:Lt.UNPACK})()),Rl}let Dl;function mv(){return typeof Dl>"u"&&(Dl=function(){const r={stencil:!0,failIfMajorPerformanceCaveat:de.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!de.ADAPTER.getWebGLRenderingContext())return!1;const e=de.ADAPTER.createCanvas();let t=e.getContext("webgl",r)||e.getContext("experimental-webgl",r);const i=!!t?.getContextAttributes()?.stencil;if(t){const s=t.getExtension("WEBGL_lose_context");s&&s.loseContext()}return t=null,i}catch{return!1}}()),Dl}var gv={grad:.9,turn:360,rad:360/(2*Math.PI)},Ki=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},wt=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*r)/t+0},oi=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),r>t?t:r>e?r:e},Af=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},ru=function(r){return{r:oi(r.r,0,255),g:oi(r.g,0,255),b:oi(r.b,0,255),a:oi(r.a)}},Ll=function(r){return{r:wt(r.r),g:wt(r.g),b:wt(r.b),a:wt(r.a,3)}},yv=/^#([0-9a-f]{3,8})$/i,Sa=function(r){var e=r.toString(16);return e.length<2?"0"+e:e},wf=function(r){var e=r.r,t=r.g,i=r.b,s=r.a,n=Math.max(e,t,i),a=n-Math.min(e,t,i),o=a?n===e?(t-i)/a:n===t?2+(i-e)/a:4+(e-t)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:s}},xf=function(r){var e=r.h,t=r.s,i=r.v,s=r.a;e=e/360*6,t/=100,i/=100;var n=Math.floor(e),a=i*(1-t),o=i*(1-(e-n)*t),l=i*(1-(1-e+n)*t),c=n%6;return{r:255*[i,o,a,a,l,i][c],g:255*[l,i,i,o,a,a][c],b:255*[a,a,l,i,i,o][c],a:s}},su=function(r){return{h:Af(r.h),s:oi(r.s,0,100),l:oi(r.l,0,100),a:oi(r.a)}},nu=function(r){return{h:wt(r.h),s:wt(r.s),l:wt(r.l),a:wt(r.a,3)}},au=function(r){return xf((t=(e=r).s,{h:e.h,s:(t*=((i=e.l)<50?i:100-i)/100)>0?2*t/(i+t)*100:0,v:i+t,a:e.a}));var e,t,i},Qn=function(r){return{h:(e=wf(r)).h,s:(s=(200-(t=e.s))*(i=e.v)/100)>0&&s<200?t*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:e.a};var e,t,i,s},vv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Av=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wv=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Oh={string:[[function(r){var e=yv.exec(r);return e?(r=e[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?wt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?wt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var e=Av.exec(r)||wv.exec(r);return e?e[2]!==e[4]||e[4]!==e[6]?null:ru({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(r){var e=vv.exec(r)||bv.exec(r);if(!e)return null;var t,i,s=su({h:(t=e[1],i=e[2],i===void 0&&(i="deg"),Number(t)*(gv[i]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return au(s)},"hsl"]],object:[[function(r){var e=r.r,t=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return Ki(e)&&Ki(t)&&Ki(i)?ru({r:Number(e),g:Number(t),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var e=r.h,t=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!Ki(e)||!Ki(t)||!Ki(i))return null;var a=su({h:Number(e),s:Number(t),l:Number(i),a:Number(n)});return au(a)},"hsl"],[function(r){var e=r.h,t=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!Ki(e)||!Ki(t)||!Ki(i))return null;var a=function(o){return{h:Af(o.h),s:oi(o.s,0,100),v:oi(o.v,0,100),a:oi(o.a)}}({h:Number(e),s:Number(t),v:Number(i),a:Number(n)});return xf(a)},"hsv"]]},ou=function(r,e){for(var t=0;t=.5},r.prototype.toHex=function(){return e=Ll(this.rgba),t=e.r,i=e.g,s=e.b,a=(n=e.a)<1?Sa(wt(255*n)):"","#"+Sa(t)+Sa(i)+Sa(s)+a;var e,t,i,s,n,a},r.prototype.toRgb=function(){return Ll(this.rgba)},r.prototype.toRgbString=function(){return e=Ll(this.rgba),t=e.r,i=e.g,s=e.b,(n=e.a)<1?"rgba("+t+", "+i+", "+s+", "+n+")":"rgb("+t+", "+i+", "+s+")";var e,t,i,s,n},r.prototype.toHsl=function(){return nu(Qn(this.rgba))},r.prototype.toHslString=function(){return e=nu(Qn(this.rgba)),t=e.h,i=e.s,s=e.l,(n=e.a)<1?"hsla("+t+", "+i+"%, "+s+"%, "+n+")":"hsl("+t+", "+i+"%, "+s+"%)";var e,t,i,s,n},r.prototype.toHsv=function(){return e=wf(this.rgba),{h:wt(e.h),s:wt(e.s),v:wt(e.v),a:wt(e.a,3)};var e},r.prototype.invert=function(){return ki({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},r.prototype.saturate=function(e){return e===void 0&&(e=.1),ki(Ol(this.rgba,e))},r.prototype.desaturate=function(e){return e===void 0&&(e=.1),ki(Ol(this.rgba,-e))},r.prototype.grayscale=function(){return ki(Ol(this.rgba,-1))},r.prototype.lighten=function(e){return e===void 0&&(e=.1),ki(lu(this.rgba,e))},r.prototype.darken=function(e){return e===void 0&&(e=.1),ki(lu(this.rgba,-e))},r.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},r.prototype.alpha=function(e){return typeof e=="number"?ki({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):wt(this.rgba.a,3);var t},r.prototype.hue=function(e){var t=Qn(this.rgba);return typeof e=="number"?ki({h:e,s:t.s,l:t.l,a:t.a}):wt(t.h)},r.prototype.isEqual=function(e){return this.toHex()===ki(e).toHex()},r}(),ki=function(r){return r instanceof Fh?r:new Fh(r)},hu=[],_v=function(r){r.forEach(function(e){hu.indexOf(e)<0&&(e(Fh,Oh),hu.push(e))})};function Ev(r,e){var t={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var s in t)i[t[s]]=s;var n={};r.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,l,c=i[this.toHex()];if(c)return c;if(a?.closest){var u=this.toRgb(),h=1/0,d="black";if(!n.length)for(var p in t)n[p]=new r(t[p]).toRgb();for(var f in t){var m=(o=u,l=n[f],Math.pow(o.r-l.r,2)+Math.pow(o.g-l.g,2)+Math.pow(o.b-l.b,2));ms===t[n]);if(e!==null&&t!==null){const s=Object.keys(e),n=Object.keys(t);return s.length!==n.length?!1:s.every(a=>e[a]===t[a])}return e===t}toRgba(){const[e,t,i,s]=this._components;return{r:e,g:t,b:i,a:s}}toRgb(){const[e,t,i]=this._components;return{r:e,g:t,b:i}}toRgbaString(){const[e,t,i]=this.toUint8RgbArray();return`rgba(${e},${t},${i},${this.alpha})`}toUint8RgbArray(e){const[t,i,s]=this._components;return e=e??[],e[0]=Math.round(t*255),e[1]=Math.round(i*255),e[2]=Math.round(s*255),e}toRgbArray(e){e=e??[];const[t,i,s]=this._components;return e[0]=t,e[1]=i,e[2]=s,e}toNumber(){return this._int}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[t,i,s,n]=oo.temp.setValue(e)._components;return this._components[0]*=t,this._components[1]*=i,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this.refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return t&&(i=i*e+.5|0,s=s*e+.5|0,n=n*e+.5|0),(e*255<<24)+(i<<16)+(s<<8)+n}toHex(){const e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(e){return this._components[3]=this._clamp(e),this}round(e){const[t,i,s]=this._components;return this._components[0]=Math.round(t*e)/e,this._components[1]=Math.round(i*e)/e,this._components[2]=Math.round(s*e)/e,this.refreshInt(),this._value=null,this}toArray(e){e=e??[];const[t,i,s,n]=this._components;return e[0]=t,e[1]=i,e[2]=s,e[3]=n,e}normalize(e){let t,i,s,n;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const a=e;t=(a>>16&255)/255,i=(a>>8&255)/255,s=(a&255)/255,n=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[t,i,s,n=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[t,i,s,n=255]=e,t/=255,i/=255,s/=255,n/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const o=oo.HEX_PATTERN.exec(e);o&&(e=`#${o[2]}`)}const a=ki(e);a.isValid()&&({r:t,g:i,b:s,a:n}=a.rgba,t/=255,i/=255,s/=255)}if(t!==void 0)this._components[0]=t,this._components[1]=i,this._components[2]=s,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${e}`)}refreshInt(){this._clamp(this._components);const[e,t,i]=this._components;this._int=(e*255<<16)+(t*255<<8)+(i*255|0)}_clamp(e,t=0,i=1){return typeof e=="number"?Math.min(Math.max(e,t),i):(e.forEach((s,n)=>{e[n]=Math.min(Math.max(s,t),i)}),e)}};Ns.shared=new Ns,Ns.temp=new Ns,Ns.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Je=Ns;function Tv(r){return Le("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),Je.shared.setValue(r).toHex()}function Sv(r){return Le("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),Je.shared.setValue(r).toNumber()}function Cv(){const r=[],e=[];for(let i=0;i<32;i++)r[i]=i,e[i]=i;r[Ee.NORMAL_NPM]=Ee.NORMAL,r[Ee.ADD_NPM]=Ee.ADD,r[Ee.SCREEN_NPM]=Ee.SCREEN,e[Ee.NORMAL]=Ee.NORMAL_NPM,e[Ee.ADD]=Ee.ADD_NPM,e[Ee.SCREEN]=Ee.SCREEN_NPM;const t=[];return t.push(e),t.push(r),t}const _f=Cv();function Ef(r,e){return _f[e?1:0][r]}function Mv(r,e=null){const t=r*6;if(e=e||new Uint16Array(t),e.length!==t)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${t}`);for(let i=0,s=0;i>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function cu(r){return!(r&r-1)&&!!r}function du(r){let e=(r>65535?1:0)<<4;r>>>=e;let t=(r>255?1:0)<<3;return r>>>=t,e|=t,t=(r>15?1:0)<<2,r>>>=t,e|=t,t=(r>3?1:0)<<1,r>>>=t,e|=t,e|r>>1}function en(r,e,t){const i=r.length;let s;if(e>=i||t===0)return;t=e+t>i?i-e:t;const n=i-t;for(s=e;s(r.Renderer="renderer",r.Application="application",r.RendererSystem="renderer-webgl-system",r.RendererPlugin="renderer-webgl-plugin",r.CanvasRendererSystem="renderer-canvas-system",r.CanvasRendererPlugin="renderer-canvas-plugin",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r))(ae||{});const Uh=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},gu=(r,e)=>Uh(r).priority??e,me={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Uh).forEach(e=>{e.type.forEach(t=>this._removeHandlers[t]?.(e))}),this},add(...r){return r.map(Uh).forEach(e=>{e.type.forEach(t=>{const i=this._addHandlers,s=this._queue;i[t]?i[t](e):(s[t]=s[t]||[],s[t].push(e))})}),this},handle(r,e,t){const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=e,s[r]=t;const n=this._queue;return n[r]&&(n[r].forEach(a=>e(a)),delete n[r]),this},handleByMap(r,e){return this.handle(r,t=>{e[t.name]=t.ref},t=>{delete e[t.name]})},handleByList(r,e,t=-1){return this.handle(r,i=>{e.includes(i.ref)||(e.push(i.ref),e.sort((s,n)=>gu(n,t)-gu(s,t)))},i=>{const s=e.indexOf(i.ref);s!==-1&&e.splice(s,1)})}};class Gh{constructor(e){typeof e=="number"?this.rawBinaryData=new ArrayBuffer(e):e instanceof Uint8Array?this.rawBinaryData=e.buffer:this.rawBinaryData=e,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(e){return this[`${e}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${e} isn't a valid view type`)}}}const Dv=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` +Deprecated since v${r}`),console.warn(i))),iu[e]=!0}function fi(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function Sn(r){return r.split("?")[0].split("#")[0]}function dv(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function uv(r,e,t){return r.replace(new RegExp(dv(e),"g"),t)}function pv(r,e){let t="",i=0,s=-1,n=0,a=-1;for(let o=0;o<=r.length;++o){if(o2){const l=t.lastIndexOf("/");if(l!==t.length-1){l===-1?(t="",i=0):(t=t.slice(0,l),i=t.length-1-t.lastIndexOf("/")),s=o,n=0;continue}}else if(t.length===2||t.length===1){t="",i=0,s=o,n=0;continue}}e&&(t.length>0?t+="/..":t="..",i=2)}else t.length>0?t+=`/${r.slice(s+1,o)}`:t=r.slice(s+1,o),i=o-s-1;s=o,n=0}else a===46&&n!==-1?++n:n=-1}return t}const Bt={toPosix(r){return uv(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){fi(r),r=this.toPosix(r);const e=/^file:\/\/\//.exec(r);if(e)return e[0];const t=/^[^/:]+:\/{0,2}/.exec(r);return t?t[0]:""},toAbsolute(r,e,t){if(fi(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=Sn(this.toPosix(e??de.ADAPTER.getBaseUrl())),s=Sn(this.toPosix(t??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?Bt.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(fi(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let e="";const t=r.startsWith("/");this.hasProtocol(r)&&(e=this.rootname(r),r=r.slice(e.length));const i=r.endsWith("/");return r=pv(r,!1),r.length>0&&i&&(r+="/"),t?`/${r}`:e+r},isAbsolute(r){return fi(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let e;for(let t=0;t0)if(e===void 0)e=i;else{const s=r[t-1]??"";this.extname(s)?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(fi(r),r.length===0)return".";r=this.toPosix(r);let e=r.charCodeAt(0);const t=e===47;let i=-1,s=!0;const n=this.getProtocol(r),a=r;r=r.slice(n.length);for(let o=r.length-1;o>=1;--o)if(e=r.charCodeAt(o),e===47){if(!s){i=o;break}}else s=!1;return i===-1?t?"/":this.isUrl(a)?n+r:n:t&&i===1?"//":n+r.slice(0,i)},rootname(r){fi(r),r=this.toPosix(r);let e="";if(r.startsWith("/")?e="/":e=this.getProtocol(r),this.isUrl(r)){const t=r.indexOf("/",e.length);t!==-1?e=r.slice(0,t):e=r,e.endsWith("/")||(e+="/")}return e},basename(r,e){fi(r),e&&fi(e),r=Sn(this.toPosix(r));let t=0,i=-1,s=!0,n;if(e!==void 0&&e.length>0&&e.length<=r.length){if(e.length===r.length&&e===r)return"";let a=e.length-1,o=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!s){t=n+1;break}}else o===-1&&(s=!1,o=n+1),a>=0&&(l===e.charCodeAt(a)?--a===-1&&(i=n):(a=-1,i=o))}return t===i?i=o:i===-1&&(i=r.length),r.slice(t,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){t=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(t,i)},extname(r){fi(r),r=Sn(this.toPosix(r));let e=-1,t=0,i=-1,s=!0,n=0;for(let a=r.length-1;a>=0;--a){const o=r.charCodeAt(a);if(o===47){if(!s){t=a+1;break}continue}i===-1&&(s=!1,i=a+1),o===46?e===-1?e=a:n!==1&&(n=1):e!==-1&&(n=-1)}return e===-1||i===-1||n===0||n===1&&e===i-1&&e===t+1?"":r.slice(e,i)},parse(r){fi(r);const e={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return e;r=Sn(this.toPosix(r));let t=r.charCodeAt(0);const i=this.isAbsolute(r);let s;e.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,a=0,o=-1,l=!0,c=r.length-1,u=0;for(;c>=s;--c){if(t=r.charCodeAt(c),t===47){if(!l){a=c+1;break}continue}o===-1&&(l=!1,o=c+1),t===46?n===-1?n=c:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||o===-1||u===0||u===1&&n===o-1&&n===a+1?o!==-1&&(a===0&&i?e.base=e.name=r.slice(1,o):e.base=e.name=r.slice(a,o)):(a===0&&i?(e.name=r.slice(1,n),e.base=r.slice(1,o)):(e.name=r.slice(a,n),e.base=r.slice(a,o)),e.ext=r.slice(n,o)),e.dir=this.dirname(r),e},sep:"/",delimiter:":"};let Rl;async function fv(){return Rl??(Rl=(async()=>{const r=document.createElement("canvas").getContext("webgl");if(!r)return Lt.UNPACK;const e=await new Promise(n=>{const a=document.createElement("video");a.onloadeddata=()=>n(a),a.onerror=()=>n(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!e)return Lt.UNPACK;const t=r.createTexture();r.bindTexture(r.TEXTURE_2D,t);const i=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,t,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,e);const s=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.deleteFramebuffer(i),r.deleteTexture(t),r.getExtension("WEBGL_lose_context")?.loseContext(),s[0]<=s[3]?Lt.PMA:Lt.UNPACK})()),Rl}let Dl;function mv(){return typeof Dl>"u"&&(Dl=function(){const r={stencil:!0,failIfMajorPerformanceCaveat:de.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!de.ADAPTER.getWebGLRenderingContext())return!1;const e=de.ADAPTER.createCanvas();let t=e.getContext("webgl",r)||e.getContext("experimental-webgl",r);const i=!!t?.getContextAttributes()?.stencil;if(t){const s=t.getExtension("WEBGL_lose_context");s&&s.loseContext()}return t=null,i}catch{return!1}}()),Dl}var gv={grad:.9,turn:360,rad:360/(2*Math.PI)},Ki=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},wt=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*r)/t+0},oi=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),r>t?t:r>e?r:e},Af=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},ru=function(r){return{r:oi(r.r,0,255),g:oi(r.g,0,255),b:oi(r.b,0,255),a:oi(r.a)}},Ll=function(r){return{r:wt(r.r),g:wt(r.g),b:wt(r.b),a:wt(r.a,3)}},yv=/^#([0-9a-f]{3,8})$/i,Sa=function(r){var e=r.toString(16);return e.length<2?"0"+e:e},wf=function(r){var e=r.r,t=r.g,i=r.b,s=r.a,n=Math.max(e,t,i),a=n-Math.min(e,t,i),o=a?n===e?(t-i)/a:n===t?2+(i-e)/a:4+(e-t)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:s}},xf=function(r){var e=r.h,t=r.s,i=r.v,s=r.a;e=e/360*6,t/=100,i/=100;var n=Math.floor(e),a=i*(1-t),o=i*(1-(e-n)*t),l=i*(1-(1-e+n)*t),c=n%6;return{r:255*[i,o,a,a,l,i][c],g:255*[l,i,i,o,a,a][c],b:255*[a,a,l,i,i,o][c],a:s}},su=function(r){return{h:Af(r.h),s:oi(r.s,0,100),l:oi(r.l,0,100),a:oi(r.a)}},nu=function(r){return{h:wt(r.h),s:wt(r.s),l:wt(r.l),a:wt(r.a,3)}},au=function(r){return xf((t=(e=r).s,{h:e.h,s:(t*=((i=e.l)<50?i:100-i)/100)>0?2*t/(i+t)*100:0,v:i+t,a:e.a}));var e,t,i},Qn=function(r){return{h:(e=wf(r)).h,s:(s=(200-(t=e.s))*(i=e.v)/100)>0&&s<200?t*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:e.a};var e,t,i,s},vv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Av=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wv=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Oh={string:[[function(r){var e=yv.exec(r);return e?(r=e[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?wt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?wt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var e=Av.exec(r)||wv.exec(r);return e?e[2]!==e[4]||e[4]!==e[6]?null:ru({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(r){var e=vv.exec(r)||bv.exec(r);if(!e)return null;var t,i,s=su({h:(t=e[1],i=e[2],i===void 0&&(i="deg"),Number(t)*(gv[i]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return au(s)},"hsl"]],object:[[function(r){var e=r.r,t=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return Ki(e)&&Ki(t)&&Ki(i)?ru({r:Number(e),g:Number(t),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var e=r.h,t=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!Ki(e)||!Ki(t)||!Ki(i))return null;var a=su({h:Number(e),s:Number(t),l:Number(i),a:Number(n)});return au(a)},"hsl"],[function(r){var e=r.h,t=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!Ki(e)||!Ki(t)||!Ki(i))return null;var a=function(o){return{h:Af(o.h),s:oi(o.s,0,100),v:oi(o.v,0,100),a:oi(o.a)}}({h:Number(e),s:Number(t),v:Number(i),a:Number(n)});return xf(a)},"hsv"]]},ou=function(r,e){for(var t=0;t=.5},r.prototype.toHex=function(){return e=Ll(this.rgba),t=e.r,i=e.g,s=e.b,a=(n=e.a)<1?Sa(wt(255*n)):"","#"+Sa(t)+Sa(i)+Sa(s)+a;var e,t,i,s,n,a},r.prototype.toRgb=function(){return Ll(this.rgba)},r.prototype.toRgbString=function(){return e=Ll(this.rgba),t=e.r,i=e.g,s=e.b,(n=e.a)<1?"rgba("+t+", "+i+", "+s+", "+n+")":"rgb("+t+", "+i+", "+s+")";var e,t,i,s,n},r.prototype.toHsl=function(){return nu(Qn(this.rgba))},r.prototype.toHslString=function(){return e=nu(Qn(this.rgba)),t=e.h,i=e.s,s=e.l,(n=e.a)<1?"hsla("+t+", "+i+"%, "+s+"%, "+n+")":"hsl("+t+", "+i+"%, "+s+"%)";var e,t,i,s,n},r.prototype.toHsv=function(){return e=wf(this.rgba),{h:wt(e.h),s:wt(e.s),v:wt(e.v),a:wt(e.a,3)};var e},r.prototype.invert=function(){return ki({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},r.prototype.saturate=function(e){return e===void 0&&(e=.1),ki(Ol(this.rgba,e))},r.prototype.desaturate=function(e){return e===void 0&&(e=.1),ki(Ol(this.rgba,-e))},r.prototype.grayscale=function(){return ki(Ol(this.rgba,-1))},r.prototype.lighten=function(e){return e===void 0&&(e=.1),ki(lu(this.rgba,e))},r.prototype.darken=function(e){return e===void 0&&(e=.1),ki(lu(this.rgba,-e))},r.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},r.prototype.alpha=function(e){return typeof e=="number"?ki({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):wt(this.rgba.a,3);var t},r.prototype.hue=function(e){var t=Qn(this.rgba);return typeof e=="number"?ki({h:e,s:t.s,l:t.l,a:t.a}):wt(t.h)},r.prototype.isEqual=function(e){return this.toHex()===ki(e).toHex()},r}(),ki=function(r){return r instanceof Fh?r:new Fh(r)},hu=[],_v=function(r){r.forEach(function(e){hu.indexOf(e)<0&&(e(Fh,Oh),hu.push(e))})};function Ev(r,e){var t={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var s in t)i[t[s]]=s;var n={};r.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,l,c=i[this.toHex()];if(c)return c;if(a?.closest){var u=this.toRgb(),h=1/0,d="black";if(!n.length)for(var p in t)n[p]=new r(t[p]).toRgb();for(var f in t){var m=(o=u,l=n[f],Math.pow(o.r-l.r,2)+Math.pow(o.g-l.g,2)+Math.pow(o.b-l.b,2));ms===t[n]);if(e!==null&&t!==null){const s=Object.keys(e),n=Object.keys(t);return s.length!==n.length?!1:s.every(a=>e[a]===t[a])}return e===t}toRgba(){const[e,t,i,s]=this._components;return{r:e,g:t,b:i,a:s}}toRgb(){const[e,t,i]=this._components;return{r:e,g:t,b:i}}toRgbaString(){const[e,t,i]=this.toUint8RgbArray();return`rgba(${e},${t},${i},${this.alpha})`}toUint8RgbArray(e){const[t,i,s]=this._components;return e=e??[],e[0]=Math.round(t*255),e[1]=Math.round(i*255),e[2]=Math.round(s*255),e}toRgbArray(e){e=e??[];const[t,i,s]=this._components;return e[0]=t,e[1]=i,e[2]=s,e}toNumber(){return this._int}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[t,i,s,n]=oo.temp.setValue(e)._components;return this._components[0]*=t,this._components[1]*=i,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this.refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return t&&(i=i*e+.5|0,s=s*e+.5|0,n=n*e+.5|0),(e*255<<24)+(i<<16)+(s<<8)+n}toHex(){const e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(e){return this._components[3]=this._clamp(e),this}round(e){const[t,i,s]=this._components;return this._components[0]=Math.round(t*e)/e,this._components[1]=Math.round(i*e)/e,this._components[2]=Math.round(s*e)/e,this.refreshInt(),this._value=null,this}toArray(e){e=e??[];const[t,i,s,n]=this._components;return e[0]=t,e[1]=i,e[2]=s,e[3]=n,e}normalize(e){let t,i,s,n;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const a=e;t=(a>>16&255)/255,i=(a>>8&255)/255,s=(a&255)/255,n=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[t,i,s,n=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[t,i,s,n=255]=e,t/=255,i/=255,s/=255,n/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const o=oo.HEX_PATTERN.exec(e);o&&(e=`#${o[2]}`)}const a=ki(e);a.isValid()&&({r:t,g:i,b:s,a:n}=a.rgba,t/=255,i/=255,s/=255)}if(t!==void 0)this._components[0]=t,this._components[1]=i,this._components[2]=s,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${e}`)}refreshInt(){this._clamp(this._components);const[e,t,i]=this._components;this._int=(e*255<<16)+(t*255<<8)+(i*255|0)}_clamp(e,t=0,i=1){return typeof e=="number"?Math.min(Math.max(e,t),i):(e.forEach((s,n)=>{e[n]=Math.min(Math.max(s,t),i)}),e)}};Ns.shared=new Ns,Ns.temp=new Ns,Ns.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Je=Ns;function Tv(r){return Le("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),Je.shared.setValue(r).toHex()}function Sv(r){return Le("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),Je.shared.setValue(r).toNumber()}function Cv(){const r=[],e=[];for(let i=0;i<32;i++)r[i]=i,e[i]=i;r[Ee.NORMAL_NPM]=Ee.NORMAL,r[Ee.ADD_NPM]=Ee.ADD,r[Ee.SCREEN_NPM]=Ee.SCREEN,e[Ee.NORMAL]=Ee.NORMAL_NPM,e[Ee.ADD]=Ee.ADD_NPM,e[Ee.SCREEN]=Ee.SCREEN_NPM;const t=[];return t.push(e),t.push(r),t}const _f=Cv();function Ef(r,e){return _f[e?1:0][r]}function Mv(r,e=null){const t=r*6;if(e=e||new Uint16Array(t),e.length!==t)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${t}`);for(let i=0,s=0;i>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function cu(r){return!(r&r-1)&&!!r}function du(r){let e=(r>65535?1:0)<<4;r>>>=e;let t=(r>255?1:0)<<3;return r>>>=t,e|=t,t=(r>15?1:0)<<2,r>>>=t,e|=t,t=(r>3?1:0)<<1,r>>>=t,e|=t,e|r>>1}function en(r,e,t){const i=r.length;let s;if(e>=i||t===0)return;t=e+t>i?i-e:t;const n=i-t;for(s=e;s(r.Renderer="renderer",r.Application="application",r.RendererSystem="renderer-webgl-system",r.RendererPlugin="renderer-webgl-plugin",r.CanvasRendererSystem="renderer-canvas-system",r.CanvasRendererPlugin="renderer-canvas-plugin",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r))(ae||{});const Uh=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},gu=(r,e)=>Uh(r).priority??e,me={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Uh).forEach(e=>{e.type.forEach(t=>this._removeHandlers[t]?.(e))}),this},add(...r){return r.map(Uh).forEach(e=>{e.type.forEach(t=>{const i=this._addHandlers,s=this._queue;i[t]?i[t](e):(s[t]=s[t]||[],s[t].push(e))})}),this},handle(r,e,t){const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=e,s[r]=t;const n=this._queue;return n[r]&&(n[r].forEach(a=>e(a)),delete n[r]),this},handleByMap(r,e){return this.handle(r,t=>{e[t.name]=t.ref},t=>{delete e[t.name]})},handleByList(r,e,t=-1){return this.handle(r,i=>{e.includes(i.ref)||(e.push(i.ref),e.sort((s,n)=>gu(n,t)-gu(s,t)))},i=>{const s=e.indexOf(i.ref);s!==-1&&e.splice(s,1)})}};class Gh{constructor(e){typeof e=="number"?this.rawBinaryData=new ArrayBuffer(e):e instanceof Uint8Array?this.rawBinaryData=e.buffer:this.rawBinaryData=e,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(e){return this[`${e}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${e} isn't a valid view type`)}}}const Dv=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` `);function Lv(r){let e="";for(let t=0;t0&&(e+=` -else `),t=0;--i){const s=Hh[i];if(s.test&&s.test(r,t))return new s(r,e)}throw new Error("Unrecognized source type to auto-detect Resource")}class Ei{constructor(e){this.items=[],this._name=e,this._aliasCount=0}emit(e,t,i,s,n,a,o,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:c,items:u}=this;this._aliasCount++;for(let h=0,d=u.length;h0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(e){return e[this._name]&&(this.ensureNonAliasedItems(),this.remove(e),this.items.push(e)),this}remove(e){const t=this.items.indexOf(e);return t!==-1&&(this.ensureNonAliasedItems(),this.items.splice(t,1)),this}contains(e){return this.items.includes(e)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(Ei.prototype,{dispatch:{value:Ei.prototype.emit},run:{value:Ei.prototype.emit}});class sa{constructor(e=0,t=0){this._width=e,this._height=t,this.destroyed=!1,this.internal=!1,this.onResize=new Ei("setRealSize"),this.onUpdate=new Ei("update"),this.onError=new Ei("onError")}bind(e){this.onResize.add(e),this.onUpdate.add(e),this.onError.add(e),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(e){this.onResize.remove(e),this.onUpdate.remove(e),this.onError.remove(e)}resize(e,t){(e!==this._width||t!==this._height)&&(this._width=e,this._height=t,this.onResize.emit(e,t))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(e,t,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(e,t){return!1}}class Qo extends sa{constructor(e,t){const{width:i,height:s}=t||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=e,this.unpackAlignment=t.unpackAlignment??4}upload(e,t,i){const s=e.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.alphaMode===Lt.UNPACK);const n=t.realWidth,a=t.realHeight;return i.width===n&&i.height===a?s.texSubImage2D(t.target,0,0,0,n,a,t.format,i.type,this.data):(i.width=n,i.height=a,s.texImage2D(t.target,0,i.internalFormat,n,a,0,t.format,i.type,this.data)),!0}dispose(){this.data=null}static test(e){return e===null||e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}}const Fv={scaleMode:er.NEAREST,alphaMode:Lt.NPM},Wh=class Us extends bn{constructor(e=null,t=null){super(),t=Object.assign({},Us.defaultOptions,t);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:a,width:o,height:l,wrapMode:c,format:u,type:h,target:d,resolution:p,resourceOptions:f}=t;e&&!(e instanceof sa)&&(e=Sf(e,f),e.internal=!0),this.resolution=p||de.RESOLUTION,this.width=Math.round((o||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=c,this._scaleMode=a,this.format=u,this.type=h,this.target=d,this.alphaMode=i,this.uid=bs(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=o>0&&l>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(e)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(e){this._mipmap!==e&&(this._mipmap=e,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(e){this._scaleMode!==e&&(this._scaleMode=e,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(e){this._wrapMode!==e&&(this._wrapMode=e,this.dirtyStyleId++)}setStyle(e,t){let i;return e!==void 0&&e!==this.scaleMode&&(this.scaleMode=e,i=!0),t!==void 0&&t!==this.mipmap&&(this.mipmap=t,i=!0),i&&this.dirtyStyleId++,this}setSize(e,t,i){return i=i||this.resolution,this.setRealSize(e*i,t*i,i)}setRealSize(e,t,i){return this.resolution=i||this.resolution,this.width=Math.round(e)/this.resolution,this.height=Math.round(t)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=cu(this.realWidth)&&cu(this.realHeight)}setResolution(e){const t=this.resolution;return t===e?this:(this.resolution=e,this.valid&&(this.width=Math.round(this.width*t)/e,this.height=Math.round(this.height*t)/e,this.emit("update",this)),this._refreshPOT(),this)}setResource(e){if(this.resource===e)return this;if(this.resource)throw new Error("Resource can be set only once");return e.bind(this),this.resource=e,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(e){this.emit("error",this,e)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete ur[this.cacheId],delete Bi[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),Us.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(e,t,i=de.STRICT_TEXTURE_CACHE){const s=typeof e=="string";let n=null;if(s)n=e;else{if(!e._pixiId){const o=t?.pixiIdPrefix||"pixiid";e._pixiId=`${o}_${bs()}`}n=e._pixiId}let a=ur[n];if(s&&i&&!a)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return a||(a=new Us(e,t),a.cacheId=n,Us.addToCache(a,n)),a}static fromBuffer(e,t,i,s){e=e||new Float32Array(t*i*4);const n=new Qo(e,{width:t,height:i,...s?.resourceOptions});let a,o;return e instanceof Float32Array?(a=re.RGBA,o=we.FLOAT):e instanceof Int32Array?(a=re.RGBA_INTEGER,o=we.INT):e instanceof Uint32Array?(a=re.RGBA_INTEGER,o=we.UNSIGNED_INT):e instanceof Int16Array?(a=re.RGBA_INTEGER,o=we.SHORT):e instanceof Uint16Array?(a=re.RGBA_INTEGER,o=we.UNSIGNED_SHORT):e instanceof Int8Array?(a=re.RGBA,o=we.BYTE):(a=re.RGBA,o=we.UNSIGNED_BYTE),n.internal=!0,new Us(n,Object.assign({},Fv,{type:o,format:a},s))}static addToCache(e,t){t&&(e.textureCacheIds.includes(t)||e.textureCacheIds.push(t),ur[t]&&ur[t]!==e&&console.warn(`BaseTexture added to the cache with an id [${t}] that already had an entry`),ur[t]=e)}static removeFromCache(e){if(typeof e=="string"){const t=ur[e];if(t){const i=t.textureCacheIds.indexOf(e);return i>-1&&t.textureCacheIds.splice(i,1),delete ur[e],t}}else if(e?.textureCacheIds){for(let t=0;t1){for(let h=0;h(r[r.POLY=0]="POLY",r[r.RECT=1]="RECT",r[r.CIRC=2]="CIRC",r[r.ELIP=3]="ELIP",r[r.RREC=4]="RREC",r))(Et||{});class Ue{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new Ue(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}}Ue.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Ca=[new Ue,new Ue,new Ue,new Ue];class Se{constructor(e=0,t=0,i=0,s=0){this.x=Number(e),this.y=Number(t),this.width=Number(i),this.height=Number(s),this.type=Et.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new Se(0,0,0,0)}clone(){return new Se(this.x,this.y,this.width,this.height)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e=this.y&&te.right?e.right:this.right)<=P)return!1;const k=this.ye.bottom?e.bottom:this.bottom)>k}const i=this.left,s=this.right,n=this.top,a=this.bottom;if(s<=i||a<=n)return!1;const o=Ca[0].set(e.left,e.top),l=Ca[1].set(e.left,e.bottom),c=Ca[2].set(e.right,e.top),u=Ca[3].set(e.right,e.bottom);if(c.x<=o.x||l.y<=o.y)return!1;const h=Math.sign(t.a*t.d-t.b*t.c);if(h===0||(t.apply(o,o),t.apply(l,l),t.apply(c,c),t.apply(u,u),Math.max(o.x,l.x,c.x,u.x)<=i||Math.min(o.x,l.x,c.x,u.x)>=s||Math.max(o.y,l.y,c.y,u.y)<=n||Math.min(o.y,l.y,c.y,u.y)>=a))return!1;const d=h*(l.y-o.y),p=h*(o.x-l.x),f=d*i+p*n,m=d*s+p*n,g=d*i+p*a,y=d*s+p*a;if(Math.max(f,m,g,y)<=d*o.x+p*o.y||Math.min(f,m,g,y)>=d*u.x+p*u.y)return!1;const b=h*(o.y-c.y),A=h*(c.x-o.x),v=b*i+A*n,E=b*s+A*n,C=b*i+A*a,M=b*s+A*a;return!(Math.max(v,E,C,M)<=b*o.x+A*o.y||Math.min(v,E,C,M)>=b*u.x+A*u.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),i=Math.min(this.x+this.width,e.x+e.width),s=Math.max(this.y,e.y),n=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(i-t,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(e=1,t=.001){const i=Math.ceil((this.x+this.width-t)*e)/e,s=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=i-this.x,this.height=s-this.y,this}enlarge(e){const t=Math.min(this.x,e.x),i=Math.max(this.x+this.width,e.x+e.width),s=Math.min(this.y,e.y),n=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=i-t,this.y=s,this.height=n-s,this}}Se.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class $o{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.radius=i,this.type=Et.CIRC}clone(){return new $o(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-e,n=this.y-t;return s*=s,n*=n,s+n<=i}getBounds(){return new Se(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}$o.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Jo{constructor(e=0,t=0,i=0,s=0){this.x=e,this.y=t,this.width=i,this.height=s,this.type=Et.ELIP}clone(){return new Jo(this.x,this.y,this.width,this.height)}contains(e,t){if(this.width<=0||this.height<=0)return!1;let i=(e-this.x)/this.width,s=(t-this.y)/this.height;return i*=i,s*=s,i+s<=1}getBounds(){return new Se(this.x-this.width,this.y-this.height,this.width,this.height)}}Jo.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class us{constructor(...e){let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){const i=[];for(let s=0,n=t.length;st!=u>t&&e<(c-o)*((t-l)/(u-l))+o&&(i=!i)}return i}}us.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,e)=>`${r}, ${e}`,"")}]`};class Zo{constructor(e=0,t=0,i=0,s=0,n=20){this.x=e,this.y=t,this.width=i,this.height=s,this.radius=n,this.type=Et.RREC}clone(){return new Zo(this.x,this.y,this.width,this.height,this.radius)}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+i&&t<=this.y+this.height-i||e>=this.x+i&&e<=this.x+this.width-i)return!0;let s=e-(this.x+i),n=t-(this.y+i);const a=i*i;if(s*s+n*n<=a||(s=e-(this.x+this.width-i),s*s+n*n<=a)||(n=t-(this.y+this.height-i),s*s+n*n<=a)||(s=e-(this.x+i),s*s+n*n<=a))return!0}return!1}}Zo.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class et{constructor(e=1,t=0,i=0,s=1,n=0,a=0){this.array=null,this.a=e,this.b=t,this.c=i,this.d=s,this.tx=n,this.ty=a}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,i,s,n,a){return this.a=e,this.b=t,this.c=i,this.d=s,this.tx=n,this.ty=a,this}toArray(e,t){this.array||(this.array=new Float32Array(9));const i=t||this.array;return e?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(e,t){t=t||new Ue;const i=e.x,s=e.y;return t.x=this.a*i+this.c*s+this.tx,t.y=this.b*i+this.d*s+this.ty,t}applyInverse(e,t){t=t||new Ue;const i=1/(this.a*this.d+this.c*-this.b),s=e.x,n=e.y;return t.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,t.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){const t=Math.cos(e),i=Math.sin(e),s=this.a,n=this.c,a=this.tx;return this.a=s*t-this.b*i,this.b=s*i+this.b*t,this.c=n*t-this.d*i,this.d=n*i+this.d*t,this.tx=a*t-this.ty*i,this.ty=a*i+this.ty*t,this}append(e){const t=this.a,i=this.b,s=this.c,n=this.d;return this.a=e.a*t+e.b*s,this.b=e.a*i+e.b*n,this.c=e.c*t+e.d*s,this.d=e.c*i+e.d*n,this.tx=e.tx*t+e.ty*s+this.tx,this.ty=e.tx*i+e.ty*n+this.ty,this}setTransform(e,t,i,s,n,a,o,l,c){return this.a=Math.cos(o+c)*n,this.b=Math.sin(o+c)*n,this.c=-Math.sin(o-l)*a,this.d=Math.cos(o-l)*a,this.tx=e-(i*this.a+s*this.c),this.ty=t-(i*this.b+s*this.d),this}prepend(e){const t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const i=this.a,s=this.c;this.a=i*e.a+this.b*e.c,this.b=i*e.b+this.b*e.d,this.c=s*e.a+this.d*e.c,this.d=s*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){const t=this.a,i=this.b,s=this.c,n=this.d,a=e.pivot,o=-Math.atan2(-s,n),l=Math.atan2(i,t),c=Math.abs(o+l);return c<1e-5||Math.abs(So-c)<1e-5?(e.rotation=l,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=o,e.skew.y=l),e.scale.x=Math.sqrt(t*t+i*i),e.scale.y=Math.sqrt(s*s+n*n),e.position.x=this.tx+(a.x*t+a.y*s),e.position.y=this.ty+(a.x*i+a.y*n),e}invert(){const e=this.a,t=this.b,i=this.c,s=this.d,n=this.tx,a=e*s-t*i;return this.a=s/a,this.b=-t/a,this.c=-i/a,this.d=e/a,this.tx=(i*this.ty-s*n)/a,this.ty=-(e*this.ty-t*n)/a,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const e=new et;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}static get IDENTITY(){return new et}static get TEMP_MATRIX(){return new et}}et.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const Kr=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],qr=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Qr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],$r=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],zh=[],If=[],Ma=Math.sign;function jv(){for(let r=0;r<16;r++){const e=[];zh.push(e);for(let t=0;t<16;t++){const i=Ma(Kr[r]*Kr[t]+Qr[r]*qr[t]),s=Ma(qr[r]*Kr[t]+$r[r]*qr[t]),n=Ma(Kr[r]*Qr[t]+Qr[r]*$r[t]),a=Ma(qr[r]*Qr[t]+$r[r]*$r[t]);for(let o=0;o<16;o++)if(Kr[o]===i&&qr[o]===s&&Qr[o]===n&&$r[o]===a){e.push(o);break}}}for(let r=0;r<16;r++){const e=new et;e.set(Kr[r],qr[r],Qr[r],$r[r],0,0),If.push(e)}}jv();const nt={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>Kr[r],uY:r=>qr[r],vX:r=>Qr[r],vY:r=>$r[r],inv:r=>r&8?r&15:-r&7,add:(r,e)=>zh[r][e],sub:(r,e)=>zh[r][nt.inv(e)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,e)=>Math.abs(r)*2<=Math.abs(e)?e>=0?nt.S:nt.N:Math.abs(e)*2<=Math.abs(r)?r>0?nt.E:nt.W:e>0?r>0?nt.SE:nt.SW:r>0?nt.NE:nt.NW,matrixAppendRotationInv:(r,e,t=0,i=0)=>{const s=If[nt.inv(e)];s.tx=t,s.ty=i,r.append(s)}};class ir{constructor(e,t,i=0,s=0){this._x=i,this._y=s,this.cb=e,this.scope=t}clone(e=this.cb,t=this.scope){return new ir(e,t,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this.cb.call(this.scope)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this.cb.call(this.scope)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this.cb.call(this.scope))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this.cb.call(this.scope))}}ir.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const jh=class{constructor(){this.worldTransform=new et,this.localTransform=new et,this.position=new ir(this.onChange,this,0,0),this.scale=new ir(this.onChange,this,1,1),this.pivot=new ir(this.onChange,this,0,0),this.skew=new ir(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const r=this.localTransform;this._localID!==this._currentLocalID&&(r.a=this._cx*this.scale.x,r.b=this._sx*this.scale.x,r.c=this._cy*this.scale.y,r.d=this._sy*this.scale.y,r.tx=this.position.x-(this.pivot.x*r.a+this.pivot.y*r.c),r.ty=this.position.y-(this.pivot.x*r.b+this.pivot.y*r.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(r){const e=this.localTransform;if(this._localID!==this._currentLocalID&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==r._worldID){const t=r.worldTransform,i=this.worldTransform;i.a=e.a*t.a+e.b*t.c,i.b=e.a*t.b+e.b*t.d,i.c=e.c*t.a+e.d*t.c,i.d=e.c*t.b+e.d*t.d,i.tx=e.tx*t.a+e.ty*t.c+t.tx,i.ty=e.tx*t.b+e.ty*t.d+t.ty,this._parentID=r._worldID,this._worldID++}}setFromMatrix(r){r.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(r){this._rotation!==r&&(this._rotation=r,this.updateSkew())}};jh.IDENTITY=new jh;let el=jh;el.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var Yv=`varying vec2 vTextureCoord; +else `),t=0;--i){const s=Hh[i];if(s.test&&s.test(r,t))return new s(r,e)}throw new Error("Unrecognized source type to auto-detect Resource")}class Ei{constructor(e){this.items=[],this._name=e,this._aliasCount=0}emit(e,t,i,s,n,a,o,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:c,items:u}=this;this._aliasCount++;for(let h=0,d=u.length;h0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(e){return e[this._name]&&(this.ensureNonAliasedItems(),this.remove(e),this.items.push(e)),this}remove(e){const t=this.items.indexOf(e);return t!==-1&&(this.ensureNonAliasedItems(),this.items.splice(t,1)),this}contains(e){return this.items.includes(e)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(Ei.prototype,{dispatch:{value:Ei.prototype.emit},run:{value:Ei.prototype.emit}});class sa{constructor(e=0,t=0){this._width=e,this._height=t,this.destroyed=!1,this.internal=!1,this.onResize=new Ei("setRealSize"),this.onUpdate=new Ei("update"),this.onError=new Ei("onError")}bind(e){this.onResize.add(e),this.onUpdate.add(e),this.onError.add(e),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(e){this.onResize.remove(e),this.onUpdate.remove(e),this.onError.remove(e)}resize(e,t){(e!==this._width||t!==this._height)&&(this._width=e,this._height=t,this.onResize.emit(e,t))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(e,t,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(e,t){return!1}}class Qo extends sa{constructor(e,t){const{width:i,height:s}=t||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=e,this.unpackAlignment=t.unpackAlignment??4}upload(e,t,i){const s=e.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.alphaMode===Lt.UNPACK);const n=t.realWidth,a=t.realHeight;return i.width===n&&i.height===a?s.texSubImage2D(t.target,0,0,0,n,a,t.format,i.type,this.data):(i.width=n,i.height=a,s.texImage2D(t.target,0,i.internalFormat,n,a,0,t.format,i.type,this.data)),!0}dispose(){this.data=null}static test(e){return e===null||e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}}const Fv={scaleMode:er.NEAREST,alphaMode:Lt.NPM},Wh=class Us extends bn{constructor(e=null,t=null){super(),t=Object.assign({},Us.defaultOptions,t);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:a,width:o,height:l,wrapMode:c,format:u,type:h,target:d,resolution:p,resourceOptions:f}=t;e&&!(e instanceof sa)&&(e=Sf(e,f),e.internal=!0),this.resolution=p||de.RESOLUTION,this.width=Math.round((o||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=c,this._scaleMode=a,this.format=u,this.type=h,this.target=d,this.alphaMode=i,this.uid=bs(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=o>0&&l>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(e)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(e){this._mipmap!==e&&(this._mipmap=e,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(e){this._scaleMode!==e&&(this._scaleMode=e,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(e){this._wrapMode!==e&&(this._wrapMode=e,this.dirtyStyleId++)}setStyle(e,t){let i;return e!==void 0&&e!==this.scaleMode&&(this.scaleMode=e,i=!0),t!==void 0&&t!==this.mipmap&&(this.mipmap=t,i=!0),i&&this.dirtyStyleId++,this}setSize(e,t,i){return i=i||this.resolution,this.setRealSize(e*i,t*i,i)}setRealSize(e,t,i){return this.resolution=i||this.resolution,this.width=Math.round(e)/this.resolution,this.height=Math.round(t)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=cu(this.realWidth)&&cu(this.realHeight)}setResolution(e){const t=this.resolution;return t===e?this:(this.resolution=e,this.valid&&(this.width=Math.round(this.width*t)/e,this.height=Math.round(this.height*t)/e,this.emit("update",this)),this._refreshPOT(),this)}setResource(e){if(this.resource===e)return this;if(this.resource)throw new Error("Resource can be set only once");return e.bind(this),this.resource=e,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(e){this.emit("error",this,e)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete pr[this.cacheId],delete Bi[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),Us.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(e,t,i=de.STRICT_TEXTURE_CACHE){const s=typeof e=="string";let n=null;if(s)n=e;else{if(!e._pixiId){const o=t?.pixiIdPrefix||"pixiid";e._pixiId=`${o}_${bs()}`}n=e._pixiId}let a=pr[n];if(s&&i&&!a)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return a||(a=new Us(e,t),a.cacheId=n,Us.addToCache(a,n)),a}static fromBuffer(e,t,i,s){e=e||new Float32Array(t*i*4);const n=new Qo(e,{width:t,height:i,...s?.resourceOptions});let a,o;return e instanceof Float32Array?(a=re.RGBA,o=we.FLOAT):e instanceof Int32Array?(a=re.RGBA_INTEGER,o=we.INT):e instanceof Uint32Array?(a=re.RGBA_INTEGER,o=we.UNSIGNED_INT):e instanceof Int16Array?(a=re.RGBA_INTEGER,o=we.SHORT):e instanceof Uint16Array?(a=re.RGBA_INTEGER,o=we.UNSIGNED_SHORT):e instanceof Int8Array?(a=re.RGBA,o=we.BYTE):(a=re.RGBA,o=we.UNSIGNED_BYTE),n.internal=!0,new Us(n,Object.assign({},Fv,{type:o,format:a},s))}static addToCache(e,t){t&&(e.textureCacheIds.includes(t)||e.textureCacheIds.push(t),pr[t]&&pr[t]!==e&&console.warn(`BaseTexture added to the cache with an id [${t}] that already had an entry`),pr[t]=e)}static removeFromCache(e){if(typeof e=="string"){const t=pr[e];if(t){const i=t.textureCacheIds.indexOf(e);return i>-1&&t.textureCacheIds.splice(i,1),delete pr[e],t}}else if(e?.textureCacheIds){for(let t=0;t1){for(let h=0;h(r[r.POLY=0]="POLY",r[r.RECT=1]="RECT",r[r.CIRC=2]="CIRC",r[r.ELIP=3]="ELIP",r[r.RREC=4]="RREC",r))(Et||{});class Ue{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new Ue(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}}Ue.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Ca=[new Ue,new Ue,new Ue,new Ue];class Se{constructor(e=0,t=0,i=0,s=0){this.x=Number(e),this.y=Number(t),this.width=Number(i),this.height=Number(s),this.type=Et.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new Se(0,0,0,0)}clone(){return new Se(this.x,this.y,this.width,this.height)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e=this.y&&te.right?e.right:this.right)<=P)return!1;const k=this.ye.bottom?e.bottom:this.bottom)>k}const i=this.left,s=this.right,n=this.top,a=this.bottom;if(s<=i||a<=n)return!1;const o=Ca[0].set(e.left,e.top),l=Ca[1].set(e.left,e.bottom),c=Ca[2].set(e.right,e.top),u=Ca[3].set(e.right,e.bottom);if(c.x<=o.x||l.y<=o.y)return!1;const h=Math.sign(t.a*t.d-t.b*t.c);if(h===0||(t.apply(o,o),t.apply(l,l),t.apply(c,c),t.apply(u,u),Math.max(o.x,l.x,c.x,u.x)<=i||Math.min(o.x,l.x,c.x,u.x)>=s||Math.max(o.y,l.y,c.y,u.y)<=n||Math.min(o.y,l.y,c.y,u.y)>=a))return!1;const d=h*(l.y-o.y),p=h*(o.x-l.x),f=d*i+p*n,m=d*s+p*n,g=d*i+p*a,y=d*s+p*a;if(Math.max(f,m,g,y)<=d*o.x+p*o.y||Math.min(f,m,g,y)>=d*u.x+p*u.y)return!1;const b=h*(o.y-c.y),A=h*(c.x-o.x),v=b*i+A*n,E=b*s+A*n,C=b*i+A*a,M=b*s+A*a;return!(Math.max(v,E,C,M)<=b*o.x+A*o.y||Math.min(v,E,C,M)>=b*u.x+A*u.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),i=Math.min(this.x+this.width,e.x+e.width),s=Math.max(this.y,e.y),n=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(i-t,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(e=1,t=.001){const i=Math.ceil((this.x+this.width-t)*e)/e,s=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=i-this.x,this.height=s-this.y,this}enlarge(e){const t=Math.min(this.x,e.x),i=Math.max(this.x+this.width,e.x+e.width),s=Math.min(this.y,e.y),n=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=i-t,this.y=s,this.height=n-s,this}}Se.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class $o{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.radius=i,this.type=Et.CIRC}clone(){return new $o(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-e,n=this.y-t;return s*=s,n*=n,s+n<=i}getBounds(){return new Se(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}$o.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Jo{constructor(e=0,t=0,i=0,s=0){this.x=e,this.y=t,this.width=i,this.height=s,this.type=Et.ELIP}clone(){return new Jo(this.x,this.y,this.width,this.height)}contains(e,t){if(this.width<=0||this.height<=0)return!1;let i=(e-this.x)/this.width,s=(t-this.y)/this.height;return i*=i,s*=s,i+s<=1}getBounds(){return new Se(this.x-this.width,this.y-this.height,this.width,this.height)}}Jo.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class us{constructor(...e){let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){const i=[];for(let s=0,n=t.length;st!=u>t&&e<(c-o)*((t-l)/(u-l))+o&&(i=!i)}return i}}us.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,e)=>`${r}, ${e}`,"")}]`};class Zo{constructor(e=0,t=0,i=0,s=0,n=20){this.x=e,this.y=t,this.width=i,this.height=s,this.radius=n,this.type=Et.RREC}clone(){return new Zo(this.x,this.y,this.width,this.height,this.radius)}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+i&&t<=this.y+this.height-i||e>=this.x+i&&e<=this.x+this.width-i)return!0;let s=e-(this.x+i),n=t-(this.y+i);const a=i*i;if(s*s+n*n<=a||(s=e-(this.x+this.width-i),s*s+n*n<=a)||(n=t-(this.y+this.height-i),s*s+n*n<=a)||(s=e-(this.x+i),s*s+n*n<=a))return!0}return!1}}Zo.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class et{constructor(e=1,t=0,i=0,s=1,n=0,a=0){this.array=null,this.a=e,this.b=t,this.c=i,this.d=s,this.tx=n,this.ty=a}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,i,s,n,a){return this.a=e,this.b=t,this.c=i,this.d=s,this.tx=n,this.ty=a,this}toArray(e,t){this.array||(this.array=new Float32Array(9));const i=t||this.array;return e?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(e,t){t=t||new Ue;const i=e.x,s=e.y;return t.x=this.a*i+this.c*s+this.tx,t.y=this.b*i+this.d*s+this.ty,t}applyInverse(e,t){t=t||new Ue;const i=1/(this.a*this.d+this.c*-this.b),s=e.x,n=e.y;return t.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,t.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){const t=Math.cos(e),i=Math.sin(e),s=this.a,n=this.c,a=this.tx;return this.a=s*t-this.b*i,this.b=s*i+this.b*t,this.c=n*t-this.d*i,this.d=n*i+this.d*t,this.tx=a*t-this.ty*i,this.ty=a*i+this.ty*t,this}append(e){const t=this.a,i=this.b,s=this.c,n=this.d;return this.a=e.a*t+e.b*s,this.b=e.a*i+e.b*n,this.c=e.c*t+e.d*s,this.d=e.c*i+e.d*n,this.tx=e.tx*t+e.ty*s+this.tx,this.ty=e.tx*i+e.ty*n+this.ty,this}setTransform(e,t,i,s,n,a,o,l,c){return this.a=Math.cos(o+c)*n,this.b=Math.sin(o+c)*n,this.c=-Math.sin(o-l)*a,this.d=Math.cos(o-l)*a,this.tx=e-(i*this.a+s*this.c),this.ty=t-(i*this.b+s*this.d),this}prepend(e){const t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const i=this.a,s=this.c;this.a=i*e.a+this.b*e.c,this.b=i*e.b+this.b*e.d,this.c=s*e.a+this.d*e.c,this.d=s*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){const t=this.a,i=this.b,s=this.c,n=this.d,a=e.pivot,o=-Math.atan2(-s,n),l=Math.atan2(i,t),c=Math.abs(o+l);return c<1e-5||Math.abs(So-c)<1e-5?(e.rotation=l,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=o,e.skew.y=l),e.scale.x=Math.sqrt(t*t+i*i),e.scale.y=Math.sqrt(s*s+n*n),e.position.x=this.tx+(a.x*t+a.y*s),e.position.y=this.ty+(a.x*i+a.y*n),e}invert(){const e=this.a,t=this.b,i=this.c,s=this.d,n=this.tx,a=e*s-t*i;return this.a=s/a,this.b=-t/a,this.c=-i/a,this.d=e/a,this.tx=(i*this.ty-s*n)/a,this.ty=-(e*this.ty-t*n)/a,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const e=new et;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}static get IDENTITY(){return new et}static get TEMP_MATRIX(){return new et}}et.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const Kr=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],qr=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Qr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],$r=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],zh=[],If=[],Ma=Math.sign;function jv(){for(let r=0;r<16;r++){const e=[];zh.push(e);for(let t=0;t<16;t++){const i=Ma(Kr[r]*Kr[t]+Qr[r]*qr[t]),s=Ma(qr[r]*Kr[t]+$r[r]*qr[t]),n=Ma(Kr[r]*Qr[t]+Qr[r]*$r[t]),a=Ma(qr[r]*Qr[t]+$r[r]*$r[t]);for(let o=0;o<16;o++)if(Kr[o]===i&&qr[o]===s&&Qr[o]===n&&$r[o]===a){e.push(o);break}}}for(let r=0;r<16;r++){const e=new et;e.set(Kr[r],qr[r],Qr[r],$r[r],0,0),If.push(e)}}jv();const nt={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>Kr[r],uY:r=>qr[r],vX:r=>Qr[r],vY:r=>$r[r],inv:r=>r&8?r&15:-r&7,add:(r,e)=>zh[r][e],sub:(r,e)=>zh[r][nt.inv(e)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,e)=>Math.abs(r)*2<=Math.abs(e)?e>=0?nt.S:nt.N:Math.abs(e)*2<=Math.abs(r)?r>0?nt.E:nt.W:e>0?r>0?nt.SE:nt.SW:r>0?nt.NE:nt.NW,matrixAppendRotationInv:(r,e,t=0,i=0)=>{const s=If[nt.inv(e)];s.tx=t,s.ty=i,r.append(s)}};class ir{constructor(e,t,i=0,s=0){this._x=i,this._y=s,this.cb=e,this.scope=t}clone(e=this.cb,t=this.scope){return new ir(e,t,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this.cb.call(this.scope)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this.cb.call(this.scope)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this.cb.call(this.scope))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this.cb.call(this.scope))}}ir.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const jh=class{constructor(){this.worldTransform=new et,this.localTransform=new et,this.position=new ir(this.onChange,this,0,0),this.scale=new ir(this.onChange,this,1,1),this.pivot=new ir(this.onChange,this,0,0),this.skew=new ir(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const r=this.localTransform;this._localID!==this._currentLocalID&&(r.a=this._cx*this.scale.x,r.b=this._sx*this.scale.x,r.c=this._cy*this.scale.y,r.d=this._sy*this.scale.y,r.tx=this.position.x-(this.pivot.x*r.a+this.pivot.y*r.c),r.ty=this.position.y-(this.pivot.x*r.b+this.pivot.y*r.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(r){const e=this.localTransform;if(this._localID!==this._currentLocalID&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==r._worldID){const t=r.worldTransform,i=this.worldTransform;i.a=e.a*t.a+e.b*t.c,i.b=e.a*t.b+e.b*t.d,i.c=e.c*t.a+e.d*t.c,i.d=e.c*t.b+e.d*t.d,i.tx=e.tx*t.a+e.ty*t.c+t.tx,i.ty=e.tx*t.b+e.ty*t.d+t.ty,this._parentID=r._worldID,this._worldID++}}setFromMatrix(r){r.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(r){this._rotation!==r&&(this._rotation=r,this.updateSkew())}};jh.IDENTITY=new jh;let el=jh;el.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var Yv=`varying vec2 vTextureCoord; uniform sampler2D uSampler; @@ -375,7 +375,7 @@ void main(void) gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); } -`;const Kh=class On extends Ot{constructor(e,t,i){const s=rr.from(e||On.defaultVertexSrc,t||On.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=On.defaultResolution,this.multisample=On.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new ji}apply(e,t,i,s,n){e.applyFilter(this,t,i,s)}get blendMode(){return this.state.blendMode}set blendMode(e){this.state.blendMode=e}get resolution(){return this._resolution}set resolution(e){this._resolution=e}static get defaultVertexSrc(){return cb}static get defaultFragmentSrc(){return hb}};Kh.defaultResolution=1,Kh.defaultMultisample=ut.NONE;let kt=Kh;class Co{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Je(0),this.alpha=1}init(e){this.clearBeforeRender=e.clearBeforeRender;const{backgroundColor:t,background:i,backgroundAlpha:s}=e,n=i??t;n!==void 0&&(this.color=n),this.alpha=s}get color(){return this._backgroundColor.value}set color(e){this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get backgroundColor(){return this._backgroundColor}destroy(){}}Co.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Co.extension={type:[ae.RendererSystem,ae.CanvasRendererSystem],name:"background"};me.add(Co);class Df{constructor(e){this.renderer=e,this.emptyRenderer=new tl(e),this.currentRenderer=this.emptyRenderer}setObjectRenderer(e){this.currentRenderer!==e&&(this.currentRenderer.stop(),this.currentRenderer=e,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(e,t){const{boundTextures:i}=this.renderer.texture;for(let s=t-1;s>=0;--s)e[s]=i[s]||null,e[s]&&(e[s]._batchLocation=s)}boundArray(e,t,i,s){const{elements:n,ids:a,count:o}=e;let l=0;for(let c=0;c=0&&h=_s.WEBGL2&&(i=e.getContext("webgl2",t)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:e}=this,t={loseContext:e.getExtension("WEBGL_lose_context"),anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc")};this.webGLVersion===1?Object.assign(this.extensions,t,{drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,t,{colorBufferFloat:e.getExtension("EXT_color_buffer_float")})}handleContextLost(e){e.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const e=this.renderer.view;this.renderer=null,e.removeEventListener!==void 0&&(e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(e){const t=e.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&e instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),t&&!t.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=i||!!e.getExtension("OES_element_index_uint");this.supports.uint32Indices=s,s||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}Mo.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},Mo.extension={type:ae.RendererSystem,name:"context"};me.add(Mo);class qh{constructor(e,t){if(this.width=Math.round(e),this.height=Math.round(t),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new Ei("disposeFramebuffer"),this.multisample=ut.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(e=0,t){return this.colorTextures[e]=t||new Me(null,{scaleMode:er.NEAREST,resolution:1,mipmap:Xt.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(e){return this.depthTexture=e||new Me(null,{scaleMode:er.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Xt.OFF,format:re.DEPTH_COMPONENT,type:we.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(e,t){if(e=Math.round(e),t=Math.round(t),!e||!t)throw new Error("Framebuffer width and height must not be zero");if(!(e===this.width&&t===this.height)){this.width=e,this.height=t,this.dirtyId++,this.dirtySize++;for(let i=0;i{const s=this.source;this.url=s.src;const n=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.update(),this._load=null,this.createBitmap?t(this.process()):t(this))};s.complete&&s.src?n():(s.onload=n,s.onerror=a=>{i(a),this.onError.emit(a)})}),this._load)}process(){const e=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const t=globalThis.createImageBitmap,i=!e.crossOrigin||e.crossOrigin==="anonymous";return this._process=fetch(e.src,{mode:i?"cors":"no-cors"}).then(s=>s.blob()).then(s=>t(s,0,0,e.width,e.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Lt.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(e,t,i){if(typeof this.alphaMode=="number"&&(t.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(e,t,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(e,t,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=t._glTextures;for(const a in n){const o=n[a];if(o!==i&&o.dirtyId!==t.dirtyId){s=!1;break}}s&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(e){return typeof HTMLImageElement<"u"&&(typeof e=="string"||e instanceof HTMLImageElement)}}class Hc{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(e,t,i){const s=t.width,n=t.height;if(i){const a=e.width/2/s,o=e.height/2/n,l=e.x/s+a,c=e.y/n+o;i=nt.add(i,nt.NW),this.x0=l+a*nt.uX(i),this.y0=c+o*nt.uY(i),i=nt.add(i,2),this.x1=l+a*nt.uX(i),this.y1=c+o*nt.uY(i),i=nt.add(i,2),this.x2=l+a*nt.uX(i),this.y2=c+o*nt.uY(i),i=nt.add(i,2),this.x3=l+a*nt.uX(i),this.y3=c+o*nt.uY(i)}else this.x0=e.x/s,this.y0=e.y/n,this.x1=(e.x+e.width)/s,this.y1=e.y/n,this.x2=(e.x+e.width)/s,this.y2=(e.y+e.height)/n,this.x3=e.x/s,this.y3=(e.y+e.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Hc.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const _u=new Hc;function Ra(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class Z extends bn{constructor(e,t,i,s,n,a,o){if(super(),this.noFrame=!1,t||(this.noFrame=!0,t=new Se(0,0,1,1)),e instanceof Z&&(e=e.baseTexture),this.baseTexture=e,this._frame=t,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=_u,this.uvMatrix=null,this.orig=i||t,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=a?new Ue(a.x,a.y):new Ue(0,0),this.defaultBorders=o,this._updateID=0,this.textureCacheIds=[],e.valid?this.noFrame?e.valid&&this.onBaseTextureUpdated(e):this.frame=t:e.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&e.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(e){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=e.width,this._frame.height=e.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(e){if(this.baseTexture){if(e){const{resource:t}=this.baseTexture;t?.url&&Bi[t.url]&&Z.removeFromCache(t.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,Z.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){const e=this._frame.clone(),t=this._frame===this.orig?e:this.orig.clone(),i=new Z(this.baseTexture,!this.noFrame&&e,t,this.trim?.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=e),i}updateUvs(){this._uvs===_u&&(this._uvs=new Hc),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(e,t={},i=de.STRICT_TEXTURE_CACHE){const s=typeof e=="string";let n=null;if(s)n=e;else if(e instanceof Me){if(!e.cacheId){const o=t?.pixiIdPrefix||"pixiid";e.cacheId=`${o}-${bs()}`,Me.addToCache(e,e.cacheId)}n=e.cacheId}else{if(!e._pixiId){const o=t?.pixiIdPrefix||"pixiid";e._pixiId=`${o}_${bs()}`}n=e._pixiId}let a=Bi[n];if(s&&i&&!a)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!a&&!(e instanceof Me)?(t.resolution||(t.resolution=ar(e)),a=new Z(new Me(e,t)),a.baseTexture.cacheId=n,Me.addToCache(a.baseTexture,n),Z.addToCache(a,n)):!a&&e instanceof Me&&(a=new Z(e),Z.addToCache(a,n)),a}static fromURL(e,t){const i=Object.assign({autoLoad:!1},t?.resourceOptions),s=Z.from(e,Object.assign({resourceOptions:i},t),!1),n=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):n.load().then(()=>Promise.resolve(s))}static fromBuffer(e,t,i,s){return new Z(Me.fromBuffer(e,t,i,s))}static fromLoader(e,t,i,s){const n=new Me(e,Object.assign({scaleMode:Me.defaultOptions.scaleMode,resolution:ar(t)},s)),{resource:a}=n;a instanceof Of&&(a.url=t);const o=new Z(n);return i||(i=t),Me.addToCache(o.baseTexture,i),Z.addToCache(o,i),i!==t&&(Me.addToCache(o.baseTexture,t),Z.addToCache(o,t)),o.baseTexture.valid?Promise.resolve(o):new Promise(l=>{o.baseTexture.once("loaded",()=>l(o))})}static addToCache(e,t){t&&(e.textureCacheIds.includes(t)||e.textureCacheIds.push(t),Bi[t]&&Bi[t]!==e&&console.warn(`Texture added to the cache with an id [${t}] that already had an entry`),Bi[t]=e)}static removeFromCache(e){if(typeof e=="string"){const t=Bi[e];if(t){const i=t.textureCacheIds.indexOf(e);return i>-1&&t.textureCacheIds.splice(i,1),delete Bi[e],t}}else if(e?.textureCacheIds){for(let t=0;tthis.baseTexture.width,o=i+n>this.baseTexture.height;if(a||o){const l=a&&o?"and":"or",c=`X: ${t} + ${s} = ${t+s} > ${this.baseTexture.width}`,u=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${c} ${l} ${u}`)}this.valid=s&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=e),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(e){this._rotate=e,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return Z._EMPTY||(Z._EMPTY=new Z(new Me),Ra(Z._EMPTY),Ra(Z._EMPTY.baseTexture)),Z._EMPTY}static get WHITE(){if(!Z._WHITE){const e=de.ADAPTER.createCanvas(16,16),t=e.getContext("2d");e.width=16,e.height=16,t.fillStyle="white",t.fillRect(0,0,16,16),Z._WHITE=new Z(Me.from(e)),Ra(Z._WHITE),Ra(Z._WHITE.baseTexture)}return Z._WHITE}}class mt extends Z{constructor(e,t){super(e,t),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(e){this.framebuffer.multisample=e}resize(e,t,i=!0){const s=this.baseTexture.resolution,n=Math.round(e*s)/s,a=Math.round(t*s)/s;this.valid=n>0&&a>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=a,i&&this.baseTexture.resize(n,a),this.updateUvs()}setResolution(e){const{baseTexture:t}=this;t.resolution!==e&&(t.setResolution(e),this.resize(t.width,t.height,!1))}static create(e){return new mt(new Lf(e))}}class Ff{constructor(e){this.texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(e,t,i=ut.NONE){const s=new Lf(Object.assign({width:e,height:t,resolution:1,multisample:i},this.textureOptions));return new mt(s)}getOptimalTexture(e,t,i=1,s=ut.NONE){let n;e=Math.max(Math.ceil(e*i-1e-6),1),t=Math.max(Math.ceil(t*i-1e-6),1),!this.enableFullScreen||e!==this._pixelsWidth||t!==this._pixelsHeight?(e=Eo(e),t=Eo(t),n=((e&65535)<<16|t&65535)>>>0,s>1&&(n+=s*4294967296)):n=s>1?-s:-1,this.texturePool[n]||(this.texturePool[n]=[]);let a=this.texturePool[n].pop();return a||(a=this.createTexture(e,t,s)),a.filterPoolKey=n,a.setResolution(i),a}getFilterTexture(e,t,i){const s=this.getOptimalTexture(e.width,e.height,t||e.resolution,i||ut.NONE);return s.filterFrame=e.filterFrame,s}returnTexture(e){const t=e.filterPoolKey;e.filterFrame=null,this.texturePool[t].push(e)}returnFilterTexture(e){this.returnTexture(e)}clear(e){if(e=e!==!1,e)for(const t in this.texturePool){const i=this.texturePool[t];if(i)for(let s=0;s0&&e.height>0;for(const t in this.texturePool){if(!(Number(t)<0))continue;const i=this.texturePool[t];if(i)for(let s=0;s1&&(u=this.getOptimalFilterTexture(c.width,c.height,t.resolution),u.filterFrame=c.filterFrame),i[h].apply(this,c,u,Li.CLEAR,t);const d=c;c=u,u=d}i[h].apply(this,c,l.renderTexture,Li.BLEND,t),h>1&&t.multisample>1&&this.returnFilterTexture(t.renderTexture),this.returnFilterTexture(c),this.returnFilterTexture(u)}t.clear(),this.statePool.push(t)}bindAndClear(e,t=Li.CLEAR){const{renderTexture:i,state:s}=this.renderer;if(e===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,e?.filterFrame){const a=this.tempRect;a.x=0,a.y=0,a.width=e.filterFrame.width,a.height=e.filterFrame.height,i.bind(e,e.filterFrame,a)}else e!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(e):this.renderer.renderTexture.bind(e,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=s.stateId&1||this.forceClear;(t===Li.CLEAR||t===Li.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(e,t,i,s){const n=this.renderer;n.state.set(e.state),this.bindAndClear(i,s),e.uniforms.uSampler=t,e.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(e),e.legacy=!!e.program.attributeData.aTextureCoord,e.legacy?(this.quadUv.map(t._frame,t.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(Ni.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(Ni.TRIANGLE_STRIP))}calculateSpriteMatrix(e,t){const{sourceFrame:i,destinationFrame:s}=this.activeState,{orig:n}=t._texture,a=e.set(s.width,0,0,s.height,i.x,i.y),o=t.worldTransform.copyTo(et.TEMP_MATRIX);return o.invert(),a.prepend(o),a.scale(1/n.width,1/n.height),a.translate(t.anchor.x,t.anchor.y),a}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(e,t,i=1,s=ut.NONE){return this.texturePool.getOptimalTexture(e,t,i,s)}getFilterTexture(e,t,i){if(typeof e=="number"){const n=e;e=t,t=n}e=e||this.activeState.renderTexture;const s=this.texturePool.getOptimalTexture(e.width,e.height,t||e.resolution,i||ut.NONE);return s.filterFrame=e.filterFrame,s}returnFilterTexture(e){this.texturePool.returnTexture(e)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(e,t){const i=Da[0],s=Da[1],n=Da[2],a=Da[3];i.set(t.left,t.top),s.set(t.left,t.bottom),n.set(t.right,t.top),a.set(t.right,t.bottom),e.apply(i,i),e.apply(s,s),e.apply(n,n),e.apply(a,a);const o=Math.min(i.x,s.x,n.x,a.x),l=Math.min(i.y,s.y,n.y,a.y),c=Math.max(i.x,s.x,n.x,a.x),u=Math.max(i.y,s.y,n.y,a.y);t.x=o,t.y=l,t.width=c-o,t.height=u-l}roundFrame(e,t,i,s,n){if(!(e.width<=0||e.height<=0||i.width<=0||i.height<=0)){if(n){const{a,b:o,c:l,d:c}=n;if((Math.abs(o)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(a)>1e-4||Math.abs(c)>1e-4))return}n=n?jl.copyFrom(n):jl.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.transformAABB(n,e),e.ceil(t),this.transformAABB(n.invert(),e)}}}Uf.extension={type:ae.RendererSystem,name:"filter"};me.add(Uf);class pb{constructor(e){this.framebuffer=e,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=ut.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const fb=new Se;class Gf{constructor(e){this.renderer=e,this.managedFramebuffers=[],this.unknownFramebuffer=new qh(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const e=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new Se,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let t=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;de.PREFER_ENV===_s.WEBGL_LEGACY&&(t=null,i=null),t?e.drawBuffers=s=>t.drawBuffersWEBGL(s):(this.hasMRT=!1,e.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=e.getInternalformatParameter(e.RENDERBUFFER,e.RGBA8,e.SAMPLES)}bind(e,t,i=0){const{gl:s}=this;if(e){const n=e.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(e);this.current!==e&&(this.current=e,s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==i&&(e.dirtyId++,e.dirtyFormat++,n.mipLevel=i),n.dirtyId!==e.dirtyId&&(n.dirtyId=e.dirtyId,n.dirtyFormat!==e.dirtyFormat?(n.dirtyFormat=e.dirtyFormat,n.dirtySize=e.dirtySize,this.updateFramebuffer(e,i)):n.dirtySize!==e.dirtySize&&(n.dirtySize=e.dirtySize,this.resizeFramebuffer(e)));for(let a=0;a>i,o=t.height>>i,l=a/t.width;this.setViewport(t.x*l,t.y*l,a,o)}else{const a=e.width>>i,o=e.height>>i;this.setViewport(0,0,a,o)}}else this.current&&(this.current=null,s.bindFramebuffer(s.FRAMEBUFFER,null)),t?this.setViewport(t.x,t.y,t.width,t.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(e,t,i,s){const n=this.viewport;e=Math.round(e),t=Math.round(t),i=Math.round(i),s=Math.round(s),(n.width!==i||n.height!==s||n.x!==e||n.y!==t)&&(n.x=e,n.y=t,n.width=i,n.height=s,this.gl.viewport(e,t,i,s))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(e,t,i,s,n=_h.COLOR|_h.DEPTH){const{gl:a}=this;a.clearColor(e,t,i,s),a.clear(n)}initFramebuffer(e){const{gl:t}=this,i=new pb(t.createFramebuffer());return i.multisample=this.detectSamples(e.multisample),e.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(e),e.disposeRunner.add(this),i}resizeFramebuffer(e){const{gl:t}=this,i=e.glFramebuffers[this.CONTEXT_UID];if(i.stencil){t.bindRenderbuffer(t.RENDERBUFFER,i.stencil);let a;this.renderer.context.webGLVersion===1?a=t.DEPTH_STENCIL:e.depth&&e.stencil?a=t.DEPTH24_STENCIL8:e.depth?a=t.DEPTH_COMPONENT24:a=t.STENCIL_INDEX8,i.msaaBuffer?t.renderbufferStorageMultisample(t.RENDERBUFFER,i.multisample,a,e.width,e.height):t.renderbufferStorage(t.RENDERBUFFER,a,e.width,e.height)}const s=e.colorTextures;let n=s.length;t.drawBuffers||(n=Math.min(n,1));for(let a=0;a1&&this.canMultisampleFramebuffer(e)?s.msaaBuffer=s.msaaBuffer||i.createRenderbuffer():s.msaaBuffer&&(i.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const o=[];for(let l=0;l1&&i.drawBuffers(o),e.depthTexture&&this.writeDepthTexture){const l=e.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,t)}if((e.stencil||e.depth)&&!(e.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let l,c;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,c=i.DEPTH_STENCIL):e.depth&&e.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,c=i.DEPTH24_STENCIL8):e.depth?(l=i.DEPTH_ATTACHMENT,c=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,c=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,c,e.width,e.height):i.renderbufferStorage(i.RENDERBUFFER,c,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,s.stencil)}else s.stencil&&(i.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(e){return this.renderer.context.webGLVersion!==1&&e.colorTextures.length<=1&&!e.depthTexture}detectSamples(e){const{msaaSamples:t}=this;let i=ut.NONE;if(e<=1||t===null)return i;for(let s=0;s=0&&this.managedFramebuffers.splice(n,1),e.disposeRunner.remove(this),t||(s.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&s.deleteRenderbuffer(i.msaaBuffer),i.stencil&&s.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,t)}disposeAll(e){const t=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;ii.createVertexArrayOES(),e.bindVertexArray=s=>i.bindVertexArrayOES(s),e.deleteVertexArray=s=>i.deleteVertexArrayOES(s)):(this.hasVao=!1,e.createVertexArray=()=>null,e.bindVertexArray=()=>null,e.deleteVertexArray=()=>null)}if(t.webGLVersion!==2){const i=e.getExtension("ANGLE_instanced_arrays");i?(e.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n),e.drawElementsInstanced=(s,n,a,o,l)=>i.drawElementsInstancedANGLE(s,n,a,o,l),e.drawArraysInstanced=(s,n,a,o)=>i.drawArraysInstancedANGLE(s,n,a,o)):this.hasInstance=!1}this.canUseUInt32ElementIndex=t.webGLVersion===2||!!t.extensions.uint32ElementIndex}bind(e,t){t=t||this.renderer.shader.shader;const{gl:i}=this;let s=e.glVertexArrayObjects[this.CONTEXT_UID],n=!1;s||(this.managedGeometries[e.id]=e,e.disposeRunner.add(this),e.glVertexArrayObjects[this.CONTEXT_UID]=s={},n=!0);const a=s[t.program.id]||this.initGeometryVao(e,t,n);this._activeGeometry=e,this._activeVao!==a&&(this._activeVao=a,this.hasVao?i.bindVertexArray(a):this.activateVao(e,t.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const e=this._activeGeometry,t=this.renderer.buffer;for(let i=0;i"u"?.5:t,this.isSimple=!1}get texture(){return this._texture}set texture(e){this._texture=e,this._textureID=-1}multiplyUvs(e,t){t===void 0&&(t=e);const i=this.mapCoord;for(let s=0;s=0;--s)e[s]=i[s]||null,e[s]&&(e[s]._batchLocation=s)}boundArray(e,t,i,s){const{elements:n,ids:a,count:o}=e;let l=0;for(let c=0;c=0&&h=_s.WEBGL2&&(i=e.getContext("webgl2",t)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:e}=this,t={loseContext:e.getExtension("WEBGL_lose_context"),anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc")};this.webGLVersion===1?Object.assign(this.extensions,t,{drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,t,{colorBufferFloat:e.getExtension("EXT_color_buffer_float")})}handleContextLost(e){e.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const e=this.renderer.view;this.renderer=null,e.removeEventListener!==void 0&&(e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(e){const t=e.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&e instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),t&&!t.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=i||!!e.getExtension("OES_element_index_uint");this.supports.uint32Indices=s,s||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}Mo.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},Mo.extension={type:ae.RendererSystem,name:"context"};me.add(Mo);class qh{constructor(e,t){if(this.width=Math.round(e),this.height=Math.round(t),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new Ei("disposeFramebuffer"),this.multisample=ut.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(e=0,t){return this.colorTextures[e]=t||new Me(null,{scaleMode:er.NEAREST,resolution:1,mipmap:Xt.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(e){return this.depthTexture=e||new Me(null,{scaleMode:er.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Xt.OFF,format:re.DEPTH_COMPONENT,type:we.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(e,t){if(e=Math.round(e),t=Math.round(t),!e||!t)throw new Error("Framebuffer width and height must not be zero");if(!(e===this.width&&t===this.height)){this.width=e,this.height=t,this.dirtyId++,this.dirtySize++;for(let i=0;i{const s=this.source;this.url=s.src;const n=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.update(),this._load=null,this.createBitmap?t(this.process()):t(this))};s.complete&&s.src?n():(s.onload=n,s.onerror=a=>{i(a),this.onError.emit(a)})}),this._load)}process(){const e=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const t=globalThis.createImageBitmap,i=!e.crossOrigin||e.crossOrigin==="anonymous";return this._process=fetch(e.src,{mode:i?"cors":"no-cors"}).then(s=>s.blob()).then(s=>t(s,0,0,e.width,e.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Lt.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(e,t,i){if(typeof this.alphaMode=="number"&&(t.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(e,t,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(e,t,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=t._glTextures;for(const a in n){const o=n[a];if(o!==i&&o.dirtyId!==t.dirtyId){s=!1;break}}s&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(e){return typeof HTMLImageElement<"u"&&(typeof e=="string"||e instanceof HTMLImageElement)}}class Hc{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(e,t,i){const s=t.width,n=t.height;if(i){const a=e.width/2/s,o=e.height/2/n,l=e.x/s+a,c=e.y/n+o;i=nt.add(i,nt.NW),this.x0=l+a*nt.uX(i),this.y0=c+o*nt.uY(i),i=nt.add(i,2),this.x1=l+a*nt.uX(i),this.y1=c+o*nt.uY(i),i=nt.add(i,2),this.x2=l+a*nt.uX(i),this.y2=c+o*nt.uY(i),i=nt.add(i,2),this.x3=l+a*nt.uX(i),this.y3=c+o*nt.uY(i)}else this.x0=e.x/s,this.y0=e.y/n,this.x1=(e.x+e.width)/s,this.y1=e.y/n,this.x2=(e.x+e.width)/s,this.y2=(e.y+e.height)/n,this.x3=e.x/s,this.y3=(e.y+e.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Hc.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const _u=new Hc;function Ra(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class Z extends bn{constructor(e,t,i,s,n,a,o){if(super(),this.noFrame=!1,t||(this.noFrame=!0,t=new Se(0,0,1,1)),e instanceof Z&&(e=e.baseTexture),this.baseTexture=e,this._frame=t,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=_u,this.uvMatrix=null,this.orig=i||t,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=a?new Ue(a.x,a.y):new Ue(0,0),this.defaultBorders=o,this._updateID=0,this.textureCacheIds=[],e.valid?this.noFrame?e.valid&&this.onBaseTextureUpdated(e):this.frame=t:e.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&e.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(e){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=e.width,this._frame.height=e.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(e){if(this.baseTexture){if(e){const{resource:t}=this.baseTexture;t?.url&&Bi[t.url]&&Z.removeFromCache(t.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,Z.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){const e=this._frame.clone(),t=this._frame===this.orig?e:this.orig.clone(),i=new Z(this.baseTexture,!this.noFrame&&e,t,this.trim?.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=e),i}updateUvs(){this._uvs===_u&&(this._uvs=new Hc),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(e,t={},i=de.STRICT_TEXTURE_CACHE){const s=typeof e=="string";let n=null;if(s)n=e;else if(e instanceof Me){if(!e.cacheId){const o=t?.pixiIdPrefix||"pixiid";e.cacheId=`${o}-${bs()}`,Me.addToCache(e,e.cacheId)}n=e.cacheId}else{if(!e._pixiId){const o=t?.pixiIdPrefix||"pixiid";e._pixiId=`${o}_${bs()}`}n=e._pixiId}let a=Bi[n];if(s&&i&&!a)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!a&&!(e instanceof Me)?(t.resolution||(t.resolution=or(e)),a=new Z(new Me(e,t)),a.baseTexture.cacheId=n,Me.addToCache(a.baseTexture,n),Z.addToCache(a,n)):!a&&e instanceof Me&&(a=new Z(e),Z.addToCache(a,n)),a}static fromURL(e,t){const i=Object.assign({autoLoad:!1},t?.resourceOptions),s=Z.from(e,Object.assign({resourceOptions:i},t),!1),n=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):n.load().then(()=>Promise.resolve(s))}static fromBuffer(e,t,i,s){return new Z(Me.fromBuffer(e,t,i,s))}static fromLoader(e,t,i,s){const n=new Me(e,Object.assign({scaleMode:Me.defaultOptions.scaleMode,resolution:or(t)},s)),{resource:a}=n;a instanceof Of&&(a.url=t);const o=new Z(n);return i||(i=t),Me.addToCache(o.baseTexture,i),Z.addToCache(o,i),i!==t&&(Me.addToCache(o.baseTexture,t),Z.addToCache(o,t)),o.baseTexture.valid?Promise.resolve(o):new Promise(l=>{o.baseTexture.once("loaded",()=>l(o))})}static addToCache(e,t){t&&(e.textureCacheIds.includes(t)||e.textureCacheIds.push(t),Bi[t]&&Bi[t]!==e&&console.warn(`Texture added to the cache with an id [${t}] that already had an entry`),Bi[t]=e)}static removeFromCache(e){if(typeof e=="string"){const t=Bi[e];if(t){const i=t.textureCacheIds.indexOf(e);return i>-1&&t.textureCacheIds.splice(i,1),delete Bi[e],t}}else if(e?.textureCacheIds){for(let t=0;tthis.baseTexture.width,o=i+n>this.baseTexture.height;if(a||o){const l=a&&o?"and":"or",c=`X: ${t} + ${s} = ${t+s} > ${this.baseTexture.width}`,u=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${c} ${l} ${u}`)}this.valid=s&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=e),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(e){this._rotate=e,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return Z._EMPTY||(Z._EMPTY=new Z(new Me),Ra(Z._EMPTY),Ra(Z._EMPTY.baseTexture)),Z._EMPTY}static get WHITE(){if(!Z._WHITE){const e=de.ADAPTER.createCanvas(16,16),t=e.getContext("2d");e.width=16,e.height=16,t.fillStyle="white",t.fillRect(0,0,16,16),Z._WHITE=new Z(Me.from(e)),Ra(Z._WHITE),Ra(Z._WHITE.baseTexture)}return Z._WHITE}}class mt extends Z{constructor(e,t){super(e,t),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(e){this.framebuffer.multisample=e}resize(e,t,i=!0){const s=this.baseTexture.resolution,n=Math.round(e*s)/s,a=Math.round(t*s)/s;this.valid=n>0&&a>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=a,i&&this.baseTexture.resize(n,a),this.updateUvs()}setResolution(e){const{baseTexture:t}=this;t.resolution!==e&&(t.setResolution(e),this.resize(t.width,t.height,!1))}static create(e){return new mt(new Lf(e))}}class Ff{constructor(e){this.texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(e,t,i=ut.NONE){const s=new Lf(Object.assign({width:e,height:t,resolution:1,multisample:i},this.textureOptions));return new mt(s)}getOptimalTexture(e,t,i=1,s=ut.NONE){let n;e=Math.max(Math.ceil(e*i-1e-6),1),t=Math.max(Math.ceil(t*i-1e-6),1),!this.enableFullScreen||e!==this._pixelsWidth||t!==this._pixelsHeight?(e=Eo(e),t=Eo(t),n=((e&65535)<<16|t&65535)>>>0,s>1&&(n+=s*4294967296)):n=s>1?-s:-1,this.texturePool[n]||(this.texturePool[n]=[]);let a=this.texturePool[n].pop();return a||(a=this.createTexture(e,t,s)),a.filterPoolKey=n,a.setResolution(i),a}getFilterTexture(e,t,i){const s=this.getOptimalTexture(e.width,e.height,t||e.resolution,i||ut.NONE);return s.filterFrame=e.filterFrame,s}returnTexture(e){const t=e.filterPoolKey;e.filterFrame=null,this.texturePool[t].push(e)}returnFilterTexture(e){this.returnTexture(e)}clear(e){if(e=e!==!1,e)for(const t in this.texturePool){const i=this.texturePool[t];if(i)for(let s=0;s0&&e.height>0;for(const t in this.texturePool){if(!(Number(t)<0))continue;const i=this.texturePool[t];if(i)for(let s=0;s1&&(u=this.getOptimalFilterTexture(c.width,c.height,t.resolution),u.filterFrame=c.filterFrame),i[h].apply(this,c,u,Li.CLEAR,t);const d=c;c=u,u=d}i[h].apply(this,c,l.renderTexture,Li.BLEND,t),h>1&&t.multisample>1&&this.returnFilterTexture(t.renderTexture),this.returnFilterTexture(c),this.returnFilterTexture(u)}t.clear(),this.statePool.push(t)}bindAndClear(e,t=Li.CLEAR){const{renderTexture:i,state:s}=this.renderer;if(e===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,e?.filterFrame){const a=this.tempRect;a.x=0,a.y=0,a.width=e.filterFrame.width,a.height=e.filterFrame.height,i.bind(e,e.filterFrame,a)}else e!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(e):this.renderer.renderTexture.bind(e,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=s.stateId&1||this.forceClear;(t===Li.CLEAR||t===Li.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(e,t,i,s){const n=this.renderer;n.state.set(e.state),this.bindAndClear(i,s),e.uniforms.uSampler=t,e.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(e),e.legacy=!!e.program.attributeData.aTextureCoord,e.legacy?(this.quadUv.map(t._frame,t.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(Ni.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(Ni.TRIANGLE_STRIP))}calculateSpriteMatrix(e,t){const{sourceFrame:i,destinationFrame:s}=this.activeState,{orig:n}=t._texture,a=e.set(s.width,0,0,s.height,i.x,i.y),o=t.worldTransform.copyTo(et.TEMP_MATRIX);return o.invert(),a.prepend(o),a.scale(1/n.width,1/n.height),a.translate(t.anchor.x,t.anchor.y),a}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(e,t,i=1,s=ut.NONE){return this.texturePool.getOptimalTexture(e,t,i,s)}getFilterTexture(e,t,i){if(typeof e=="number"){const n=e;e=t,t=n}e=e||this.activeState.renderTexture;const s=this.texturePool.getOptimalTexture(e.width,e.height,t||e.resolution,i||ut.NONE);return s.filterFrame=e.filterFrame,s}returnFilterTexture(e){this.texturePool.returnTexture(e)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(e,t){const i=Da[0],s=Da[1],n=Da[2],a=Da[3];i.set(t.left,t.top),s.set(t.left,t.bottom),n.set(t.right,t.top),a.set(t.right,t.bottom),e.apply(i,i),e.apply(s,s),e.apply(n,n),e.apply(a,a);const o=Math.min(i.x,s.x,n.x,a.x),l=Math.min(i.y,s.y,n.y,a.y),c=Math.max(i.x,s.x,n.x,a.x),u=Math.max(i.y,s.y,n.y,a.y);t.x=o,t.y=l,t.width=c-o,t.height=u-l}roundFrame(e,t,i,s,n){if(!(e.width<=0||e.height<=0||i.width<=0||i.height<=0)){if(n){const{a,b:o,c:l,d:c}=n;if((Math.abs(o)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(a)>1e-4||Math.abs(c)>1e-4))return}n=n?jl.copyFrom(n):jl.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.transformAABB(n,e),e.ceil(t),this.transformAABB(n.invert(),e)}}}Uf.extension={type:ae.RendererSystem,name:"filter"};me.add(Uf);class pb{constructor(e){this.framebuffer=e,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=ut.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const fb=new Se;class Gf{constructor(e){this.renderer=e,this.managedFramebuffers=[],this.unknownFramebuffer=new qh(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const e=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new Se,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let t=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;de.PREFER_ENV===_s.WEBGL_LEGACY&&(t=null,i=null),t?e.drawBuffers=s=>t.drawBuffersWEBGL(s):(this.hasMRT=!1,e.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=e.getInternalformatParameter(e.RENDERBUFFER,e.RGBA8,e.SAMPLES)}bind(e,t,i=0){const{gl:s}=this;if(e){const n=e.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(e);this.current!==e&&(this.current=e,s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==i&&(e.dirtyId++,e.dirtyFormat++,n.mipLevel=i),n.dirtyId!==e.dirtyId&&(n.dirtyId=e.dirtyId,n.dirtyFormat!==e.dirtyFormat?(n.dirtyFormat=e.dirtyFormat,n.dirtySize=e.dirtySize,this.updateFramebuffer(e,i)):n.dirtySize!==e.dirtySize&&(n.dirtySize=e.dirtySize,this.resizeFramebuffer(e)));for(let a=0;a>i,o=t.height>>i,l=a/t.width;this.setViewport(t.x*l,t.y*l,a,o)}else{const a=e.width>>i,o=e.height>>i;this.setViewport(0,0,a,o)}}else this.current&&(this.current=null,s.bindFramebuffer(s.FRAMEBUFFER,null)),t?this.setViewport(t.x,t.y,t.width,t.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(e,t,i,s){const n=this.viewport;e=Math.round(e),t=Math.round(t),i=Math.round(i),s=Math.round(s),(n.width!==i||n.height!==s||n.x!==e||n.y!==t)&&(n.x=e,n.y=t,n.width=i,n.height=s,this.gl.viewport(e,t,i,s))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(e,t,i,s,n=_h.COLOR|_h.DEPTH){const{gl:a}=this;a.clearColor(e,t,i,s),a.clear(n)}initFramebuffer(e){const{gl:t}=this,i=new pb(t.createFramebuffer());return i.multisample=this.detectSamples(e.multisample),e.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(e),e.disposeRunner.add(this),i}resizeFramebuffer(e){const{gl:t}=this,i=e.glFramebuffers[this.CONTEXT_UID];if(i.stencil){t.bindRenderbuffer(t.RENDERBUFFER,i.stencil);let a;this.renderer.context.webGLVersion===1?a=t.DEPTH_STENCIL:e.depth&&e.stencil?a=t.DEPTH24_STENCIL8:e.depth?a=t.DEPTH_COMPONENT24:a=t.STENCIL_INDEX8,i.msaaBuffer?t.renderbufferStorageMultisample(t.RENDERBUFFER,i.multisample,a,e.width,e.height):t.renderbufferStorage(t.RENDERBUFFER,a,e.width,e.height)}const s=e.colorTextures;let n=s.length;t.drawBuffers||(n=Math.min(n,1));for(let a=0;a1&&this.canMultisampleFramebuffer(e)?s.msaaBuffer=s.msaaBuffer||i.createRenderbuffer():s.msaaBuffer&&(i.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const o=[];for(let l=0;l1&&i.drawBuffers(o),e.depthTexture&&this.writeDepthTexture){const l=e.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,t)}if((e.stencil||e.depth)&&!(e.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let l,c;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,c=i.DEPTH_STENCIL):e.depth&&e.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,c=i.DEPTH24_STENCIL8):e.depth?(l=i.DEPTH_ATTACHMENT,c=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,c=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,c,e.width,e.height):i.renderbufferStorage(i.RENDERBUFFER,c,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,s.stencil)}else s.stencil&&(i.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(e){return this.renderer.context.webGLVersion!==1&&e.colorTextures.length<=1&&!e.depthTexture}detectSamples(e){const{msaaSamples:t}=this;let i=ut.NONE;if(e<=1||t===null)return i;for(let s=0;s=0&&this.managedFramebuffers.splice(n,1),e.disposeRunner.remove(this),t||(s.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&s.deleteRenderbuffer(i.msaaBuffer),i.stencil&&s.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,t)}disposeAll(e){const t=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;ii.createVertexArrayOES(),e.bindVertexArray=s=>i.bindVertexArrayOES(s),e.deleteVertexArray=s=>i.deleteVertexArrayOES(s)):(this.hasVao=!1,e.createVertexArray=()=>null,e.bindVertexArray=()=>null,e.deleteVertexArray=()=>null)}if(t.webGLVersion!==2){const i=e.getExtension("ANGLE_instanced_arrays");i?(e.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n),e.drawElementsInstanced=(s,n,a,o,l)=>i.drawElementsInstancedANGLE(s,n,a,o,l),e.drawArraysInstanced=(s,n,a,o)=>i.drawArraysInstancedANGLE(s,n,a,o)):this.hasInstance=!1}this.canUseUInt32ElementIndex=t.webGLVersion===2||!!t.extensions.uint32ElementIndex}bind(e,t){t=t||this.renderer.shader.shader;const{gl:i}=this;let s=e.glVertexArrayObjects[this.CONTEXT_UID],n=!1;s||(this.managedGeometries[e.id]=e,e.disposeRunner.add(this),e.glVertexArrayObjects[this.CONTEXT_UID]=s={},n=!0);const a=s[t.program.id]||this.initGeometryVao(e,t,n);this._activeGeometry=e,this._activeVao!==a&&(this._activeVao=a,this.hasVao?i.bindVertexArray(a):this.activateVao(e,t.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const e=this._activeGeometry,t=this.renderer.buffer;for(let i=0;i"u"?.5:t,this.isSimple=!1}get texture(){return this._texture}set texture(e){this._texture=e,this._textureID=-1}multiplyUvs(e,t){t===void 0&&(t=e);const i=this.mapCoord;for(let s=0;s>1,i++;this.stateId=e.data}for(let t=0;te.systems[s]),i=[...t,...Object.keys(e.systems).filter(s=>!t.includes(s))];for(const s of i)this.addSystem(e.systems[s],s)}addRunners(...e){e.forEach(t=>{this.runners[t]=new Ei(t)})}addSystem(e,t){const i=new e(this);if(this[t])throw new Error(`Whoops! The name "${t}" is already in use`);this[t]=i,this._systemsHash[t]=i;for(const s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(e,t){const i=Object.keys(this._systemsHash);e.items.forEach(s=>{const n=i.find(a=>this._systemsHash[a]===s);s[e.name](t[n])})}destroy(){Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash={}}}const Fn=class ho{constructor(e){this.renderer=e,this.count=0,this.checkCount=0,this.maxIdle=ho.defaultMaxIdle,this.checkCountMax=ho.defaultCheckCountMax,this.mode=ho.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Pc.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const e=this.renderer.texture,t=e.managedTextures;let i=!1;for(let s=0;sthis.maxIdle&&(e.destroyTexture(n,!0),t[s]=null,i=!0)}if(i){let s=0;for(let n=0;n=0;s--)this.unload(e.children[s])}destroy(){this.renderer=null}};Fn.defaultMode=Pc.AUTO,Fn.defaultMaxIdle=60*60,Fn.defaultCheckCountMax=60*10,Fn.extension={type:ae.RendererSystem,name:"textureGC"};let Zr=Fn;me.add(Zr);class Xl{constructor(e){this.texture=e,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=we.UNSIGNED_BYTE,this.internalFormat=re.RGBA,this.samplerType=0}}function Gb(r){let e;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?e={[r.RGB]:ce.FLOAT,[r.RGBA]:ce.FLOAT,[r.ALPHA]:ce.FLOAT,[r.LUMINANCE]:ce.FLOAT,[r.LUMINANCE_ALPHA]:ce.FLOAT,[r.R8]:ce.FLOAT,[r.R8_SNORM]:ce.FLOAT,[r.RG8]:ce.FLOAT,[r.RG8_SNORM]:ce.FLOAT,[r.RGB8]:ce.FLOAT,[r.RGB8_SNORM]:ce.FLOAT,[r.RGB565]:ce.FLOAT,[r.RGBA4]:ce.FLOAT,[r.RGB5_A1]:ce.FLOAT,[r.RGBA8]:ce.FLOAT,[r.RGBA8_SNORM]:ce.FLOAT,[r.RGB10_A2]:ce.FLOAT,[r.RGB10_A2UI]:ce.FLOAT,[r.SRGB8]:ce.FLOAT,[r.SRGB8_ALPHA8]:ce.FLOAT,[r.R16F]:ce.FLOAT,[r.RG16F]:ce.FLOAT,[r.RGB16F]:ce.FLOAT,[r.RGBA16F]:ce.FLOAT,[r.R32F]:ce.FLOAT,[r.RG32F]:ce.FLOAT,[r.RGB32F]:ce.FLOAT,[r.RGBA32F]:ce.FLOAT,[r.R11F_G11F_B10F]:ce.FLOAT,[r.RGB9_E5]:ce.FLOAT,[r.R8I]:ce.INT,[r.R8UI]:ce.UINT,[r.R16I]:ce.INT,[r.R16UI]:ce.UINT,[r.R32I]:ce.INT,[r.R32UI]:ce.UINT,[r.RG8I]:ce.INT,[r.RG8UI]:ce.UINT,[r.RG16I]:ce.INT,[r.RG16UI]:ce.UINT,[r.RG32I]:ce.INT,[r.RG32UI]:ce.UINT,[r.RGB8I]:ce.INT,[r.RGB8UI]:ce.UINT,[r.RGB16I]:ce.INT,[r.RGB16UI]:ce.UINT,[r.RGB32I]:ce.INT,[r.RGB32UI]:ce.UINT,[r.RGBA8I]:ce.INT,[r.RGBA8UI]:ce.UINT,[r.RGBA16I]:ce.INT,[r.RGBA16UI]:ce.UINT,[r.RGBA32I]:ce.INT,[r.RGBA32UI]:ce.UINT,[r.DEPTH_COMPONENT16]:ce.FLOAT,[r.DEPTH_COMPONENT24]:ce.FLOAT,[r.DEPTH_COMPONENT32F]:ce.FLOAT,[r.DEPTH_STENCIL]:ce.FLOAT,[r.DEPTH24_STENCIL8]:ce.FLOAT,[r.DEPTH32F_STENCIL8]:ce.FLOAT}:e={[r.RGB]:ce.FLOAT,[r.RGBA]:ce.FLOAT,[r.ALPHA]:ce.FLOAT,[r.LUMINANCE]:ce.FLOAT,[r.LUMINANCE_ALPHA]:ce.FLOAT,[r.DEPTH_STENCIL]:ce.FLOAT},e}function Hb(r){let e;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?e={[we.UNSIGNED_BYTE]:{[re.RGBA]:r.RGBA8,[re.RGB]:r.RGB8,[re.RG]:r.RG8,[re.RED]:r.R8,[re.RGBA_INTEGER]:r.RGBA8UI,[re.RGB_INTEGER]:r.RGB8UI,[re.RG_INTEGER]:r.RG8UI,[re.RED_INTEGER]:r.R8UI,[re.ALPHA]:r.ALPHA,[re.LUMINANCE]:r.LUMINANCE,[re.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[we.BYTE]:{[re.RGBA]:r.RGBA8_SNORM,[re.RGB]:r.RGB8_SNORM,[re.RG]:r.RG8_SNORM,[re.RED]:r.R8_SNORM,[re.RGBA_INTEGER]:r.RGBA8I,[re.RGB_INTEGER]:r.RGB8I,[re.RG_INTEGER]:r.RG8I,[re.RED_INTEGER]:r.R8I},[we.UNSIGNED_SHORT]:{[re.RGBA_INTEGER]:r.RGBA16UI,[re.RGB_INTEGER]:r.RGB16UI,[re.RG_INTEGER]:r.RG16UI,[re.RED_INTEGER]:r.R16UI,[re.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[we.SHORT]:{[re.RGBA_INTEGER]:r.RGBA16I,[re.RGB_INTEGER]:r.RGB16I,[re.RG_INTEGER]:r.RG16I,[re.RED_INTEGER]:r.R16I},[we.UNSIGNED_INT]:{[re.RGBA_INTEGER]:r.RGBA32UI,[re.RGB_INTEGER]:r.RGB32UI,[re.RG_INTEGER]:r.RG32UI,[re.RED_INTEGER]:r.R32UI,[re.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[we.INT]:{[re.RGBA_INTEGER]:r.RGBA32I,[re.RGB_INTEGER]:r.RGB32I,[re.RG_INTEGER]:r.RG32I,[re.RED_INTEGER]:r.R32I},[we.FLOAT]:{[re.RGBA]:r.RGBA32F,[re.RGB]:r.RGB32F,[re.RG]:r.RG32F,[re.RED]:r.R32F,[re.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[we.HALF_FLOAT]:{[re.RGBA]:r.RGBA16F,[re.RGB]:r.RGB16F,[re.RG]:r.RG16F,[re.RED]:r.R16F},[we.UNSIGNED_SHORT_5_6_5]:{[re.RGB]:r.RGB565},[we.UNSIGNED_SHORT_4_4_4_4]:{[re.RGBA]:r.RGBA4},[we.UNSIGNED_SHORT_5_5_5_1]:{[re.RGBA]:r.RGB5_A1},[we.UNSIGNED_INT_2_10_10_10_REV]:{[re.RGBA]:r.RGB10_A2,[re.RGBA_INTEGER]:r.RGB10_A2UI},[we.UNSIGNED_INT_10F_11F_11F_REV]:{[re.RGB]:r.R11F_G11F_B10F},[we.UNSIGNED_INT_5_9_9_9_REV]:{[re.RGB]:r.RGB9_E5},[we.UNSIGNED_INT_24_8]:{[re.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[we.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[re.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:e={[we.UNSIGNED_BYTE]:{[re.RGBA]:r.RGBA,[re.RGB]:r.RGB,[re.ALPHA]:r.ALPHA,[re.LUMINANCE]:r.LUMINANCE,[re.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[we.UNSIGNED_SHORT_5_6_5]:{[re.RGB]:r.RGB},[we.UNSIGNED_SHORT_4_4_4_4]:{[re.RGBA]:r.RGBA},[we.UNSIGNED_SHORT_5_5_5_1]:{[re.RGBA]:r.RGBA}},e}class Zf{constructor(e){this.renderer=e,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new Me,this.hasIntegerTextures=!1}contextChange(){const e=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=Hb(e),this.samplerTypes=Gb(e);const t=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=t;for(let s=0;s=0;--n){const a=t[n];a&&a._glTextures[s].samplerType!==ce.FLOAT&&this.renderer.texture.unbind(a)}}initTexture(e){const t=new Xl(this.gl.createTexture());return t.dirtyId=-1,e._glTextures[this.CONTEXT_UID]=t,this.managedTextures.push(e),e.on("dispose",this.destroyTexture,this),t}initTextureType(e,t){t.internalFormat=this.internalFormats[e.type]?.[e.format]??e.format,t.samplerType=this.samplerTypes[t.internalFormat]??ce.FLOAT,this.webGLVersion===2&&e.type===we.HALF_FLOAT?t.type=this.gl.HALF_FLOAT:t.type=e.type}updateTexture(e){const t=e._glTextures[this.CONTEXT_UID];if(!t)return;const i=this.renderer;if(this.initTextureType(e,t),e.resource?.upload(i,e,t))t.samplerType!==ce.FLOAT&&(this.hasIntegerTextures=!0);else{const s=e.realWidth,n=e.realHeight,a=i.gl;(t.width!==s||t.height!==n||t.dirtyId<0)&&(t.width=s,t.height=n,a.texImage2D(e.target,0,t.internalFormat,s,n,0,e.format,t.type,null))}e.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(e),t.dirtyId=e.dirtyId}destroyTexture(e,t){const{gl:i}=this;if(e=e.castToBaseTexture(),e._glTextures[this.CONTEXT_UID]&&(this.unbind(e),i.deleteTexture(e._glTextures[this.CONTEXT_UID].texture),e.off("dispose",this.destroyTexture,this),delete e._glTextures[this.CONTEXT_UID],!t)){const s=this.managedTextures.indexOf(e);s!==-1&&en(this.managedTextures,s,1)}}updateTextureStyle(e){const t=e._glTextures[this.CONTEXT_UID];t&&((e.mipmap===Xt.POW2||this.webGLVersion!==2)&&!e.isPowerOfTwo?t.mipmap=!1:t.mipmap=e.mipmap>=1,this.webGLVersion!==2&&!e.isPowerOfTwo?t.wrapMode=Pr.CLAMP:t.wrapMode=e.wrapMode,e.resource?.style(this.renderer,e,t)||this.setStyle(e,t),t.dirtyStyleId=e.dirtyStyleId)}setStyle(e,t){const i=this.gl;if(t.mipmap&&e.mipmap!==Xt.ON_MANUAL&&i.generateMipmap(e.target),i.texParameteri(e.target,i.TEXTURE_WRAP_S,t.wrapMode),i.texParameteri(e.target,i.TEXTURE_WRAP_T,t.wrapMode),t.mipmap){i.texParameteri(e.target,i.TEXTURE_MIN_FILTER,e.scaleMode===er.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&e.anisotropicLevel>0&&e.scaleMode===er.LINEAR){const n=Math.min(e.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(e.target,s.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(e.target,i.TEXTURE_MIN_FILTER,e.scaleMode===er.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(e.target,i.TEXTURE_MAG_FILTER,e.scaleMode===er.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Zf.extension={type:ae.RendererSystem,name:"texture"};me.add(Zf);class em{constructor(e){this.renderer=e}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(e){const{gl:t,CONTEXT_UID:i}=this,s=e._glTransformFeedbacks[i]||this.createGLTransformFeedback(e);t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,s)}unbind(){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(e,t){const{gl:i,renderer:s}=this;t&&s.shader.bind(t),i.beginTransformFeedback(e)}endTransformFeedback(){const{gl:e}=this;e.endTransformFeedback()}createGLTransformFeedback(e){const{gl:t,renderer:i,CONTEXT_UID:s}=this,n=t.createTransformFeedback();e._glTransformFeedbacks[s]=n,t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,n);for(let a=0;a(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(As||{});class Kl{constructor(e,t=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=e,this.context=t,this.priority=i,this.once=s}match(e,t=null){return this.fn===e&&this.context===t}emit(e){this.fn&&(this.context?this.fn.call(this.context,e):this.fn(e));const t=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const t=this.next;return this.next=e?null:t,this.previous=null,t}}const tm=class Vt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Kl(null,null,1/0),this.deltaMS=1/Vt.targetFPMS,this.elapsedMS=1/Vt.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(e,t,i=As.NORMAL){return this._addListener(new Kl(e,t,i))}addOnce(e,t,i=As.NORMAL){return this._addListener(new Kl(e,t,i,!0))}_addListener(e){let t=this._head.next,i=this._head;if(!t)e.connect(i);else{for(;t;){if(e.priority>t.priority){e.connect(i);break}i=t,t=t.next}e.previous||e.connect(i)}return this._startIfPossible(),this}remove(e,t){let i=this._head.next;for(;i;)i.match(e,t)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){const n=e-this._lastFrame|0;if(n{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?Ft.shared:new Ft,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}im.extension=ae.Application;me.add(im);const rm=[];me.handleByList(ae.Renderer,rm);function Wb(r){for(const e of rm)if(e.test(r))return new e(r);throw new Error("Unable to auto-detect a suitable renderer.")}var Vb=`attribute vec2 aVertexPosition; +`))}}let kb=0;const La={textureCount:0,uboCount:0};class $f{constructor(e){this.destroyed=!1,this.renderer=e,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=kb++}systemCheck(){if(!tb())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(e){this.gl=e,this.reset()}bind(e,t){e.disposeRunner.add(this),e.uniforms.globals=this.renderer.globalUniforms;const i=e.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(e);return this.shader=e,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),t||(La.textureCount=0,La.uboCount=0,this.syncUniformGroup(e.uniformGroup,La)),s}setUniforms(e){const t=this.shader.program,i=t.glPrograms[this.renderer.CONTEXT_UID];t.syncUniforms(i.uniformData,e,this.renderer)}syncUniformGroup(e,t){const i=this.getGlProgram();(!e.static||e.dirtyId!==i.uniformDirtyGroups[e.id])&&(i.uniformDirtyGroups[e.id]=e.dirtyId,this.syncUniforms(e,i,t))}syncUniforms(e,t,i){(e.syncUniforms[this.shader.program.id]||this.createSyncGroups(e))(t.uniformData,e.uniforms,this.renderer,i)}createSyncGroups(e){const t=this.getSignature(e,this.shader.program.uniformData,"u");return this.cache[t]||(this.cache[t]=Qv(e,this.shader.program.uniformData)),e.syncUniforms[this.shader.program.id]=this.cache[t],e.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(e,t){const i=this.getGlProgram();if(!e.static||e.dirtyId!==0||!i.uniformGroups[e.id]){e.dirtyId=0;const s=i.uniformGroups[e.id]||this.createSyncBufferGroup(e,i,t);e.buffer.update(),s(i.uniformData,e.uniforms,this.renderer,La,e.buffer)}this.renderer.buffer.bindBufferBase(e.buffer,i.uniformBufferBindings[t])}createSyncBufferGroup(e,t,i){const{gl:s}=this.renderer;this.renderer.buffer.bind(e.buffer);const n=this.gl.getUniformBlockIndex(t.program,i);t.uniformBufferBindings[i]=this.shader.uniformBindCount,s.uniformBlockBinding(t.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const a=this.getSignature(e,this.shader.program.uniformData,"ubo");let o=this._uboCache[a];if(o||(o=this._uboCache[a]=Ib(e,this.shader.program.uniformData)),e.autoManage){const l=new Float32Array(o.size/4);e.buffer.update(l)}return t.uniformGroups[e.id]=o.syncFunc,t.uniformGroups[e.id]}getSignature(e,t,i){const s=e.uniforms,n=[`${i}-`];for(const a in s)n.push(a),t[a]&&n.push(t[a].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(e){const t=this.gl,i=e.program,s=Eb(t,i);return i.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(e){this.shader===e&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}$f.extension={type:ae.RendererSystem,name:"shader"};me.add($f);class Io{constructor(e){this.renderer=e}run(e){const{renderer:t}=this;t.runners.init.emit(t.options),e.hello&&console.log(`PixiJS 7.3.1 - ${t.rendererLogId} - https://pixijs.com`),t.resize(t.screen.width,t.screen.height)}destroy(){}}Io.defaultOptions={hello:!1},Io.extension={type:[ae.RendererSystem,ae.CanvasRendererSystem],name:"startup"};me.add(Io);function Bb(r,e=[]){return e[Ee.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.ADD]=[r.ONE,r.ONE],e[Ee.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.NONE]=[0,0],e[Ee.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],e[Ee.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ee.SRC_IN]=[r.DST_ALPHA,r.ZERO],e[Ee.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],e[Ee.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],e[Ee.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],e[Ee.DST_IN]=[r.ZERO,r.SRC_ALPHA],e[Ee.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],e[Ee.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],e[Ee.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],e[Ee.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],e}const Pb=0,Rb=1,Db=2,Lb=3,Ob=4,Fb=5,Jf=class Qh{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=Ee.NONE,this._blendEq=!1,this.map=[],this.map[Pb]=this.setBlend,this.map[Rb]=this.setOffset,this.map[Db]=this.setCullFace,this.map[Lb]=this.setDepthTest,this.map[Ob]=this.setFrontFace,this.map[Fb]=this.setDepthMask,this.checks=[],this.defaultState=new ji,this.defaultState.blend=!0}contextChange(e){this.gl=e,this.blendModes=Bb(e),this.set(this.defaultState),this.reset()}set(e){if(e=e||this.defaultState,this.stateId!==e.data){let t=this.stateId^e.data,i=0;for(;t;)t&1&&this.map[i].call(this,!!(e.data&1<>1,i++;this.stateId=e.data}for(let t=0;te.systems[s]),i=[...t,...Object.keys(e.systems).filter(s=>!t.includes(s))];for(const s of i)this.addSystem(e.systems[s],s)}addRunners(...e){e.forEach(t=>{this.runners[t]=new Ei(t)})}addSystem(e,t){const i=new e(this);if(this[t])throw new Error(`Whoops! The name "${t}" is already in use`);this[t]=i,this._systemsHash[t]=i;for(const s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(e,t){const i=Object.keys(this._systemsHash);e.items.forEach(s=>{const n=i.find(a=>this._systemsHash[a]===s);s[e.name](t[n])})}destroy(){Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash={}}}const Fn=class ho{constructor(e){this.renderer=e,this.count=0,this.checkCount=0,this.maxIdle=ho.defaultMaxIdle,this.checkCountMax=ho.defaultCheckCountMax,this.mode=ho.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Pc.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const e=this.renderer.texture,t=e.managedTextures;let i=!1;for(let s=0;sthis.maxIdle&&(e.destroyTexture(n,!0),t[s]=null,i=!0)}if(i){let s=0;for(let n=0;n=0;s--)this.unload(e.children[s])}destroy(){this.renderer=null}};Fn.defaultMode=Pc.AUTO,Fn.defaultMaxIdle=60*60,Fn.defaultCheckCountMax=60*10,Fn.extension={type:ae.RendererSystem,name:"textureGC"};let Zr=Fn;me.add(Zr);class Xl{constructor(e){this.texture=e,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=we.UNSIGNED_BYTE,this.internalFormat=re.RGBA,this.samplerType=0}}function Gb(r){let e;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?e={[r.RGB]:ce.FLOAT,[r.RGBA]:ce.FLOAT,[r.ALPHA]:ce.FLOAT,[r.LUMINANCE]:ce.FLOAT,[r.LUMINANCE_ALPHA]:ce.FLOAT,[r.R8]:ce.FLOAT,[r.R8_SNORM]:ce.FLOAT,[r.RG8]:ce.FLOAT,[r.RG8_SNORM]:ce.FLOAT,[r.RGB8]:ce.FLOAT,[r.RGB8_SNORM]:ce.FLOAT,[r.RGB565]:ce.FLOAT,[r.RGBA4]:ce.FLOAT,[r.RGB5_A1]:ce.FLOAT,[r.RGBA8]:ce.FLOAT,[r.RGBA8_SNORM]:ce.FLOAT,[r.RGB10_A2]:ce.FLOAT,[r.RGB10_A2UI]:ce.FLOAT,[r.SRGB8]:ce.FLOAT,[r.SRGB8_ALPHA8]:ce.FLOAT,[r.R16F]:ce.FLOAT,[r.RG16F]:ce.FLOAT,[r.RGB16F]:ce.FLOAT,[r.RGBA16F]:ce.FLOAT,[r.R32F]:ce.FLOAT,[r.RG32F]:ce.FLOAT,[r.RGB32F]:ce.FLOAT,[r.RGBA32F]:ce.FLOAT,[r.R11F_G11F_B10F]:ce.FLOAT,[r.RGB9_E5]:ce.FLOAT,[r.R8I]:ce.INT,[r.R8UI]:ce.UINT,[r.R16I]:ce.INT,[r.R16UI]:ce.UINT,[r.R32I]:ce.INT,[r.R32UI]:ce.UINT,[r.RG8I]:ce.INT,[r.RG8UI]:ce.UINT,[r.RG16I]:ce.INT,[r.RG16UI]:ce.UINT,[r.RG32I]:ce.INT,[r.RG32UI]:ce.UINT,[r.RGB8I]:ce.INT,[r.RGB8UI]:ce.UINT,[r.RGB16I]:ce.INT,[r.RGB16UI]:ce.UINT,[r.RGB32I]:ce.INT,[r.RGB32UI]:ce.UINT,[r.RGBA8I]:ce.INT,[r.RGBA8UI]:ce.UINT,[r.RGBA16I]:ce.INT,[r.RGBA16UI]:ce.UINT,[r.RGBA32I]:ce.INT,[r.RGBA32UI]:ce.UINT,[r.DEPTH_COMPONENT16]:ce.FLOAT,[r.DEPTH_COMPONENT24]:ce.FLOAT,[r.DEPTH_COMPONENT32F]:ce.FLOAT,[r.DEPTH_STENCIL]:ce.FLOAT,[r.DEPTH24_STENCIL8]:ce.FLOAT,[r.DEPTH32F_STENCIL8]:ce.FLOAT}:e={[r.RGB]:ce.FLOAT,[r.RGBA]:ce.FLOAT,[r.ALPHA]:ce.FLOAT,[r.LUMINANCE]:ce.FLOAT,[r.LUMINANCE_ALPHA]:ce.FLOAT,[r.DEPTH_STENCIL]:ce.FLOAT},e}function Hb(r){let e;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?e={[we.UNSIGNED_BYTE]:{[re.RGBA]:r.RGBA8,[re.RGB]:r.RGB8,[re.RG]:r.RG8,[re.RED]:r.R8,[re.RGBA_INTEGER]:r.RGBA8UI,[re.RGB_INTEGER]:r.RGB8UI,[re.RG_INTEGER]:r.RG8UI,[re.RED_INTEGER]:r.R8UI,[re.ALPHA]:r.ALPHA,[re.LUMINANCE]:r.LUMINANCE,[re.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[we.BYTE]:{[re.RGBA]:r.RGBA8_SNORM,[re.RGB]:r.RGB8_SNORM,[re.RG]:r.RG8_SNORM,[re.RED]:r.R8_SNORM,[re.RGBA_INTEGER]:r.RGBA8I,[re.RGB_INTEGER]:r.RGB8I,[re.RG_INTEGER]:r.RG8I,[re.RED_INTEGER]:r.R8I},[we.UNSIGNED_SHORT]:{[re.RGBA_INTEGER]:r.RGBA16UI,[re.RGB_INTEGER]:r.RGB16UI,[re.RG_INTEGER]:r.RG16UI,[re.RED_INTEGER]:r.R16UI,[re.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[we.SHORT]:{[re.RGBA_INTEGER]:r.RGBA16I,[re.RGB_INTEGER]:r.RGB16I,[re.RG_INTEGER]:r.RG16I,[re.RED_INTEGER]:r.R16I},[we.UNSIGNED_INT]:{[re.RGBA_INTEGER]:r.RGBA32UI,[re.RGB_INTEGER]:r.RGB32UI,[re.RG_INTEGER]:r.RG32UI,[re.RED_INTEGER]:r.R32UI,[re.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[we.INT]:{[re.RGBA_INTEGER]:r.RGBA32I,[re.RGB_INTEGER]:r.RGB32I,[re.RG_INTEGER]:r.RG32I,[re.RED_INTEGER]:r.R32I},[we.FLOAT]:{[re.RGBA]:r.RGBA32F,[re.RGB]:r.RGB32F,[re.RG]:r.RG32F,[re.RED]:r.R32F,[re.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[we.HALF_FLOAT]:{[re.RGBA]:r.RGBA16F,[re.RGB]:r.RGB16F,[re.RG]:r.RG16F,[re.RED]:r.R16F},[we.UNSIGNED_SHORT_5_6_5]:{[re.RGB]:r.RGB565},[we.UNSIGNED_SHORT_4_4_4_4]:{[re.RGBA]:r.RGBA4},[we.UNSIGNED_SHORT_5_5_5_1]:{[re.RGBA]:r.RGB5_A1},[we.UNSIGNED_INT_2_10_10_10_REV]:{[re.RGBA]:r.RGB10_A2,[re.RGBA_INTEGER]:r.RGB10_A2UI},[we.UNSIGNED_INT_10F_11F_11F_REV]:{[re.RGB]:r.R11F_G11F_B10F},[we.UNSIGNED_INT_5_9_9_9_REV]:{[re.RGB]:r.RGB9_E5},[we.UNSIGNED_INT_24_8]:{[re.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[we.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[re.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:e={[we.UNSIGNED_BYTE]:{[re.RGBA]:r.RGBA,[re.RGB]:r.RGB,[re.ALPHA]:r.ALPHA,[re.LUMINANCE]:r.LUMINANCE,[re.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[we.UNSIGNED_SHORT_5_6_5]:{[re.RGB]:r.RGB},[we.UNSIGNED_SHORT_4_4_4_4]:{[re.RGBA]:r.RGBA},[we.UNSIGNED_SHORT_5_5_5_1]:{[re.RGBA]:r.RGBA}},e}class Zf{constructor(e){this.renderer=e,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new Me,this.hasIntegerTextures=!1}contextChange(){const e=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=Hb(e),this.samplerTypes=Gb(e);const t=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=t;for(let s=0;s=0;--n){const a=t[n];a&&a._glTextures[s].samplerType!==ce.FLOAT&&this.renderer.texture.unbind(a)}}initTexture(e){const t=new Xl(this.gl.createTexture());return t.dirtyId=-1,e._glTextures[this.CONTEXT_UID]=t,this.managedTextures.push(e),e.on("dispose",this.destroyTexture,this),t}initTextureType(e,t){t.internalFormat=this.internalFormats[e.type]?.[e.format]??e.format,t.samplerType=this.samplerTypes[t.internalFormat]??ce.FLOAT,this.webGLVersion===2&&e.type===we.HALF_FLOAT?t.type=this.gl.HALF_FLOAT:t.type=e.type}updateTexture(e){const t=e._glTextures[this.CONTEXT_UID];if(!t)return;const i=this.renderer;if(this.initTextureType(e,t),e.resource?.upload(i,e,t))t.samplerType!==ce.FLOAT&&(this.hasIntegerTextures=!0);else{const s=e.realWidth,n=e.realHeight,a=i.gl;(t.width!==s||t.height!==n||t.dirtyId<0)&&(t.width=s,t.height=n,a.texImage2D(e.target,0,t.internalFormat,s,n,0,e.format,t.type,null))}e.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(e),t.dirtyId=e.dirtyId}destroyTexture(e,t){const{gl:i}=this;if(e=e.castToBaseTexture(),e._glTextures[this.CONTEXT_UID]&&(this.unbind(e),i.deleteTexture(e._glTextures[this.CONTEXT_UID].texture),e.off("dispose",this.destroyTexture,this),delete e._glTextures[this.CONTEXT_UID],!t)){const s=this.managedTextures.indexOf(e);s!==-1&&en(this.managedTextures,s,1)}}updateTextureStyle(e){const t=e._glTextures[this.CONTEXT_UID];t&&((e.mipmap===Xt.POW2||this.webGLVersion!==2)&&!e.isPowerOfTwo?t.mipmap=!1:t.mipmap=e.mipmap>=1,this.webGLVersion!==2&&!e.isPowerOfTwo?t.wrapMode=Rr.CLAMP:t.wrapMode=e.wrapMode,e.resource?.style(this.renderer,e,t)||this.setStyle(e,t),t.dirtyStyleId=e.dirtyStyleId)}setStyle(e,t){const i=this.gl;if(t.mipmap&&e.mipmap!==Xt.ON_MANUAL&&i.generateMipmap(e.target),i.texParameteri(e.target,i.TEXTURE_WRAP_S,t.wrapMode),i.texParameteri(e.target,i.TEXTURE_WRAP_T,t.wrapMode),t.mipmap){i.texParameteri(e.target,i.TEXTURE_MIN_FILTER,e.scaleMode===er.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&e.anisotropicLevel>0&&e.scaleMode===er.LINEAR){const n=Math.min(e.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(e.target,s.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(e.target,i.TEXTURE_MIN_FILTER,e.scaleMode===er.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(e.target,i.TEXTURE_MAG_FILTER,e.scaleMode===er.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Zf.extension={type:ae.RendererSystem,name:"texture"};me.add(Zf);class em{constructor(e){this.renderer=e}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(e){const{gl:t,CONTEXT_UID:i}=this,s=e._glTransformFeedbacks[i]||this.createGLTransformFeedback(e);t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,s)}unbind(){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(e,t){const{gl:i,renderer:s}=this;t&&s.shader.bind(t),i.beginTransformFeedback(e)}endTransformFeedback(){const{gl:e}=this;e.endTransformFeedback()}createGLTransformFeedback(e){const{gl:t,renderer:i,CONTEXT_UID:s}=this,n=t.createTransformFeedback();e._glTransformFeedbacks[s]=n,t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,n);for(let a=0;a(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(As||{});class Kl{constructor(e,t=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=e,this.context=t,this.priority=i,this.once=s}match(e,t=null){return this.fn===e&&this.context===t}emit(e){this.fn&&(this.context?this.fn.call(this.context,e):this.fn(e));const t=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const t=this.next;return this.next=e?null:t,this.previous=null,t}}const tm=class Vt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Kl(null,null,1/0),this.deltaMS=1/Vt.targetFPMS,this.elapsedMS=1/Vt.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(e,t,i=As.NORMAL){return this._addListener(new Kl(e,t,i))}addOnce(e,t,i=As.NORMAL){return this._addListener(new Kl(e,t,i,!0))}_addListener(e){let t=this._head.next,i=this._head;if(!t)e.connect(i);else{for(;t;){if(e.priority>t.priority){e.connect(i);break}i=t,t=t.next}e.previous||e.connect(i)}return this._startIfPossible(),this}remove(e,t){let i=this._head.next;for(;i;)i.match(e,t)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){const n=e-this._lastFrame|0;if(n{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?Ft.shared:new Ft,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}im.extension=ae.Application;me.add(im);const rm=[];me.handleByList(ae.Renderer,rm);function Wb(r){for(const e of rm)if(e.test(r))return new e(r);throw new Error("Unable to auto-detect a suitable renderer.")}var Vb=`attribute vec2 aVertexPosition; attribute vec2 aTextureCoord; uniform mat3 projectionMatrix; @@ -523,7 +523,7 @@ void main(void) gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); } -`;const jb=Vb,sm=zb;class nm{constructor(e){this.renderer=e}contextChange(e){let t;if(this.renderer.context.webGLVersion===1){const i=e.getParameter(e.FRAMEBUFFER_BINDING);e.bindFramebuffer(e.FRAMEBUFFER,null),t=e.getParameter(e.SAMPLES),e.bindFramebuffer(e.FRAMEBUFFER,i)}else{const i=e.getParameter(e.DRAW_FRAMEBUFFER_BINDING);e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),t=e.getParameter(e.SAMPLES),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,i)}t>=ut.HIGH?this.multisample=ut.HIGH:t>=ut.MEDIUM?this.multisample=ut.MEDIUM:t>=ut.LOW?this.multisample=ut.LOW:this.multisample=ut.NONE}destroy(){}}nm.extension={type:ae.RendererSystem,name:"_multisample"};me.add(nm);class Yb{constructor(e){this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class am{constructor(e){this.renderer=e,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(e){const{gl:t,CONTEXT_UID:i}=this,s=e._glBuffers[i]||this.createGLBuffer(e);t.bindBuffer(e.type,s.buffer)}unbind(e){const{gl:t}=this;t.bindBuffer(e,null)}bindBufferBase(e,t){const{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[t]!==e){const n=e._glBuffers[s]||this.createGLBuffer(e);this.boundBufferBases[t]=e,i.bindBufferBase(i.UNIFORM_BUFFER,t,n.buffer)}}bindBufferRange(e,t,i){const{gl:s,CONTEXT_UID:n}=this;i=i||0;const a=e._glBuffers[n]||this.createGLBuffer(e);s.bindBufferRange(s.UNIFORM_BUFFER,t||0,a.buffer,i*256,256)}update(e){const{gl:t,CONTEXT_UID:i}=this,s=e._glBuffers[i]||this.createGLBuffer(e);if(e._updateID!==s.updateID)if(s.updateID=e._updateID,t.bindBuffer(e.type,s.buffer),s.byteLength>=e.data.byteLength)t.bufferSubData(e.type,0,e.data);else{const n=e.static?t.STATIC_DRAW:t.DYNAMIC_DRAW;s.byteLength=e.data.byteLength,t.bufferData(e.type,e.data,n)}}dispose(e,t){if(!this.managedBuffers[e.id])return;delete this.managedBuffers[e.id];const i=e._glBuffers[this.CONTEXT_UID],s=this.gl;e.disposeRunner.remove(this),i&&(t||s.deleteBuffer(i.buffer),delete e._glBuffers[this.CONTEXT_UID])}disposeAll(e){const t=Object.keys(this.managedBuffers);for(let i=0;it.resource).filter(t=>t).map(t=>t.load());return this._load=Promise.all(e).then(()=>{const{realWidth:t,realHeight:i}=this.items[0];return this.resize(t,i),this.update(),Promise.resolve(this)}),this._load}}class Xb extends lm{constructor(e,t){const{width:i,height:s}=t||{};let n,a;Array.isArray(e)?(n=e,a=e.length):a=e,super(a,{width:i,height:s}),n&&this.initFromArray(n,t)}addBaseTextureAt(e,t){if(e.resource)this.addResourceAt(e.resource,t);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(e){super.bind(e),e.target=$s.TEXTURE_2D_ARRAY}upload(e,t,i){const{length:s,itemDirtyIds:n,items:a}=this,{gl:o}=e;i.dirtyId<0&&o.texImage3D(o.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,t.format,i.type,null);for(let l=0;l0)if(e.resource)this.addResourceAt(e.resource,t);else throw new Error("CubeResource does not support copying of renderTexture.");else e.target=$s.TEXTURE_CUBE_MAP_POSITIVE_X+t,e.parentTextureArray=this.baseTexture,this.items[t]=e;return e.valid&&!this.valid&&this.resize(e.realWidth,e.realHeight),this.items[t]=e,this}upload(e,t,i){const s=this.itemDirtyIds;for(let n=0;n{if(this.url===null){e(this);return}try{const i=await de.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Lt.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),e(this)}catch(i){if(this.destroyed)return;t(i),this.onError.emit(i)}}),this._load)}upload(e,t,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(t.alphaMode=this.alphaMode),super.upload(e,t,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(e){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof e=="string"||e instanceof ImageBitmap)}static get EMPTY(){return Ks._EMPTY=Ks._EMPTY??de.ADAPTER.createCanvas(0,0),Ks._EMPTY}}const Jh=class uo extends Or{constructor(e,t){t=t||{},super(de.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=e,this.scale=t.scale||1,this._overrideWidth=t.width,this._overrideHeight=t.height,this._resolve=null,this._crossorigin=t.crossorigin,this._load=null,t.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(e=>{if(this._resolve=()=>{this.update(),e(this)},uo.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const e=new Image;Or.crossOrigin(e,this.svg,this._crossorigin),e.src=this.svg,e.onerror=t=>{this._resolve&&(e.onerror=null,this.onError.emit(t))},e.onload=()=>{if(!this._resolve)return;const t=e.width,i=e.height;if(!t||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=t*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*t,n=this._overrideHeight||this._overrideWidth/t*i),s=Math.round(s),n=Math.round(n);const a=this.source;a.width=s,a.height=n,a._pixiId=`canvas_${bs()}`,a.getContext("2d").drawImage(e,0,0,t,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(e){const t=uo.SVG_SIZE.exec(e),i={};return t&&(i[t[1]]=Math.round(parseFloat(t[3])),i[t[5]]=Math.round(parseFloat(t[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(e,t){return t==="svg"||typeof e=="string"&&e.startsWith("data:image/svg+xml")||typeof e=="string"&&uo.SVG_XML.test(e)}};Jh.SVG_XML=/^(<\?xml[^?]+\?>)?\s*()]*-->)?\s*\]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Zh=Jh;const ec=class tc extends Or{constructor(e,t){if(t=t||{},!(e instanceof HTMLVideoElement)){const i=document.createElement("video");t.autoLoad!==!1&&i.setAttribute("preload","auto"),t.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),t.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),t.loop===!0&&i.setAttribute("loop",""),t.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof e=="string"&&(e=[e]);const s=e[0].src||e[0];Or.crossOrigin(i,s,t.crossorigin);for(let n=0;n{this.valid?t(this):(this._resolve=t,this._reject=i,e.load())}),this._load}_onError(e){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){const e=this.source;return!e.paused&&!e.ended&&this._isSourceReady()}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!t&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&e.play()}dispose(){this._configureAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(Ft.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Ft.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Ft.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e,t){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement||tc.TYPES.includes(t)}};ec.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],ec.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let cm=ec;Hh.push(Ks,Of,Kb,cm,Zh,Qo,qb,Xb);class Bo{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(e){return this.minX>this.maxX||this.minY>this.maxY?Se.EMPTY:(e=e||new Se(0,0,1,1),e.x=this.minX,e.y=this.minY,e.width=this.maxX-this.minX,e.height=this.maxY-this.minY,e)}addPoint(e){this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y)}addPointMatrix(e,t){const{a:i,b:s,c:n,d:a,tx:o,ty:l}=e,c=i*t.x+n*t.y+o,u=s*t.x+a*t.y+l;this.minX=Math.min(this.minX,c),this.maxX=Math.max(this.maxX,c),this.minY=Math.min(this.minY,u),this.maxY=Math.max(this.maxY,u)}addQuad(e){let t=this.minX,i=this.minY,s=this.maxX,n=this.maxY,a=e[0],o=e[1];t=as?a:s,n=o>n?o:n,a=e[2],o=e[3],t=as?a:s,n=o>n?o:n,a=e[4],o=e[5],t=as?a:s,n=o>n?o:n,a=e[6],o=e[7],t=as?a:s,n=o>n?o:n,this.minX=t,this.minY=i,this.maxX=s,this.maxY=n}addFrame(e,t,i,s,n){this.addFrameMatrix(e.worldTransform,t,i,s,n)}addFrameMatrix(e,t,i,s,n){const a=e.a,o=e.b,l=e.c,c=e.d,u=e.tx,h=e.ty;let d=this.minX,p=this.minY,f=this.maxX,m=this.maxY,g=a*t+l*i+u,y=o*t+c*i+h;d=gf?g:f,m=y>m?y:m,g=a*s+l*i+u,y=o*s+c*i+h,d=gf?g:f,m=y>m?y:m,g=a*t+l*n+u,y=o*t+c*n+h,d=gf?g:f,m=y>m?y:m,g=a*s+l*n+u,y=o*s+c*n+h,d=gf?g:f,m=y>m?y:m,this.minX=d,this.minY=p,this.maxX=f,this.maxY=m}addVertexData(e,t,i){let s=this.minX,n=this.minY,a=this.maxX,o=this.maxY;for(let l=t;la?c:a,o=u>o?u:o}this.minX=s,this.minY=n,this.maxX=a,this.maxY=o}addVertices(e,t,i,s){this.addVerticesMatrix(e.worldTransform,t,i,s)}addVerticesMatrix(e,t,i,s,n=0,a=n){const o=e.a,l=e.b,c=e.c,u=e.d,h=e.tx,d=e.ty;let p=this.minX,f=this.minY,m=this.maxX,g=this.maxY;for(let y=i;ys?e.maxX:s,this.maxY=e.maxY>n?e.maxY:n}addBoundsMask(e,t){const i=e.minX>t.minX?e.minX:t.minX,s=e.minY>t.minY?e.minY:t.minY,n=e.maxXc?n:c,this.maxY=a>u?a:u}}addBoundsMatrix(e,t){this.addFrameMatrix(t,e.minX,e.minY,e.maxX,e.maxY)}addBoundsArea(e,t){const i=e.minX>t.x?e.minX:t.x,s=e.minY>t.y?e.minY:t.y,n=e.maxXc?n:c,this.maxY=a>u?a:u}}pad(e=0,t=e){this.isEmpty()||(this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t)}addFramePad(e,t,i,s,n,a){e-=n,t-=a,i+=n,s+=a,this.minX=this.minXi?this.maxX:i,this.minY=this.minYs?this.maxY:s}}class ot extends bn{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new el,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new Bo,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(e){const t=Object.keys(e);for(let i=0;i1)for(let t=0;tthis.children.length)throw new Error(`${e}addChildAt: The index ${t} supplied is out of bounds ${this.children.length}`);return e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.splice(t,0,e),this._boundsID++,this.onChildrenChange(t),e.emit("added",this),this.emit("childAdded",e,this,t),e}swapChildren(e,t){if(e===t)return;const i=this.getChildIndex(e),s=this.getChildIndex(t);this.children[i]=t,this.children[s]=e,this.onChildrenChange(i=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(e);en(this.children,i,1),this.children.splice(t,0,e),this.onChildrenChange(t)}getChildAt(e){if(e<0||e>=this.children.length)throw new Error(`getChildAt: Index (${e}) does not exist.`);return this.children[e]}removeChild(...e){if(e.length>1)for(let t=0;t0&&n<=s){a=this.children.splice(i,n);for(let o=0;o1&&this.children.sort(Jb),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let e=0,t=this.children.length;e0&&t.height>0))return;let i,s;this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==ic.prototype._render&&(i=this.getBounds(!0));const n=e.projection.transform;if(n&&(s?(s=$b.copyFrom(s),s.prepend(n)):s=n),i&&t.intersects(i,s))this._render(e);else if(this.cullArea)return;for(let a=0,o=this.children.length;a=s&&In.x=n&&In.y=ut.HIGH?this.multisample=ut.HIGH:t>=ut.MEDIUM?this.multisample=ut.MEDIUM:t>=ut.LOW?this.multisample=ut.LOW:this.multisample=ut.NONE}destroy(){}}nm.extension={type:ae.RendererSystem,name:"_multisample"};me.add(nm);class Yb{constructor(e){this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class am{constructor(e){this.renderer=e,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(e){const{gl:t,CONTEXT_UID:i}=this,s=e._glBuffers[i]||this.createGLBuffer(e);t.bindBuffer(e.type,s.buffer)}unbind(e){const{gl:t}=this;t.bindBuffer(e,null)}bindBufferBase(e,t){const{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[t]!==e){const n=e._glBuffers[s]||this.createGLBuffer(e);this.boundBufferBases[t]=e,i.bindBufferBase(i.UNIFORM_BUFFER,t,n.buffer)}}bindBufferRange(e,t,i){const{gl:s,CONTEXT_UID:n}=this;i=i||0;const a=e._glBuffers[n]||this.createGLBuffer(e);s.bindBufferRange(s.UNIFORM_BUFFER,t||0,a.buffer,i*256,256)}update(e){const{gl:t,CONTEXT_UID:i}=this,s=e._glBuffers[i]||this.createGLBuffer(e);if(e._updateID!==s.updateID)if(s.updateID=e._updateID,t.bindBuffer(e.type,s.buffer),s.byteLength>=e.data.byteLength)t.bufferSubData(e.type,0,e.data);else{const n=e.static?t.STATIC_DRAW:t.DYNAMIC_DRAW;s.byteLength=e.data.byteLength,t.bufferData(e.type,e.data,n)}}dispose(e,t){if(!this.managedBuffers[e.id])return;delete this.managedBuffers[e.id];const i=e._glBuffers[this.CONTEXT_UID],s=this.gl;e.disposeRunner.remove(this),i&&(t||s.deleteBuffer(i.buffer),delete e._glBuffers[this.CONTEXT_UID])}disposeAll(e){const t=Object.keys(this.managedBuffers);for(let i=0;it.resource).filter(t=>t).map(t=>t.load());return this._load=Promise.all(e).then(()=>{const{realWidth:t,realHeight:i}=this.items[0];return this.resize(t,i),this.update(),Promise.resolve(this)}),this._load}}class Xb extends lm{constructor(e,t){const{width:i,height:s}=t||{};let n,a;Array.isArray(e)?(n=e,a=e.length):a=e,super(a,{width:i,height:s}),n&&this.initFromArray(n,t)}addBaseTextureAt(e,t){if(e.resource)this.addResourceAt(e.resource,t);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(e){super.bind(e),e.target=$s.TEXTURE_2D_ARRAY}upload(e,t,i){const{length:s,itemDirtyIds:n,items:a}=this,{gl:o}=e;i.dirtyId<0&&o.texImage3D(o.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,t.format,i.type,null);for(let l=0;l0)if(e.resource)this.addResourceAt(e.resource,t);else throw new Error("CubeResource does not support copying of renderTexture.");else e.target=$s.TEXTURE_CUBE_MAP_POSITIVE_X+t,e.parentTextureArray=this.baseTexture,this.items[t]=e;return e.valid&&!this.valid&&this.resize(e.realWidth,e.realHeight),this.items[t]=e,this}upload(e,t,i){const s=this.itemDirtyIds;for(let n=0;n{if(this.url===null){e(this);return}try{const i=await de.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Lt.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),e(this)}catch(i){if(this.destroyed)return;t(i),this.onError.emit(i)}}),this._load)}upload(e,t,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(t.alphaMode=this.alphaMode),super.upload(e,t,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(e){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof e=="string"||e instanceof ImageBitmap)}static get EMPTY(){return Ks._EMPTY=Ks._EMPTY??de.ADAPTER.createCanvas(0,0),Ks._EMPTY}}const Jh=class uo extends Or{constructor(e,t){t=t||{},super(de.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=e,this.scale=t.scale||1,this._overrideWidth=t.width,this._overrideHeight=t.height,this._resolve=null,this._crossorigin=t.crossorigin,this._load=null,t.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(e=>{if(this._resolve=()=>{this.update(),e(this)},uo.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const e=new Image;Or.crossOrigin(e,this.svg,this._crossorigin),e.src=this.svg,e.onerror=t=>{this._resolve&&(e.onerror=null,this.onError.emit(t))},e.onload=()=>{if(!this._resolve)return;const t=e.width,i=e.height;if(!t||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=t*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*t,n=this._overrideHeight||this._overrideWidth/t*i),s=Math.round(s),n=Math.round(n);const a=this.source;a.width=s,a.height=n,a._pixiId=`canvas_${bs()}`,a.getContext("2d").drawImage(e,0,0,t,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(e){const t=uo.SVG_SIZE.exec(e),i={};return t&&(i[t[1]]=Math.round(parseFloat(t[3])),i[t[5]]=Math.round(parseFloat(t[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(e,t){return t==="svg"||typeof e=="string"&&e.startsWith("data:image/svg+xml")||typeof e=="string"&&uo.SVG_XML.test(e)}};Jh.SVG_XML=/^(<\?xml[^?]+\?>)?\s*()]*-->)?\s*\]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Zh=Jh;const ec=class tc extends Or{constructor(e,t){if(t=t||{},!(e instanceof HTMLVideoElement)){const i=document.createElement("video");t.autoLoad!==!1&&i.setAttribute("preload","auto"),t.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),t.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),t.loop===!0&&i.setAttribute("loop",""),t.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof e=="string"&&(e=[e]);const s=e[0].src||e[0];Or.crossOrigin(i,s,t.crossorigin);for(let n=0;n{this.valid?t(this):(this._resolve=t,this._reject=i,e.load())}),this._load}_onError(e){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){const e=this.source;return!e.paused&&!e.ended&&this._isSourceReady()}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!t&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&e.play()}dispose(){this._configureAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(Ft.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Ft.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Ft.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e,t){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement||tc.TYPES.includes(t)}};ec.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],ec.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let cm=ec;Hh.push(Ks,Of,Kb,cm,Zh,Qo,qb,Xb);class Bo{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(e){return this.minX>this.maxX||this.minY>this.maxY?Se.EMPTY:(e=e||new Se(0,0,1,1),e.x=this.minX,e.y=this.minY,e.width=this.maxX-this.minX,e.height=this.maxY-this.minY,e)}addPoint(e){this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y)}addPointMatrix(e,t){const{a:i,b:s,c:n,d:a,tx:o,ty:l}=e,c=i*t.x+n*t.y+o,u=s*t.x+a*t.y+l;this.minX=Math.min(this.minX,c),this.maxX=Math.max(this.maxX,c),this.minY=Math.min(this.minY,u),this.maxY=Math.max(this.maxY,u)}addQuad(e){let t=this.minX,i=this.minY,s=this.maxX,n=this.maxY,a=e[0],o=e[1];t=as?a:s,n=o>n?o:n,a=e[2],o=e[3],t=as?a:s,n=o>n?o:n,a=e[4],o=e[5],t=as?a:s,n=o>n?o:n,a=e[6],o=e[7],t=as?a:s,n=o>n?o:n,this.minX=t,this.minY=i,this.maxX=s,this.maxY=n}addFrame(e,t,i,s,n){this.addFrameMatrix(e.worldTransform,t,i,s,n)}addFrameMatrix(e,t,i,s,n){const a=e.a,o=e.b,l=e.c,c=e.d,u=e.tx,h=e.ty;let d=this.minX,p=this.minY,f=this.maxX,m=this.maxY,g=a*t+l*i+u,y=o*t+c*i+h;d=gf?g:f,m=y>m?y:m,g=a*s+l*i+u,y=o*s+c*i+h,d=gf?g:f,m=y>m?y:m,g=a*t+l*n+u,y=o*t+c*n+h,d=gf?g:f,m=y>m?y:m,g=a*s+l*n+u,y=o*s+c*n+h,d=gf?g:f,m=y>m?y:m,this.minX=d,this.minY=p,this.maxX=f,this.maxY=m}addVertexData(e,t,i){let s=this.minX,n=this.minY,a=this.maxX,o=this.maxY;for(let l=t;la?c:a,o=u>o?u:o}this.minX=s,this.minY=n,this.maxX=a,this.maxY=o}addVertices(e,t,i,s){this.addVerticesMatrix(e.worldTransform,t,i,s)}addVerticesMatrix(e,t,i,s,n=0,a=n){const o=e.a,l=e.b,c=e.c,u=e.d,h=e.tx,d=e.ty;let p=this.minX,f=this.minY,m=this.maxX,g=this.maxY;for(let y=i;ys?e.maxX:s,this.maxY=e.maxY>n?e.maxY:n}addBoundsMask(e,t){const i=e.minX>t.minX?e.minX:t.minX,s=e.minY>t.minY?e.minY:t.minY,n=e.maxXc?n:c,this.maxY=a>u?a:u}}addBoundsMatrix(e,t){this.addFrameMatrix(t,e.minX,e.minY,e.maxX,e.maxY)}addBoundsArea(e,t){const i=e.minX>t.x?e.minX:t.x,s=e.minY>t.y?e.minY:t.y,n=e.maxXc?n:c,this.maxY=a>u?a:u}}pad(e=0,t=e){this.isEmpty()||(this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t)}addFramePad(e,t,i,s,n,a){e-=n,t-=a,i+=n,s+=a,this.minX=this.minXi?this.maxX:i,this.minY=this.minYs?this.maxY:s}}class ot extends bn{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new el,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new Bo,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(e){const t=Object.keys(e);for(let i=0;i1)for(let t=0;tthis.children.length)throw new Error(`${e}addChildAt: The index ${t} supplied is out of bounds ${this.children.length}`);return e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.splice(t,0,e),this._boundsID++,this.onChildrenChange(t),e.emit("added",this),this.emit("childAdded",e,this,t),e}swapChildren(e,t){if(e===t)return;const i=this.getChildIndex(e),s=this.getChildIndex(t);this.children[i]=t,this.children[s]=e,this.onChildrenChange(i=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(e);en(this.children,i,1),this.children.splice(t,0,e),this.onChildrenChange(t)}getChildAt(e){if(e<0||e>=this.children.length)throw new Error(`getChildAt: Index (${e}) does not exist.`);return this.children[e]}removeChild(...e){if(e.length>1)for(let t=0;t0&&n<=s){a=this.children.splice(i,n);for(let o=0;o1&&this.children.sort(Jb),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let e=0,t=this.children.length;e0&&t.height>0))return;let i,s;this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==ic.prototype._render&&(i=this.getBounds(!0));const n=e.projection.transform;if(n&&(s?(s=$b.copyFrom(s),s.prepend(n)):s=n),i&&t.intersects(i,s))this._render(e);else if(this.cullArea)return;for(let a=0,o=this.children.length;a=s&&In.x=n&&In.y{Object.defineProperty(Mu,r,{get(){return Le("7.1.0",`filters.${r} has moved to ${r}`),e}})});class yA{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){this.tickerAdded||!this.domElement||(Ft.system.add(this.tickerUpdate,this,As.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Ft.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const e=this.events.rootPointerEvent;this.events.supportsTouchEvents&&e.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY}))}tickerUpdate(e){this._deltaTime+=e,!(this._deltaTimei.priority-s.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;const t=this.mappingTable[e.type];if(t)for(let i=0,s=t.length;i=0;s--)if(e.currentTarget=i[s],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,i=this._allInteractiveElements){if(i.length===0)return;e.eventPhase=e.BUBBLING_PHASE;const s=Array.isArray(t)?t:[t];for(let n=i.length-1;n>=0;n--)s.forEach(a=>{e.currentTarget=i[n],this.notifyTarget(e,a)})}propagationPath(e){const t=[e];for(let i=0;i=0;h--){const d=u[h],p=this.hitTestMoveRecursive(d,this._isInteractive(t)?t:d.eventMode,i,s,n,a||n(e,i));if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=e.isInteractive();(p.length>0||f)&&(f&&this._allInteractiveElements.push(e),p.push(e)),this._hitElements.length===0&&(this._hitElements=p),o=!0}}}const l=this._isInteractive(t),c=e.isInteractive();return c&&c&&this._allInteractiveElements.push(e),a||this._hitElements.length>0?null:o?this._hitElements:l&&!n(e,i)&&s(e,i)?c?[e]:[]:null}hitTestRecursive(e,t,i,s,n){if(this._interactivePrune(e)||n(e,i))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Er.pauseUpdate=!1),e.interactiveChildren&&e.children){const l=e.children;for(let c=l.length-1;c>=0;c--){const u=l[c],h=this.hitTestRecursive(u,this._isInteractive(t)?t:u.eventMode,i,s,n);if(h){if(h.length>0&&!h[h.length-1].parent)continue;const d=e.isInteractive();return(h.length>0||d)&&h.push(e),h}}}const a=this._isInteractive(t),o=e.isInteractive();return a&&s(e,i)?o?[e]:[]:null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){return!!(!e||e.isMask||!e.visible||!e.renderable||e.eventMode==="none"||e.eventMode==="passive"&&!e.interactiveChildren||e.isMask)}hitPruneFn(e,t){if(e.hitArea&&(e.worldTransform.applyInverse(t,ql),!e.hitArea.contains(ql.x,ql.y)))return!0;if(e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;if(i&&!i.containsPoint?.(t))return!0}return!1}hitTestFn(e,t){return e.eventMode==="passive"?!1:e.hitArea?!0:e.containsPoint?e.containsPoint(t):!1}notifyTarget(e,t){t=t??e.type;const i=`on${t}`;e.currentTarget[i]?.(e);const s=e.eventPhase===e.CAPTURING_PHASE||e.eventPhase===e.AT_TARGET?`${t}capture`:t;this.notifyListeners(e,s),e.eventPhase===e.AT_TARGET&&this.notifyListeners(e,t)}mapPointerDown(e){if(!(e instanceof bi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.createPointerEvent(e);if(this.dispatchEvent(t,"pointerdown"),t.pointerType==="touch")this.dispatchEvent(t,"touchstart");else if(t.pointerType==="mouse"||t.pointerType==="pen"){const s=t.button===2;this.dispatchEvent(t,s?"rightdown":"mousedown")}const i=this.trackingData(e.pointerId);i.pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){if(!(e instanceof bi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const t=this.createPointerEvent(e);this._isPointerMoveEvent=!1;const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.trackingData(e.pointerId),n=this.findMountedTarget(s.overTargets);if(s.overTargets?.length>0&&n!==t.target){const l=e.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(e,l,n);if(this.dispatchEvent(c,"pointerout"),i&&this.dispatchEvent(c,"mouseout"),!t.composedPath().includes(n)){const u=this.createPointerEvent(e,"pointerleave",n);for(u.eventPhase=u.AT_TARGET;u.target&&!t.composedPath().includes(u.target);)u.currentTarget=u.target,this.notifyTarget(u),i&&this.notifyTarget(u,"mouseleave"),u.target=u.target.parent;this.freeEvent(u)}this.freeEvent(c)}if(n!==t.target){const l=e.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(t,l);this.dispatchEvent(c,"pointerover"),i&&this.dispatchEvent(c,"mouseover");let u=n?.parent;for(;u&&u!==this.rootTarget.parent&&u!==t.target;)u=u.parent;if(!u||u===this.rootTarget.parent){const h=this.clonePointerEvent(t,"pointerenter");for(h.eventPhase=h.AT_TARGET;h.target&&h.target!==n&&h.target!==this.rootTarget.parent;)h.currentTarget=h.target,this.notifyTarget(h),i&&this.notifyTarget(h,"mouseenter"),h.target=h.target.parent;this.freeEvent(h)}this.freeEvent(c)}const a=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?a.push("pointermove"):this.dispatchEvent(t,"pointermove"),o&&a.push("globalpointermove"),t.pointerType==="touch"&&(this.moveOnAll?a.splice(1,0,"touchmove"):this.dispatchEvent(t,"touchmove"),o&&a.push("globaltouchmove")),i&&(this.moveOnAll?a.splice(1,0,"mousemove"):this.dispatchEvent(t,"mousemove"),o&&a.push("globalmousemove"),this.cursor=t.target?.cursor),a.length>0&&this.all(t,a),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){if(!(e instanceof bi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),i=this.createPointerEvent(e),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=i.target?.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;t.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(e){if(!(e instanceof bi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId);if(t.overTargets){const i=e.pointerType==="mouse"||e.pointerType==="pen",s=this.findMountedTarget(t.overTargets),n=this.createPointerEvent(e,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const a=this.createPointerEvent(e,"pointerleave",s);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),i&&this.notifyTarget(a,"mouseleave"),a.target=a.target.parent;t.overTargets=null,this.freeEvent(n),this.freeEvent(a)}this.cursor=null}mapPointerUp(e){if(!(e instanceof bi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=performance.now(),i=this.createPointerEvent(e);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const o=i.button===2;this.dispatchEvent(i,o?"rightup":"mouseup")}const s=this.trackingData(e.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[e.button]);let a=n;if(n&&!i.composedPath().includes(n)){let o=n;for(;o&&!i.composedPath().includes(o);){if(i.currentTarget=o,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}o=o.parent}delete s.pressTargetsByButton[e.button],a=o}if(a){const o=this.clonePointerEvent(i,"click");o.target=a,o.path=null,s.clicksByButton[e.button]||(s.clicksByButton[e.button]={clickCount:0,target:o.target,timeStamp:t});const l=s.clicksByButton[e.button];if(l.target===o.target&&t-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=o.target,l.timeStamp=t,o.detail=l.clickCount,o.pointerType==="mouse"){const c=o.button===2;this.dispatchEvent(o,c?"rightclick":"click")}else o.pointerType==="touch"&&this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(i)}mapPointerUpOutside(e){if(!(e instanceof bi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),i=this.findMountedTarget(t.pressTargetsByButton[e.button]),s=this.createPointerEvent(e);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(s)}mapWheel(e){if(!(e instanceof rn)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let i=1;i(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),t[i]=s,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){const{view:t,resolution:i}=this.renderer;this.setTargetElement(t),this.resolution=i,oc._defaultEventMode=e.eventMode??"auto",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(e){e=e||"default";let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this.currentCursor===e)return;this.currentCursor=e;const i=this.cursorStyles[e];if(i)switch(typeof i){case"string":t&&(this.domElement.style.cursor=i);break;case"function":i(e);break;case"object":t&&Object.assign(this.domElement.style,i);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.domElement.style.cursor=e)}get pointer(){return this.rootPointerEvent}onPointerDown(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this.normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!("cancelable"in e))&&e.preventDefault();for(let i=0,s=t.length;i0&&(t=e.composedPath()[0]);const i=t!==this.domElement?"outside":"",s=this.normalizeToPointerData(e);for(let n=0,a=s.length;n"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=e.type,t.push(n)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){const i=e;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=wA),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,t.push(i)}else t.push(e);return t}normalizeWheelEvent(e){const t=this.rootWheelEvent;return this.transferMouseData(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.nativeEvent=e,t.type=e.type,t}bootstrapEvent(e,t){return e.originalEvent=null,e.nativeEvent=t,e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist,this.transferMouseData(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.isTrusted=t.isTrusted,e.type==="pointerleave"&&(e.type="pointerout"),e.type.startsWith("mouse")&&(e.type=e.type.replace("mouse","pointer")),e.type.startsWith("touch")&&(e.type=xA[e.type]||e.type),e}transferMouseData(e,t){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}};ac.extension={name:"events",type:[ae.RendererSystem,ae.CanvasRendererSystem]},ac.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let lc=ac;me.add(lc);function Iu(r){return r==="dynamic"||r==="static"}const _A={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??Iu(lc.defaultEventMode)},set interactive(r){Le("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=r,this.eventMode=r?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??lc.defaultEventMode},set eventMode(r){this._internalInteractive=Iu(r),this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,s=typeof e=="function"?void 0:e;r=i?`${r}capture`:r,e=typeof e=="function"?e:e.handleEvent,this.on(r,e,s)},removeEventListener(r,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,s=typeof e=="function"?void 0:e;r=i?`${r}capture`:r,e=typeof e=="function"?e:e.handleEvent,this.off(r,e,s)},dispatchEvent(r){if(!(r instanceof pa))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};ot.mixin(_A);const EA={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};ot.mixin(EA);const TA=9,Oa=100,SA=0,CA=0,ku=2,Bu=1,MA=-1e3,IA=-1e3,kA=2;class pm{constructor(e){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(tr.tablet||tr.phone)&&this.createTouchHook();const t=document.createElement("div");t.style.width=`${Oa}px`,t.style.height=`${Oa}px`,t.style.position="absolute",t.style.top=`${SA}px`,t.style.left=`${CA}px`,t.style.zIndex=ku.toString(),this.div=t,this.renderer=e,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const e=document.createElement("button");e.style.width=`${Bu}px`,e.style.height=`${Bu}px`,e.style.position="absolute",e.style.top=`${MA}px`,e.style.left=`${IA}px`,e.style.zIndex=kA.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),this.renderer.view.parentNode?.appendChild(this.div))}deactivate(){!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),this.div.parentNode?.removeChild(this.div))}updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&e.isInteractive()&&(e._accessibleActive||this.addChild(e),e.renderId=this.renderId);const t=e.children;if(t)for(let i=0;i title : ${e.title}
tabIndex: ${e.tabIndex}`}capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this.renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}addChild(e){let t=this.pool.pop();t||(t=document.createElement("button"),t.style.width=`${Oa}px`,t.style.height=`${Oa}px`,t.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",t.style.position="absolute",t.style.zIndex=ku.toString(),t.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?t.setAttribute("aria-live","off"):t.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?t.setAttribute("aria-relevant","additions"):t.setAttribute("aria-relevant","text"),t.addEventListener("click",this._onClick.bind(this)),t.addEventListener("focus",this._onFocus.bind(this)),t.addEventListener("focusout",this._onFocusOut.bind(this))),t.style.pointerEvents=e.accessiblePointerEvents,t.type=e.accessibleType,e.accessibleTitle&&e.accessibleTitle!==null?t.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(t.title=`displayObject ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&t.setAttribute("aria-label",e.accessibleHint),this.debug&&this.updateDebugHTML(t),e._accessibleActive=!0,e._accessibleDiv=t,t.displayObject=e,this.children.push(e),this.div.appendChild(e._accessibleDiv),e._accessibleDiv.tabIndex=e.tabIndex}_dispatchEvent(e,t){const{displayObject:i}=e.target,s=this.renderer.events.rootBoundary,n=Object.assign(new pa(s),{target:i});s.rootTarget=this.renderer.lastObjectRendered,t.forEach(a=>s.dispatchEvent(n,a))}_onClick(e){this._dispatchEvent(e,["click","pointertap","tap"])}_onFocus(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","assertive"),this._dispatchEvent(e,["mouseover"])}_onFocusOut(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","polite"),this._dispatchEvent(e,["mouseout"])}_onKeyDown(e){e.keyCode===TA&&this.activate()}_onMouseMove(e){e.movementX===0&&e.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}pm.extension={name:"accessibility",type:[ae.RendererPlugin,ae.CanvasRendererPlugin]};me.add(pm);const fm=class hc{constructor(e){this.stage=new xe,e=Object.assign({forceCanvas:!1},e),this.renderer=Wb(e),hc._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render(this.stage)}get view(){return this.renderer?.view}get screen(){return this.renderer?.screen}destroy(e,t){const i=hc._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(e),this.renderer=null}};fm._plugins=[];let BA=fm;me.handleByList(ae.Application,BA._plugins);class mm{static init(e){Object.defineProperty(this,"resizeTo",{set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let t,i;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;t=s,i=n}this.renderer.resize(t,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}mm.extension=ae.Application;me.add(mm);const Pu={loader:ae.LoadParser,resolver:ae.ResolveParser,cache:ae.CacheParser,detection:ae.DetectionParser};me.handle(ae.Asset,r=>{const e=r.ref;Object.entries(Pu).filter(([t])=>!!e[t]).forEach(([t,i])=>me.add(Object.assign(e[t],{extension:e[t].extension??i})))},r=>{const e=r.ref;Object.keys(Pu).filter(t=>!!e[t]).forEach(t=>me.remove(e[t]))});class PA{constructor(e,t=!1){this._loader=e,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=t}add(e){e.forEach(t=>{this._assetList.push(t)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const e=[],t=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i(Array.isArray(r)||(r=[r]),e?r.map(i=>typeof i=="string"||t?e(i):i):r),cc=(r,e)=>{const t=e.split("?")[1];return t&&(r+=`?${t}`),r};function gm(r,e,t,i,s){const n=e[t];for(let a=0;a{const a=n.substring(1,n.length-1).split(",");s.push(a)}),gm(r,s,0,t,i)}else i.push(r);return i}const Ro=r=>!Array.isArray(r);class DA{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const t=this._cache.get(e);return t||console.warn(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){const i=wi(e);let s;for(let o=0;o{s[o]=t}));const n=Object.keys(s),a={cacheKeys:n,keys:i};if(i.forEach(o=>{this._cacheMap.set(o,a)}),n.forEach(o=>{this._cache.has(o)&&this._cache.get(o)!==t&&console.warn("[Cache] already has key:",o),this._cache.set(o,s[o])}),t instanceof Z){const o=t;i.forEach(l=>{o.baseTexture!==Z.EMPTY.baseTexture&&Me.addToCache(o.baseTexture,l),Z.addToCache(o,l)})}}remove(e){if(!this._cacheMap.has(e)){console.warn(`[Assets] Asset id ${e} was not found in the Cache`);return}const t=this._cacheMap.get(e);t.cacheKeys.forEach(i=>{this._cache.delete(i)}),t.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const ss=new DA;class LA{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(e,t,i)=>(this._parsersValidated=!1,e[t]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(e,t){const i={promise:null,parser:null};return i.promise=(async()=>{let s=null,n=null;if(t.loadParser&&(n=this._parserHash[t.loadParser],n||console.warn(`[Assets] specified load parser "${t.loadParser}" not found while loading ${e}`)),!n){for(let a=0;a({alias:[c],src:c})),o=a.length,l=a.map(async c=>{const u=Bt.toAbsolute(c.src);if(!s[c.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,c)),s[c.src]=await this.promiseCache[u].promise,t&&t(++i/o)}catch(h){throw delete this.promiseCache[u],delete s[c.src],new Error(`[Loader.load] Failed to load ${u}. +`;class gA extends kt{constructor(e=.5,t=Math.random()){super(sm,mA,{uNoise:0,uSeed:0}),this.noise=e,this.seed=t}get noise(){return this.uniforms.uNoise}set noise(e){this.uniforms.uNoise=e}get seed(){return this.uniforms.uSeed}set seed(e){this.uniforms.uSeed=e}}const Mu={AlphaFilter:iA,BlurFilter:lA,BlurFilterPass:rc,ColorMatrixFilter:sc,DisplacementFilter:uA,FXAAFilter:nc,NoiseFilter:gA};Object.entries(Mu).forEach(([r,e])=>{Object.defineProperty(Mu,r,{get(){return Le("7.1.0",`filters.${r} has moved to ${r}`),e}})});class yA{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){this.tickerAdded||!this.domElement||(Ft.system.add(this.tickerUpdate,this,As.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Ft.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const e=this.events.rootPointerEvent;this.events.supportsTouchEvents&&e.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY}))}tickerUpdate(e){this._deltaTime+=e,!(this._deltaTimei.priority-s.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;const t=this.mappingTable[e.type];if(t)for(let i=0,s=t.length;i=0;s--)if(e.currentTarget=i[s],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,i=this._allInteractiveElements){if(i.length===0)return;e.eventPhase=e.BUBBLING_PHASE;const s=Array.isArray(t)?t:[t];for(let n=i.length-1;n>=0;n--)s.forEach(a=>{e.currentTarget=i[n],this.notifyTarget(e,a)})}propagationPath(e){const t=[e];for(let i=0;i=0;h--){const d=u[h],p=this.hitTestMoveRecursive(d,this._isInteractive(t)?t:d.eventMode,i,s,n,a||n(e,i));if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=e.isInteractive();(p.length>0||f)&&(f&&this._allInteractiveElements.push(e),p.push(e)),this._hitElements.length===0&&(this._hitElements=p),o=!0}}}const l=this._isInteractive(t),c=e.isInteractive();return c&&c&&this._allInteractiveElements.push(e),a||this._hitElements.length>0?null:o?this._hitElements:l&&!n(e,i)&&s(e,i)?c?[e]:[]:null}hitTestRecursive(e,t,i,s,n){if(this._interactivePrune(e)||n(e,i))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Tr.pauseUpdate=!1),e.interactiveChildren&&e.children){const l=e.children;for(let c=l.length-1;c>=0;c--){const u=l[c],h=this.hitTestRecursive(u,this._isInteractive(t)?t:u.eventMode,i,s,n);if(h){if(h.length>0&&!h[h.length-1].parent)continue;const d=e.isInteractive();return(h.length>0||d)&&h.push(e),h}}}const a=this._isInteractive(t),o=e.isInteractive();return a&&s(e,i)?o?[e]:[]:null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){return!!(!e||e.isMask||!e.visible||!e.renderable||e.eventMode==="none"||e.eventMode==="passive"&&!e.interactiveChildren||e.isMask)}hitPruneFn(e,t){if(e.hitArea&&(e.worldTransform.applyInverse(t,ql),!e.hitArea.contains(ql.x,ql.y)))return!0;if(e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;if(i&&!i.containsPoint?.(t))return!0}return!1}hitTestFn(e,t){return e.eventMode==="passive"?!1:e.hitArea?!0:e.containsPoint?e.containsPoint(t):!1}notifyTarget(e,t){t=t??e.type;const i=`on${t}`;e.currentTarget[i]?.(e);const s=e.eventPhase===e.CAPTURING_PHASE||e.eventPhase===e.AT_TARGET?`${t}capture`:t;this.notifyListeners(e,s),e.eventPhase===e.AT_TARGET&&this.notifyListeners(e,t)}mapPointerDown(e){if(!(e instanceof bi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.createPointerEvent(e);if(this.dispatchEvent(t,"pointerdown"),t.pointerType==="touch")this.dispatchEvent(t,"touchstart");else if(t.pointerType==="mouse"||t.pointerType==="pen"){const s=t.button===2;this.dispatchEvent(t,s?"rightdown":"mousedown")}const i=this.trackingData(e.pointerId);i.pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){if(!(e instanceof bi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const t=this.createPointerEvent(e);this._isPointerMoveEvent=!1;const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.trackingData(e.pointerId),n=this.findMountedTarget(s.overTargets);if(s.overTargets?.length>0&&n!==t.target){const l=e.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(e,l,n);if(this.dispatchEvent(c,"pointerout"),i&&this.dispatchEvent(c,"mouseout"),!t.composedPath().includes(n)){const u=this.createPointerEvent(e,"pointerleave",n);for(u.eventPhase=u.AT_TARGET;u.target&&!t.composedPath().includes(u.target);)u.currentTarget=u.target,this.notifyTarget(u),i&&this.notifyTarget(u,"mouseleave"),u.target=u.target.parent;this.freeEvent(u)}this.freeEvent(c)}if(n!==t.target){const l=e.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(t,l);this.dispatchEvent(c,"pointerover"),i&&this.dispatchEvent(c,"mouseover");let u=n?.parent;for(;u&&u!==this.rootTarget.parent&&u!==t.target;)u=u.parent;if(!u||u===this.rootTarget.parent){const h=this.clonePointerEvent(t,"pointerenter");for(h.eventPhase=h.AT_TARGET;h.target&&h.target!==n&&h.target!==this.rootTarget.parent;)h.currentTarget=h.target,this.notifyTarget(h),i&&this.notifyTarget(h,"mouseenter"),h.target=h.target.parent;this.freeEvent(h)}this.freeEvent(c)}const a=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?a.push("pointermove"):this.dispatchEvent(t,"pointermove"),o&&a.push("globalpointermove"),t.pointerType==="touch"&&(this.moveOnAll?a.splice(1,0,"touchmove"):this.dispatchEvent(t,"touchmove"),o&&a.push("globaltouchmove")),i&&(this.moveOnAll?a.splice(1,0,"mousemove"):this.dispatchEvent(t,"mousemove"),o&&a.push("globalmousemove"),this.cursor=t.target?.cursor),a.length>0&&this.all(t,a),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){if(!(e instanceof bi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),i=this.createPointerEvent(e),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=i.target?.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;t.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(e){if(!(e instanceof bi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId);if(t.overTargets){const i=e.pointerType==="mouse"||e.pointerType==="pen",s=this.findMountedTarget(t.overTargets),n=this.createPointerEvent(e,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const a=this.createPointerEvent(e,"pointerleave",s);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),i&&this.notifyTarget(a,"mouseleave"),a.target=a.target.parent;t.overTargets=null,this.freeEvent(n),this.freeEvent(a)}this.cursor=null}mapPointerUp(e){if(!(e instanceof bi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=performance.now(),i=this.createPointerEvent(e);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const o=i.button===2;this.dispatchEvent(i,o?"rightup":"mouseup")}const s=this.trackingData(e.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[e.button]);let a=n;if(n&&!i.composedPath().includes(n)){let o=n;for(;o&&!i.composedPath().includes(o);){if(i.currentTarget=o,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}o=o.parent}delete s.pressTargetsByButton[e.button],a=o}if(a){const o=this.clonePointerEvent(i,"click");o.target=a,o.path=null,s.clicksByButton[e.button]||(s.clicksByButton[e.button]={clickCount:0,target:o.target,timeStamp:t});const l=s.clicksByButton[e.button];if(l.target===o.target&&t-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=o.target,l.timeStamp=t,o.detail=l.clickCount,o.pointerType==="mouse"){const c=o.button===2;this.dispatchEvent(o,c?"rightclick":"click")}else o.pointerType==="touch"&&this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(i)}mapPointerUpOutside(e){if(!(e instanceof bi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),i=this.findMountedTarget(t.pressTargetsByButton[e.button]),s=this.createPointerEvent(e);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(s)}mapWheel(e){if(!(e instanceof rn)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let i=1;i(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),t[i]=s,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){const{view:t,resolution:i}=this.renderer;this.setTargetElement(t),this.resolution=i,oc._defaultEventMode=e.eventMode??"auto",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(e){e=e||"default";let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this.currentCursor===e)return;this.currentCursor=e;const i=this.cursorStyles[e];if(i)switch(typeof i){case"string":t&&(this.domElement.style.cursor=i);break;case"function":i(e);break;case"object":t&&Object.assign(this.domElement.style,i);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.domElement.style.cursor=e)}get pointer(){return this.rootPointerEvent}onPointerDown(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this.normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!("cancelable"in e))&&e.preventDefault();for(let i=0,s=t.length;i0&&(t=e.composedPath()[0]);const i=t!==this.domElement?"outside":"",s=this.normalizeToPointerData(e);for(let n=0,a=s.length;n"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=e.type,t.push(n)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){const i=e;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=wA),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,t.push(i)}else t.push(e);return t}normalizeWheelEvent(e){const t=this.rootWheelEvent;return this.transferMouseData(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.nativeEvent=e,t.type=e.type,t}bootstrapEvent(e,t){return e.originalEvent=null,e.nativeEvent=t,e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist,this.transferMouseData(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.isTrusted=t.isTrusted,e.type==="pointerleave"&&(e.type="pointerout"),e.type.startsWith("mouse")&&(e.type=e.type.replace("mouse","pointer")),e.type.startsWith("touch")&&(e.type=xA[e.type]||e.type),e}transferMouseData(e,t){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}};ac.extension={name:"events",type:[ae.RendererSystem,ae.CanvasRendererSystem]},ac.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let lc=ac;me.add(lc);function Iu(r){return r==="dynamic"||r==="static"}const _A={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??Iu(lc.defaultEventMode)},set interactive(r){Le("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=r,this.eventMode=r?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??lc.defaultEventMode},set eventMode(r){this._internalInteractive=Iu(r),this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,s=typeof e=="function"?void 0:e;r=i?`${r}capture`:r,e=typeof e=="function"?e:e.handleEvent,this.on(r,e,s)},removeEventListener(r,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,s=typeof e=="function"?void 0:e;r=i?`${r}capture`:r,e=typeof e=="function"?e:e.handleEvent,this.off(r,e,s)},dispatchEvent(r){if(!(r instanceof pa))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};ot.mixin(_A);const EA={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};ot.mixin(EA);const TA=9,Oa=100,SA=0,CA=0,ku=2,Bu=1,MA=-1e3,IA=-1e3,kA=2;class pm{constructor(e){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(tr.tablet||tr.phone)&&this.createTouchHook();const t=document.createElement("div");t.style.width=`${Oa}px`,t.style.height=`${Oa}px`,t.style.position="absolute",t.style.top=`${SA}px`,t.style.left=`${CA}px`,t.style.zIndex=ku.toString(),this.div=t,this.renderer=e,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const e=document.createElement("button");e.style.width=`${Bu}px`,e.style.height=`${Bu}px`,e.style.position="absolute",e.style.top=`${MA}px`,e.style.left=`${IA}px`,e.style.zIndex=kA.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),this.renderer.view.parentNode?.appendChild(this.div))}deactivate(){!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),this.div.parentNode?.removeChild(this.div))}updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&e.isInteractive()&&(e._accessibleActive||this.addChild(e),e.renderId=this.renderId);const t=e.children;if(t)for(let i=0;i title : ${e.title}
tabIndex: ${e.tabIndex}`}capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this.renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}addChild(e){let t=this.pool.pop();t||(t=document.createElement("button"),t.style.width=`${Oa}px`,t.style.height=`${Oa}px`,t.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",t.style.position="absolute",t.style.zIndex=ku.toString(),t.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?t.setAttribute("aria-live","off"):t.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?t.setAttribute("aria-relevant","additions"):t.setAttribute("aria-relevant","text"),t.addEventListener("click",this._onClick.bind(this)),t.addEventListener("focus",this._onFocus.bind(this)),t.addEventListener("focusout",this._onFocusOut.bind(this))),t.style.pointerEvents=e.accessiblePointerEvents,t.type=e.accessibleType,e.accessibleTitle&&e.accessibleTitle!==null?t.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(t.title=`displayObject ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&t.setAttribute("aria-label",e.accessibleHint),this.debug&&this.updateDebugHTML(t),e._accessibleActive=!0,e._accessibleDiv=t,t.displayObject=e,this.children.push(e),this.div.appendChild(e._accessibleDiv),e._accessibleDiv.tabIndex=e.tabIndex}_dispatchEvent(e,t){const{displayObject:i}=e.target,s=this.renderer.events.rootBoundary,n=Object.assign(new pa(s),{target:i});s.rootTarget=this.renderer.lastObjectRendered,t.forEach(a=>s.dispatchEvent(n,a))}_onClick(e){this._dispatchEvent(e,["click","pointertap","tap"])}_onFocus(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","assertive"),this._dispatchEvent(e,["mouseover"])}_onFocusOut(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","polite"),this._dispatchEvent(e,["mouseout"])}_onKeyDown(e){e.keyCode===TA&&this.activate()}_onMouseMove(e){e.movementX===0&&e.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}pm.extension={name:"accessibility",type:[ae.RendererPlugin,ae.CanvasRendererPlugin]};me.add(pm);const fm=class hc{constructor(e){this.stage=new xe,e=Object.assign({forceCanvas:!1},e),this.renderer=Wb(e),hc._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render(this.stage)}get view(){return this.renderer?.view}get screen(){return this.renderer?.screen}destroy(e,t){const i=hc._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(e),this.renderer=null}};fm._plugins=[];let BA=fm;me.handleByList(ae.Application,BA._plugins);class mm{static init(e){Object.defineProperty(this,"resizeTo",{set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let t,i;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;t=s,i=n}this.renderer.resize(t,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}mm.extension=ae.Application;me.add(mm);const Pu={loader:ae.LoadParser,resolver:ae.ResolveParser,cache:ae.CacheParser,detection:ae.DetectionParser};me.handle(ae.Asset,r=>{const e=r.ref;Object.entries(Pu).filter(([t])=>!!e[t]).forEach(([t,i])=>me.add(Object.assign(e[t],{extension:e[t].extension??i})))},r=>{const e=r.ref;Object.keys(Pu).filter(t=>!!e[t]).forEach(t=>me.remove(e[t]))});class PA{constructor(e,t=!1){this._loader=e,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=t}add(e){e.forEach(t=>{this._assetList.push(t)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const e=[],t=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i(Array.isArray(r)||(r=[r]),e?r.map(i=>typeof i=="string"||t?e(i):i):r),cc=(r,e)=>{const t=e.split("?")[1];return t&&(r+=`?${t}`),r};function gm(r,e,t,i,s){const n=e[t];for(let a=0;a{const a=n.substring(1,n.length-1).split(",");s.push(a)}),gm(r,s,0,t,i)}else i.push(r);return i}const Ro=r=>!Array.isArray(r);class DA{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const t=this._cache.get(e);return t||console.warn(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){const i=wi(e);let s;for(let o=0;o{s[o]=t}));const n=Object.keys(s),a={cacheKeys:n,keys:i};if(i.forEach(o=>{this._cacheMap.set(o,a)}),n.forEach(o=>{this._cache.has(o)&&this._cache.get(o)!==t&&console.warn("[Cache] already has key:",o),this._cache.set(o,s[o])}),t instanceof Z){const o=t;i.forEach(l=>{o.baseTexture!==Z.EMPTY.baseTexture&&Me.addToCache(o.baseTexture,l),Z.addToCache(o,l)})}}remove(e){if(!this._cacheMap.has(e)){console.warn(`[Assets] Asset id ${e} was not found in the Cache`);return}const t=this._cacheMap.get(e);t.cacheKeys.forEach(i=>{this._cache.delete(i)}),t.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const ss=new DA;class LA{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(e,t,i)=>(this._parsersValidated=!1,e[t]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(e,t){const i={promise:null,parser:null};return i.promise=(async()=>{let s=null,n=null;if(t.loadParser&&(n=this._parserHash[t.loadParser],n||console.warn(`[Assets] specified load parser "${t.loadParser}" not found while loading ${e}`)),!n){for(let a=0;a({alias:[c],src:c})),o=a.length,l=a.map(async c=>{const u=Bt.toAbsolute(c.src);if(!s[c.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,c)),s[c.src]=await this.promiseCache[u].promise,t&&t(++i/o)}catch(h){throw delete this.promiseCache[u],delete s[c.src],new Error(`[Loader.load] Failed to load ${u}. ${h}`)}});return await Promise.all(l),n?s[a[0].src]:s}async unload(e){const t=wi(e,i=>({alias:[i],src:i})).map(async i=>{const s=Bt.toAbsolute(i.src),n=this.promiseCache[s];if(n){const a=await n.promise;delete this.promiseCache[s],n.parser?.unload?.(a,i,this)}});await Promise.all(t)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(e=>e.name).reduce((e,t)=>(e[t.name]&&console.warn(`[Assets] loadParser name conflict "${t.name}"`),{...e,[t.name]:t}),{})}}var Mi=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Mi||{});const OA=".json",FA="application/json",NA={extension:{type:ae.LoadParser,priority:Mi.Low},name:"loadJson",test(r){return wn(r,FA)||Hr(r,OA)},async load(r){return await(await de.ADAPTER.fetch(r)).json()}};me.add(NA);const UA=".txt",GA="text/plain",HA={name:"loadTxt",extension:{type:ae.LoadParser,priority:Mi.Low},test(r){return wn(r,GA)||Hr(r,UA)},async load(r){return await(await de.ADAPTER.fetch(r)).text()}};me.add(HA);const WA=["normal","bold","100","200","300","400","500","600","700","800","900"],VA=[".ttf",".otf",".woff",".woff2"],zA=["font/ttf","font/otf","font/woff","font/woff2"],jA=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function YA(r){const e=Bt.extname(r),t=Bt.basename(r,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=t.length>0;for(const n of t)if(!n.match(jA)){i=!1;break}let s=t.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const XA={extension:{type:ae.LoadParser,priority:Mi.Low},name:"loadWebFont",test(r){return wn(r,zA)||Hr(r,VA)},async load(r,e){const t=de.ADAPTER.getFontFaceSet();if(t){const i=[],s=e.data?.family??YA(r),n=e.data?.weights?.filter(o=>WA.includes(o))??["normal"],a=e.data??{};for(let o=0;ode.ADAPTER.getFontFaceSet().delete(e))}};me.add(XA);let Ru=0,Ql;const KA="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=",qA={id:"checkImageBitmap",code:` async function checkImageBitmap() { @@ -919,8 +919,8 @@ ${h}`)}});return await Promise.all(l),n?s[a[0].src]:s}async unload(e){const t=wi id: event.data.id, }); } - };`};let $l;class $A{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(e=>{const t=URL.createObjectURL(new Blob([qA.code],{type:"application/javascript"})),i=new Worker(t);i.addEventListener("message",s=>{i.terminate(),URL.revokeObjectURL(t),e(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(e){return this._run("loadImageBitmap",[e])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Ql===void 0&&(Ql=navigator.hardwareConcurrency||4);let e=this.workerPool.pop();return!e&&this._createdWorkers{this.complete(t.data),this.returnWorker(t.target),this.next()})),e}returnWorker(e){this.workerPool.push(e)}complete(e){e.error!==void 0?this.resolveHash[e.uuid].reject(e.error):this.resolveHash[e.uuid].resolve(e.data),this.resolveHash[e.uuid]=null}async _run(e,t){await this._initWorkers();const i=new Promise((s,n)=>{this.queue.push({id:e,arguments:t,resolve:s,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const e=this.getWorker();if(!e)return;const t=this.queue.pop(),i=t.id;this.resolveHash[Ru]={resolve:t.resolve,reject:t.reject},e.postMessage({data:t.arguments,uuid:Ru++,id:i})}}const Du=new $A;function fa(r,e,t){r.resource.internal=!0;const i=new Z(r),s=()=>{delete e.promiseCache[t],ss.has(t)&&ss.remove(t)};return i.baseTexture.once("destroyed",()=>{t in e.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),s())}),i.once("destroyed",()=>{r.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),s())}),i}const JA=[".jpeg",".jpg",".png",".webp",".avif"],ZA=["image/jpeg","image/png","image/webp","image/avif"];async function ew(r){const e=await de.ADAPTER.fetch(r);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${e.status} ${e.statusText}`);const t=await e.blob();return await createImageBitmap(t)}const il={name:"loadTextures",extension:{type:ae.LoadParser,priority:Mi.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return wn(r,ZA)||Hr(r,JA)},async load(r,e,t){const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await Du.isImageBitmapSupported()?s=await Du.loadImageBitmap(r):s=await ew(r):s=await new Promise((o,l)=>{const c=new Image;c.crossOrigin=this.config.crossOrigin,c.src=r,c.complete?o(c):(c.onload=()=>o(c),c.onerror=u=>l(u))});const n={...e.data};n.resolution??(n.resolution=ar(r)),i&&n.resourceOptions?.ownsImageBitmap===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const a=new Me(s,n);return a.resource.src=r,fa(a,t,r)},unload(r){r.destroy(!0)}};me.add(il);const tw=".svg",iw="image/svg+xml",rw={extension:{type:ae.LoadParser,priority:Mi.High},name:"loadSVG",test(r){return wn(r,iw)||Hr(r,tw)},async testParse(r){return Zh.test(r)},async parse(r,e,t){const i=new Zh(r,e?.data?.resourceOptions);await i.load();const s=new Me(i,{resolution:ar(r),...e?.data});return s.resource.src=e.src,fa(s,t,e.src)},async load(r,e){return(await de.ADAPTER.fetch(r)).text()},unload:il.unload};me.add(rw);const sw=[".mp4",".m4v",".webm",".ogv"],aw=["video/mp4","video/webm","video/ogg"],ow={name:"loadVideo",extension:{type:ae.LoadParser,priority:Mi.High},config:{defaultAutoPlay:!0},test(r){return wn(r,aw)||Hr(r,sw)},async load(r,e,t){let i;const s=await(await de.ADAPTER.fetch(r)).blob(),n=URL.createObjectURL(s);try{const a={autoPlay:this.config.defaultAutoPlay,...e?.data?.resourceOptions},o=new cm(n,a);await o.load();const l=new Me(o,{alphaMode:await fv(),resolution:ar(r),...e?.data});l.resource.src=r,i=fa(l,t,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(a){throw URL.revokeObjectURL(n),a}return i},unload(r){r.destroy(!0)}};me.add(ow);class lw{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e=="string")this._defaultSearchParams=e;else{const t=e;this._defaultSearchParams=Object.keys(t).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(t[i])}`).join("&")}}getAlias(e){const{alias:t,name:i,src:s,srcs:n}=e;return wi(t||i||s||n,a=>typeof a=="string"?a:Array.isArray(a)?a.map(o=>o?.src??o?.srcs??o):a?.src||a?.srcs?a.src??a.srcs:a,!0)}addManifest(e){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){const i=[];Array.isArray(t)?t.forEach(s=>{const n=s.src??s.srcs,a=s.alias??s.name;let o;if(typeof a=="string"){const l=this._createBundleAssetId(e,a);i.push(l),o=[a,l]}else{const l=a.map(c=>this._createBundleAssetId(e,c));i.push(...l),o=[...a,...l]}this.add({...s,alias:o,src:n})}):Object.keys(t).forEach(s=>{const n=[s,this._createBundleAssetId(e,s)];if(typeof t[s]=="string")this.add({alias:n,src:t[s]});else if(Array.isArray(t[s]))this.add({alias:n,src:t[s]});else{const a=t[s],o=a.src??a.srcs;this.add({...a,alias:n,src:Array.isArray(o)?o:[o]})}i.push(...n)}),this._bundles[e]=i}add(e,t,i,s,n){const a=[];typeof e=="string"||Array.isArray(e)&&typeof e[0]=="string"?(Le("7.2.0",`Assets.add now uses an object instead of individual parameters. -Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),a.push({alias:e,src:t,data:i,format:s,loadParser:n})):Array.isArray(e)?a.push(...e):a.push(e);let o;o=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},wi(a).forEach(l=>{const{src:c,srcs:u}=l;let{data:h,format:d,loadParser:p}=l;const f=wi(c||u).map(y=>typeof y=="string"?RA(y):Array.isArray(y)?y:[y]),m=this.getAlias(l);Array.isArray(m)?m.forEach(o):o(m);const g=[];f.forEach(y=>{y.forEach(b=>{let A={};if(typeof b!="object"){A.src=b;for(let v=0;v{this._assetMap[y]=g})})}resolveBundle(e){const t=Ro(e);e=wi(e);const i={};return e.forEach(s=>{const n=this._bundles[s];if(n){const a=this.resolve(n),o={};for(const l in a){const c=a[l];o[this._extractAssetIdFromBundle(s,l)]=c}i[s]=o}}),t?i[e[0]]:i}resolveUrl(e){const t=this.resolve(e);if(typeof e!="string"){const i={};for(const s in t)i[s]=t[s].src;return i}return t.src}resolve(e){const t=Ro(e);e=wi(e);const i={};return e.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const a=n[0],o=this._getPreferredOrder(n);o?.priority.forEach(l=>{o.params[l].forEach(c=>{const u=n.filter(h=>h[l]?h[l]===c:!1);u.length&&(n=u)})}),this._resolverHash[s]=n[0]??a}else this._resolverHash[s]=this.buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),t?i[e[0]]:i}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;tn.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;const t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}buildResolvedAsset(e,t){const{aliases:i,data:s,loadParser:n,format:a}=t;return(this._basePath||this._rootPath)&&(e.src=Bt.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=i??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...s||{},...e.data},e.loadParser=n??e.loadParser,e.format=a??e.src.split(".").pop(),e.srcs=e.src,e.name=e.alias,e}}class hw{constructor(){this._detections=[],this._initialized=!1,this.resolver=new lw,this.loader=new LA,this.cache=ss,this._backgroundLoader=new PA(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(e={}){if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Asset.init()?");return}if(this._initialized=!0,e.defaultSearchParams&&this.resolver.setDefaultSearchParams(e.defaultSearchParams),e.basePath&&(this.resolver.basePath=e.basePath),e.bundleIdentifier&&this.resolver.setBundleIdentifier(e.bundleIdentifier),e.manifest){let n=e.manifest;typeof n=="string"&&(n=await this.load(n)),this.resolver.addManifest(n)}const t=e.texturePreference?.resolution??1,i=typeof t=="number"?[t]:t,s=await this._detectFormats({preferredFormats:e.texturePreference?.format,skipDetections:e.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),e.preferences&&this.setPreferences(e.preferences)}add(e,t,i,s,n){this.resolver.add(e,t,i,s,n)}async load(e,t){this._initialized||await this.init();const i=Ro(e),s=wi(e).map(o=>{if(typeof o!="string"){const l=this.resolver.getAlias(o);return l.some(c=>!this.resolver.hasKey(c))&&this.add(o),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),n=this.resolver.resolve(s),a=await this._mapLoadToResolve(n,t);return i?a[s[0]]:a}addBundle(e,t){this.resolver.addBundle(e,t)}async loadBundle(e,t){this._initialized||await this.init();let i=!1;typeof e=="string"&&(i=!0,e=[e]);const s=this.resolver.resolveBundle(e),n={},a=Object.keys(s);let o=0,l=0;const c=()=>{t?.(++o/l)},u=a.map(h=>{const d=s[h];return l+=Object.keys(d).length,this._mapLoadToResolve(d,c).then(p=>{n[h]=p})});return await Promise.all(u),i?n[e[0]]:n}async backgroundLoad(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolve(e);this._backgroundLoader.add(Object.values(t))}async backgroundLoadBundle(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolveBundle(e);Object.values(t).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(e){if(typeof e=="string")return ss.get(e);const t={};for(let i=0;i{const c=n[o.src],u=[o.src];o.alias&&u.push(...o.alias),a[s[l]]=c,ss.set(u,c)}),a}async unload(e){this._initialized||await this.init();const t=wi(e).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(t);await this._unloadFromResolved(i)}async unloadBundle(e){this._initialized||await this.init(),e=wi(e);const t=this.resolver.resolveBundle(e),i=Object.keys(t).map(s=>this._unloadFromResolved(t[s]));await Promise.all(i)}async _unloadFromResolved(e){const t=Object.values(e);t.forEach(i=>{ss.remove(i.src)}),await this.loader.unload(t)}async _detectFormats(e){let t=[];e.preferredFormats&&(t=Array.isArray(e.preferredFormats)?e.preferredFormats:[e.preferredFormats]);for(const i of e.detections)e.skipDetections||await i.test()?t=await i.add(t):e.skipDetections||(t=await i.remove(t));return t=t.filter((i,s)=>t.indexOf(i)===s),t}get detections(){return this._detections}get preferWorkers(){return il.config.preferWorkers}set preferWorkers(e){Le("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:e})}setPreferences(e){this.loader.parsers.forEach(t=>{t.config&&Object.keys(t.config).filter(i=>i in e).forEach(i=>{t.config[i]=e[i]})})}}const qs=new hw;me.handleByList(ae.LoadParser,qs.loader.parsers).handleByList(ae.ResolveParser,qs.resolver.parsers).handleByList(ae.CacheParser,qs.cache.parsers).handleByList(ae.DetectionParser,qs.detections);const cw={extension:ae.CacheParser,test:r=>Array.isArray(r)&&r.every(e=>e instanceof Z),getCacheableAssets:(r,e)=>{const t={};return r.forEach(i=>{e.forEach((s,n)=>{t[i+(n===0?"":n+1)]=s})}),t}};me.add(cw);const dw={extension:{type:ae.DetectionParser,priority:1},test:async()=>{const r="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=";return new Promise(e=>{const t=new Image;t.onload=()=>{e(!0)},t.onerror=()=>{e(!1)},t.src=r})},add:async r=>[...r,"avif"],remove:async r=>r.filter(e=>e!=="avif")};me.add(dw);const uw={extension:{type:ae.DetectionParser,priority:0},test:async()=>{const r="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=";return new Promise(e=>{const t=new Image;t.onload=()=>{e(!0)},t.onerror=()=>{e(!1)},t.src=r})},add:async r=>[...r,"webp"],remove:async r=>r.filter(e=>e!=="webp")};me.add(uw);const Lu=["png","jpg","jpeg"],pw={extension:{type:ae.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Lu],remove:async r=>r.filter(e=>!Lu.includes(e))};me.add(pw);const fw="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function zc(r){return fw?!1:document.createElement("video").canPlayType(r)!==""}const mw={extension:{type:ae.DetectionParser,priority:0},test:async()=>zc("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(e=>e!=="webm")};me.add(mw);const gw={extension:{type:ae.DetectionParser,priority:0},test:async()=>zc("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(e=>e!=="mp4"&&e!=="m4v")};me.add(gw);const yw={extension:{type:ae.DetectionParser,priority:0},test:async()=>zc("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(e=>e!=="ogv")};me.add(yw);const vw={extension:ae.ResolveParser,test:il.test,parse:r=>({resolution:parseFloat(de.RETINA_PREFIX.exec(r)?.[1]??"1"),format:r.split(".").pop(),src:r})};me.add(vw);var zt=(r=>(r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",r[r.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",r[r.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r))(zt||{});const Do={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35986:1,34798:1,37808:1};let Qi,Hs;function Ou(){Hs={s3tc:Qi.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Qi.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:Qi.getExtension("WEBGL_compressed_texture_etc"),etc1:Qi.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:Qi.getExtension("WEBGL_compressed_texture_pvrtc")||Qi.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:Qi.getExtension("WEBGL_compressed_texture_atc"),astc:Qi.getExtension("WEBGL_compressed_texture_astc")}}const bw={extension:{type:ae.DetectionParser,priority:2},test:async()=>{const r=de.ADAPTER.createCanvas().getContext("webgl");return r?(Qi=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{Hs||Ou();const e=[];for(const t in Hs)Hs[t]&&e.push(t);return[...e,...r]},remove:async r=>(Hs||Ou(),r.filter(e=>!(e in Hs)))};me.add(bw);class Aw extends Qo{constructor(e,t={width:1,height:1,autoLoad:!0}){let i,s;typeof e=="string"?(i=e,s=new Uint8Array):(i=null,s=e),super(s,t),this.origin=i,this.buffer=s?new Gh(s):null,this._load=null,this.loaded=!1,this.origin!==null&&t.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(e){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(e=>e.blob()).then(e=>e.arrayBuffer()).then(e=>(this.data=new Uint32Array(e),this.buffer=new Gh(e),this.loaded=!0,this.onBlobLoaded(e),this.update(),this)),this._load)}}class ps extends Aw{constructor(e,t){super(e,t),this.format=t.format,this.levels=t.levels||1,this._width=t.width,this._height=t.height,this._extension=ps._formatToExtension(this.format),(t.levelBuffers||this.buffer)&&(this._levelBuffers=t.levelBuffers||ps._createLevelBuffers(e instanceof Uint8Array?e:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(e,t,i){const s=e.gl;if(!e.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,a=this.levels;n=33776&&e<=33779)return"s3tc";if(e>=37488&&e<=37497)return"etc";if(e>=35840&&e<=35843)return"pvrtc";if(e>=36196)return"etc1";if(e>=35986&&e<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")}static _createLevelBuffers(e,t,i,s,n,a,o){const l=new Array(i);let c=e.byteOffset,u=a,h=o,d=u+s-1&~(s-1),p=h+n-1&~(n-1),f=d*p*Do[t];for(let m=0;m1?u:d,levelHeight:i>1?h:p,levelBuffer:new Uint8Array(e.buffer,c,f)},c+=f,u=u>>1||1,h=h>>1||1,d=u+s-1&~(s-1),p=h+n-1&~(n-1),f=d*p*Do[t];return l}}const Jl=4,Fa=124,ww=32,Fu=20,xw=542327876,Na={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},_w={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},Ua={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},Ew=1,Tw=2,Sw=4,Cw=64,Mw=512,Iw=131072,kw=827611204,Bw=861165636,Pw=894720068,Rw=808540228,Dw=4,Lw={[kw]:zt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Bw]:zt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Pw]:zt.COMPRESSED_RGBA_S3TC_DXT5_EXT},Ow={70:zt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:zt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:zt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:zt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:zt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:zt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:zt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:zt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:zt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function Fw(r){const e=new Uint32Array(r);if(e[0]!==xw)throw new Error("Invalid DDS file magic word");const t=new Uint32Array(r,0,Fa/Uint32Array.BYTES_PER_ELEMENT),i=t[Na.HEIGHT],s=t[Na.WIDTH],n=t[Na.MIPMAP_COUNT],a=new Uint32Array(r,Na.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,ww/Uint32Array.BYTES_PER_ELEMENT),o=a[Ew];if(o&Sw){const l=a[_w.FOURCC];if(l!==Rw){const b=Lw[l],A=Jl+Fa,v=new Uint8Array(r,A);return[new ps(v,{format:b,width:s,height:i,levels:n})]}const c=Jl+Fa,u=new Uint32Array(e.buffer,c,Fu/Uint32Array.BYTES_PER_ELEMENT),h=u[Ua.DXGI_FORMAT],d=u[Ua.RESOURCE_DIMENSION],p=u[Ua.MISC_FLAG],f=u[Ua.ARRAY_SIZE],m=Ow[h];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${h}`);if(p===Dw)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const g=new Array,y=Jl+Fa+Fu;if(f===1)g.push(new Uint8Array(r,y));else{const b=Do[m];let A=0,v=s,E=i;for(let M=0;M>>1,E=E>>>1}let C=y;for(let M=0;Mnew ps(b,{format:m,width:s,height:i,levels:n}))}throw o&Cw?new Error("DDSParser does not support uncompressed texture data."):o&Mw?new Error("DDSParser does not supported YUV uncompressed texture data."):o&Iw?new Error("DDSParser does not support single-channel (lumninance) texture data!"):o&Tw?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const Nu=[171,75,84,88,32,49,49,187,13,10,26,10],Nw=67305985,mi={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},dc=64,Uu={[we.UNSIGNED_BYTE]:1,[we.UNSIGNED_SHORT]:2,[we.INT]:4,[we.UNSIGNED_INT]:4,[we.FLOAT]:4,[we.HALF_FLOAT]:8},Uw={[re.RGBA]:4,[re.RGB]:3,[re.RG]:2,[re.RED]:1,[re.LUMINANCE]:1,[re.LUMINANCE_ALPHA]:2,[re.ALPHA]:1},Gw={[we.UNSIGNED_SHORT_4_4_4_4]:2,[we.UNSIGNED_SHORT_5_5_5_1]:2,[we.UNSIGNED_SHORT_5_6_5]:2};function Hw(r,e,t=!1){const i=new DataView(e);if(!Ww(r,i))return null;const s=i.getUint32(mi.ENDIANNESS,!0)===Nw,n=i.getUint32(mi.GL_TYPE,s),a=i.getUint32(mi.GL_FORMAT,s),o=i.getUint32(mi.GL_INTERNAL_FORMAT,s),l=i.getUint32(mi.PIXEL_WIDTH,s),c=i.getUint32(mi.PIXEL_HEIGHT,s)||1,u=i.getUint32(mi.PIXEL_DEPTH,s)||1,h=i.getUint32(mi.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(mi.NUMBER_OF_FACES,s),p=i.getUint32(mi.NUMBER_OF_MIPMAP_LEVELS,s),f=i.getUint32(mi.BYTES_OF_KEY_VALUE_DATA,s);if(c===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(h!==1)throw new Error("WebGL does not support array textures");const m=4,g=4,y=l+3&-4,b=c+3&-4,A=new Array(h);let v=l*c;n===0&&(v=y*b);let E;if(n!==0?Uu[n]?E=Uu[n]*Uw[a]:E=Gw[n]:E=Do[o],E===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const C=t?zw(i,f,s):null;let M=v*E,P=l,k=c,N=y,H=b,T=dc+f;for(let S=0;S1||n!==0?P:N,levelHeight:p>1||n!==0?k:H,levelBuffer:new Uint8Array(e,F,M)},F+=M}T+=w+4,T=T%4!==0?T+4-T%4:T,P=P>>1||1,k=k>>1||1,N=P+m-1&~(m-1),H=k+g-1&~(g-1),M=N*H*E}return n!==0?{uncompressed:A.map(S=>{let w=S[0].levelBuffer,F=!1;return n===we.FLOAT?w=new Float32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4):n===we.UNSIGNED_INT?(F=!0,w=new Uint32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4)):n===we.INT&&(F=!0,w=new Int32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4)),{resource:new Qo(w,{width:S[0].levelWidth,height:S[0].levelHeight}),type:n,format:F?Vw(a):a}}),kvData:C}:{compressed:A.map(S=>new ps(null,{format:o,width:l,height:c,levels:p,levelBuffers:S})),kvData:C}}function Ww(r,e){for(let t=0;te-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l{const a=new Me(n,{mipmap:Xt.OFF,alphaMode:Lt.NO_PREMULTIPLIED_ALPHA,resolution:ar(r),...e.data});return fa(a,t,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(e=>e.destroy(!0)):r.destroy(!0)}};me.add(jw);const Yw={extension:{type:ae.LoadParser,priority:Mi.High},name:"loadKTX",test(r){return Hr(r,".ktx")},async load(r,e,t){const i=await(await de.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:a}=Hw(r,i),o=s??n,l={mipmap:Xt.OFF,alphaMode:Lt.NO_PREMULTIPLIED_ALPHA,resolution:ar(r),...e.data},c=o.map(u=>{o===n&&Object.assign(l,{type:u.type,format:u.format});const h=u.resource??u,d=new Me(h,l);return d.ktxKeyValueData=a,fa(d,t,r)});return c.length===1?c[0]:c},unload(r){Array.isArray(r)?r.forEach(e=>e.destroy(!0)):r.destroy(!0)}};me.add(Yw);const Xw={extension:ae.ResolveParser,test:r=>{const e=r.split("?")[0].split(".").pop();return["basis","ktx","dds"].includes(e)},parse:r=>{if(r.split("?")[0].split(".").pop()==="ktx"){const e=[".s3tc.ktx",".s3tc_sRGB.ktx",".etc.ktx",".etc1.ktx",".pvrt.ktx",".atc.ktx",".astc.ktx"];if(e.some(t=>r.endsWith(t)))return{resolution:parseFloat(de.RETINA_PREFIX.exec(r)?.[1]??"1"),format:e.find(t=>r.endsWith(t)),src:r}}return{resolution:parseFloat(de.RETINA_PREFIX.exec(r)?.[1]??"1"),format:r.split(".").pop(),src:r}}};me.add(Xw);const Ga=new Se,Kw=4,ym=class Un{constructor(e){this.renderer=e,this._rendererPremultipliedAlpha=!1}contextChange(){const e=this.renderer?.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(e&&e.alpha&&e.premultipliedAlpha)}async image(e,t,i,s){const n=new Image;return n.src=await this.base64(e,t,i,s),n}async base64(e,t,i,s){const n=this.canvas(e,s);if(n.toBlob!==void 0)return new Promise((a,o)=>{n.toBlob(l=>{if(!l){o(new Error("ICanvas.toBlob failed!"));return}const c=new FileReader;c.onload=()=>a(c.result),c.onerror=o,c.readAsDataURL(l)},t,i)});if(n.toDataURL!==void 0)return n.toDataURL(t,i);if(n.convertToBlob!==void 0){const a=await n.convertToBlob({type:t,quality:i});return new Promise((o,l)=>{const c=new FileReader;c.onload=()=>o(c.result),c.onerror=l,c.readAsDataURL(a)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(e,t){const{pixels:i,width:s,height:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(e,t);a&&Un._flipY(i,s,n),o&&Un._unpremultiplyAlpha(i);const l=new kv(s,n,1),c=new ImageData(new Uint8ClampedArray(i.buffer),s,n);return l.context.putImageData(c,0,0),l.canvas}pixels(e,t){const{pixels:i,width:s,height:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(e,t);return a&&Un._flipY(i,s,n),o&&Un._unpremultiplyAlpha(i),i}_rawPixels(e,t){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let s,n=!1,a=!1,o,l=!1;e&&(e instanceof mt?o=e:(o=i.generateTexture(e,{region:t,resolution:i.resolution,multisample:i.multisample}),l=!0,t&&(Ga.width=t.width,Ga.height=t.height,t=Ga)));const c=i.gl;if(o){if(s=o.baseTexture.resolution,t=t??o.frame,n=!1,a=o.baseTexture.alphaMode>0&&o.baseTexture.format===re.RGBA,!l){i.renderTexture.bind(o);const p=o.framebuffer.glFramebuffers[i.CONTEXT_UID];p.blitFramebuffer&&i.framebuffer.bind(p.blitFramebuffer)}}else s=i.resolution,t||(t=Ga,t.width=i.width/s,t.height=i.height/s),n=!0,a=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(t.width*s),1),h=Math.max(Math.round(t.height*s),1),d=new Uint8Array(Kw*u*h);return c.readPixels(Math.round(t.x*s),Math.round(t.y*s),u,h,c.RGBA,c.UNSIGNED_BYTE,d),l&&o?.destroy(!0),{pixels:d,width:u,height:h,flipY:n,premultipliedAlpha:a}}destroy(){this.renderer=null}static _flipY(e,t,i){const s=t<<2,n=i>>1,a=new Uint8Array(s);for(let o=0;o=0&&o>=0&&s>=0&&n>=0)){e.length=0;return}const l=Math.ceil(2.3*Math.sqrt(a+o)),c=l*8+(s?4:0)+(n?4:0);if(e.length=c,c===0)return;if(l===0){e.length=8,e[0]=e[6]=t+s,e[1]=e[3]=i+n,e[2]=e[4]=t-s,e[5]=e[7]=i-n;return}let u=0,h=l*4+(s?2:0)+2,d=h,p=c;{const f=s+a,m=n,g=t+f,y=t-f,b=i+m;if(e[u++]=g,e[u++]=b,e[--h]=b,e[--h]=y,n){const A=i-m;e[d++]=y,e[d++]=A,e[--p]=A,e[--p]=g}}for(let f=1;f0||e&&i<=0){const s=t/2;for(let n=s+s%2;n=6){Gu(t,!1);const a=[];for(let c=0;c=0&&n>=0&&a.push(t,i,t+s,i,t+s,i+n,t,i+n)},triangulate(r,e){const t=r.points,i=e.points;if(t.length===0)return;const s=i.length/2;i.push(t[0],t[1],t[2],t[3],t[6],t[7],t[4],t[5]),e.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},$w={build(r){Lo.build(r)},triangulate(r,e){Lo.triangulate(r,e)}};var ei=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(ei||{}),Br=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(Br||{});const ln={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,e=20){if(!this.adaptive||!r||isNaN(r))return e;let t=Math.ceil(r/this.maxLength);return tthis.maxSegments&&(t=this.maxSegments),t}};class Hu{static curveTo(e,t,i,s,n,a){const o=a[a.length-2],l=a[a.length-1]-t,c=o-e,u=s-t,h=i-e,d=Math.abs(l*h-c*u);if(d<1e-8||n===0)return(a[a.length-2]!==e||a[a.length-1]!==t)&&a.push(e,t),null;const p=l*l+c*c,f=u*u+h*h,m=l*u+c*h,g=n*Math.sqrt(p)/d,y=n*Math.sqrt(f)/d,b=g*m/p,A=y*m/f,v=g*h+y*c,E=g*u+y*l,C=c*(y+b),M=l*(y+b),P=h*(g+A),k=u*(g+A),N=Math.atan2(M-E,C-v),H=Math.atan2(k-E,P-v);return{cx:v+e,cy:E+t,radius:n,startAngle:N,endAngle:H,anticlockwise:c*u>h*l}}static arc(e,t,i,s,n,a,o,l,c){const u=o-a,h=ln._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/So)*40),d=u/(h*2),p=d*2,f=Math.cos(d),m=Math.sin(d),g=h-1,y=g%1/g;for(let b=0;b<=g;++b){const A=b+y*b,v=d+a+p*A,E=Math.cos(v),C=-Math.sin(v);c.push((f*E+m*C)*n+i,(f*-C+m*E)*n+s)}}}class Jw{constructor(){this.reset()}begin(e,t,i){this.reset(),this.style=e,this.start=t,this.attribStart=i}end(e,t){this.attribSize=t-this.attribStart,this.size=e-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class jc{static curveLength(e,t,i,s,n,a,o,l){let c=0,u=0,h=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,A=0,v=e,E=t;for(let C=1;C<=10;++C)u=C/10,h=u*u,d=h*u,p=1-u,f=p*p,m=f*p,g=m*e+3*f*u*i+3*p*h*n+d*o,y=m*t+3*f*u*s+3*p*h*a+d*l,b=v-g,A=E-y,v=g,E=y,c+=Math.sqrt(b*b+A*A);return c}static curveTo(e,t,i,s,n,a,o){const l=o[o.length-2],c=o[o.length-1];o.length-=2;const u=ln._segmentsCount(jc.curveLength(l,c,e,t,i,s,n,a));let h=0,d=0,p=0,f=0,m=0;o.push(l,c);for(let g=1,y=0;g<=u;++g)y=g/u,h=1-y,d=h*h,p=d*h,f=y*y,m=f*y,o.push(p*l+3*d*y*e+3*h*f*i+m*n,p*c+3*d*y*t+3*h*f*s+m*a)}}function Wu(r,e,t,i,s,n,a,o){const l=r-t*s,c=e-i*s,u=r+t*n,h=e+i*n;let d,p;a?(d=i,p=-t):(d=-i,p=t);const f=l+d,m=c+p,g=u+d,y=h+p;return o.push(f,m,g,y),2}function Xr(r,e,t,i,s,n,a,o){const l=t-r,c=i-e;let u=Math.atan2(l,c),h=Math.atan2(s-r,n-e);o&&uh&&(h+=Math.PI*2);let d=u;const p=h-u,f=Math.abs(p),m=Math.sqrt(l*l+c*c),g=(15*f*Math.sqrt(m)/Math.PI>>0)+1,y=p/g;if(d+=y,o){a.push(r,e,t,i);for(let b=1,A=d;b=0&&(n.join===ei.ROUND?d+=Xr(A,v,A-M*S,v-P*S,A-k*S,v-N*S,u,!1)+4:d+=2,u.push(A-k*w,v-N*w,A+k*S,v+N*S));continue}const K=(-M+y)*(-P+v)-(-M+A)*(-P+b),ge=(-k+E)*(-N+v)-(-k+A)*(-N+C),Te=(te*ge-G*K)/ee,he=(D*K-R*ge)/ee,pe=(Te-A)*(Te-A)+(he-v)*(he-v),be=A+(Te-A)*S,oe=v+(he-v)*S,ue=A-(Te-A)*w,ve=v-(he-v)*w,x=Math.min(te*te+R*R,G*G+D*D),j=Q?S:w,V=x+j*j*m,B=pe<=V;let I=n.join;if(I===ei.MITER&&pe/m>g&&(I=ei.BEVEL),B)switch(I){case ei.MITER:{u.push(be,oe,ue,ve);break}case ei.BEVEL:{Q?u.push(be,oe,A+M*w,v+P*w,be,oe,A+k*w,v+N*w):u.push(A-M*S,v-P*S,ue,ve,A-k*S,v-N*S,ue,ve),d+=2;break}case ei.ROUND:{Q?(u.push(be,oe,A+M*w,v+P*w),d+=Xr(A,v,A+M*w,v+P*w,A+k*w,v+N*w,u,!0)+4,u.push(be,oe,A+k*w,v+N*w)):(u.push(A-M*S,v-P*S,ue,ve),d+=Xr(A,v,A-M*S,v-P*S,A-k*S,v-N*S,u,!1)+4,u.push(A-k*S,v-N*S,ue,ve));break}}else{switch(u.push(A-M*S,v-P*S,A+M*w,v+P*w),I){case ei.MITER:{Q?u.push(ue,ve,ue,ve):u.push(be,oe,be,oe),d+=2;break}case ei.ROUND:{Q?d+=Xr(A,v,A+M*w,v+P*w,A+k*w,v+N*w,u,!0)+2:d+=Xr(A,v,A-M*S,v-P*S,A-k*S,v-N*S,u,!1)+2;break}}u.push(A-k*S,v-N*S,A+k*w,v+N*w),d+=2}}y=i[(h-2)*2],b=i[(h-2)*2+1],A=i[(h-1)*2],v=i[(h-1)*2+1],M=-(b-v),P=y-A,H=Math.sqrt(M*M+P*P),M/=H,P/=H,M*=f,P*=f,u.push(A-M*S,v-P*S,A+M*w,v+P*w),l||(n.cap===Br.ROUND?d+=Xr(A-M*(S-w)*.5,v-P*(S-w)*.5,A-M*S,v-P*S,A+M*w,v+P*w,u,!1)+2:n.cap===Br.SQUARE&&(d+=Wu(A,v,M,P,S,w,!1,u)));const F=e.indices,z=ln.epsilon*ln.epsilon;for(let L=p;L0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(e,t=null,i=null,s=null){const n=new Oo(e,t,i,s);return this.graphicsData.push(n),this.dirty++,this}drawHole(e,t=null){if(!this.graphicsData.length)return null;const i=new Oo(e,null,null,t),s=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=s.lineStyle,s.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let e=0;e0&&(i=this.batches[this.batches.length-1],s=i.style);for(let l=this.shapeIndex;l65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&o===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=o?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(e,t){return!(!e||!t||e.texture.baseTexture!==t.texture.baseTexture||e.color+e.alpha!==t.color+t.alpha||!!e.native!=!!t.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let e=0,t=this.graphicsData.length;e65535*2)return!1;const e=this.batches;for(let t=0;t0&&(s=Ha.pop(),s||(s=new Vh,s.texArray=new Xh),this.drawCalls.push(s)),s.start=u,s.size=0,s.texArray.count=0,s.type=c),m.touched=1,m._batchEnabled=e,m._batchLocation=n,m.wrapMode=Pr.REPEAT,s.texArray.elements[s.texArray.count++]=m,n++)),s.size+=d.size,u+=d.size,o=m._batchLocation,this.addColors(t,f.color,f.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,o,d.attribSize,d.attribStart)}Me._globalBatch=e,this.packAttributes()}packAttributes(){const e=this.points,t=this.uvs,i=this.colors,s=this.textureIds,n=new ArrayBuffer(e.length*3*4),a=new Float32Array(n),o=new Uint32Array(n);let l=0;for(let c=0;c0&&e.alpha>0;return i?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._lineStyle,{visible:i},e)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const e=this.currentPath.points,t=this.currentPath.points.length;t>2&&(this.drawShape(this.currentPath),this.currentPath=new us,this.currentPath.closeStroke=!1,this.currentPath.points.push(e[t-2],e[t-1]))}else this.currentPath=new us,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(e,t){return this.startPoly(),this.currentPath.points[0]=e,this.currentPath.points[1]=t,this}lineTo(e,t){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,s=i[i.length-2],n=i[i.length-1];return(s!==e||n!==t)&&i.push(e,t),this}_initCurve(e=0,t=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[e,t]):this.moveTo(e,t)}quadraticCurveTo(e,t,i,s){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),Yc.curveTo(e,t,i,s,n),this}bezierCurveTo(e,t,i,s,n,a){return this._initCurve(),jc.curveTo(e,t,i,s,n,a,this.currentPath.points),this}arcTo(e,t,i,s,n){this._initCurve(e,t);const a=this.currentPath.points,o=Hu.curveTo(e,t,i,s,n,a);if(o){const{cx:l,cy:c,radius:u,startAngle:h,endAngle:d,anticlockwise:p}=o;this.arc(l,c,u,h,d,p)}return this}arc(e,t,i,s,n,a=!1){if(s===n)return this;if(!a&&n<=s?n+=So:a&&s<=n&&(s+=So),n-s===0)return this;const o=e+Math.cos(s)*i,l=t+Math.sin(s)*i,c=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const h=Math.abs(u[u.length-2]-o),d=Math.abs(u[u.length-1]-l);h0;return i?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._fillStyle,{visible:i},e)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(e,t,i,s){return this.drawShape(new Se(e,t,i,s))}drawRoundedRect(e,t,i,s,n){return this.drawShape(new Zo(e,t,i,s,n))}drawCircle(e,t,i){return this.drawShape(new $o(e,t,i))}drawEllipse(e,t,i,s){return this.drawShape(new Jo(e,t,i,s))}drawPolygon(...e){let t,i=!0;const s=e[0];s.points?(i=s.closeStroke,t=s.points):Array.isArray(e[0])?t=e[0]:t=e;const n=new us(t);return n.closeStroke=i,this.drawShape(n),this}drawShape(e){return this._holeMode?this._geometry.drawHole(e,this._matrix):this._geometry.drawShape(e,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const e=this._geometry.graphicsData;return e.length===1&&e[0].shape.type===Et.RECT&&!e[0].matrix&&!e[0].holes.length&&!(e[0].lineStyle.visible&&e[0].lineStyle.width)}_render(e){this.finishPoly();const t=this._geometry;t.updateBatches(),t.batchable?(this.batchDirty!==t.batchDirty&&this._populateBatches(),this._renderBatched(e)):(e.batch.flush(),this._renderDirect(e))}_populateBatches(){const e=this._geometry,t=this.blendMode,i=e.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=e.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(e.points);for(let s=0;s{const t=URL.createObjectURL(new Blob([qA.code],{type:"application/javascript"})),i=new Worker(t);i.addEventListener("message",s=>{i.terminate(),URL.revokeObjectURL(t),e(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(e){return this._run("loadImageBitmap",[e])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Ql===void 0&&(Ql=navigator.hardwareConcurrency||4);let e=this.workerPool.pop();return!e&&this._createdWorkers{this.complete(t.data),this.returnWorker(t.target),this.next()})),e}returnWorker(e){this.workerPool.push(e)}complete(e){e.error!==void 0?this.resolveHash[e.uuid].reject(e.error):this.resolveHash[e.uuid].resolve(e.data),this.resolveHash[e.uuid]=null}async _run(e,t){await this._initWorkers();const i=new Promise((s,n)=>{this.queue.push({id:e,arguments:t,resolve:s,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const e=this.getWorker();if(!e)return;const t=this.queue.pop(),i=t.id;this.resolveHash[Ru]={resolve:t.resolve,reject:t.reject},e.postMessage({data:t.arguments,uuid:Ru++,id:i})}}const Du=new $A;function fa(r,e,t){r.resource.internal=!0;const i=new Z(r),s=()=>{delete e.promiseCache[t],ss.has(t)&&ss.remove(t)};return i.baseTexture.once("destroyed",()=>{t in e.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),s())}),i.once("destroyed",()=>{r.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),s())}),i}const JA=[".jpeg",".jpg",".png",".webp",".avif"],ZA=["image/jpeg","image/png","image/webp","image/avif"];async function ew(r){const e=await de.ADAPTER.fetch(r);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${e.status} ${e.statusText}`);const t=await e.blob();return await createImageBitmap(t)}const il={name:"loadTextures",extension:{type:ae.LoadParser,priority:Mi.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return wn(r,ZA)||Hr(r,JA)},async load(r,e,t){const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await Du.isImageBitmapSupported()?s=await Du.loadImageBitmap(r):s=await ew(r):s=await new Promise((o,l)=>{const c=new Image;c.crossOrigin=this.config.crossOrigin,c.src=r,c.complete?o(c):(c.onload=()=>o(c),c.onerror=u=>l(u))});const n={...e.data};n.resolution??(n.resolution=or(r)),i&&n.resourceOptions?.ownsImageBitmap===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const a=new Me(s,n);return a.resource.src=r,fa(a,t,r)},unload(r){r.destroy(!0)}};me.add(il);const tw=".svg",iw="image/svg+xml",rw={extension:{type:ae.LoadParser,priority:Mi.High},name:"loadSVG",test(r){return wn(r,iw)||Hr(r,tw)},async testParse(r){return Zh.test(r)},async parse(r,e,t){const i=new Zh(r,e?.data?.resourceOptions);await i.load();const s=new Me(i,{resolution:or(r),...e?.data});return s.resource.src=e.src,fa(s,t,e.src)},async load(r,e){return(await de.ADAPTER.fetch(r)).text()},unload:il.unload};me.add(rw);const sw=[".mp4",".m4v",".webm",".ogv"],aw=["video/mp4","video/webm","video/ogg"],ow={name:"loadVideo",extension:{type:ae.LoadParser,priority:Mi.High},config:{defaultAutoPlay:!0},test(r){return wn(r,aw)||Hr(r,sw)},async load(r,e,t){let i;const s=await(await de.ADAPTER.fetch(r)).blob(),n=URL.createObjectURL(s);try{const a={autoPlay:this.config.defaultAutoPlay,...e?.data?.resourceOptions},o=new cm(n,a);await o.load();const l=new Me(o,{alphaMode:await fv(),resolution:or(r),...e?.data});l.resource.src=r,i=fa(l,t,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(a){throw URL.revokeObjectURL(n),a}return i},unload(r){r.destroy(!0)}};me.add(ow);class lw{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e=="string")this._defaultSearchParams=e;else{const t=e;this._defaultSearchParams=Object.keys(t).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(t[i])}`).join("&")}}getAlias(e){const{alias:t,name:i,src:s,srcs:n}=e;return wi(t||i||s||n,a=>typeof a=="string"?a:Array.isArray(a)?a.map(o=>o?.src??o?.srcs??o):a?.src||a?.srcs?a.src??a.srcs:a,!0)}addManifest(e){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){const i=[];Array.isArray(t)?t.forEach(s=>{const n=s.src??s.srcs,a=s.alias??s.name;let o;if(typeof a=="string"){const l=this._createBundleAssetId(e,a);i.push(l),o=[a,l]}else{const l=a.map(c=>this._createBundleAssetId(e,c));i.push(...l),o=[...a,...l]}this.add({...s,alias:o,src:n})}):Object.keys(t).forEach(s=>{const n=[s,this._createBundleAssetId(e,s)];if(typeof t[s]=="string")this.add({alias:n,src:t[s]});else if(Array.isArray(t[s]))this.add({alias:n,src:t[s]});else{const a=t[s],o=a.src??a.srcs;this.add({...a,alias:n,src:Array.isArray(o)?o:[o]})}i.push(...n)}),this._bundles[e]=i}add(e,t,i,s,n){const a=[];typeof e=="string"||Array.isArray(e)&&typeof e[0]=="string"?(Le("7.2.0",`Assets.add now uses an object instead of individual parameters. +Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),a.push({alias:e,src:t,data:i,format:s,loadParser:n})):Array.isArray(e)?a.push(...e):a.push(e);let o;o=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},wi(a).forEach(l=>{const{src:c,srcs:u}=l;let{data:h,format:d,loadParser:p}=l;const f=wi(c||u).map(y=>typeof y=="string"?RA(y):Array.isArray(y)?y:[y]),m=this.getAlias(l);Array.isArray(m)?m.forEach(o):o(m);const g=[];f.forEach(y=>{y.forEach(b=>{let A={};if(typeof b!="object"){A.src=b;for(let v=0;v{this._assetMap[y]=g})})}resolveBundle(e){const t=Ro(e);e=wi(e);const i={};return e.forEach(s=>{const n=this._bundles[s];if(n){const a=this.resolve(n),o={};for(const l in a){const c=a[l];o[this._extractAssetIdFromBundle(s,l)]=c}i[s]=o}}),t?i[e[0]]:i}resolveUrl(e){const t=this.resolve(e);if(typeof e!="string"){const i={};for(const s in t)i[s]=t[s].src;return i}return t.src}resolve(e){const t=Ro(e);e=wi(e);const i={};return e.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const a=n[0],o=this._getPreferredOrder(n);o?.priority.forEach(l=>{o.params[l].forEach(c=>{const u=n.filter(h=>h[l]?h[l]===c:!1);u.length&&(n=u)})}),this._resolverHash[s]=n[0]??a}else this._resolverHash[s]=this.buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),t?i[e[0]]:i}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;tn.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;const t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}buildResolvedAsset(e,t){const{aliases:i,data:s,loadParser:n,format:a}=t;return(this._basePath||this._rootPath)&&(e.src=Bt.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=i??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...s||{},...e.data},e.loadParser=n??e.loadParser,e.format=a??e.src.split(".").pop(),e.srcs=e.src,e.name=e.alias,e}}class hw{constructor(){this._detections=[],this._initialized=!1,this.resolver=new lw,this.loader=new LA,this.cache=ss,this._backgroundLoader=new PA(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(e={}){if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Asset.init()?");return}if(this._initialized=!0,e.defaultSearchParams&&this.resolver.setDefaultSearchParams(e.defaultSearchParams),e.basePath&&(this.resolver.basePath=e.basePath),e.bundleIdentifier&&this.resolver.setBundleIdentifier(e.bundleIdentifier),e.manifest){let n=e.manifest;typeof n=="string"&&(n=await this.load(n)),this.resolver.addManifest(n)}const t=e.texturePreference?.resolution??1,i=typeof t=="number"?[t]:t,s=await this._detectFormats({preferredFormats:e.texturePreference?.format,skipDetections:e.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),e.preferences&&this.setPreferences(e.preferences)}add(e,t,i,s,n){this.resolver.add(e,t,i,s,n)}async load(e,t){this._initialized||await this.init();const i=Ro(e),s=wi(e).map(o=>{if(typeof o!="string"){const l=this.resolver.getAlias(o);return l.some(c=>!this.resolver.hasKey(c))&&this.add(o),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),n=this.resolver.resolve(s),a=await this._mapLoadToResolve(n,t);return i?a[s[0]]:a}addBundle(e,t){this.resolver.addBundle(e,t)}async loadBundle(e,t){this._initialized||await this.init();let i=!1;typeof e=="string"&&(i=!0,e=[e]);const s=this.resolver.resolveBundle(e),n={},a=Object.keys(s);let o=0,l=0;const c=()=>{t?.(++o/l)},u=a.map(h=>{const d=s[h];return l+=Object.keys(d).length,this._mapLoadToResolve(d,c).then(p=>{n[h]=p})});return await Promise.all(u),i?n[e[0]]:n}async backgroundLoad(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolve(e);this._backgroundLoader.add(Object.values(t))}async backgroundLoadBundle(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolveBundle(e);Object.values(t).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(e){if(typeof e=="string")return ss.get(e);const t={};for(let i=0;i{const c=n[o.src],u=[o.src];o.alias&&u.push(...o.alias),a[s[l]]=c,ss.set(u,c)}),a}async unload(e){this._initialized||await this.init();const t=wi(e).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(t);await this._unloadFromResolved(i)}async unloadBundle(e){this._initialized||await this.init(),e=wi(e);const t=this.resolver.resolveBundle(e),i=Object.keys(t).map(s=>this._unloadFromResolved(t[s]));await Promise.all(i)}async _unloadFromResolved(e){const t=Object.values(e);t.forEach(i=>{ss.remove(i.src)}),await this.loader.unload(t)}async _detectFormats(e){let t=[];e.preferredFormats&&(t=Array.isArray(e.preferredFormats)?e.preferredFormats:[e.preferredFormats]);for(const i of e.detections)e.skipDetections||await i.test()?t=await i.add(t):e.skipDetections||(t=await i.remove(t));return t=t.filter((i,s)=>t.indexOf(i)===s),t}get detections(){return this._detections}get preferWorkers(){return il.config.preferWorkers}set preferWorkers(e){Le("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:e})}setPreferences(e){this.loader.parsers.forEach(t=>{t.config&&Object.keys(t.config).filter(i=>i in e).forEach(i=>{t.config[i]=e[i]})})}}const qs=new hw;me.handleByList(ae.LoadParser,qs.loader.parsers).handleByList(ae.ResolveParser,qs.resolver.parsers).handleByList(ae.CacheParser,qs.cache.parsers).handleByList(ae.DetectionParser,qs.detections);const cw={extension:ae.CacheParser,test:r=>Array.isArray(r)&&r.every(e=>e instanceof Z),getCacheableAssets:(r,e)=>{const t={};return r.forEach(i=>{e.forEach((s,n)=>{t[i+(n===0?"":n+1)]=s})}),t}};me.add(cw);const dw={extension:{type:ae.DetectionParser,priority:1},test:async()=>{const r="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=";return new Promise(e=>{const t=new Image;t.onload=()=>{e(!0)},t.onerror=()=>{e(!1)},t.src=r})},add:async r=>[...r,"avif"],remove:async r=>r.filter(e=>e!=="avif")};me.add(dw);const uw={extension:{type:ae.DetectionParser,priority:0},test:async()=>{const r="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=";return new Promise(e=>{const t=new Image;t.onload=()=>{e(!0)},t.onerror=()=>{e(!1)},t.src=r})},add:async r=>[...r,"webp"],remove:async r=>r.filter(e=>e!=="webp")};me.add(uw);const Lu=["png","jpg","jpeg"],pw={extension:{type:ae.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Lu],remove:async r=>r.filter(e=>!Lu.includes(e))};me.add(pw);const fw="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function zc(r){return fw?!1:document.createElement("video").canPlayType(r)!==""}const mw={extension:{type:ae.DetectionParser,priority:0},test:async()=>zc("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(e=>e!=="webm")};me.add(mw);const gw={extension:{type:ae.DetectionParser,priority:0},test:async()=>zc("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(e=>e!=="mp4"&&e!=="m4v")};me.add(gw);const yw={extension:{type:ae.DetectionParser,priority:0},test:async()=>zc("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(e=>e!=="ogv")};me.add(yw);const vw={extension:ae.ResolveParser,test:il.test,parse:r=>({resolution:parseFloat(de.RETINA_PREFIX.exec(r)?.[1]??"1"),format:r.split(".").pop(),src:r})};me.add(vw);var zt=(r=>(r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",r[r.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",r[r.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r))(zt||{});const Do={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35986:1,34798:1,37808:1};let Qi,Hs;function Ou(){Hs={s3tc:Qi.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Qi.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:Qi.getExtension("WEBGL_compressed_texture_etc"),etc1:Qi.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:Qi.getExtension("WEBGL_compressed_texture_pvrtc")||Qi.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:Qi.getExtension("WEBGL_compressed_texture_atc"),astc:Qi.getExtension("WEBGL_compressed_texture_astc")}}const bw={extension:{type:ae.DetectionParser,priority:2},test:async()=>{const r=de.ADAPTER.createCanvas().getContext("webgl");return r?(Qi=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{Hs||Ou();const e=[];for(const t in Hs)Hs[t]&&e.push(t);return[...e,...r]},remove:async r=>(Hs||Ou(),r.filter(e=>!(e in Hs)))};me.add(bw);class Aw extends Qo{constructor(e,t={width:1,height:1,autoLoad:!0}){let i,s;typeof e=="string"?(i=e,s=new Uint8Array):(i=null,s=e),super(s,t),this.origin=i,this.buffer=s?new Gh(s):null,this._load=null,this.loaded=!1,this.origin!==null&&t.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(e){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(e=>e.blob()).then(e=>e.arrayBuffer()).then(e=>(this.data=new Uint32Array(e),this.buffer=new Gh(e),this.loaded=!0,this.onBlobLoaded(e),this.update(),this)),this._load)}}class ps extends Aw{constructor(e,t){super(e,t),this.format=t.format,this.levels=t.levels||1,this._width=t.width,this._height=t.height,this._extension=ps._formatToExtension(this.format),(t.levelBuffers||this.buffer)&&(this._levelBuffers=t.levelBuffers||ps._createLevelBuffers(e instanceof Uint8Array?e:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(e,t,i){const s=e.gl;if(!e.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,a=this.levels;n=33776&&e<=33779)return"s3tc";if(e>=37488&&e<=37497)return"etc";if(e>=35840&&e<=35843)return"pvrtc";if(e>=36196)return"etc1";if(e>=35986&&e<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")}static _createLevelBuffers(e,t,i,s,n,a,o){const l=new Array(i);let c=e.byteOffset,u=a,h=o,d=u+s-1&~(s-1),p=h+n-1&~(n-1),f=d*p*Do[t];for(let m=0;m1?u:d,levelHeight:i>1?h:p,levelBuffer:new Uint8Array(e.buffer,c,f)},c+=f,u=u>>1||1,h=h>>1||1,d=u+s-1&~(s-1),p=h+n-1&~(n-1),f=d*p*Do[t];return l}}const Jl=4,Fa=124,ww=32,Fu=20,xw=542327876,Na={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},_w={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},Ua={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},Ew=1,Tw=2,Sw=4,Cw=64,Mw=512,Iw=131072,kw=827611204,Bw=861165636,Pw=894720068,Rw=808540228,Dw=4,Lw={[kw]:zt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Bw]:zt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Pw]:zt.COMPRESSED_RGBA_S3TC_DXT5_EXT},Ow={70:zt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:zt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:zt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:zt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:zt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:zt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:zt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:zt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:zt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function Fw(r){const e=new Uint32Array(r);if(e[0]!==xw)throw new Error("Invalid DDS file magic word");const t=new Uint32Array(r,0,Fa/Uint32Array.BYTES_PER_ELEMENT),i=t[Na.HEIGHT],s=t[Na.WIDTH],n=t[Na.MIPMAP_COUNT],a=new Uint32Array(r,Na.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,ww/Uint32Array.BYTES_PER_ELEMENT),o=a[Ew];if(o&Sw){const l=a[_w.FOURCC];if(l!==Rw){const b=Lw[l],A=Jl+Fa,v=new Uint8Array(r,A);return[new ps(v,{format:b,width:s,height:i,levels:n})]}const c=Jl+Fa,u=new Uint32Array(e.buffer,c,Fu/Uint32Array.BYTES_PER_ELEMENT),h=u[Ua.DXGI_FORMAT],d=u[Ua.RESOURCE_DIMENSION],p=u[Ua.MISC_FLAG],f=u[Ua.ARRAY_SIZE],m=Ow[h];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${h}`);if(p===Dw)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const g=new Array,y=Jl+Fa+Fu;if(f===1)g.push(new Uint8Array(r,y));else{const b=Do[m];let A=0,v=s,E=i;for(let M=0;M>>1,E=E>>>1}let C=y;for(let M=0;Mnew ps(b,{format:m,width:s,height:i,levels:n}))}throw o&Cw?new Error("DDSParser does not support uncompressed texture data."):o&Mw?new Error("DDSParser does not supported YUV uncompressed texture data."):o&Iw?new Error("DDSParser does not support single-channel (lumninance) texture data!"):o&Tw?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const Nu=[171,75,84,88,32,49,49,187,13,10,26,10],Nw=67305985,mi={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},dc=64,Uu={[we.UNSIGNED_BYTE]:1,[we.UNSIGNED_SHORT]:2,[we.INT]:4,[we.UNSIGNED_INT]:4,[we.FLOAT]:4,[we.HALF_FLOAT]:8},Uw={[re.RGBA]:4,[re.RGB]:3,[re.RG]:2,[re.RED]:1,[re.LUMINANCE]:1,[re.LUMINANCE_ALPHA]:2,[re.ALPHA]:1},Gw={[we.UNSIGNED_SHORT_4_4_4_4]:2,[we.UNSIGNED_SHORT_5_5_5_1]:2,[we.UNSIGNED_SHORT_5_6_5]:2};function Hw(r,e,t=!1){const i=new DataView(e);if(!Ww(r,i))return null;const s=i.getUint32(mi.ENDIANNESS,!0)===Nw,n=i.getUint32(mi.GL_TYPE,s),a=i.getUint32(mi.GL_FORMAT,s),o=i.getUint32(mi.GL_INTERNAL_FORMAT,s),l=i.getUint32(mi.PIXEL_WIDTH,s),c=i.getUint32(mi.PIXEL_HEIGHT,s)||1,u=i.getUint32(mi.PIXEL_DEPTH,s)||1,h=i.getUint32(mi.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(mi.NUMBER_OF_FACES,s),p=i.getUint32(mi.NUMBER_OF_MIPMAP_LEVELS,s),f=i.getUint32(mi.BYTES_OF_KEY_VALUE_DATA,s);if(c===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(h!==1)throw new Error("WebGL does not support array textures");const m=4,g=4,y=l+3&-4,b=c+3&-4,A=new Array(h);let v=l*c;n===0&&(v=y*b);let E;if(n!==0?Uu[n]?E=Uu[n]*Uw[a]:E=Gw[n]:E=Do[o],E===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const C=t?zw(i,f,s):null;let M=v*E,P=l,k=c,N=y,H=b,T=dc+f;for(let S=0;S1||n!==0?P:N,levelHeight:p>1||n!==0?k:H,levelBuffer:new Uint8Array(e,F,M)},F+=M}T+=w+4,T=T%4!==0?T+4-T%4:T,P=P>>1||1,k=k>>1||1,N=P+m-1&~(m-1),H=k+g-1&~(g-1),M=N*H*E}return n!==0?{uncompressed:A.map(S=>{let w=S[0].levelBuffer,F=!1;return n===we.FLOAT?w=new Float32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4):n===we.UNSIGNED_INT?(F=!0,w=new Uint32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4)):n===we.INT&&(F=!0,w=new Int32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4)),{resource:new Qo(w,{width:S[0].levelWidth,height:S[0].levelHeight}),type:n,format:F?Vw(a):a}}),kvData:C}:{compressed:A.map(S=>new ps(null,{format:o,width:l,height:c,levels:p,levelBuffers:S})),kvData:C}}function Ww(r,e){for(let t=0;te-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l{const a=new Me(n,{mipmap:Xt.OFF,alphaMode:Lt.NO_PREMULTIPLIED_ALPHA,resolution:or(r),...e.data});return fa(a,t,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(e=>e.destroy(!0)):r.destroy(!0)}};me.add(jw);const Yw={extension:{type:ae.LoadParser,priority:Mi.High},name:"loadKTX",test(r){return Hr(r,".ktx")},async load(r,e,t){const i=await(await de.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:a}=Hw(r,i),o=s??n,l={mipmap:Xt.OFF,alphaMode:Lt.NO_PREMULTIPLIED_ALPHA,resolution:or(r),...e.data},c=o.map(u=>{o===n&&Object.assign(l,{type:u.type,format:u.format});const h=u.resource??u,d=new Me(h,l);return d.ktxKeyValueData=a,fa(d,t,r)});return c.length===1?c[0]:c},unload(r){Array.isArray(r)?r.forEach(e=>e.destroy(!0)):r.destroy(!0)}};me.add(Yw);const Xw={extension:ae.ResolveParser,test:r=>{const e=r.split("?")[0].split(".").pop();return["basis","ktx","dds"].includes(e)},parse:r=>{if(r.split("?")[0].split(".").pop()==="ktx"){const e=[".s3tc.ktx",".s3tc_sRGB.ktx",".etc.ktx",".etc1.ktx",".pvrt.ktx",".atc.ktx",".astc.ktx"];if(e.some(t=>r.endsWith(t)))return{resolution:parseFloat(de.RETINA_PREFIX.exec(r)?.[1]??"1"),format:e.find(t=>r.endsWith(t)),src:r}}return{resolution:parseFloat(de.RETINA_PREFIX.exec(r)?.[1]??"1"),format:r.split(".").pop(),src:r}}};me.add(Xw);const Ga=new Se,Kw=4,ym=class Un{constructor(e){this.renderer=e,this._rendererPremultipliedAlpha=!1}contextChange(){const e=this.renderer?.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(e&&e.alpha&&e.premultipliedAlpha)}async image(e,t,i,s){const n=new Image;return n.src=await this.base64(e,t,i,s),n}async base64(e,t,i,s){const n=this.canvas(e,s);if(n.toBlob!==void 0)return new Promise((a,o)=>{n.toBlob(l=>{if(!l){o(new Error("ICanvas.toBlob failed!"));return}const c=new FileReader;c.onload=()=>a(c.result),c.onerror=o,c.readAsDataURL(l)},t,i)});if(n.toDataURL!==void 0)return n.toDataURL(t,i);if(n.convertToBlob!==void 0){const a=await n.convertToBlob({type:t,quality:i});return new Promise((o,l)=>{const c=new FileReader;c.onload=()=>o(c.result),c.onerror=l,c.readAsDataURL(a)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(e,t){const{pixels:i,width:s,height:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(e,t);a&&Un._flipY(i,s,n),o&&Un._unpremultiplyAlpha(i);const l=new kv(s,n,1),c=new ImageData(new Uint8ClampedArray(i.buffer),s,n);return l.context.putImageData(c,0,0),l.canvas}pixels(e,t){const{pixels:i,width:s,height:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(e,t);return a&&Un._flipY(i,s,n),o&&Un._unpremultiplyAlpha(i),i}_rawPixels(e,t){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let s,n=!1,a=!1,o,l=!1;e&&(e instanceof mt?o=e:(o=i.generateTexture(e,{region:t,resolution:i.resolution,multisample:i.multisample}),l=!0,t&&(Ga.width=t.width,Ga.height=t.height,t=Ga)));const c=i.gl;if(o){if(s=o.baseTexture.resolution,t=t??o.frame,n=!1,a=o.baseTexture.alphaMode>0&&o.baseTexture.format===re.RGBA,!l){i.renderTexture.bind(o);const p=o.framebuffer.glFramebuffers[i.CONTEXT_UID];p.blitFramebuffer&&i.framebuffer.bind(p.blitFramebuffer)}}else s=i.resolution,t||(t=Ga,t.width=i.width/s,t.height=i.height/s),n=!0,a=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(t.width*s),1),h=Math.max(Math.round(t.height*s),1),d=new Uint8Array(Kw*u*h);return c.readPixels(Math.round(t.x*s),Math.round(t.y*s),u,h,c.RGBA,c.UNSIGNED_BYTE,d),l&&o?.destroy(!0),{pixels:d,width:u,height:h,flipY:n,premultipliedAlpha:a}}destroy(){this.renderer=null}static _flipY(e,t,i){const s=t<<2,n=i>>1,a=new Uint8Array(s);for(let o=0;o=0&&o>=0&&s>=0&&n>=0)){e.length=0;return}const l=Math.ceil(2.3*Math.sqrt(a+o)),c=l*8+(s?4:0)+(n?4:0);if(e.length=c,c===0)return;if(l===0){e.length=8,e[0]=e[6]=t+s,e[1]=e[3]=i+n,e[2]=e[4]=t-s,e[5]=e[7]=i-n;return}let u=0,h=l*4+(s?2:0)+2,d=h,p=c;{const f=s+a,m=n,g=t+f,y=t-f,b=i+m;if(e[u++]=g,e[u++]=b,e[--h]=b,e[--h]=y,n){const A=i-m;e[d++]=y,e[d++]=A,e[--p]=A,e[--p]=g}}for(let f=1;f0||e&&i<=0){const s=t/2;for(let n=s+s%2;n=6){Gu(t,!1);const a=[];for(let c=0;c=0&&n>=0&&a.push(t,i,t+s,i,t+s,i+n,t,i+n)},triangulate(r,e){const t=r.points,i=e.points;if(t.length===0)return;const s=i.length/2;i.push(t[0],t[1],t[2],t[3],t[6],t[7],t[4],t[5]),e.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},$w={build(r){Lo.build(r)},triangulate(r,e){Lo.triangulate(r,e)}};var ei=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(ei||{}),Pr=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(Pr||{});const ln={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,e=20){if(!this.adaptive||!r||isNaN(r))return e;let t=Math.ceil(r/this.maxLength);return tthis.maxSegments&&(t=this.maxSegments),t}};class Hu{static curveTo(e,t,i,s,n,a){const o=a[a.length-2],l=a[a.length-1]-t,c=o-e,u=s-t,h=i-e,d=Math.abs(l*h-c*u);if(d<1e-8||n===0)return(a[a.length-2]!==e||a[a.length-1]!==t)&&a.push(e,t),null;const p=l*l+c*c,f=u*u+h*h,m=l*u+c*h,g=n*Math.sqrt(p)/d,y=n*Math.sqrt(f)/d,b=g*m/p,A=y*m/f,v=g*h+y*c,E=g*u+y*l,C=c*(y+b),M=l*(y+b),P=h*(g+A),k=u*(g+A),N=Math.atan2(M-E,C-v),H=Math.atan2(k-E,P-v);return{cx:v+e,cy:E+t,radius:n,startAngle:N,endAngle:H,anticlockwise:c*u>h*l}}static arc(e,t,i,s,n,a,o,l,c){const u=o-a,h=ln._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/So)*40),d=u/(h*2),p=d*2,f=Math.cos(d),m=Math.sin(d),g=h-1,y=g%1/g;for(let b=0;b<=g;++b){const A=b+y*b,v=d+a+p*A,E=Math.cos(v),C=-Math.sin(v);c.push((f*E+m*C)*n+i,(f*-C+m*E)*n+s)}}}class Jw{constructor(){this.reset()}begin(e,t,i){this.reset(),this.style=e,this.start=t,this.attribStart=i}end(e,t){this.attribSize=t-this.attribStart,this.size=e-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class jc{static curveLength(e,t,i,s,n,a,o,l){let c=0,u=0,h=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,A=0,v=e,E=t;for(let C=1;C<=10;++C)u=C/10,h=u*u,d=h*u,p=1-u,f=p*p,m=f*p,g=m*e+3*f*u*i+3*p*h*n+d*o,y=m*t+3*f*u*s+3*p*h*a+d*l,b=v-g,A=E-y,v=g,E=y,c+=Math.sqrt(b*b+A*A);return c}static curveTo(e,t,i,s,n,a,o){const l=o[o.length-2],c=o[o.length-1];o.length-=2;const u=ln._segmentsCount(jc.curveLength(l,c,e,t,i,s,n,a));let h=0,d=0,p=0,f=0,m=0;o.push(l,c);for(let g=1,y=0;g<=u;++g)y=g/u,h=1-y,d=h*h,p=d*h,f=y*y,m=f*y,o.push(p*l+3*d*y*e+3*h*f*i+m*n,p*c+3*d*y*t+3*h*f*s+m*a)}}function Wu(r,e,t,i,s,n,a,o){const l=r-t*s,c=e-i*s,u=r+t*n,h=e+i*n;let d,p;a?(d=i,p=-t):(d=-i,p=t);const f=l+d,m=c+p,g=u+d,y=h+p;return o.push(f,m,g,y),2}function Xr(r,e,t,i,s,n,a,o){const l=t-r,c=i-e;let u=Math.atan2(l,c),h=Math.atan2(s-r,n-e);o&&uh&&(h+=Math.PI*2);let d=u;const p=h-u,f=Math.abs(p),m=Math.sqrt(l*l+c*c),g=(15*f*Math.sqrt(m)/Math.PI>>0)+1,y=p/g;if(d+=y,o){a.push(r,e,t,i);for(let b=1,A=d;b=0&&(n.join===ei.ROUND?d+=Xr(A,v,A-M*S,v-P*S,A-k*S,v-N*S,u,!1)+4:d+=2,u.push(A-k*w,v-N*w,A+k*S,v+N*S));continue}const K=(-M+y)*(-P+v)-(-M+A)*(-P+b),ge=(-k+E)*(-N+v)-(-k+A)*(-N+C),Te=(te*ge-G*K)/ee,he=(D*K-R*ge)/ee,pe=(Te-A)*(Te-A)+(he-v)*(he-v),be=A+(Te-A)*S,oe=v+(he-v)*S,ue=A-(Te-A)*w,ve=v-(he-v)*w,x=Math.min(te*te+R*R,G*G+D*D),j=Q?S:w,V=x+j*j*m,B=pe<=V;let I=n.join;if(I===ei.MITER&&pe/m>g&&(I=ei.BEVEL),B)switch(I){case ei.MITER:{u.push(be,oe,ue,ve);break}case ei.BEVEL:{Q?u.push(be,oe,A+M*w,v+P*w,be,oe,A+k*w,v+N*w):u.push(A-M*S,v-P*S,ue,ve,A-k*S,v-N*S,ue,ve),d+=2;break}case ei.ROUND:{Q?(u.push(be,oe,A+M*w,v+P*w),d+=Xr(A,v,A+M*w,v+P*w,A+k*w,v+N*w,u,!0)+4,u.push(be,oe,A+k*w,v+N*w)):(u.push(A-M*S,v-P*S,ue,ve),d+=Xr(A,v,A-M*S,v-P*S,A-k*S,v-N*S,u,!1)+4,u.push(A-k*S,v-N*S,ue,ve));break}}else{switch(u.push(A-M*S,v-P*S,A+M*w,v+P*w),I){case ei.MITER:{Q?u.push(ue,ve,ue,ve):u.push(be,oe,be,oe),d+=2;break}case ei.ROUND:{Q?d+=Xr(A,v,A+M*w,v+P*w,A+k*w,v+N*w,u,!0)+2:d+=Xr(A,v,A-M*S,v-P*S,A-k*S,v-N*S,u,!1)+2;break}}u.push(A-k*S,v-N*S,A+k*w,v+N*w),d+=2}}y=i[(h-2)*2],b=i[(h-2)*2+1],A=i[(h-1)*2],v=i[(h-1)*2+1],M=-(b-v),P=y-A,H=Math.sqrt(M*M+P*P),M/=H,P/=H,M*=f,P*=f,u.push(A-M*S,v-P*S,A+M*w,v+P*w),l||(n.cap===Pr.ROUND?d+=Xr(A-M*(S-w)*.5,v-P*(S-w)*.5,A-M*S,v-P*S,A+M*w,v+P*w,u,!1)+2:n.cap===Pr.SQUARE&&(d+=Wu(A,v,M,P,S,w,!1,u)));const F=e.indices,z=ln.epsilon*ln.epsilon;for(let L=p;L0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(e,t=null,i=null,s=null){const n=new Oo(e,t,i,s);return this.graphicsData.push(n),this.dirty++,this}drawHole(e,t=null){if(!this.graphicsData.length)return null;const i=new Oo(e,null,null,t),s=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=s.lineStyle,s.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let e=0;e0&&(i=this.batches[this.batches.length-1],s=i.style);for(let l=this.shapeIndex;l65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&o===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=o?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(e,t){return!(!e||!t||e.texture.baseTexture!==t.texture.baseTexture||e.color+e.alpha!==t.color+t.alpha||!!e.native!=!!t.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let e=0,t=this.graphicsData.length;e65535*2)return!1;const e=this.batches;for(let t=0;t0&&(s=Ha.pop(),s||(s=new Vh,s.texArray=new Xh),this.drawCalls.push(s)),s.start=u,s.size=0,s.texArray.count=0,s.type=c),m.touched=1,m._batchEnabled=e,m._batchLocation=n,m.wrapMode=Rr.REPEAT,s.texArray.elements[s.texArray.count++]=m,n++)),s.size+=d.size,u+=d.size,o=m._batchLocation,this.addColors(t,f.color,f.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,o,d.attribSize,d.attribStart)}Me._globalBatch=e,this.packAttributes()}packAttributes(){const e=this.points,t=this.uvs,i=this.colors,s=this.textureIds,n=new ArrayBuffer(e.length*3*4),a=new Float32Array(n),o=new Uint32Array(n);let l=0;for(let c=0;c0&&e.alpha>0;return i?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._lineStyle,{visible:i},e)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const e=this.currentPath.points,t=this.currentPath.points.length;t>2&&(this.drawShape(this.currentPath),this.currentPath=new us,this.currentPath.closeStroke=!1,this.currentPath.points.push(e[t-2],e[t-1]))}else this.currentPath=new us,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(e,t){return this.startPoly(),this.currentPath.points[0]=e,this.currentPath.points[1]=t,this}lineTo(e,t){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,s=i[i.length-2],n=i[i.length-1];return(s!==e||n!==t)&&i.push(e,t),this}_initCurve(e=0,t=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[e,t]):this.moveTo(e,t)}quadraticCurveTo(e,t,i,s){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),Yc.curveTo(e,t,i,s,n),this}bezierCurveTo(e,t,i,s,n,a){return this._initCurve(),jc.curveTo(e,t,i,s,n,a,this.currentPath.points),this}arcTo(e,t,i,s,n){this._initCurve(e,t);const a=this.currentPath.points,o=Hu.curveTo(e,t,i,s,n,a);if(o){const{cx:l,cy:c,radius:u,startAngle:h,endAngle:d,anticlockwise:p}=o;this.arc(l,c,u,h,d,p)}return this}arc(e,t,i,s,n,a=!1){if(s===n)return this;if(!a&&n<=s?n+=So:a&&s<=n&&(s+=So),n-s===0)return this;const o=e+Math.cos(s)*i,l=t+Math.sin(s)*i,c=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const h=Math.abs(u[u.length-2]-o),d=Math.abs(u[u.length-1]-l);h0;return i?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._fillStyle,{visible:i},e)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(e,t,i,s){return this.drawShape(new Se(e,t,i,s))}drawRoundedRect(e,t,i,s,n){return this.drawShape(new Zo(e,t,i,s,n))}drawCircle(e,t,i){return this.drawShape(new $o(e,t,i))}drawEllipse(e,t,i,s){return this.drawShape(new Jo(e,t,i,s))}drawPolygon(...e){let t,i=!0;const s=e[0];s.points?(i=s.closeStroke,t=s.points):Array.isArray(e[0])?t=e[0]:t=e;const n=new us(t);return n.closeStroke=i,this.drawShape(n),this}drawShape(e){return this._holeMode?this._geometry.drawHole(e,this._matrix):this._geometry.drawShape(e,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const e=this._geometry.graphicsData;return e.length===1&&e[0].shape.type===Et.RECT&&!e[0].matrix&&!e[0].holes.length&&!(e[0].lineStyle.visible&&e[0].lineStyle.width)}_render(e){this.finishPoly();const t=this._geometry;t.updateBatches(),t.batchable?(this.batchDirty!==t.batchDirty&&this._populateBatches(),this._renderBatched(e)):(e.batch.flush(),this._renderDirect(e))}_populateBatches(){const e=this._geometry,t=this.blendMode,i=e.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=e.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(e.points);for(let s=0;si&&!e.autoResize&&(a=i);let o=e._buffers;o||(o=e._buffers=this.generateBuffers(e));const l=t[0]._texture.baseTexture,c=l.alphaMode>0;this.state.blendMode=Ef(e.blendMode,c),n.state.set(this.state);const u=n.gl,h=e.worldTransform.copyTo(this.tempMatrix);h.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=h.toArray(!0),this.shader.uniforms.uColor=Je.shared.setValue(e.tintRgb).premultiply(e.worldAlpha,c).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=l,this.renderer.shader.bind(this.shader);let d=!1;for(let p=0,f=0;ps&&(m=s),f>=o.length&&o.push(this._generateOneMoreBuffer(e));const g=o[f];g.uploadDynamic(t,p,m);const y=e._bufferUpdateIDs[f]||0;d=d||g._updateID0);s[a]=c,s[a+n]=c,s[a+n*2]=c,s[a+n*3]=c,a+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Em.extension={name:"particle",type:ae.RendererPlugin};me.add(Em);var sl=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(sl||{});const Va={willReadFrequently:!0},Pi=class ye{static get experimentalLetterSpacingSupported(){let e=ye._experimentalLetterSpacingSupported;if(e!==void 0){const t=de.ADAPTER.getCanvasRenderingContext2D().prototype;e=ye._experimentalLetterSpacingSupported="letterSpacing"in t||"textLetterSpacing"in t}return e}constructor(e,t,i,s,n,a,o,l,c){this.text=e,this.style=t,this.width=i,this.height=s,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=l,this.fontProperties=c}static measureText(e,t,i,s=ye._canvas){i=i??t.wordWrap;const n=t.toFontString(),a=ye.measureFont(n);a.fontSize===0&&(a.fontSize=t.fontSize,a.ascent=t.fontSize);const o=s.getContext("2d",Va);o.font=n;const l=(i?ye.wordWrap(e,t,s):e).split(/(?:\r\n|\r|\n)/),c=new Array(l.length);let u=0;for(let f=0;f0&&(s?n-=t:n+=(ye.graphemeSegmenter(e).length-1)*t),n}static wordWrap(e,t,i=ye._canvas){const s=i.getContext("2d",Va);let n=0,a="",o="";const l=Object.create(null),{letterSpacing:c,whiteSpace:u}=t,h=ye.collapseSpaces(u),d=ye.collapseNewlines(u);let p=!h;const f=t.wordWrapWidth+c,m=ye.tokenize(e);for(let g=0;gf)if(a!==""&&(o+=ye.addLine(a),a="",n=0),ye.canBreakWords(y,t.breakWords)){const A=ye.wordWrapSplit(y);for(let v=0;vf&&(o+=ye.addLine(a),p=!1,a="",n=0),a+=E,n+=P}}else{a.length>0&&(o+=ye.addLine(a),a="",n=0);const A=g===m.length-1;o+=ye.addLine(y,!A),p=!1,a="",n=0}else b+n>f&&(p=!1,o+=ye.addLine(a),a="",n=0),(a.length>0||!ye.isBreakingSpace(y)||p)&&(a+=y,n+=b)}return o+=ye.addLine(a,!1),o}static addLine(e,t=!0){return e=ye.trimRight(e),e=t?`${e} -`:e,e}static getFromCache(e,t,i,s){let n=i[e];return typeof n!="number"&&(n=ye._measureText(e,t,s)+t,i[e]=n),n}static collapseSpaces(e){return e==="normal"||e==="pre-line"}static collapseNewlines(e){return e==="normal"}static trimRight(e){if(typeof e!="string")return"";for(let t=e.length-1;t>=0;t--){const i=e[t];if(!ye.isBreakingSpace(i))break;e=e.slice(0,-1)}return e}static isNewline(e){return typeof e!="string"?!1:ye._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,t){return typeof e!="string"?!1:ye._breakingSpaces.includes(e.charCodeAt(0))}static tokenize(e){const t=[];let i="";if(typeof e!="string")return t;for(let s=0;so;--d){for(let m=0;m{if(typeof Intl?.Segmenter=="function"){const r=new Intl.Segmenter;return e=>[...r.segment(e)].map(t=>t.segment)}return r=>[...r]})(),Pi.experimentalLetterSpacing=!1,Pi._fonts={},Pi._newlines=[10,13],Pi._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let xr=Pi;const c1=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Tm=class Gn{constructor(e){this.styleID=0,this.reset(),rh(this,e,e)}clone(){const e={};return rh(e,this,Gn.defaultStyle),new Gn(e)}reset(){rh(this,Gn.defaultStyle,Gn.defaultStyle)}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(this._dropShadow=e,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(e){this._dropShadowAlpha!==e&&(this._dropShadowAlpha=e,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(e){this._dropShadowAngle!==e&&(this._dropShadowAngle=e,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(e){this._dropShadowBlur!==e&&(this._dropShadowBlur=e,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(e){const t=ih(e);this._dropShadowColor!==t&&(this._dropShadowColor=t,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(e){this._dropShadowDistance!==e&&(this._dropShadowDistance=e,this.styleID++)}get fill(){return this._fill}set fill(e){const t=ih(e);this._fill!==t&&(this._fill=t,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(e){this._fillGradientType!==e&&(this._fillGradientType=e,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(e){d1(this._fillGradientStops,e)||(this._fillGradientStops=e,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(e){this.fontFamily!==e&&(this._fontFamily=e,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(this._fontSize=e,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.styleID++)}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(e){this._lineJoin!==e&&(this._lineJoin=e,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(e){this._miterLimit!==e&&(this._miterLimit=e,this.styleID++)}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.styleID++)}get stroke(){return this._stroke}set stroke(e){const t=ih(e);this._stroke!==t&&(this._stroke=t,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(e){this._strokeThickness!==e&&(this._strokeThickness=e,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.styleID++)}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.styleID++)}toFontString(){const e=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let t=this.fontFamily;Array.isArray(this.fontFamily)||(t=this.fontFamily.split(","));for(let i=t.length-1;i>=0;i--){let s=t[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!c1.includes(s)&&(s=`"${s}"`),t[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${e} ${t.join(",")}`}};Tm.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:sl.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Fr=Tm;function ih(r){const e=Je.shared,t=i=>{const s=e.setValue(i);return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(r)?r.map(t):t(r)}function d1(r,e){if(!Array.isArray(r)||!Array.isArray(e)||r.length!==e.length)return!1;for(let t=0;t0&&f>m&&(g=(m+f)/2);const y=m+d,b=i.lineHeight*(p+1);let A=y;p+10}}function f1(r,e){let t=!1;if(r?._textures?.length){for(let i=0;i{this.queue&&this.prepareItems()},this.registerFindHook(b1),this.registerFindHook(A1),this.registerFindHook(f1),this.registerFindHook(m1),this.registerFindHook(g1),this.registerUploadHook(y1),this.registerUploadHook(v1)}upload(e){return new Promise(t=>{e&&this.add(e),this.queue.length?(this.completes.push(t),this.ticking||(this.ticking=!0,Ft.system.addOnce(this.tick,this,As.UTILITY))):t()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const e=this.queue[0];let t=!1;if(e&&!e._destroyed){for(let i=0,s=this.uploadHooks.length;i=0;t--)this.add(e.children[t]);return this}destroy(){this.ticking&&Ft.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};Mm.uploadsPerFrame=4;let mc=Mm;Object.defineProperties(de,{UPLOADS_PER_FRAME:{get(){return mc.uploadsPerFrame},set(r){Le("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),mc.uploadsPerFrame=r}}});function km(r,e){return e instanceof Me?(e._glTextures[r.CONTEXT_UID]||r.texture.bind(e),!0):!1}function w1(r,e){if(!(e instanceof ma))return!1;const{geometry:t}=e;e.finishPoly(),t.updateBatches();const{batches:i}=t;for(let s=0;s=s&&kn.x=n&&kn.y=0;t--){const i=e[t];if(!ye.isBreakingSpace(i))break;e=e.slice(0,-1)}return e}static isNewline(e){return typeof e!="string"?!1:ye._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,t){return typeof e!="string"?!1:ye._breakingSpaces.includes(e.charCodeAt(0))}static tokenize(e){const t=[];let i="";if(typeof e!="string")return t;for(let s=0;so;--d){for(let m=0;m{if(typeof Intl?.Segmenter=="function"){const r=new Intl.Segmenter;return e=>[...r.segment(e)].map(t=>t.segment)}return r=>[...r]})(),Pi.experimentalLetterSpacing=!1,Pi._fonts={},Pi._newlines=[10,13],Pi._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let _r=Pi;const c1=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Tm=class Gn{constructor(e){this.styleID=0,this.reset(),rh(this,e,e)}clone(){const e={};return rh(e,this,Gn.defaultStyle),new Gn(e)}reset(){rh(this,Gn.defaultStyle,Gn.defaultStyle)}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(this._dropShadow=e,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(e){this._dropShadowAlpha!==e&&(this._dropShadowAlpha=e,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(e){this._dropShadowAngle!==e&&(this._dropShadowAngle=e,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(e){this._dropShadowBlur!==e&&(this._dropShadowBlur=e,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(e){const t=ih(e);this._dropShadowColor!==t&&(this._dropShadowColor=t,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(e){this._dropShadowDistance!==e&&(this._dropShadowDistance=e,this.styleID++)}get fill(){return this._fill}set fill(e){const t=ih(e);this._fill!==t&&(this._fill=t,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(e){this._fillGradientType!==e&&(this._fillGradientType=e,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(e){d1(this._fillGradientStops,e)||(this._fillGradientStops=e,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(e){this.fontFamily!==e&&(this._fontFamily=e,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(this._fontSize=e,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.styleID++)}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(e){this._lineJoin!==e&&(this._lineJoin=e,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(e){this._miterLimit!==e&&(this._miterLimit=e,this.styleID++)}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.styleID++)}get stroke(){return this._stroke}set stroke(e){const t=ih(e);this._stroke!==t&&(this._stroke=t,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(e){this._strokeThickness!==e&&(this._strokeThickness=e,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.styleID++)}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.styleID++)}toFontString(){const e=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let t=this.fontFamily;Array.isArray(this.fontFamily)||(t=this.fontFamily.split(","));for(let i=t.length-1;i>=0;i--){let s=t[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!c1.includes(s)&&(s=`"${s}"`),t[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${e} ${t.join(",")}`}};Tm.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:sl.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Fr=Tm;function ih(r){const e=Je.shared,t=i=>{const s=e.setValue(i);return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(r)?r.map(t):t(r)}function d1(r,e){if(!Array.isArray(r)||!Array.isArray(e)||r.length!==e.length)return!1;for(let t=0;t0&&f>m&&(g=(m+f)/2);const y=m+d,b=i.lineHeight*(p+1);let A=y;p+10}}function f1(r,e){let t=!1;if(r?._textures?.length){for(let i=0;i{this.queue&&this.prepareItems()},this.registerFindHook(b1),this.registerFindHook(A1),this.registerFindHook(f1),this.registerFindHook(m1),this.registerFindHook(g1),this.registerUploadHook(y1),this.registerUploadHook(v1)}upload(e){return new Promise(t=>{e&&this.add(e),this.queue.length?(this.completes.push(t),this.ticking||(this.ticking=!0,Ft.system.addOnce(this.tick,this,As.UTILITY))):t()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const e=this.queue[0];let t=!1;if(e&&!e._destroyed){for(let i=0,s=this.uploadHooks.length;i=0;t--)this.add(e.children[t]);return this}destroy(){this.ticking&&Ft.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};Mm.uploadsPerFrame=4;let mc=Mm;Object.defineProperties(de,{UPLOADS_PER_FRAME:{get(){return mc.uploadsPerFrame},set(r){Le("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),mc.uploadsPerFrame=r}}});function km(r,e){return e instanceof Me?(e._glTextures[r.CONTEXT_UID]||r.texture.bind(e),!0):!1}function w1(r,e){if(!(e instanceof ma))return!1;const{geometry:t}=e;e.finishPoly(),t.updateBatches();const{batches:i}=t;for(let s=0;s=s&&kn.x=n&&kn.y1?Ot.from(E1,_1,t):Ot.from(Xu,T1,t)}render(e){const t=this.renderer,i=this.quad;let s=i.vertices;s[0]=s[6]=e._width*-e.anchor.x,s[1]=s[3]=e._height*-e.anchor.y,s[2]=s[4]=e._width*(1-e.anchor.x),s[5]=s[7]=e._height*(1-e.anchor.y);const n=e.uvRespectAnchor?e.anchor.x:0,a=e.uvRespectAnchor?e.anchor.y:0;s=i.uvs,s[0]=s[6]=-n,s[1]=s[3]=-a,s[2]=s[4]=1-n,s[5]=s[7]=1-a,i.invalidate();const o=e._texture,l=o.baseTexture,c=l.alphaMode>0,u=e.tileTransform.localTransform,h=e.uvMatrix;let d=l.isPowerOfTwo&&o.frame.width===l.width&&o.frame.height===l.height;d&&(l._glTextures[t.CONTEXT_UID]?d=l.wrapMode!==Pr.CLAMP:l.wrapMode===Pr.CLAMP&&(l.wrapMode=Pr.REPEAT));const p=d?this.simpleShader:this.shader,f=o.width,m=o.height,g=e._width,y=e._height;za.set(u.a*f/g,u.b*f/y,u.c*m/g,u.d*m/y,u.tx/g,u.ty/y),za.invert(),d?za.prepend(h.mapCoord):(p.uniforms.uMapCoord=h.mapCoord.toArray(!0),p.uniforms.uClampFrame=h.uClampFrame,p.uniforms.uClampOffset=h.uClampOffset),p.uniforms.uTransform=za.toArray(!0),p.uniforms.uColor=Je.shared.setValue(e.tint).premultiply(e.worldAlpha,c).toArray(p.uniforms.uColor),p.uniforms.translationMatrix=e.transform.worldTransform.toArray(!0),p.uniforms.uSampler=o,t.shader.bind(p),t.geometry.bind(i),this.state.blendMode=Ef(e.blendMode,c),t.state.set(this.state),t.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Pm.extension={name:"tilingSprite",type:ae.RendererPlugin};me.add(Pm);const Rm=class Hn{constructor(e,t,i=null){this.linkedSheets=[],this._texture=e instanceof Z?e:null,this.baseTexture=e instanceof Me?e:this._texture.baseTexture,this.textures={},this.animations={},this.data=t;const s=this.baseTexture.resource;this.resolution=this._updateResolution(i||(s?s.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(e=null){const{scale:t}=this.data.meta;let i=ar(e,null);return i===null&&(i=parseFloat(t??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=Hn.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(e){let t=e;const i=Hn.BATCH_SIZE;for(;t-e{this._batchIndex*Hn.BATCH_SIZE{i[s]=e}),Object.keys(e.textures).forEach(s=>{i[s]=e.textures[s]}),!t){const s=Bt.dirname(r[0]);e.linkedSheets.forEach((n,a)=>{const o=Dm([`${s}/${e.data.meta.related_multi_packs[a]}`],n,!0);Object.assign(i,o)})}return i}const M1={extension:ae.Asset,cache:{test:r=>r instanceof Ku,getCacheableAssets:(r,e)=>Dm(r,e,!1)},resolver:{test:r=>{const e=r.split("?")[0].split("."),t=e.pop(),i=e.pop();return t==="json"&&C1.includes(i)},parse:r=>{const e=r.split(".");return{resolution:parseFloat(de.RETINA_PREFIX.exec(r)?.[1]??"1"),format:e[e.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:ae.LoadParser,priority:Mi.Normal},async testParse(r,e){return Bt.extname(e.src).toLowerCase()===".json"&&!!r.frames},async parse(r,e,t){let i=Bt.dirname(e.src);i&&i.lastIndexOf("/")!==i.length-1&&(i+="/");let s=i+r.meta.image;s=cc(s,e.src);const n=(await t.load([s]))[s],a=new Ku(n.baseTexture,r,e.src);await a.parse();const o=r?.meta?.related_multi_packs;if(Array.isArray(o)){const l=[];for(const u of o){if(typeof u!="string")continue;let h=i+u;e.data?.ignoreMultiPack||(h=cc(h,e.src),l.push(t.load({src:h,data:{ignoreMultiPack:!0}})))}const c=await Promise.all(l);a.linkedSheets=c,c.forEach(u=>{u.linkedSheets=[a].concat(a.linkedSheets.filter(h=>h!==u))})}return a},unload(r){r.destroy(!0)}}};me.add(M1);class Fo{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class fo{static test(e){return typeof e=="string"&&e.startsWith("info face=")}static parse(e){const t=e.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in t){const a=t[n].match(/^[a-z]+/gm)[0],o=t[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const c in o){const u=o[c].split("="),h=u[0],d=u[1].replace(/"/gm,""),p=parseFloat(d),f=isNaN(p)?d:p;l[h]=f}i[a].push(l)}const s=new Fo;return i.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),i.char.forEach(n=>s.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),i.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class gc{static test(e){const t=e;return typeof e!="string"&&"getElementsByTagName"in e&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(e){const t=new Fo,i=e.getElementsByTagName("info"),s=e.getElementsByTagName("common"),n=e.getElementsByTagName("page"),a=e.getElementsByTagName("char"),o=e.getElementsByTagName("kerning"),l=e.getElementsByTagName("distanceField");for(let c=0;c")?gc.test(de.ADAPTER.parseXML(e)):!1}static parse(e){return gc.parse(de.ADAPTER.parseXML(e))}}const sh=[fo,gc,yc];function I1(r){for(let e=0;e=l-N*a){if(m===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${h.fontFamily}', fontSize: ${h.fontSize}px, char: '${M}')`);--C,g=null,y=null,b=null,m=0,f=0,A=0;continue}if(A=Math.max(N+P.fontProperties.descent,A),H*a+f>=d){if(f===0)throw new Error(`[BitmapFont] textureWidth ${o}px is too small (fontFamily: '${h.fontFamily}', fontSize: ${h.fontSize}px, char: '${M}')`);--C,m+=A*a,m=Math.ceil(m),f=0,A=0;continue}B1(g,y,P,f,m,a,h);const T=mo(P.text);p.char.push({id:T,page:v.length-1,x:f/a,y:m/a,width:H,height:N,xoffset:0,yoffset:0,xadvance:k-(h.dropShadow?h.dropShadowDistance:0)-(h.stroke?h.strokeThickness:0)}),f+=(H+2*n)*a,f=Math.ceil(f)}if(!i?.skipKerning)for(let C=0,M=u.length;C1?Ot.from(E1,_1,t):Ot.from(Xu,T1,t)}render(e){const t=this.renderer,i=this.quad;let s=i.vertices;s[0]=s[6]=e._width*-e.anchor.x,s[1]=s[3]=e._height*-e.anchor.y,s[2]=s[4]=e._width*(1-e.anchor.x),s[5]=s[7]=e._height*(1-e.anchor.y);const n=e.uvRespectAnchor?e.anchor.x:0,a=e.uvRespectAnchor?e.anchor.y:0;s=i.uvs,s[0]=s[6]=-n,s[1]=s[3]=-a,s[2]=s[4]=1-n,s[5]=s[7]=1-a,i.invalidate();const o=e._texture,l=o.baseTexture,c=l.alphaMode>0,u=e.tileTransform.localTransform,h=e.uvMatrix;let d=l.isPowerOfTwo&&o.frame.width===l.width&&o.frame.height===l.height;d&&(l._glTextures[t.CONTEXT_UID]?d=l.wrapMode!==Rr.CLAMP:l.wrapMode===Rr.CLAMP&&(l.wrapMode=Rr.REPEAT));const p=d?this.simpleShader:this.shader,f=o.width,m=o.height,g=e._width,y=e._height;za.set(u.a*f/g,u.b*f/y,u.c*m/g,u.d*m/y,u.tx/g,u.ty/y),za.invert(),d?za.prepend(h.mapCoord):(p.uniforms.uMapCoord=h.mapCoord.toArray(!0),p.uniforms.uClampFrame=h.uClampFrame,p.uniforms.uClampOffset=h.uClampOffset),p.uniforms.uTransform=za.toArray(!0),p.uniforms.uColor=Je.shared.setValue(e.tint).premultiply(e.worldAlpha,c).toArray(p.uniforms.uColor),p.uniforms.translationMatrix=e.transform.worldTransform.toArray(!0),p.uniforms.uSampler=o,t.shader.bind(p),t.geometry.bind(i),this.state.blendMode=Ef(e.blendMode,c),t.state.set(this.state),t.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Pm.extension={name:"tilingSprite",type:ae.RendererPlugin};me.add(Pm);const Rm=class Hn{constructor(e,t,i=null){this.linkedSheets=[],this._texture=e instanceof Z?e:null,this.baseTexture=e instanceof Me?e:this._texture.baseTexture,this.textures={},this.animations={},this.data=t;const s=this.baseTexture.resource;this.resolution=this._updateResolution(i||(s?s.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(e=null){const{scale:t}=this.data.meta;let i=or(e,null);return i===null&&(i=parseFloat(t??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=Hn.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(e){let t=e;const i=Hn.BATCH_SIZE;for(;t-e{this._batchIndex*Hn.BATCH_SIZE{i[s]=e}),Object.keys(e.textures).forEach(s=>{i[s]=e.textures[s]}),!t){const s=Bt.dirname(r[0]);e.linkedSheets.forEach((n,a)=>{const o=Dm([`${s}/${e.data.meta.related_multi_packs[a]}`],n,!0);Object.assign(i,o)})}return i}const M1={extension:ae.Asset,cache:{test:r=>r instanceof Ku,getCacheableAssets:(r,e)=>Dm(r,e,!1)},resolver:{test:r=>{const e=r.split("?")[0].split("."),t=e.pop(),i=e.pop();return t==="json"&&C1.includes(i)},parse:r=>{const e=r.split(".");return{resolution:parseFloat(de.RETINA_PREFIX.exec(r)?.[1]??"1"),format:e[e.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:ae.LoadParser,priority:Mi.Normal},async testParse(r,e){return Bt.extname(e.src).toLowerCase()===".json"&&!!r.frames},async parse(r,e,t){let i=Bt.dirname(e.src);i&&i.lastIndexOf("/")!==i.length-1&&(i+="/");let s=i+r.meta.image;s=cc(s,e.src);const n=(await t.load([s]))[s],a=new Ku(n.baseTexture,r,e.src);await a.parse();const o=r?.meta?.related_multi_packs;if(Array.isArray(o)){const l=[];for(const u of o){if(typeof u!="string")continue;let h=i+u;e.data?.ignoreMultiPack||(h=cc(h,e.src),l.push(t.load({src:h,data:{ignoreMultiPack:!0}})))}const c=await Promise.all(l);a.linkedSheets=c,c.forEach(u=>{u.linkedSheets=[a].concat(a.linkedSheets.filter(h=>h!==u))})}return a},unload(r){r.destroy(!0)}}};me.add(M1);class Fo{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class fo{static test(e){return typeof e=="string"&&e.startsWith("info face=")}static parse(e){const t=e.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in t){const a=t[n].match(/^[a-z]+/gm)[0],o=t[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const c in o){const u=o[c].split("="),h=u[0],d=u[1].replace(/"/gm,""),p=parseFloat(d),f=isNaN(p)?d:p;l[h]=f}i[a].push(l)}const s=new Fo;return i.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),i.char.forEach(n=>s.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),i.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class gc{static test(e){const t=e;return typeof e!="string"&&"getElementsByTagName"in e&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(e){const t=new Fo,i=e.getElementsByTagName("info"),s=e.getElementsByTagName("common"),n=e.getElementsByTagName("page"),a=e.getElementsByTagName("char"),o=e.getElementsByTagName("kerning"),l=e.getElementsByTagName("distanceField");for(let c=0;c")?gc.test(de.ADAPTER.parseXML(e)):!1}static parse(e){return gc.parse(de.ADAPTER.parseXML(e))}}const sh=[fo,gc,yc];function I1(r){for(let e=0;e=l-N*a){if(m===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${h.fontFamily}', fontSize: ${h.fontSize}px, char: '${M}')`);--C,g=null,y=null,b=null,m=0,f=0,A=0;continue}if(A=Math.max(N+P.fontProperties.descent,A),H*a+f>=d){if(f===0)throw new Error(`[BitmapFont] textureWidth ${o}px is too small (fontFamily: '${h.fontFamily}', fontSize: ${h.fontSize}px, char: '${M}')`);--C,m+=A*a,m=Math.ceil(m),f=0,A=0;continue}B1(g,y,P,f,m,a,h);const T=mo(P.text);p.char.push({id:T,page:v.length-1,x:f/a,y:m/a,width:H,height:N,xoffset:0,yoffset:0,xadvance:k-(h.dropShadow?h.dropShadowDistance:0)-(h.stroke?h.strokeThickness:0)}),f+=(H+2*n)*a,f=Math.ceil(f)}if(!i?.skipKerning)for(let C=0,M=u.length;C{this.dirty=!0},this,0,0),this._roundPixels=de.ROUND_PIXELS,this.dirty=!0,this._resolution=de.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){const e=Ar.available[this._fontName],t=this.fontSize,i=t/e.size,s=new Ue,n=[],a=[],o=[],l=this._text.replace(/(?:\r\n|\r)/g,` +`;const qu=[],Qu=[],$u=[],Om=class Fm extends xe{constructor(e,t={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:a,fontName:o,fontSize:l}=Object.assign({},Fm.styleDefaults,t);if(!wr.available[o])throw new Error(`Missing BitmapFont "${o}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new Je(s),this._font=void 0,this._fontName=o,this._fontSize=l,this.text=e,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=a,this._anchor=new ir(()=>{this.dirty=!0},this,0,0),this._roundPixels=de.ROUND_PIXELS,this.dirty=!0,this._resolution=de.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){const e=wr.available[this._fontName],t=this.fontSize,i=t/e.size,s=new Ue,n=[],a=[],o=[],l=this._text.replace(/(?:\r\n|\r)/g,` `)||" ",c=Lm(l),u=this._maxWidth*e.size/t,h=e.distanceFieldType==="none"?qu:Qu;let d=null,p=0,f=0,m=0,g=-1,y=0,b=0,A=0,v=0;for(let H=0;H0&&s.x>u&&(++b,en(n,1+g-b,1+H-g),H=g,g=-1,a.push(y),o.push(n.length>0?n[n.length-1].prevSpaces:0),f=Math.max(f,y),m++,s.x=0,s.y+=e.lineHeight,d=null,v=0)}const E=c[c.length-1];E!=="\r"&&E!==` -`&&(/(?:\s)/.test(E)&&(p=y),a.push(p),f=Math.max(f,p),o.push(-1));const C=[];for(let H=0;H<=m;H++){let T=0;this._align==="right"?T=f-a[H]:this._align==="center"?T=(f-a[H])/2:this._align==="justify"&&(T=o[H]<0?0:(f-a[H])/o[H]),C.push(T)}const M=n.length,P={},k=[],N=this._activePagesMeshData;h.push(...N);for(let H=0;H6*S)||T.vertices.lengtht[s.mesh.texture.baseTexture.uid]).forEach(s=>{s.mesh.texture=Z.EMPTY});for(const s in t)t[s].destroy(),delete t[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(e)}};Om.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};let Fe=Om;const L1=[".xml",".fnt"],O1={extension:{type:ae.LoadParser,priority:Mi.Normal},name:"loadBitmapFont",test(r){return L1.includes(Bt.extname(r).toLowerCase())},async testParse(r){return fo.test(r)||yc.test(r)},async parse(r,e,t){const i=fo.test(r)?fo.parse(r):yc.parse(r),{src:s}=e,{page:n}=i,a=[];for(let c=0;co[c]);return Ar.install(i,l,!0)},async load(r,e){return(await de.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};me.add(O1);const vc=class Ws extends Fr{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(e){return new Ws(Object.keys(Ws.defaultOptions).reduce((t,i)=>({...t,[i]:e[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(e=>{URL.revokeObjectURL(e.src),e.refs--,e.refs===0&&(e.fontFace&&document.fonts.delete(e.fontFace),delete Ws.availableFonts[e.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(e,t={}){const{availableFonts:i}=Ws;if(i[e]){const s=i[e];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return de.ADAPTER.fetch(e).then(s=>s.blob()).then(async s=>new Promise((n,a)=>{const o=URL.createObjectURL(s),l=new FileReader;l.onload=()=>n([o,l.result]),l.onerror=a,l.readAsDataURL(s)})).then(async([s,n])=>{const a=Object.assign({family:Bt.basename(e,Bt.extname(e)),weight:"normal",style:"normal",display:"auto",src:s,dataSrc:n,refs:1,originalUrl:e,fontFace:null},t);i[e]=a,this._fonts.push(a),this.styleID++;const o=new FontFace(a.family,`url(${a.src})`,{weight:a.weight,style:a.style,display:a.display});a.fontFace=o,await o.load(),document.fonts.add(o),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...e){const t=e.filter(i=>!this._overrides.includes(i));t.length>0&&(this._overrides.push(...t),this.styleID++)}removeOverride(...e){const t=e.filter(i=>this._overrides.includes(i));t.length>0&&(this._overrides=this._overrides.filter(i=>!t.includes(i)),this.styleID++)}toCSS(e){return[`transform: scale(${e})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((e,t)=>`${e} +`&&(/(?:\s)/.test(E)&&(p=y),a.push(p),f=Math.max(f,p),o.push(-1));const C=[];for(let H=0;H<=m;H++){let T=0;this._align==="right"?T=f-a[H]:this._align==="center"?T=(f-a[H])/2:this._align==="justify"&&(T=o[H]<0?0:(f-a[H])/o[H]),C.push(T)}const M=n.length,P={},k=[],N=this._activePagesMeshData;h.push(...N);for(let H=0;H6*S)||T.vertices.lengtht[s.mesh.texture.baseTexture.uid]).forEach(s=>{s.mesh.texture=Z.EMPTY});for(const s in t)t[s].destroy(),delete t[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(e)}};Om.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};let Fe=Om;const L1=[".xml",".fnt"],O1={extension:{type:ae.LoadParser,priority:Mi.Normal},name:"loadBitmapFont",test(r){return L1.includes(Bt.extname(r).toLowerCase())},async testParse(r){return fo.test(r)||yc.test(r)},async parse(r,e,t){const i=fo.test(r)?fo.parse(r):yc.parse(r),{src:s}=e,{page:n}=i,a=[];for(let c=0;co[c]);return wr.install(i,l,!0)},async load(r,e){return(await de.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};me.add(O1);const vc=class Ws extends Fr{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(e){return new Ws(Object.keys(Ws.defaultOptions).reduce((t,i)=>({...t,[i]:e[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(e=>{URL.revokeObjectURL(e.src),e.refs--,e.refs===0&&(e.fontFace&&document.fonts.delete(e.fontFace),delete Ws.availableFonts[e.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(e,t={}){const{availableFonts:i}=Ws;if(i[e]){const s=i[e];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return de.ADAPTER.fetch(e).then(s=>s.blob()).then(async s=>new Promise((n,a)=>{const o=URL.createObjectURL(s),l=new FileReader;l.onload=()=>n([o,l.result]),l.onerror=a,l.readAsDataURL(s)})).then(async([s,n])=>{const a=Object.assign({family:Bt.basename(e,Bt.extname(e)),weight:"normal",style:"normal",display:"auto",src:s,dataSrc:n,refs:1,originalUrl:e,fontFace:null},t);i[e]=a,this._fonts.push(a),this.styleID++;const o=new FontFace(a.family,`url(${a.src})`,{weight:a.weight,style:a.style,display:a.display});a.fontFace=o,await o.load(),document.fonts.add(o),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...e){const t=e.filter(i=>!this._overrides.includes(i));t.length>0&&(this._overrides.push(...t),this.styleID++)}removeOverride(...e){const t=e.filter(i=>this._overrides.includes(i));t.length>0&&(this._overrides=this._overrides.filter(i=>!t.includes(i)),this.styleID++)}toCSS(e){return[`transform: scale(${e})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((e,t)=>`${e} @font-face { font-family: "${t.family}"; src: url('${t.dataSrc}'); font-weight: ${t.weight}; font-style: ${t.style}; font-display: ${t.display}; - }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(e){this._stylesheet!==e&&(this._stylesheet=e,this.styleID++)}normalizeColor(e){return Array.isArray(e)&&(e=Sv(e)),typeof e=="number"?Tv(e):e}dropShadowToCSS(){let e=this.normalizeColor(this.dropShadowColor);const t=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);e.startsWith("#")&&t<1&&(e+=(t*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${e}`:`text-shadow: ${n} ${e}`}reset(){Object.assign(this,Ws.defaultOptions)}onBeforeDraw(){const{fontsDirty:e}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&e?new Promise(t=>setTimeout(t,100)):Promise.resolve()}get isSafari(){const{userAgent:e}=de.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(e)}set fillGradientStops(e){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(e){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(e){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(e){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(e){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(e){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(e){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};vc.availableFonts={},vc.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let nh=vc;const ja=class Vs extends ke{constructor(e="",t={}){super(Z.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,s=Z.from(i,{scaleMode:de.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new Se,s.trim=new Se,this.texture=s;const n="http://www.w3.org/2000/svg",a="http://www.w3.org/1999/xhtml",o=document.createElementNS(n,"svg"),l=document.createElementNS(n,"foreignObject"),c=document.createElementNS(a,"div"),u=document.createElementNS(a,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",o.appendChild(l),this.maxWidth=Vs.defaultMaxWidth,this.maxHeight=Vs.defaultMaxHeight,this._domElement=c,this._styleElement=u,this._svgRoot=o,this._foreignObject=l,this._foreignObject.appendChild(u),this._foreignObject.appendChild(c),this._image=i,this._loadImage=new Image,this._autoResolution=Vs.defaultAutoResolution,this._resolution=Vs.defaultResolution??de.RESOLUTION,this.text=e,this.style=t}measureText(e){const{text:t,style:i,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},e);Object.assign(this._domElement,{innerHTML:t,style:i.toCSS(s)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:a,height:o}=n;(a>this.maxWidth||o>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const l=Math.min(this.maxWidth,Math.ceil(a)),c=Math.min(this.maxHeight,Math.ceil(o));return this._svgRoot.setAttribute("width",l.toString()),this._svgRoot.setAttribute("height",c.toString()),t!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:this._style?.toCSS(s)}),this._styleElement.textContent=this._style?.toGlobalCSS()),{width:l+i.padding*2,height:c+i.padding*2}}async updateText(e=!0){const{style:t,_image:i,_loadImage:s}=this;if(this.localStyleID!==t.styleID&&(this.dirty=!0,this.localStyleID=t.styleID),!this.dirty&&e)return;const{width:n,height:a}=this.measureText();i.width=s.width=Math.ceil(Math.max(1,n)),i.height=s.height=Math.ceil(Math.max(1,a)),this._updateID++;const o=this._updateID;await new Promise(l=>{s.onload=async()=>{if(o/gi,"

").replace(/
/gi,"
").replace(/ /gi," ")}};ja.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},ja.defaultMaxWidth=2024,ja.defaultMaxHeight=2024,ja.defaultAutoResolution=!0;var Ut="top",ci="bottom",di="right",Gt="left",Qc="auto",ga=[Ut,ci,di,Gt],hn="start",na="end",F1="clippingParents",Nm="viewport",Bn="popper",N1="reference",Ju=ga.reduce(function(r,e){return r.concat([e+"-"+hn,e+"-"+na])},[]),Um=[].concat(ga,[Qc]).reduce(function(r,e){return r.concat([e,e+"-"+hn,e+"-"+na])},[]),U1="beforeRead",G1="read",H1="afterRead",W1="beforeMain",V1="main",z1="afterMain",j1="beforeWrite",Y1="write",X1="afterWrite",K1=[U1,G1,H1,W1,V1,z1,j1,Y1,X1];function zi(r){return r?(r.nodeName||"").toLowerCase():null}function Kt(r){if(r==null)return window;if(r.toString()!=="[object Window]"){var e=r.ownerDocument;return e&&e.defaultView||window}return r}function ws(r){var e=Kt(r).Element;return r instanceof e||r instanceof Element}function li(r){var e=Kt(r).HTMLElement;return r instanceof e||r instanceof HTMLElement}function $c(r){if(typeof ShadowRoot>"u")return!1;var e=Kt(r).ShadowRoot;return r instanceof e||r instanceof ShadowRoot}function q1(r){var e=r.state;Object.keys(e.elements).forEach(function(t){var i=e.styles[t]||{},s=e.attributes[t]||{},n=e.elements[t];!li(n)||!zi(n)||(Object.assign(n.style,i),Object.keys(s).forEach(function(a){var o=s[a];o===!1?n.removeAttribute(a):n.setAttribute(a,o===!0?"":o)}))})}function Q1(r){var e=r.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(i){var s=e.elements[i],n=e.attributes[i]||{},a=Object.keys(e.styles.hasOwnProperty(i)?e.styles[i]:t[i]),o=a.reduce(function(l,c){return l[c]="",l},{});!li(s)||!zi(s)||(Object.assign(s.style,o),Object.keys(n).forEach(function(l){s.removeAttribute(l)}))})}}const Gm={name:"applyStyles",enabled:!0,phase:"write",fn:q1,effect:Q1,requires:["computeStyles"]};function Hi(r){return r.split("-")[0]}var fs=Math.max,No=Math.min,cn=Math.round;function bc(){var r=navigator.userAgentData;return r!=null&&r.brands&&Array.isArray(r.brands)?r.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function Hm(){return!/^((?!chrome|android).)*safari/i.test(bc())}function dn(r,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var i=r.getBoundingClientRect(),s=1,n=1;e&&li(r)&&(s=r.offsetWidth>0&&cn(i.width)/r.offsetWidth||1,n=r.offsetHeight>0&&cn(i.height)/r.offsetHeight||1);var a=ws(r)?Kt(r):window,o=a.visualViewport,l=!Hm()&&t,c=(i.left+(l&&o?o.offsetLeft:0))/s,u=(i.top+(l&&o?o.offsetTop:0))/n,h=i.width/s,d=i.height/n;return{width:h,height:d,top:u,right:c+h,bottom:u+d,left:c,x:c,y:u}}function Jc(r){var e=dn(r),t=r.offsetWidth,i=r.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-i)<=1&&(i=e.height),{x:r.offsetLeft,y:r.offsetTop,width:t,height:i}}function Wm(r,e){var t=e.getRootNode&&e.getRootNode();if(r.contains(e))return!0;if(t&&$c(t)){var i=e;do{if(i&&r.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function or(r){return Kt(r).getComputedStyle(r)}function $1(r){return["table","td","th"].indexOf(zi(r))>=0}function Wr(r){return((ws(r)?r.ownerDocument:r.document)||window.document).documentElement}function nl(r){return zi(r)==="html"?r:r.assignedSlot||r.parentNode||($c(r)?r.host:null)||Wr(r)}function Zu(r){return!li(r)||or(r).position==="fixed"?null:r.offsetParent}function J1(r){var e=/firefox/i.test(bc()),t=/Trident/i.test(bc());if(t&&li(r)){var i=or(r);if(i.position==="fixed")return null}var s=nl(r);for($c(s)&&(s=s.host);li(s)&&["html","body"].indexOf(zi(s))<0;){var n=or(s);if(n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].indexOf(n.willChange)!==-1||e&&n.willChange==="filter"||e&&n.filter&&n.filter!=="none")return s;s=s.parentNode}return null}function ya(r){for(var e=Kt(r),t=Zu(r);t&&$1(t)&&or(t).position==="static";)t=Zu(t);return t&&(zi(t)==="html"||zi(t)==="body"&&or(t).position==="static")?e:t||J1(r)||e}function Zc(r){return["top","bottom"].indexOf(r)>=0?"x":"y"}function $n(r,e,t){return fs(r,No(e,t))}function Z1(r,e,t){var i=$n(r,e,t);return i>t?t:i}function Vm(){return{top:0,right:0,bottom:0,left:0}}function zm(r){return Object.assign({},Vm(),r)}function jm(r,e){return e.reduce(function(t,i){return t[i]=r,t},{})}var ex=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,zm(typeof e!="number"?e:jm(e,ga))};function tx(r){var e,t=r.state,i=r.name,s=r.options,n=t.elements.arrow,a=t.modifiersData.popperOffsets,o=Hi(t.placement),l=Zc(o),c=[Gt,di].indexOf(o)>=0,u=c?"height":"width";if(!(!n||!a)){var h=ex(s.padding,t),d=Jc(n),p=l==="y"?Ut:Gt,f=l==="y"?ci:di,m=t.rects.reference[u]+t.rects.reference[l]-a[l]-t.rects.popper[u],g=a[l]-t.rects.reference[l],y=ya(n),b=y?l==="y"?y.clientHeight||0:y.clientWidth||0:0,A=m/2-g/2,v=h[p],E=b-d[u]-h[f],C=b/2-d[u]/2+A,M=$n(v,C,E),P=l;t.modifiersData[i]=(e={},e[P]=M,e.centerOffset=M-C,e)}}function ix(r){var e=r.state,t=r.options,i=t.element,s=i===void 0?"[data-popper-arrow]":i;s!=null&&(typeof s=="string"&&(s=e.elements.popper.querySelector(s),!s)||Wm(e.elements.popper,s)&&(e.elements.arrow=s))}const rx={name:"arrow",enabled:!0,phase:"main",fn:tx,effect:ix,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function un(r){return r.split("-")[1]}var sx={top:"auto",right:"auto",bottom:"auto",left:"auto"};function nx(r,e){var t=r.x,i=r.y,s=e.devicePixelRatio||1;return{x:cn(t*s)/s||0,y:cn(i*s)/s||0}}function ep(r){var e,t=r.popper,i=r.popperRect,s=r.placement,n=r.variation,a=r.offsets,o=r.position,l=r.gpuAcceleration,c=r.adaptive,u=r.roundOffsets,h=r.isFixed,d=a.x,p=d===void 0?0:d,f=a.y,m=f===void 0?0:f,g=typeof u=="function"?u({x:p,y:m}):{x:p,y:m};p=g.x,m=g.y;var y=a.hasOwnProperty("x"),b=a.hasOwnProperty("y"),A=Gt,v=Ut,E=window;if(c){var C=ya(t),M="clientHeight",P="clientWidth";if(C===Kt(t)&&(C=Wr(t),or(C).position!=="static"&&o==="absolute"&&(M="scrollHeight",P="scrollWidth")),C=C,s===Ut||(s===Gt||s===di)&&n===na){v=ci;var k=h&&C===E&&E.visualViewport?E.visualViewport.height:C[M];m-=k-i.height,m*=l?1:-1}if(s===Gt||(s===Ut||s===ci)&&n===na){A=di;var N=h&&C===E&&E.visualViewport?E.visualViewport.width:C[P];p-=N-i.width,p*=l?1:-1}}var H=Object.assign({position:o},c&&sx),T=u===!0?nx({x:p,y:m},Kt(t)):{x:p,y:m};if(p=T.x,m=T.y,l){var S;return Object.assign({},H,(S={},S[v]=b?"0":"",S[A]=y?"0":"",S.transform=(E.devicePixelRatio||1)<=1?"translate("+p+"px, "+m+"px)":"translate3d("+p+"px, "+m+"px, 0)",S))}return Object.assign({},H,(e={},e[v]=b?m+"px":"",e[A]=y?p+"px":"",e.transform="",e))}function ax(r){var e=r.state,t=r.options,i=t.gpuAcceleration,s=i===void 0?!0:i,n=t.adaptive,a=n===void 0?!0:n,o=t.roundOffsets,l=o===void 0?!0:o,c={placement:Hi(e.placement),variation:un(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:s,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,ep(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:a,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,ep(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const ox={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:ax,data:{}};var Ya={passive:!0};function lx(r){var e=r.state,t=r.instance,i=r.options,s=i.scroll,n=s===void 0?!0:s,a=i.resize,o=a===void 0?!0:a,l=Kt(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return n&&c.forEach(function(u){u.addEventListener("scroll",t.update,Ya)}),o&&l.addEventListener("resize",t.update,Ya),function(){n&&c.forEach(function(u){u.removeEventListener("scroll",t.update,Ya)}),o&&l.removeEventListener("resize",t.update,Ya)}}const hx={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:lx,data:{}};var cx={left:"right",right:"left",bottom:"top",top:"bottom"};function go(r){return r.replace(/left|right|bottom|top/g,function(e){return cx[e]})}var dx={start:"end",end:"start"};function tp(r){return r.replace(/start|end/g,function(e){return dx[e]})}function ed(r){var e=Kt(r),t=e.pageXOffset,i=e.pageYOffset;return{scrollLeft:t,scrollTop:i}}function td(r){return dn(Wr(r)).left+ed(r).scrollLeft}function ux(r,e){var t=Kt(r),i=Wr(r),s=t.visualViewport,n=i.clientWidth,a=i.clientHeight,o=0,l=0;if(s){n=s.width,a=s.height;var c=Hm();(c||!c&&e==="fixed")&&(o=s.offsetLeft,l=s.offsetTop)}return{width:n,height:a,x:o+td(r),y:l}}function px(r){var e,t=Wr(r),i=ed(r),s=(e=r.ownerDocument)==null?void 0:e.body,n=fs(t.scrollWidth,t.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),a=fs(t.scrollHeight,t.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),o=-i.scrollLeft+td(r),l=-i.scrollTop;return or(s||t).direction==="rtl"&&(o+=fs(t.clientWidth,s?s.clientWidth:0)-n),{width:n,height:a,x:o,y:l}}function id(r){var e=or(r),t=e.overflow,i=e.overflowX,s=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+s+i)}function Ym(r){return["html","body","#document"].indexOf(zi(r))>=0?r.ownerDocument.body:li(r)&&id(r)?r:Ym(nl(r))}function Jn(r,e){var t;e===void 0&&(e=[]);var i=Ym(r),s=i===((t=r.ownerDocument)==null?void 0:t.body),n=Kt(i),a=s?[n].concat(n.visualViewport||[],id(i)?i:[]):i,o=e.concat(a);return s?o:o.concat(Jn(nl(a)))}function Ac(r){return Object.assign({},r,{left:r.x,top:r.y,right:r.x+r.width,bottom:r.y+r.height})}function fx(r,e){var t=dn(r,!1,e==="fixed");return t.top=t.top+r.clientTop,t.left=t.left+r.clientLeft,t.bottom=t.top+r.clientHeight,t.right=t.left+r.clientWidth,t.width=r.clientWidth,t.height=r.clientHeight,t.x=t.left,t.y=t.top,t}function ip(r,e,t){return e===Nm?Ac(ux(r,t)):ws(e)?fx(e,t):Ac(px(Wr(r)))}function mx(r){var e=Jn(nl(r)),t=["absolute","fixed"].indexOf(or(r).position)>=0,i=t&&li(r)?ya(r):r;return ws(i)?e.filter(function(s){return ws(s)&&Wm(s,i)&&zi(s)!=="body"}):[]}function gx(r,e,t,i){var s=e==="clippingParents"?mx(r):[].concat(e),n=[].concat(s,[t]),a=n[0],o=n.reduce(function(l,c){var u=ip(r,c,i);return l.top=fs(u.top,l.top),l.right=No(u.right,l.right),l.bottom=No(u.bottom,l.bottom),l.left=fs(u.left,l.left),l},ip(r,a,i));return o.width=o.right-o.left,o.height=o.bottom-o.top,o.x=o.left,o.y=o.top,o}function Xm(r){var e=r.reference,t=r.element,i=r.placement,s=i?Hi(i):null,n=i?un(i):null,a=e.x+e.width/2-t.width/2,o=e.y+e.height/2-t.height/2,l;switch(s){case Ut:l={x:a,y:e.y-t.height};break;case ci:l={x:a,y:e.y+e.height};break;case di:l={x:e.x+e.width,y:o};break;case Gt:l={x:e.x-t.width,y:o};break;default:l={x:e.x,y:e.y}}var c=s?Zc(s):null;if(c!=null){var u=c==="y"?"height":"width";switch(n){case hn:l[c]=l[c]-(e[u]/2-t[u]/2);break;case na:l[c]=l[c]+(e[u]/2-t[u]/2);break}}return l}function aa(r,e){e===void 0&&(e={});var t=e,i=t.placement,s=i===void 0?r.placement:i,n=t.strategy,a=n===void 0?r.strategy:n,o=t.boundary,l=o===void 0?F1:o,c=t.rootBoundary,u=c===void 0?Nm:c,h=t.elementContext,d=h===void 0?Bn:h,p=t.altBoundary,f=p===void 0?!1:p,m=t.padding,g=m===void 0?0:m,y=zm(typeof g!="number"?g:jm(g,ga)),b=d===Bn?N1:Bn,A=r.rects.popper,v=r.elements[f?b:d],E=gx(ws(v)?v:v.contextElement||Wr(r.elements.popper),l,u,a),C=dn(r.elements.reference),M=Xm({reference:C,element:A,strategy:"absolute",placement:s}),P=Ac(Object.assign({},A,M)),k=d===Bn?P:C,N={top:E.top-k.top+y.top,bottom:k.bottom-E.bottom+y.bottom,left:E.left-k.left+y.left,right:k.right-E.right+y.right},H=r.modifiersData.offset;if(d===Bn&&H){var T=H[s];Object.keys(N).forEach(function(S){var w=[di,ci].indexOf(S)>=0?1:-1,F=[Ut,ci].indexOf(S)>=0?"y":"x";N[S]+=T[F]*w})}return N}function yx(r,e){e===void 0&&(e={});var t=e,i=t.placement,s=t.boundary,n=t.rootBoundary,a=t.padding,o=t.flipVariations,l=t.allowedAutoPlacements,c=l===void 0?Um:l,u=un(i),h=u?o?Ju:Ju.filter(function(f){return un(f)===u}):ga,d=h.filter(function(f){return c.indexOf(f)>=0});d.length===0&&(d=h);var p=d.reduce(function(f,m){return f[m]=aa(r,{placement:m,boundary:s,rootBoundary:n,padding:a})[Hi(m)],f},{});return Object.keys(p).sort(function(f,m){return p[f]-p[m]})}function vx(r){if(Hi(r)===Qc)return[];var e=go(r);return[tp(r),e,tp(e)]}function bx(r){var e=r.state,t=r.options,i=r.name;if(!e.modifiersData[i]._skip){for(var s=t.mainAxis,n=s===void 0?!0:s,a=t.altAxis,o=a===void 0?!0:a,l=t.fallbackPlacements,c=t.padding,u=t.boundary,h=t.rootBoundary,d=t.altBoundary,p=t.flipVariations,f=p===void 0?!0:p,m=t.allowedAutoPlacements,g=e.options.placement,y=Hi(g),b=y===g,A=l||(b||!f?[go(g)]:vx(g)),v=[g].concat(A).reduce(function(Q,K){return Q.concat(Hi(K)===Qc?yx(e,{placement:K,boundary:u,rootBoundary:h,padding:c,flipVariations:f,allowedAutoPlacements:m}):K)},[]),E=e.rects.reference,C=e.rects.popper,M=new Map,P=!0,k=v[0],N=0;N=0,F=w?"width":"height",z=aa(e,{placement:H,boundary:u,rootBoundary:h,altBoundary:d,padding:c}),L=w?S?di:Gt:S?ci:Ut;E[F]>C[F]&&(L=go(L));var te=go(L),R=[];if(n&&R.push(z[T]<=0),o&&R.push(z[L]<=0,z[te]<=0),R.every(function(Q){return Q})){k=H,P=!1;break}M.set(H,R)}if(P)for(var G=f?3:1,D=function(K){var ge=v.find(function(Te){var he=M.get(Te);if(he)return he.slice(0,K).every(function(pe){return pe})});if(ge)return k=ge,"break"},O=G;O>0;O--){var ee=D(O);if(ee==="break")break}e.placement!==k&&(e.modifiersData[i]._skip=!0,e.placement=k,e.reset=!0)}}const Ax={name:"flip",enabled:!0,phase:"main",fn:bx,requiresIfExists:["offset"],data:{_skip:!1}};function rp(r,e,t){return t===void 0&&(t={x:0,y:0}),{top:r.top-e.height-t.y,right:r.right-e.width+t.x,bottom:r.bottom-e.height+t.y,left:r.left-e.width-t.x}}function sp(r){return[Ut,di,ci,Gt].some(function(e){return r[e]>=0})}function wx(r){var e=r.state,t=r.name,i=e.rects.reference,s=e.rects.popper,n=e.modifiersData.preventOverflow,a=aa(e,{elementContext:"reference"}),o=aa(e,{altBoundary:!0}),l=rp(a,i),c=rp(o,s,n),u=sp(l),h=sp(c);e.modifiersData[t]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:h},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":h})}const xx={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:wx};function _x(r,e,t){var i=Hi(r),s=[Gt,Ut].indexOf(i)>=0?-1:1,n=typeof t=="function"?t(Object.assign({},e,{placement:r})):t,a=n[0],o=n[1];return a=a||0,o=(o||0)*s,[Gt,di].indexOf(i)>=0?{x:o,y:a}:{x:a,y:o}}function Ex(r){var e=r.state,t=r.options,i=r.name,s=t.offset,n=s===void 0?[0,0]:s,a=Um.reduce(function(u,h){return u[h]=_x(h,e.rects,n),u},{}),o=a[e.placement],l=o.x,c=o.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[i]=a}const Tx={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Ex};function Sx(r){var e=r.state,t=r.name;e.modifiersData[t]=Xm({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const Cx={name:"popperOffsets",enabled:!0,phase:"read",fn:Sx,data:{}};function Mx(r){return r==="x"?"y":"x"}function Ix(r){var e=r.state,t=r.options,i=r.name,s=t.mainAxis,n=s===void 0?!0:s,a=t.altAxis,o=a===void 0?!1:a,l=t.boundary,c=t.rootBoundary,u=t.altBoundary,h=t.padding,d=t.tether,p=d===void 0?!0:d,f=t.tetherOffset,m=f===void 0?0:f,g=aa(e,{boundary:l,rootBoundary:c,padding:h,altBoundary:u}),y=Hi(e.placement),b=un(e.placement),A=!b,v=Zc(y),E=Mx(v),C=e.modifiersData.popperOffsets,M=e.rects.reference,P=e.rects.popper,k=typeof m=="function"?m(Object.assign({},e.rects,{placement:e.placement})):m,N=typeof k=="number"?{mainAxis:k,altAxis:k}:Object.assign({mainAxis:0,altAxis:0},k),H=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,T={x:0,y:0};if(C){if(n){var S,w=v==="y"?Ut:Gt,F=v==="y"?ci:di,z=v==="y"?"height":"width",L=C[v],te=L+g[w],R=L-g[F],G=p?-P[z]/2:0,D=b===hn?M[z]:P[z],O=b===hn?-P[z]:-M[z],ee=e.elements.arrow,Q=p&&ee?Jc(ee):{width:0,height:0},K=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:Vm(),ge=K[w],Te=K[F],he=$n(0,M[z],Q[z]),pe=A?M[z]/2-G-he-ge-N.mainAxis:D-he-ge-N.mainAxis,be=A?-M[z]/2+G+he+Te+N.mainAxis:O+he+Te+N.mainAxis,oe=e.elements.arrow&&ya(e.elements.arrow),ue=oe?v==="y"?oe.clientTop||0:oe.clientLeft||0:0,ve=(S=H?.[v])!=null?S:0,x=L+pe-ve-ue,j=L+be-ve,V=$n(p?No(te,x):te,L,p?fs(R,j):R);C[v]=V,T[v]=V-L}if(o){var B,I=v==="x"?Ut:Gt,U=v==="x"?ci:di,q=C[E],J=E==="y"?"height":"width",W=q+g[I],ie=q-g[U],le=[Ut,Gt].indexOf(y)!==-1,se=(B=H?.[E])!=null?B:0,Ae=le?W:q-M[J]-P[J]-se+N.altAxis,je=le?q+M[J]+P[J]-se-N.altAxis:ie,Pe=p&&le?Z1(Ae,q,je):$n(p?Ae:W,q,p?je:ie);C[E]=Pe,T[E]=Pe-q}e.modifiersData[i]=T}}const kx={name:"preventOverflow",enabled:!0,phase:"main",fn:Ix,requiresIfExists:["offset"]};function Bx(r){return{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}}function Px(r){return r===Kt(r)||!li(r)?ed(r):Bx(r)}function Rx(r){var e=r.getBoundingClientRect(),t=cn(e.width)/r.offsetWidth||1,i=cn(e.height)/r.offsetHeight||1;return t!==1||i!==1}function Dx(r,e,t){t===void 0&&(t=!1);var i=li(e),s=li(e)&&Rx(e),n=Wr(e),a=dn(r,s,t),o={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(i||!i&&!t)&&((zi(e)!=="body"||id(n))&&(o=Px(e)),li(e)?(l=dn(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):n&&(l.x=td(n))),{x:a.left+o.scrollLeft-l.x,y:a.top+o.scrollTop-l.y,width:a.width,height:a.height}}function Lx(r){var e=new Map,t=new Set,i=[];r.forEach(function(n){e.set(n.name,n)});function s(n){t.add(n.name);var a=[].concat(n.requires||[],n.requiresIfExists||[]);a.forEach(function(o){if(!t.has(o)){var l=e.get(o);l&&s(l)}}),i.push(n)}return r.forEach(function(n){t.has(n.name)||s(n)}),i}function Ox(r){var e=Lx(r);return K1.reduce(function(t,i){return t.concat(e.filter(function(s){return s.phase===i}))},[])}function Fx(r){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(r())})})),e}}function Nx(r){var e=r.reduce(function(t,i){var s=t[i.name];return t[i.name]=s?Object.assign({},s,i,{options:Object.assign({},s.options,i.options),data:Object.assign({},s.data,i.data)}):i,t},{});return Object.keys(e).map(function(t){return e[t]})}var np={placement:"bottom",modifiers:[],strategy:"absolute"};function ap(){for(var r=arguments.length,e=new Array(r),t=0;t-1}function Jm(r,e){return typeof r=="function"?r.apply(void 0,e):r}function op(r,e){if(e===0)return r;var t;return function(i){clearTimeout(t),t=setTimeout(function(){r(i)},e)}}function zx(r){return r.split(/\s+/).filter(Boolean)}function zs(r){return[].concat(r)}function lp(r,e){r.indexOf(e)===-1&&r.push(e)}function jx(r){return r.filter(function(e,t){return r.indexOf(e)===t})}function Yx(r){return r.split("-")[0]}function Uo(r){return[].slice.call(r)}function hp(r){return Object.keys(r).reduce(function(e,t){return r[t]!==void 0&&(e[t]=r[t]),e},{})}function Zn(){return document.createElement("div")}function al(r){return["Element","Fragment"].some(function(e){return rd(r,e)})}function Xx(r){return rd(r,"NodeList")}function Kx(r){return rd(r,"MouseEvent")}function qx(r){return!!(r&&r._tippy&&r._tippy.reference===r)}function Qx(r){return al(r)?[r]:Xx(r)?Uo(r):Array.isArray(r)?r:Uo(document.querySelectorAll(r))}function oh(r,e){r.forEach(function(t){t&&(t.style.transitionDuration=e+"ms")})}function cp(r,e){r.forEach(function(t){t&&t.setAttribute("data-state",e)})}function $x(r){var e,t=zs(r),i=t[0];return i!=null&&(e=i.ownerDocument)!=null&&e.body?i.ownerDocument:document}function Jx(r,e){var t=e.clientX,i=e.clientY;return r.every(function(s){var n=s.popperRect,a=s.popperState,o=s.props,l=o.interactiveBorder,c=Yx(a.placement),u=a.modifiersData.offset;if(!u)return!0;var h=c==="bottom"?u.top.y:0,d=c==="top"?u.bottom.y:0,p=c==="right"?u.left.x:0,f=c==="left"?u.right.x:0,m=n.top-i+h>l,g=i-n.bottom-d>l,y=n.left-t+p>l,b=t-n.right-f>l;return m||g||y||b})}function lh(r,e,t){var i=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(s){r[i](s,t)})}function dp(r,e){for(var t=e;t;){var i;if(r.contains(t))return!0;t=t.getRootNode==null||(i=t.getRootNode())==null?void 0:i.host}return!1}var Fi={isTouch:!1},up=0;function Zx(){Fi.isTouch||(Fi.isTouch=!0,window.performance&&document.addEventListener("mousemove",Zm))}function Zm(){var r=performance.now();r-up<20&&(Fi.isTouch=!1,document.removeEventListener("mousemove",Zm)),up=r}function e_(){var r=document.activeElement;if(qx(r)){var e=r._tippy;r.blur&&!e.state.isVisible&&r.blur()}}function t_(){document.addEventListener("touchstart",Zx,es),window.addEventListener("blur",e_)}var i_=typeof window<"u"&&typeof document<"u",r_=i_?!!window.msCrypto:!1,s_={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},n_={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},_i=Object.assign({appendTo:$m,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},s_,n_),a_=Object.keys(_i),o_=function(e){var t=Object.keys(e);t.forEach(function(i){_i[i]=e[i]})};function eg(r){var e=r.plugins||[],t=e.reduce(function(i,s){var n=s.name,a=s.defaultValue;if(n){var o;i[n]=r[n]!==void 0?r[n]:(o=_i[n])!=null?o:a}return i},{});return Object.assign({},r,t)}function l_(r,e){var t=e?Object.keys(eg(Object.assign({},_i,{plugins:e}))):a_,i=t.reduce(function(s,n){var a=(r.getAttribute("data-tippy-"+n)||"").trim();if(!a)return s;if(n==="content")s[n]=a;else try{s[n]=JSON.parse(a)}catch{s[n]=a}return s},{});return i}function pp(r,e){var t=Object.assign({},e,{content:Jm(e.content,[r])},e.ignoreAttributes?{}:l_(r,e.plugins));return t.aria=Object.assign({},_i.aria,t.aria),t.aria={expanded:t.aria.expanded==="auto"?e.interactive:t.aria.expanded,content:t.aria.content==="auto"?e.interactive?null:"describedby":t.aria.content},t}var h_=function(){return"innerHTML"};function wc(r,e){r[h_()]=e}function fp(r){var e=Zn();return r===!0?e.className=qm:(e.className=Qm,al(r)?e.appendChild(r):wc(e,r)),e}function mp(r,e){al(e.content)?(wc(r,""),r.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?wc(r,e.content):r.textContent=e.content)}function xc(r){var e=r.firstElementChild,t=Uo(e.children);return{box:e,content:t.find(function(i){return i.classList.contains(Km)}),arrow:t.find(function(i){return i.classList.contains(qm)||i.classList.contains(Qm)}),backdrop:t.find(function(i){return i.classList.contains(Vx)})}}function tg(r){var e=Zn(),t=Zn();t.className=Wx,t.setAttribute("data-state","hidden"),t.setAttribute("tabindex","-1");var i=Zn();i.className=Km,i.setAttribute("data-state","hidden"),mp(i,r.props),e.appendChild(t),t.appendChild(i),s(r.props,r.props);function s(n,a){var o=xc(e),l=o.box,c=o.content,u=o.arrow;a.theme?l.setAttribute("data-theme",a.theme):l.removeAttribute("data-theme"),typeof a.animation=="string"?l.setAttribute("data-animation",a.animation):l.removeAttribute("data-animation"),a.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof a.maxWidth=="number"?a.maxWidth+"px":a.maxWidth,a.role?l.setAttribute("role",a.role):l.removeAttribute("role"),(n.content!==a.content||n.allowHTML!==a.allowHTML)&&mp(c,r.props),a.arrow?u?n.arrow!==a.arrow&&(l.removeChild(u),l.appendChild(fp(a.arrow))):l.appendChild(fp(a.arrow)):u&&l.removeChild(u)}return{popper:e,onUpdate:s}}tg.$$tippy=!0;var c_=1,Xa=[],hh=[];function d_(r,e){var t=pp(r,Object.assign({},_i,eg(hp(e)))),i,s,n,a=!1,o=!1,l=!1,c=!1,u,h,d,p=[],f=op(x,t.interactiveDebounce),m,g=c_++,y=null,b=jx(t.plugins),A={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},v={id:g,reference:r,popper:Zn(),popperInstance:y,props:t,state:A,plugins:b,clearDelayTimeouts:Ae,setProps:je,setContent:Pe,show:Rt,hide:zr,hideWithInteractivity:qt,enable:le,disable:se,unmount:jr,destroy:st};if(!t.render)return v;var E=t.render(v),C=E.popper,M=E.onUpdate;C.setAttribute("data-tippy-root",""),C.id="tippy-"+v.id,v.popper=C,r._tippy=v,C._tippy=v;var P=b.map(function(X){return X.fn(v)}),k=r.hasAttribute("aria-expanded");return oe(),G(),L(),te("onCreate",[v]),t.showOnCreate&&W(),C.addEventListener("mouseenter",function(){v.props.interactive&&v.state.isVisible&&v.clearDelayTimeouts()}),C.addEventListener("mouseleave",function(){v.props.interactive&&v.props.trigger.indexOf("mouseenter")>=0&&w().addEventListener("mousemove",f)}),v;function N(){var X=v.props.touch;return Array.isArray(X)?X:[X,0]}function H(){return N()[0]==="hold"}function T(){var X;return!!((X=v.props.render)!=null&&X.$$tippy)}function S(){return m||r}function w(){var X=S().parentNode;return X?$x(X):document}function F(){return xc(C)}function z(X){return v.state.isMounted&&!v.state.isVisible||Fi.isTouch||u&&u.type==="focus"?0:ah(v.props.delay,X?0:1,_i.delay)}function L(X){X===void 0&&(X=!1),C.style.pointerEvents=v.props.interactive&&!X?"":"none",C.style.zIndex=""+v.props.zIndex}function te(X,fe,_e){if(_e===void 0&&(_e=!0),P.forEach(function(Ne){Ne[X]&&Ne[X].apply(Ne,fe)}),_e){var ze;(ze=v.props)[X].apply(ze,fe)}}function R(){var X=v.props.aria;if(X.content){var fe="aria-"+X.content,_e=C.id,ze=zs(v.props.triggerTarget||r);ze.forEach(function(Ne){var xt=Ne.getAttribute(fe);if(v.state.isVisible)Ne.setAttribute(fe,xt?xt+" "+_e:_e);else{var Dt=xt&&xt.replace(_e,"").trim();Dt?Ne.setAttribute(fe,Dt):Ne.removeAttribute(fe)}})}}function G(){if(!(k||!v.props.aria.expanded)){var X=zs(v.props.triggerTarget||r);X.forEach(function(fe){v.props.interactive?fe.setAttribute("aria-expanded",v.state.isVisible&&fe===S()?"true":"false"):fe.removeAttribute("aria-expanded")})}}function D(){w().removeEventListener("mousemove",f),Xa=Xa.filter(function(X){return X!==f})}function O(X){if(!(Fi.isTouch&&(l||X.type==="mousedown"))){var fe=X.composedPath&&X.composedPath()[0]||X.target;if(!(v.props.interactive&&dp(C,fe))){if(zs(v.props.triggerTarget||r).some(function(_e){return dp(_e,fe)})){if(Fi.isTouch||v.state.isVisible&&v.props.trigger.indexOf("click")>=0)return}else te("onClickOutside",[v,X]);v.props.hideOnClick===!0&&(v.clearDelayTimeouts(),v.hide(),o=!0,setTimeout(function(){o=!1}),v.state.isMounted||ge())}}}function ee(){l=!0}function Q(){l=!1}function K(){var X=w();X.addEventListener("mousedown",O,!0),X.addEventListener("touchend",O,es),X.addEventListener("touchstart",Q,es),X.addEventListener("touchmove",ee,es)}function ge(){var X=w();X.removeEventListener("mousedown",O,!0),X.removeEventListener("touchend",O,es),X.removeEventListener("touchstart",Q,es),X.removeEventListener("touchmove",ee,es)}function Te(X,fe){pe(X,function(){!v.state.isVisible&&C.parentNode&&C.parentNode.contains(C)&&fe()})}function he(X,fe){pe(X,fe)}function pe(X,fe){var _e=F().box;function ze(Ne){Ne.target===_e&&(lh(_e,"remove",ze),fe())}if(X===0)return fe();lh(_e,"remove",h),lh(_e,"add",ze),h=ze}function be(X,fe,_e){_e===void 0&&(_e=!1);var ze=zs(v.props.triggerTarget||r);ze.forEach(function(Ne){Ne.addEventListener(X,fe,_e),p.push({node:Ne,eventType:X,handler:fe,options:_e})})}function oe(){H()&&(be("touchstart",ve,{passive:!0}),be("touchend",j,{passive:!0})),zx(v.props.trigger).forEach(function(X){if(X!=="manual")switch(be(X,ve),X){case"mouseenter":be("mouseleave",j);break;case"focus":be(r_?"focusout":"blur",V);break;case"focusin":be("focusout",V);break}})}function ue(){p.forEach(function(X){var fe=X.node,_e=X.eventType,ze=X.handler,Ne=X.options;fe.removeEventListener(_e,ze,Ne)}),p=[]}function ve(X){var fe,_e=!1;if(!(!v.state.isEnabled||B(X)||o)){var ze=((fe=u)==null?void 0:fe.type)==="focus";u=X,m=X.currentTarget,G(),!v.state.isVisible&&Kx(X)&&Xa.forEach(function(Ne){return Ne(X)}),X.type==="click"&&(v.props.trigger.indexOf("mouseenter")<0||a)&&v.props.hideOnClick!==!1&&v.state.isVisible?_e=!0:W(X),X.type==="click"&&(a=!_e),_e&&!ze&&ie(X)}}function x(X){var fe=X.target,_e=S().contains(fe)||C.contains(fe);if(!(X.type==="mousemove"&&_e)){var ze=J().concat(C).map(function(Ne){var xt,Dt=Ne._tippy,Yi=(xt=Dt.popperInstance)==null?void 0:xt.state;return Yi?{popperRect:Ne.getBoundingClientRect(),popperState:Yi,props:t}:null}).filter(Boolean);Jx(ze,X)&&(D(),ie(X))}}function j(X){var fe=B(X)||v.props.trigger.indexOf("click")>=0&&a;if(!fe){if(v.props.interactive){v.hideWithInteractivity(X);return}ie(X)}}function V(X){v.props.trigger.indexOf("focusin")<0&&X.target!==S()||v.props.interactive&&X.relatedTarget&&C.contains(X.relatedTarget)||ie(X)}function B(X){return Fi.isTouch?H()!==X.type.indexOf("touch")>=0:!1}function I(){U();var X=v.props,fe=X.popperOptions,_e=X.placement,ze=X.offset,Ne=X.getReferenceClientRect,xt=X.moveTransition,Dt=T()?xc(C).arrow:null,Yi=Ne?{getBoundingClientRect:Ne,contextElement:Ne.contextElement||S()}:r,dr={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(va){var Cs=va.state;if(T()){var Lg=F(),bl=Lg.box;["placement","reference-hidden","escaped"].forEach(function(ba){ba==="placement"?bl.setAttribute("data-placement",Cs.placement):Cs.attributes.popper["data-popper-"+ba]?bl.setAttribute("data-"+ba,""):bl.removeAttribute("data-"+ba)}),Cs.attributes.popper={}}}},Qt=[{name:"offset",options:{offset:ze}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!xt}},dr];T()&&Dt&&Qt.push({name:"arrow",options:{element:Dt,padding:3}}),Qt.push.apply(Qt,fe?.modifiers||[]),v.popperInstance=Hx(Yi,C,Object.assign({},fe,{placement:_e,onFirstUpdate:d,modifiers:Qt}))}function U(){v.popperInstance&&(v.popperInstance.destroy(),v.popperInstance=null)}function q(){var X=v.props.appendTo,fe,_e=S();v.props.interactive&&X===$m||X==="parent"?fe=_e.parentNode:fe=Jm(X,[_e]),fe.contains(C)||fe.appendChild(C),v.state.isMounted=!0,I()}function J(){return Uo(C.querySelectorAll("[data-tippy-root]"))}function W(X){v.clearDelayTimeouts(),X&&te("onTrigger",[v,X]),K();var fe=z(!0),_e=N(),ze=_e[0],Ne=_e[1];Fi.isTouch&&ze==="hold"&&Ne&&(fe=Ne),fe?i=setTimeout(function(){v.show()},fe):v.show()}function ie(X){if(v.clearDelayTimeouts(),te("onUntrigger",[v,X]),!v.state.isVisible){ge();return}if(!(v.props.trigger.indexOf("mouseenter")>=0&&v.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(X.type)>=0&&a)){var fe=z(!1);fe?s=setTimeout(function(){v.state.isVisible&&v.hide()},fe):n=requestAnimationFrame(function(){v.hide()})}}function le(){v.state.isEnabled=!0}function se(){v.hide(),v.state.isEnabled=!1}function Ae(){clearTimeout(i),clearTimeout(s),cancelAnimationFrame(n)}function je(X){if(!v.state.isDestroyed){te("onBeforeUpdate",[v,X]),ue();var fe=v.props,_e=pp(r,Object.assign({},fe,hp(X),{ignoreAttributes:!0}));v.props=_e,oe(),fe.interactiveDebounce!==_e.interactiveDebounce&&(D(),f=op(x,_e.interactiveDebounce)),fe.triggerTarget&&!_e.triggerTarget?zs(fe.triggerTarget).forEach(function(ze){ze.removeAttribute("aria-expanded")}):_e.triggerTarget&&r.removeAttribute("aria-expanded"),G(),L(),M&&M(fe,_e),v.popperInstance&&(I(),J().forEach(function(ze){requestAnimationFrame(ze._tippy.popperInstance.forceUpdate)})),te("onAfterUpdate",[v,X])}}function Pe(X){v.setProps({content:X})}function Rt(){var X=v.state.isVisible,fe=v.state.isDestroyed,_e=!v.state.isEnabled,ze=Fi.isTouch&&!v.props.touch,Ne=ah(v.props.duration,0,_i.duration);if(!(X||fe||_e||ze)&&!S().hasAttribute("disabled")&&(te("onShow",[v],!1),v.props.onShow(v)!==!1)){if(v.state.isVisible=!0,T()&&(C.style.visibility="visible"),L(),K(),v.state.isMounted||(C.style.transition="none"),T()){var xt=F(),Dt=xt.box,Yi=xt.content;oh([Dt,Yi],0)}d=function(){var Qt;if(!(!v.state.isVisible||c)){if(c=!0,C.offsetHeight,C.style.transition=v.props.moveTransition,T()&&v.props.animation){var vl=F(),va=vl.box,Cs=vl.content;oh([va,Cs],Ne),cp([va,Cs],"visible")}R(),G(),lp(hh,v),(Qt=v.popperInstance)==null||Qt.forceUpdate(),te("onMount",[v]),v.props.animation&&T()&&he(Ne,function(){v.state.isShown=!0,te("onShown",[v])})}},q()}}function zr(){var X=!v.state.isVisible,fe=v.state.isDestroyed,_e=!v.state.isEnabled,ze=ah(v.props.duration,1,_i.duration);if(!(X||fe||_e)&&(te("onHide",[v],!1),v.props.onHide(v)!==!1)){if(v.state.isVisible=!1,v.state.isShown=!1,c=!1,a=!1,T()&&(C.style.visibility="hidden"),D(),ge(),L(!0),T()){var Ne=F(),xt=Ne.box,Dt=Ne.content;v.props.animation&&(oh([xt,Dt],ze),cp([xt,Dt],"hidden"))}R(),G(),v.props.animation?T()&&Te(ze,v.unmount):v.unmount()}}function qt(X){w().addEventListener("mousemove",f),lp(Xa,f),f(X)}function jr(){v.state.isVisible&&v.hide(),v.state.isMounted&&(U(),J().forEach(function(X){X._tippy.unmount()}),C.parentNode&&C.parentNode.removeChild(C),hh=hh.filter(function(X){return X!==v}),v.state.isMounted=!1,te("onHidden",[v]))}function st(){v.state.isDestroyed||(v.clearDelayTimeouts(),v.unmount(),ue(),delete r._tippy,v.state.isDestroyed=!0,te("onDestroy",[v]))}}function Mt(r,e){e===void 0&&(e={});var t=_i.plugins.concat(e.plugins||[]);t_();var i=Object.assign({},e,{plugins:t}),s=Qx(r),n=s.reduce(function(a,o){var l=o&&d_(o,i);return l&&a.push(l),a},[]);return al(r)?n[0]:n}Mt.defaultProps=_i;Mt.setDefaultProps=o_;Mt.currentInput=Fi;Object.assign({},Gm,{effect:function(e){var t=e.state,i={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,i.popper),t.styles=i,t.elements.arrow&&Object.assign(t.elements.arrow.style,i.arrow)}});Mt.setDefaultProps({render:tg});const u_="modulepreload",p_=function(r){return"/smeditor/"+r},gp={},ui=function(e,t,i){if(!t||t.length===0)return e();const s=document.getElementsByTagName("link");return Promise.all(t.map(n=>{if(n=p_(n),n in gp)return;gp[n]=!0;const a=n.endsWith(".css"),o=a?'[rel="stylesheet"]':"";if(!!i)for(let u=s.length-1;u>=0;u--){const h=s[u];if(h.href===n&&(!a||h.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${n}"]${o}`))return;const c=document.createElement("link");if(c.rel=a?"stylesheet":u_,a||(c.as="script",c.crossOrigin=""),c.href=n,document.head.appendChild(c),a)return new Promise((u,h)=>{c.addEventListener("load",u),c.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${n}`)))})})).then(()=>e()).catch(n=>{const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=n,window.dispatchEvent(a),!a.defaultPrevented)throw n})},Go={INVALID:["seeking position failed.","InvalidStateError"],GONE:["A requested file or directory could not be found at the time an operation was processed.","NotFoundError"],MISMATCH:["The path supplied exists, but was not an entry of requested type.","TypeMismatchError"],MOD_ERR:["The object can not be modified in this way.","InvalidModificationError"],SYNTAX:r=>[`Failed to execute 'write' on 'UnderlyingSinkBase': Invalid params passed. ${r}`,"SyntaxError"],ABORT:["The operation was aborted","AbortError"],SECURITY:["It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources.","SecurityError"],DISALLOWED:["The request is not allowed by the user agent or the platform in the current context.","NotAllowedError"]},f_=r=>typeof r=="object"&&typeof r.type<"u";async function m_(r){var e,t,i;const{FolderHandle:s,FileHandle:n}=await ui(()=>import("./memory-ba8edfa0.js"),[]),{FileSystemDirectoryHandle:a}=await ui(()=>Promise.resolve().then(()=>IE),void 0),o=(t=(e=r[0].webkitRelativePath)===null||e===void 0?void 0:e.split("/",1)[0])!==null&&t!==void 0?t:"",l=new s(o,!1);for(let c=0;c(f._entries[m]||(f._entries[m]=new s(m,!1)),f._entries[m]),l);p._entries[d]=new n(u.name,u,!1)}return new a(l)}async function g_(r){const{FileHandle:e}=await ui(()=>import("./memory-ba8edfa0.js"),[]),{FileSystemFileHandle:t}=await ui(()=>Promise.resolve().then(()=>gg),void 0);return Array.from(r).map(s=>new t(new e(s.name,s,!1)))}const ig=Object.freeze(Object.defineProperty({__proto__:null,errors:Go,isChunkObject:f_,makeDirHandleFromFileList:m_,makeFileHandlesFromFileList:g_},Symbol.toStringTag,{value:"Module"}));var hs={};/*! howler.js v2.2.4 | (c) 2013-2020, James Simpson of GoldFire Studios | MIT License | howlerjs.com */(function(r){(function(){var e=function(){this.init()};e.prototype={init:function(){var h=this||t;return h._counter=1e3,h._html5AudioPool=[],h.html5PoolSize=10,h._codecs={},h._howls=[],h._muted=!1,h._volume=1,h._canPlayEvent="canplaythrough",h._navigator=typeof window<"u"&&window.navigator?window.navigator:null,h.masterGain=null,h.noAudio=!1,h.usingWebAudio=!0,h.autoSuspend=!0,h.ctx=null,h.autoUnlock=!0,h._setup(),h},volume:function(h){var d=this||t;if(h=parseFloat(h),d.ctx||u(),h!==void 0&&h>=0&&h<=1){if(d._volume=h,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(h,t.ctx.currentTime);for(var p=0;p=0;d--)h._howls[d].unload();return h.usingWebAudio&&h.ctx&&h.ctx.close!==void 0&&(h.ctx.close(),h.ctx=null,u()),h},codecs:function(h){return(this||t)._codecs[h.replace(/^x-/,"")]},_setup:function(){var h=this||t;if(h.state=h.ctx&&h.ctx.state||"suspended",h._autoSuspend(),!h.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;d.oncanplaythrough===void 0&&(h._canPlayEvent="canplay")}catch{h.noAudio=!0}else h.noAudio=!0;try{var d=new Audio;d.muted&&(h.noAudio=!0)}catch{}return h.noAudio||h._setupCodecs(),h},_setupCodecs:function(){var h=this||t,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return h}if(!d||typeof d.canPlayType!="function")return h;var p=d.canPlayType("audio/mpeg;").replace(/^no$/,""),f=h._navigator?h._navigator.userAgent:"",m=f.match(/OPR\/(\d+)/g),g=m&&parseInt(m[0].split("/")[1],10)<33,y=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,b=f.match(/Version\/(.*?) /),A=y&&b&&parseInt(b[1],10)<15;return h._codecs={mp3:!(g||!p&&!d.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!p,opus:!!d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(d.canPlayType('audio/wav; codecs="1"')||d.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!d.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!d.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(d.canPlayType("audio/x-m4a;")||d.canPlayType("audio/m4a;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(d.canPlayType("audio/x-m4b;")||d.canPlayType("audio/m4b;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(d.canPlayType("audio/x-mp4;")||d.canPlayType("audio/mp4;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!(A||!d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!(A||!d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!d.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(d.canPlayType("audio/x-flac;")||d.canPlayType("audio/flac;")).replace(/^no$/,"")},h},_unlockAudio:function(){var h=this||t;if(!h._audioUnlocked&&h.ctx){h._audioUnlocked=!1,h.autoUnlock=!1,h._mobileUnloaded||h.ctx.sampleRate===44100||(h._mobileUnloaded=!0,h.unload()),h._scratchBuffer=h.ctx.createBuffer(1,1,22050);var d=function(p){for(;h._html5AudioPool.length0?y._seek:p._sprite[h][0]/1e3),v=Math.max(0,(p._sprite[h][0]+p._sprite[h][1])/1e3-A),E=1e3*v/Math.abs(y._rate),C=p._sprite[h][0]/1e3,M=(p._sprite[h][0]+p._sprite[h][1])/1e3;y._sprite=h,y._ended=!1;var P=function(){y._paused=!1,y._seek=A,y._start=C,y._stop=M,y._loop=!(!y._loop&&!p._sprite[h][2])};if(A>=M)return void p._ended(y);var k=y._node;if(p._webAudio){var N=function(){p._playLock=!1,P(),p._refreshBuffer(y);var w=y._muted||p._muted?0:y._volume;k.gain.setValueAtTime(w,t.ctx.currentTime),y._playStart=t.ctx.currentTime,k.bufferSource.start===void 0?y._loop?k.bufferSource.noteGrainOn(0,A,86400):k.bufferSource.noteGrainOn(0,A,v):y._loop?k.bufferSource.start(0,A,86400):k.bufferSource.start(0,A,v),E!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),E)),d||setTimeout(function(){p._emit("play",y._id),p._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?N():(p._playLock=!0,p.once("resume",N),p._clearTimer(y._id))}else{var H=function(){k.currentTime=A,k.muted=y._muted||p._muted||t._muted||k.muted,k.volume=y._volume*t.volume(),k.playbackRate=y._rate;try{var w=k.play();if(w&&typeof Promise<"u"&&(w instanceof Promise||typeof w.then=="function")?(p._playLock=!0,P(),w.then(function(){p._playLock=!1,k._unlocked=!0,d?p._loadQueue():p._emit("play",y._id)}).catch(function(){p._playLock=!1,p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),y._ended=!0,y._paused=!0})):d||(p._playLock=!1,P(),p._emit("play",y._id)),k.playbackRate=y._rate,k.paused)return void p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");h!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),E):(p._endTimers[y._id]=function(){p._ended(y),k.removeEventListener("ended",p._endTimers[y._id],!1)},k.addEventListener("ended",p._endTimers[y._id],!1))}catch(F){p._emit("playerror",y._id,F)}};k.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(k.src=p._src,k.load());var T=window&&window.ejecta||!k.readyState&&t._navigator.isCocoonJS;if(k.readyState>=3||T)H();else{p._playLock=!0,p._state="loading";var S=function(){p._state="loaded",H(),k.removeEventListener(t._canPlayEvent,S,!1)};k.addEventListener(t._canPlayEvent,S,!1),p._clearTimer(y._id)}}return y._id},pause:function(h){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(h)}}),d;for(var p=d._getSoundIds(h),f=0;f=0?d=parseInt(f[0],10):h=parseFloat(f[0]):f.length>=2&&(h=parseFloat(f[0]),d=parseInt(f[1],10));var m;if(!(h!==void 0&&h>=0&&h<=1))return m=d?p._soundById(d):p._sounds[0],m?m._volume:0;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"volume",action:function(){p.volume.apply(p,f)}}),p;d===void 0&&(p._volume=h),d=p._getSoundIds(d);for(var g=0;g0?f/v:f),C=Date.now();h._fadeTo=p,h._interval=setInterval(function(){var M=(Date.now()-C)/f;C=Date.now(),b+=A*M,b=Math.round(100*b)/100,b=A<0?Math.max(p,b):Math.min(p,b),y._webAudio?h._volume=b:y.volume(b,h._id,!0),g&&(y._volume=b),(pd&&b>=p)&&(clearInterval(h._interval),h._interval=null,h._fadeTo=null,y.volume(p,h._id),y._emit("fade",h._id))},E)},_stopFade:function(h){var d=this,p=d._soundById(h);return p&&p._interval&&(d._webAudio&&p._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(p._interval),p._interval=null,d.volume(p._fadeTo,h),p._fadeTo=null,d._emit("fade",h)),d},loop:function(){var h,d,p,f=this,m=arguments;if(m.length===0)return f._loop;if(m.length===1){if(typeof m[0]!="boolean")return!!(p=f._soundById(parseInt(m[0],10)))&&p._loop;h=m[0],f._loop=h}else m.length===2&&(h=m[0],d=parseInt(m[1],10));for(var g=f._getSoundIds(d),y=0;y=0?d=parseInt(f[0],10):h=parseFloat(f[0])}else f.length===2&&(h=parseFloat(f[0]),d=parseInt(f[1],10));var y;if(typeof h!="number")return y=p._soundById(d),y?y._rate:p._rate;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"rate",action:function(){p.rate.apply(p,f)}}),p;d===void 0&&(p._rate=h),d=p._getSoundIds(d);for(var b=0;b=0?d=parseInt(f[0],10):p._sounds.length&&(d=p._sounds[0]._id,h=parseFloat(f[0]))}else f.length===2&&(h=parseFloat(f[0]),d=parseInt(f[1],10));if(d===void 0)return 0;if(typeof h=="number"&&(p._state!=="loaded"||p._playLock))return p._queue.push({event:"seek",action:function(){p.seek.apply(p,f)}}),p;var y=p._soundById(d);if(y){if(!(typeof h=="number"&&h>=0)){if(p._webAudio){var b=p.playing(d)?t.ctx.currentTime-y._playStart:0,A=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(A+b*Math.abs(y._rate))}return y._node.currentTime}var v=p.playing(d);v&&p.pause(d,!0),y._seek=h,y._ended=!1,p._clearTimer(d),p._webAudio||!y._node||isNaN(y._node.duration)||(y._node.currentTime=h);var E=function(){v&&p.play(d,!0),p._emit("seek",d)};if(v&&!p._webAudio){var C=function(){p._playLock?setTimeout(C,0):E()};setTimeout(C,0)}else E()}return p},playing:function(h){var d=this;if(typeof h=="number"){var p=d._soundById(h);return!!p&&!p._paused}for(var f=0;f=0&&t._howls.splice(f,1);var m=!0;for(p=0;p=0){m=!1;break}return n&&m&&delete n[h._src],t.noAudio=!1,h._state="unloaded",h._sounds=[],h=null,null},on:function(h,d,p,f){var m=this,g=m["_on"+h];return typeof d=="function"&&g.push(f?{id:p,fn:d,once:f}:{id:p,fn:d}),m},off:function(h,d,p){var f=this,m=f["_on"+h],g=0;if(typeof d=="number"&&(p=d,d=null),d||p)for(g=0;g=0;g--)m[g].id&&m[g].id!==d&&h!=="load"||(setTimeout(function(y){y.call(this,d,p)}.bind(f,m[g].fn),0),m[g].once&&f.off(h,m[g].fn,m[g].id));return f._loadQueue(h),f},_loadQueue:function(h){var d=this;if(d._queue.length>0){var p=d._queue[0];p.event===h&&(d._queue.shift(),d._loadQueue()),h||p.action()}return d},_ended:function(h){var d=this,p=h._sprite;if(!d._webAudio&&h._node&&!h._node.paused&&!h._node.ended&&h._node.currentTime=0;f--){if(p<=d)return;h._sounds[f]._ended&&(h._webAudio&&h._sounds[f]._node&&h._sounds[f]._node.disconnect(0),h._sounds.splice(f,1),p--)}}},_getSoundIds:function(h){var d=this;if(h===void 0){for(var p=[],f=0;f=0;if(!h.bufferSource)return d;if(t._scratchBuffer&&h.bufferSource&&(h.bufferSource.onended=null,h.bufferSource.disconnect(0),p))try{h.bufferSource.buffer=t._scratchBuffer}catch{}return h.bufferSource=null,d},_clearSound:function(h){/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent)||(h.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var s=function(h){this._parent=h,this.init()};s.prototype={init:function(){var h=this,d=h._parent;return h._muted=d._muted,h._loop=d._loop,h._volume=d._volume,h._rate=d._rate,h._seek=0,h._paused=!0,h._ended=!0,h._sprite="__default",h._id=++t._counter,d._sounds.push(h),h.create(),h},create:function(){var h=this,d=h._parent,p=t._muted||h._muted||h._parent._muted?0:h._volume;return d._webAudio?(h._node=t.ctx.createGain===void 0?t.ctx.createGainNode():t.ctx.createGain(),h._node.gain.setValueAtTime(p,t.ctx.currentTime),h._node.paused=!0,h._node.connect(t.masterGain)):t.noAudio||(h._node=t._obtainHtml5Audio(),h._errorFn=h._errorListener.bind(h),h._node.addEventListener("error",h._errorFn,!1),h._loadFn=h._loadListener.bind(h),h._node.addEventListener(t._canPlayEvent,h._loadFn,!1),h._endFn=h._endListener.bind(h),h._node.addEventListener("ended",h._endFn,!1),h._node.src=d._src,h._node.preload=d._preload===!0?"auto":d._preload,h._node.volume=p*t.volume(),h._node.load()),h},reset:function(){var h=this,d=h._parent;return h._muted=d._muted,h._loop=d._loop,h._volume=d._volume,h._rate=d._rate,h._seek=0,h._rateSeek=0,h._paused=!0,h._ended=!0,h._sprite="__default",h._id=++t._counter,h},_errorListener:function(){var h=this;h._parent._emit("loaderror",h._id,h._node.error?h._node.error.code:0),h._node.removeEventListener("error",h._errorFn,!1)},_loadListener:function(){var h=this,d=h._parent;d._duration=Math.ceil(10*h._node.duration)/10,Object.keys(d._sprite).length===0&&(d._sprite={__default:[0,1e3*d._duration]}),d._state!=="loaded"&&(d._state="loaded",d._emit("load"),d._loadQueue()),h._node.removeEventListener(t._canPlayEvent,h._loadFn,!1)},_endListener:function(){var h=this,d=h._parent;d._duration===1/0&&(d._duration=Math.ceil(10*h._node.duration)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=1e3*d._duration),d._ended(h)),h._node.removeEventListener("ended",h._endFn,!1)}};var n={},a=function(h){var d=h._src;if(n[d])return h._duration=n[d].duration,void c(h);if(/^data:[^;]+;base64,/.test(d)){for(var p=atob(d.split(",")[1]),f=new Uint8Array(p.length),m=0;m0?(n[d._src]=m,c(d,m)):p()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(h).then(f).catch(p):t.ctx.decodeAudioData(h,f,p)},c=function(h,d){d&&!h._duration&&(h._duration=d.duration),Object.keys(h._sprite).length===0&&(h._sprite={__default:[0,1e3*h._duration]}),h._state!=="loaded"&&(h._state="loaded",h._emit("load"),h._loadQueue())},u=function(){if(t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var h=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),d=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),p=d?parseInt(d[1],10):null;if(h&&p&&p<9){var f=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!f&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=t.ctx.createGain===void 0?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};r.Howler=t,r.Howl=i,typeof si<"u"?(si.HowlerGlobal=e,si.Howler=t,si.Howl=i,si.Sound=s):typeof window<"u"&&(window.HowlerGlobal=e,window.Howler=t,window.Howl=i,window.Sound=s)})()})(hs);const y_="/smeditor/assets/assist_tick-b8aada2a.ogg",rg="/smeditor/assets/metronome_high-6fa54e52.ogg",sg="/smeditor/assets/metronome_low-4db4e760.ogg",v_="/smeditor/assets/mine-b65ce42d.ogg",ol=[".aac",".mid",".midi",".mp3",".oga",".ogg",".opus",".wav",".webm",".weba",".flac",".aiff"],ts=[".bmp",".gif",".jpeg",".jpg",".png",".tif",".tiff",".webp"];function b_(r){return r.type!="Hold"&&r.type!="Roll"}function Be(r){return r.type=="Hold"||r.type=="Roll"}class A_{cols=[];keyDown(e){this.cols[e]=(this.cols[e]??0)+1}keyUp(e){this.cols[e]=(this.cols[e]??1)-1,this.cols[e]=Math.max(this.cols[e],0)}isPressed(e){return!!this.cols[e]}getHeldCols(){return this.cols.map((e,t)=>t).filter(e=>this.isPressed(e))}reset(){this.cols=[]}}const yp=["audio.rate","chart.snap","chart.CMod","play.timingCollection"];class Ho{static general={spinnerStep:1,smoothAnimations:!0,warnBeforeExit:!0};static chart={CMod:!1,reverse:!1,mousePlacement:!1,zoom:1,speed:250,snap:1,hideWarpedArrows:!1,hideFakedArrows:!1,doSpeedChanges:!0,drawNoteFlash:!0,receptorYPos:-200,maxDrawBeats:20,maxDrawBeatsBack:10,scroll:{scrollSensitivity:1,scrollSnapEveryScroll:!navigator.userAgent.includes("Mac"),invertZoomScroll:!1,invertReverseScroll:!0},waveform:{enabled:!0,antialiasing:!0,color:6316402,opacity:.5,allowFilter:!0,filteredColor:1987134,filteredOpacity:.5,lineHeight:1,speedChanges:!0},timingEventOrder:{left:["LABELS","FAKES","TIMESIGNATURES","DELAYS","WARPS","STOPS","BPMS"],right:["SPEEDS","SCROLLS","TICKCOUNTS","COMBOS","ATTACKS","BGCHANGES","FGCHANGES"]},renderTimingEvent:{BPMS:!0,STOPS:!0,DELAYS:!0,WARPS:!0,FAKES:!0,COMBOS:!0,SPEEDS:!0,LABELS:!0,SCROLLS:!0,TIMESIGNATURES:!0,TICKCOUNTS:!0,BGCHANGES:!0,FGCHANGES:!0,ATTACKS:!0},noteskin:{"dance-single":"default","dance-double":"default","dance-couple":"default","dance-solo":"default","dance-solodouble":"default","dance-threepanel":"default","dance-threedouble":"default"}};static audio={assistTick:!1,metronome:!1,rate:1,masterVolume:1,songVolume:.2,soundEffectVolume:.5,allowFilter:!0};static play={offset:0,effectOffset:0,visualOffset:0,hideBarlines:!1,judgmentTilt:!0,timingCollection:"ITG",timingWindowScale:1,timingWindowAdd:0,defaultTimingCollection:{"dance-single":"ITG","dance-double":"ITG","dance-threepanel":"ITG","dance-threedouble":"ITG","dance-solo":"ITG","dance-solodouble":"ITG"}};static performance={antialiasing:!1,resolution:window.devicePixelRatio};static debug={showFPS:!1,showTimers:!1};static experimental={}}class _ extends Ho{static extractOptions(e,t){return Object.entries(e).reduce((i,s)=>{const n=t?t+".":"";return typeof s[1]=="object"&&!Array.isArray(s[1])?i=i.concat(this.extractOptions(s[1],n+s[0])):(s[0]=n+s[0],i.push([s[0],s[1]])),i},[])}static applyOption(e){if(typeof this.getDefaultOption(e[0])!=typeof e[1])return console.warn("Couldn't load option "+e[0]+": the value "+e[1]+" ("+typeof e[1]+") does not match the type "+typeof this.getDefaultOption(e[0]));const t=e[0].split("."),i=t.pop();let s=this;for(const n of t)if(n in s)s=s[n];else return console.warn("Couldn't load option "+e[0]+": the id doesn't exist");s[i]=e[1]}static getDefaultOption(e){const t=e.split(".");let i=Ho;for(const s of t)if(s in i)i=i[s];else return;if(!(typeof i=="object"&&!Array.isArray(i)))return i}static getOption(e){const t=e.split(".");let i=this;for(const s of t)if(s in i)i=i[s];else return;if(!(typeof i=="object"&&!Array.isArray(i)))return i}static saveOptions(){const e={};for(const t of this.extractOptions(this)){if(yp.includes(t[0]))continue;const i=this.getDefaultOption(t[0]);if(i==null){console.warn("Couldn't save option "+t[0]+": the id doesn't exist");continue}typeof i!=typeof t[1]?(console.warn("Couldn't save option "+t[0]+": the value "+t[1]+" does not match the type "+typeof this.getDefaultOption(t[0])),e[t[0]]=i):e[t[0]]=t[1]}localStorage.setItem("options",JSON.stringify(e))}static loadOptions(){const e=localStorage.getItem("options");if(!e)return;const t=JSON.parse(e);if(typeof t!="object")return console.error("Couldn't load options from storage");for(const i of Object.entries(t))yp.includes(i[0])||this.applyOption(i)}static clearSave(){localStorage.removeItem("options")}}const ng={};for(const r of Object.entries(Ho))ng[r[0]]=JSON.parse(JSON.stringify(r[1]));Object.assign(_,ng);var ti="INUMBER",xn="IOP1",_n="IOP2",En="IOP3",lr="IVAR",xs="IVARNAME",pn="IFUNCALL",ll="IFUNDEF",Ht="IEXPR",sd="IEXPREVAL",Es="IMEMBER",hl="IENDSTATEMENT",fn="IARRAY";function We(r,e){this.type=r,this.value=e??0}We.prototype.toString=function(){switch(this.type){case ti:case xn:case _n:case En:case lr:case xs:case hl:return this.value;case pn:return"CALL "+this.value;case ll:return"DEF "+this.value;case fn:return"ARRAY "+this.value;case Es:return"."+this.value;default:return"Invalid Instruction"}};function cl(r){return new We(xn,r)}function cr(r){return new We(_n,r)}function ag(r){return new We(En,r)}function _c(r,e,t,i,s){for(var n=[],a=[],o,l,c,u,h=0;h1)l=n.pop(),o=n.pop(),u=t[d.value],d=new We(ti,u(o.value,l.value)),n.push(d);else if(p===En&&n.length>2)c=n.pop(),l=n.pop(),o=n.pop(),d.value==="?"?n.push(o.value?l.value:c.value):(u=i[d.value],d=new We(ti,u(o.value,l.value,c.value)),n.push(d));else if(p===xn&&n.length>0)o=n.pop(),u=e[d.value],d=new We(ti,u(o.value)),n.push(d);else if(p===Ht){for(;n.length>0;)a.push(n.shift());a.push(new We(Ht,_c(d.value,e,t,i,s)))}else if(p===Es&&n.length>0)o=n.pop(),n.push(new We(ti,o.value[d.value]));else{for(;n.length>0;)a.push(n.shift());a.push(d)}}for(;n.length>0;)a.push(n.shift());return a}function og(r,e,t){for(var i=[],s=0;s0;)l.unshift(qi(i.pop(),t));if(o=i.pop(),o.apply&&o.call)i.push(o.apply(void 0,l));else throw new Error(o+" is not a function")}else if(p===ll)i.push(function(){for(var m=i.pop(),g=[],y=d.value;y-- >0;)g.unshift(i.pop());var b=i.pop(),A=function(){for(var v=Object.assign({},t),E=0,C=g.length;E0;)l.unshift(i.pop());i.push(l)}else throw new Error("invalid Expression")}if(i.length>1)throw new Error("invalid Expression (parity)");return i[0]===0?0:qi(i[0],t)}function w_(r,e,t){return nd(r)?r:{type:sd,value:function(i){return ns(r.value,e,i)}}}function nd(r){return r&&r.type===sd}function qi(r,e){return nd(r)?r.value(e):r}function ad(r,e){for(var t=[],i,s,n,a,o,l,c=0;c0;)o.unshift(t.pop());a=t.pop(),t.push(a+"("+o.join(", ")+")")}else if(h===ll){for(s=t.pop(),l=u.value,o=[];l-- >0;)o.unshift(t.pop());i=t.pop(),e?t.push("("+i+" = function("+o.join(", ")+") { return "+s+" })"):t.push("("+i+"("+o.join(", ")+") = "+s+")")}else if(h===Es)i=t.pop(),t.push(i+"."+u.value);else if(h===fn){for(l=u.value,o=[];l-- >0;)o.unshift(t.pop());t.push("["+o.join(", ")+"]")}else if(h===Ht)t.push("("+ad(u.value,e)+")");else if(h!==hl)throw new Error("invalid Expression")}return t.length>1&&(e?t=[t.join(",")]:t=[t.join(";")]),String(t[0])}function vp(r){return typeof r=="string"?JSON.stringify(r).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"):r}function Qs(r,e){for(var t=0;t=this.expression.length)return this.newToken(oa,"EOF");if(this.isWhitespace()||this.isComment())return this.next();if(this.isRadixInteger()||this.isNumber()||this.isOperator()||this.isString()||this.isParen()||this.isBracket()||this.isComma()||this.isSemicolon()||this.isNamedOp()||this.isConst()||this.isName())return this.current;this.parseError('Unknown character "'+this.expression.charAt(this.pos)+'"')};ct.prototype.isString=function(){var r=!1,e=this.pos,t=this.expression.charAt(e);if(t==="'"||t==='"')for(var i=this.expression.indexOf(t,e+1);i>=0&&this.pos"9")))break}if(e>r){var i=this.expression.substring(r,e);if(i in this.consts)return this.current=this.newToken(dl,this.consts[i]),this.pos+=i.length,!0}return!1};ct.prototype.isNamedOp=function(){for(var r=this.pos,e=r;e"9")))break}if(e>r){var i=this.expression.substring(r,e);if(this.isOperatorEnabled(i)&&(i in this.binaryOps||i in this.unaryOps||i in this.ternaryOps))return this.current=this.newToken(Qe,i),this.pos+=i.length,!0}return!1};ct.prototype.isName=function(){for(var r=this.pos,e=r,t=!1;e"9"))break}else t=!0}if(t){var s=this.expression.substring(r,e);return this.current=this.newToken(ld,s),this.pos+=s.length,!0}return!1};ct.prototype.isWhitespace=function(){for(var r=!1,e=this.expression.charAt(this.pos);(e===" "||e===" "||e===` + }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(e){this._stylesheet!==e&&(this._stylesheet=e,this.styleID++)}normalizeColor(e){return Array.isArray(e)&&(e=Sv(e)),typeof e=="number"?Tv(e):e}dropShadowToCSS(){let e=this.normalizeColor(this.dropShadowColor);const t=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);e.startsWith("#")&&t<1&&(e+=(t*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${e}`:`text-shadow: ${n} ${e}`}reset(){Object.assign(this,Ws.defaultOptions)}onBeforeDraw(){const{fontsDirty:e}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&e?new Promise(t=>setTimeout(t,100)):Promise.resolve()}get isSafari(){const{userAgent:e}=de.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(e)}set fillGradientStops(e){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(e){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(e){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(e){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(e){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(e){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(e){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};vc.availableFonts={},vc.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let nh=vc;const ja=class Vs extends ke{constructor(e="",t={}){super(Z.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,s=Z.from(i,{scaleMode:de.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new Se,s.trim=new Se,this.texture=s;const n="http://www.w3.org/2000/svg",a="http://www.w3.org/1999/xhtml",o=document.createElementNS(n,"svg"),l=document.createElementNS(n,"foreignObject"),c=document.createElementNS(a,"div"),u=document.createElementNS(a,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",o.appendChild(l),this.maxWidth=Vs.defaultMaxWidth,this.maxHeight=Vs.defaultMaxHeight,this._domElement=c,this._styleElement=u,this._svgRoot=o,this._foreignObject=l,this._foreignObject.appendChild(u),this._foreignObject.appendChild(c),this._image=i,this._loadImage=new Image,this._autoResolution=Vs.defaultAutoResolution,this._resolution=Vs.defaultResolution??de.RESOLUTION,this.text=e,this.style=t}measureText(e){const{text:t,style:i,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},e);Object.assign(this._domElement,{innerHTML:t,style:i.toCSS(s)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:a,height:o}=n;(a>this.maxWidth||o>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const l=Math.min(this.maxWidth,Math.ceil(a)),c=Math.min(this.maxHeight,Math.ceil(o));return this._svgRoot.setAttribute("width",l.toString()),this._svgRoot.setAttribute("height",c.toString()),t!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:this._style?.toCSS(s)}),this._styleElement.textContent=this._style?.toGlobalCSS()),{width:l+i.padding*2,height:c+i.padding*2}}async updateText(e=!0){const{style:t,_image:i,_loadImage:s}=this;if(this.localStyleID!==t.styleID&&(this.dirty=!0,this.localStyleID=t.styleID),!this.dirty&&e)return;const{width:n,height:a}=this.measureText();i.width=s.width=Math.ceil(Math.max(1,n)),i.height=s.height=Math.ceil(Math.max(1,a)),this._updateID++;const o=this._updateID;await new Promise(l=>{s.onload=async()=>{if(o/gi,"
").replace(/
/gi,"
").replace(/ /gi," ")}};ja.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},ja.defaultMaxWidth=2024,ja.defaultMaxHeight=2024,ja.defaultAutoResolution=!0;var Ut="top",ci="bottom",di="right",Gt="left",Qc="auto",ga=[Ut,ci,di,Gt],hn="start",na="end",F1="clippingParents",Nm="viewport",Bn="popper",N1="reference",Ju=ga.reduce(function(r,e){return r.concat([e+"-"+hn,e+"-"+na])},[]),Um=[].concat(ga,[Qc]).reduce(function(r,e){return r.concat([e,e+"-"+hn,e+"-"+na])},[]),U1="beforeRead",G1="read",H1="afterRead",W1="beforeMain",V1="main",z1="afterMain",j1="beforeWrite",Y1="write",X1="afterWrite",K1=[U1,G1,H1,W1,V1,z1,j1,Y1,X1];function zi(r){return r?(r.nodeName||"").toLowerCase():null}function Kt(r){if(r==null)return window;if(r.toString()!=="[object Window]"){var e=r.ownerDocument;return e&&e.defaultView||window}return r}function ws(r){var e=Kt(r).Element;return r instanceof e||r instanceof Element}function li(r){var e=Kt(r).HTMLElement;return r instanceof e||r instanceof HTMLElement}function $c(r){if(typeof ShadowRoot>"u")return!1;var e=Kt(r).ShadowRoot;return r instanceof e||r instanceof ShadowRoot}function q1(r){var e=r.state;Object.keys(e.elements).forEach(function(t){var i=e.styles[t]||{},s=e.attributes[t]||{},n=e.elements[t];!li(n)||!zi(n)||(Object.assign(n.style,i),Object.keys(s).forEach(function(a){var o=s[a];o===!1?n.removeAttribute(a):n.setAttribute(a,o===!0?"":o)}))})}function Q1(r){var e=r.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(i){var s=e.elements[i],n=e.attributes[i]||{},a=Object.keys(e.styles.hasOwnProperty(i)?e.styles[i]:t[i]),o=a.reduce(function(l,c){return l[c]="",l},{});!li(s)||!zi(s)||(Object.assign(s.style,o),Object.keys(n).forEach(function(l){s.removeAttribute(l)}))})}}const Gm={name:"applyStyles",enabled:!0,phase:"write",fn:q1,effect:Q1,requires:["computeStyles"]};function Hi(r){return r.split("-")[0]}var fs=Math.max,No=Math.min,cn=Math.round;function bc(){var r=navigator.userAgentData;return r!=null&&r.brands&&Array.isArray(r.brands)?r.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function Hm(){return!/^((?!chrome|android).)*safari/i.test(bc())}function dn(r,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var i=r.getBoundingClientRect(),s=1,n=1;e&&li(r)&&(s=r.offsetWidth>0&&cn(i.width)/r.offsetWidth||1,n=r.offsetHeight>0&&cn(i.height)/r.offsetHeight||1);var a=ws(r)?Kt(r):window,o=a.visualViewport,l=!Hm()&&t,c=(i.left+(l&&o?o.offsetLeft:0))/s,u=(i.top+(l&&o?o.offsetTop:0))/n,h=i.width/s,d=i.height/n;return{width:h,height:d,top:u,right:c+h,bottom:u+d,left:c,x:c,y:u}}function Jc(r){var e=dn(r),t=r.offsetWidth,i=r.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-i)<=1&&(i=e.height),{x:r.offsetLeft,y:r.offsetTop,width:t,height:i}}function Wm(r,e){var t=e.getRootNode&&e.getRootNode();if(r.contains(e))return!0;if(t&&$c(t)){var i=e;do{if(i&&r.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function lr(r){return Kt(r).getComputedStyle(r)}function $1(r){return["table","td","th"].indexOf(zi(r))>=0}function Wr(r){return((ws(r)?r.ownerDocument:r.document)||window.document).documentElement}function nl(r){return zi(r)==="html"?r:r.assignedSlot||r.parentNode||($c(r)?r.host:null)||Wr(r)}function Zu(r){return!li(r)||lr(r).position==="fixed"?null:r.offsetParent}function J1(r){var e=/firefox/i.test(bc()),t=/Trident/i.test(bc());if(t&&li(r)){var i=lr(r);if(i.position==="fixed")return null}var s=nl(r);for($c(s)&&(s=s.host);li(s)&&["html","body"].indexOf(zi(s))<0;){var n=lr(s);if(n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].indexOf(n.willChange)!==-1||e&&n.willChange==="filter"||e&&n.filter&&n.filter!=="none")return s;s=s.parentNode}return null}function ya(r){for(var e=Kt(r),t=Zu(r);t&&$1(t)&&lr(t).position==="static";)t=Zu(t);return t&&(zi(t)==="html"||zi(t)==="body"&&lr(t).position==="static")?e:t||J1(r)||e}function Zc(r){return["top","bottom"].indexOf(r)>=0?"x":"y"}function $n(r,e,t){return fs(r,No(e,t))}function Z1(r,e,t){var i=$n(r,e,t);return i>t?t:i}function Vm(){return{top:0,right:0,bottom:0,left:0}}function zm(r){return Object.assign({},Vm(),r)}function jm(r,e){return e.reduce(function(t,i){return t[i]=r,t},{})}var ex=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,zm(typeof e!="number"?e:jm(e,ga))};function tx(r){var e,t=r.state,i=r.name,s=r.options,n=t.elements.arrow,a=t.modifiersData.popperOffsets,o=Hi(t.placement),l=Zc(o),c=[Gt,di].indexOf(o)>=0,u=c?"height":"width";if(!(!n||!a)){var h=ex(s.padding,t),d=Jc(n),p=l==="y"?Ut:Gt,f=l==="y"?ci:di,m=t.rects.reference[u]+t.rects.reference[l]-a[l]-t.rects.popper[u],g=a[l]-t.rects.reference[l],y=ya(n),b=y?l==="y"?y.clientHeight||0:y.clientWidth||0:0,A=m/2-g/2,v=h[p],E=b-d[u]-h[f],C=b/2-d[u]/2+A,M=$n(v,C,E),P=l;t.modifiersData[i]=(e={},e[P]=M,e.centerOffset=M-C,e)}}function ix(r){var e=r.state,t=r.options,i=t.element,s=i===void 0?"[data-popper-arrow]":i;s!=null&&(typeof s=="string"&&(s=e.elements.popper.querySelector(s),!s)||Wm(e.elements.popper,s)&&(e.elements.arrow=s))}const rx={name:"arrow",enabled:!0,phase:"main",fn:tx,effect:ix,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function un(r){return r.split("-")[1]}var sx={top:"auto",right:"auto",bottom:"auto",left:"auto"};function nx(r,e){var t=r.x,i=r.y,s=e.devicePixelRatio||1;return{x:cn(t*s)/s||0,y:cn(i*s)/s||0}}function ep(r){var e,t=r.popper,i=r.popperRect,s=r.placement,n=r.variation,a=r.offsets,o=r.position,l=r.gpuAcceleration,c=r.adaptive,u=r.roundOffsets,h=r.isFixed,d=a.x,p=d===void 0?0:d,f=a.y,m=f===void 0?0:f,g=typeof u=="function"?u({x:p,y:m}):{x:p,y:m};p=g.x,m=g.y;var y=a.hasOwnProperty("x"),b=a.hasOwnProperty("y"),A=Gt,v=Ut,E=window;if(c){var C=ya(t),M="clientHeight",P="clientWidth";if(C===Kt(t)&&(C=Wr(t),lr(C).position!=="static"&&o==="absolute"&&(M="scrollHeight",P="scrollWidth")),C=C,s===Ut||(s===Gt||s===di)&&n===na){v=ci;var k=h&&C===E&&E.visualViewport?E.visualViewport.height:C[M];m-=k-i.height,m*=l?1:-1}if(s===Gt||(s===Ut||s===ci)&&n===na){A=di;var N=h&&C===E&&E.visualViewport?E.visualViewport.width:C[P];p-=N-i.width,p*=l?1:-1}}var H=Object.assign({position:o},c&&sx),T=u===!0?nx({x:p,y:m},Kt(t)):{x:p,y:m};if(p=T.x,m=T.y,l){var S;return Object.assign({},H,(S={},S[v]=b?"0":"",S[A]=y?"0":"",S.transform=(E.devicePixelRatio||1)<=1?"translate("+p+"px, "+m+"px)":"translate3d("+p+"px, "+m+"px, 0)",S))}return Object.assign({},H,(e={},e[v]=b?m+"px":"",e[A]=y?p+"px":"",e.transform="",e))}function ax(r){var e=r.state,t=r.options,i=t.gpuAcceleration,s=i===void 0?!0:i,n=t.adaptive,a=n===void 0?!0:n,o=t.roundOffsets,l=o===void 0?!0:o,c={placement:Hi(e.placement),variation:un(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:s,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,ep(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:a,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,ep(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const ox={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:ax,data:{}};var Ya={passive:!0};function lx(r){var e=r.state,t=r.instance,i=r.options,s=i.scroll,n=s===void 0?!0:s,a=i.resize,o=a===void 0?!0:a,l=Kt(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return n&&c.forEach(function(u){u.addEventListener("scroll",t.update,Ya)}),o&&l.addEventListener("resize",t.update,Ya),function(){n&&c.forEach(function(u){u.removeEventListener("scroll",t.update,Ya)}),o&&l.removeEventListener("resize",t.update,Ya)}}const hx={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:lx,data:{}};var cx={left:"right",right:"left",bottom:"top",top:"bottom"};function go(r){return r.replace(/left|right|bottom|top/g,function(e){return cx[e]})}var dx={start:"end",end:"start"};function tp(r){return r.replace(/start|end/g,function(e){return dx[e]})}function ed(r){var e=Kt(r),t=e.pageXOffset,i=e.pageYOffset;return{scrollLeft:t,scrollTop:i}}function td(r){return dn(Wr(r)).left+ed(r).scrollLeft}function ux(r,e){var t=Kt(r),i=Wr(r),s=t.visualViewport,n=i.clientWidth,a=i.clientHeight,o=0,l=0;if(s){n=s.width,a=s.height;var c=Hm();(c||!c&&e==="fixed")&&(o=s.offsetLeft,l=s.offsetTop)}return{width:n,height:a,x:o+td(r),y:l}}function px(r){var e,t=Wr(r),i=ed(r),s=(e=r.ownerDocument)==null?void 0:e.body,n=fs(t.scrollWidth,t.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),a=fs(t.scrollHeight,t.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),o=-i.scrollLeft+td(r),l=-i.scrollTop;return lr(s||t).direction==="rtl"&&(o+=fs(t.clientWidth,s?s.clientWidth:0)-n),{width:n,height:a,x:o,y:l}}function id(r){var e=lr(r),t=e.overflow,i=e.overflowX,s=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+s+i)}function Ym(r){return["html","body","#document"].indexOf(zi(r))>=0?r.ownerDocument.body:li(r)&&id(r)?r:Ym(nl(r))}function Jn(r,e){var t;e===void 0&&(e=[]);var i=Ym(r),s=i===((t=r.ownerDocument)==null?void 0:t.body),n=Kt(i),a=s?[n].concat(n.visualViewport||[],id(i)?i:[]):i,o=e.concat(a);return s?o:o.concat(Jn(nl(a)))}function Ac(r){return Object.assign({},r,{left:r.x,top:r.y,right:r.x+r.width,bottom:r.y+r.height})}function fx(r,e){var t=dn(r,!1,e==="fixed");return t.top=t.top+r.clientTop,t.left=t.left+r.clientLeft,t.bottom=t.top+r.clientHeight,t.right=t.left+r.clientWidth,t.width=r.clientWidth,t.height=r.clientHeight,t.x=t.left,t.y=t.top,t}function ip(r,e,t){return e===Nm?Ac(ux(r,t)):ws(e)?fx(e,t):Ac(px(Wr(r)))}function mx(r){var e=Jn(nl(r)),t=["absolute","fixed"].indexOf(lr(r).position)>=0,i=t&&li(r)?ya(r):r;return ws(i)?e.filter(function(s){return ws(s)&&Wm(s,i)&&zi(s)!=="body"}):[]}function gx(r,e,t,i){var s=e==="clippingParents"?mx(r):[].concat(e),n=[].concat(s,[t]),a=n[0],o=n.reduce(function(l,c){var u=ip(r,c,i);return l.top=fs(u.top,l.top),l.right=No(u.right,l.right),l.bottom=No(u.bottom,l.bottom),l.left=fs(u.left,l.left),l},ip(r,a,i));return o.width=o.right-o.left,o.height=o.bottom-o.top,o.x=o.left,o.y=o.top,o}function Xm(r){var e=r.reference,t=r.element,i=r.placement,s=i?Hi(i):null,n=i?un(i):null,a=e.x+e.width/2-t.width/2,o=e.y+e.height/2-t.height/2,l;switch(s){case Ut:l={x:a,y:e.y-t.height};break;case ci:l={x:a,y:e.y+e.height};break;case di:l={x:e.x+e.width,y:o};break;case Gt:l={x:e.x-t.width,y:o};break;default:l={x:e.x,y:e.y}}var c=s?Zc(s):null;if(c!=null){var u=c==="y"?"height":"width";switch(n){case hn:l[c]=l[c]-(e[u]/2-t[u]/2);break;case na:l[c]=l[c]+(e[u]/2-t[u]/2);break}}return l}function aa(r,e){e===void 0&&(e={});var t=e,i=t.placement,s=i===void 0?r.placement:i,n=t.strategy,a=n===void 0?r.strategy:n,o=t.boundary,l=o===void 0?F1:o,c=t.rootBoundary,u=c===void 0?Nm:c,h=t.elementContext,d=h===void 0?Bn:h,p=t.altBoundary,f=p===void 0?!1:p,m=t.padding,g=m===void 0?0:m,y=zm(typeof g!="number"?g:jm(g,ga)),b=d===Bn?N1:Bn,A=r.rects.popper,v=r.elements[f?b:d],E=gx(ws(v)?v:v.contextElement||Wr(r.elements.popper),l,u,a),C=dn(r.elements.reference),M=Xm({reference:C,element:A,strategy:"absolute",placement:s}),P=Ac(Object.assign({},A,M)),k=d===Bn?P:C,N={top:E.top-k.top+y.top,bottom:k.bottom-E.bottom+y.bottom,left:E.left-k.left+y.left,right:k.right-E.right+y.right},H=r.modifiersData.offset;if(d===Bn&&H){var T=H[s];Object.keys(N).forEach(function(S){var w=[di,ci].indexOf(S)>=0?1:-1,F=[Ut,ci].indexOf(S)>=0?"y":"x";N[S]+=T[F]*w})}return N}function yx(r,e){e===void 0&&(e={});var t=e,i=t.placement,s=t.boundary,n=t.rootBoundary,a=t.padding,o=t.flipVariations,l=t.allowedAutoPlacements,c=l===void 0?Um:l,u=un(i),h=u?o?Ju:Ju.filter(function(f){return un(f)===u}):ga,d=h.filter(function(f){return c.indexOf(f)>=0});d.length===0&&(d=h);var p=d.reduce(function(f,m){return f[m]=aa(r,{placement:m,boundary:s,rootBoundary:n,padding:a})[Hi(m)],f},{});return Object.keys(p).sort(function(f,m){return p[f]-p[m]})}function vx(r){if(Hi(r)===Qc)return[];var e=go(r);return[tp(r),e,tp(e)]}function bx(r){var e=r.state,t=r.options,i=r.name;if(!e.modifiersData[i]._skip){for(var s=t.mainAxis,n=s===void 0?!0:s,a=t.altAxis,o=a===void 0?!0:a,l=t.fallbackPlacements,c=t.padding,u=t.boundary,h=t.rootBoundary,d=t.altBoundary,p=t.flipVariations,f=p===void 0?!0:p,m=t.allowedAutoPlacements,g=e.options.placement,y=Hi(g),b=y===g,A=l||(b||!f?[go(g)]:vx(g)),v=[g].concat(A).reduce(function(Q,K){return Q.concat(Hi(K)===Qc?yx(e,{placement:K,boundary:u,rootBoundary:h,padding:c,flipVariations:f,allowedAutoPlacements:m}):K)},[]),E=e.rects.reference,C=e.rects.popper,M=new Map,P=!0,k=v[0],N=0;N=0,F=w?"width":"height",z=aa(e,{placement:H,boundary:u,rootBoundary:h,altBoundary:d,padding:c}),L=w?S?di:Gt:S?ci:Ut;E[F]>C[F]&&(L=go(L));var te=go(L),R=[];if(n&&R.push(z[T]<=0),o&&R.push(z[L]<=0,z[te]<=0),R.every(function(Q){return Q})){k=H,P=!1;break}M.set(H,R)}if(P)for(var G=f?3:1,D=function(K){var ge=v.find(function(Te){var he=M.get(Te);if(he)return he.slice(0,K).every(function(pe){return pe})});if(ge)return k=ge,"break"},O=G;O>0;O--){var ee=D(O);if(ee==="break")break}e.placement!==k&&(e.modifiersData[i]._skip=!0,e.placement=k,e.reset=!0)}}const Ax={name:"flip",enabled:!0,phase:"main",fn:bx,requiresIfExists:["offset"],data:{_skip:!1}};function rp(r,e,t){return t===void 0&&(t={x:0,y:0}),{top:r.top-e.height-t.y,right:r.right-e.width+t.x,bottom:r.bottom-e.height+t.y,left:r.left-e.width-t.x}}function sp(r){return[Ut,di,ci,Gt].some(function(e){return r[e]>=0})}function wx(r){var e=r.state,t=r.name,i=e.rects.reference,s=e.rects.popper,n=e.modifiersData.preventOverflow,a=aa(e,{elementContext:"reference"}),o=aa(e,{altBoundary:!0}),l=rp(a,i),c=rp(o,s,n),u=sp(l),h=sp(c);e.modifiersData[t]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:h},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":h})}const xx={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:wx};function _x(r,e,t){var i=Hi(r),s=[Gt,Ut].indexOf(i)>=0?-1:1,n=typeof t=="function"?t(Object.assign({},e,{placement:r})):t,a=n[0],o=n[1];return a=a||0,o=(o||0)*s,[Gt,di].indexOf(i)>=0?{x:o,y:a}:{x:a,y:o}}function Ex(r){var e=r.state,t=r.options,i=r.name,s=t.offset,n=s===void 0?[0,0]:s,a=Um.reduce(function(u,h){return u[h]=_x(h,e.rects,n),u},{}),o=a[e.placement],l=o.x,c=o.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[i]=a}const Tx={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Ex};function Sx(r){var e=r.state,t=r.name;e.modifiersData[t]=Xm({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const Cx={name:"popperOffsets",enabled:!0,phase:"read",fn:Sx,data:{}};function Mx(r){return r==="x"?"y":"x"}function Ix(r){var e=r.state,t=r.options,i=r.name,s=t.mainAxis,n=s===void 0?!0:s,a=t.altAxis,o=a===void 0?!1:a,l=t.boundary,c=t.rootBoundary,u=t.altBoundary,h=t.padding,d=t.tether,p=d===void 0?!0:d,f=t.tetherOffset,m=f===void 0?0:f,g=aa(e,{boundary:l,rootBoundary:c,padding:h,altBoundary:u}),y=Hi(e.placement),b=un(e.placement),A=!b,v=Zc(y),E=Mx(v),C=e.modifiersData.popperOffsets,M=e.rects.reference,P=e.rects.popper,k=typeof m=="function"?m(Object.assign({},e.rects,{placement:e.placement})):m,N=typeof k=="number"?{mainAxis:k,altAxis:k}:Object.assign({mainAxis:0,altAxis:0},k),H=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,T={x:0,y:0};if(C){if(n){var S,w=v==="y"?Ut:Gt,F=v==="y"?ci:di,z=v==="y"?"height":"width",L=C[v],te=L+g[w],R=L-g[F],G=p?-P[z]/2:0,D=b===hn?M[z]:P[z],O=b===hn?-P[z]:-M[z],ee=e.elements.arrow,Q=p&&ee?Jc(ee):{width:0,height:0},K=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:Vm(),ge=K[w],Te=K[F],he=$n(0,M[z],Q[z]),pe=A?M[z]/2-G-he-ge-N.mainAxis:D-he-ge-N.mainAxis,be=A?-M[z]/2+G+he+Te+N.mainAxis:O+he+Te+N.mainAxis,oe=e.elements.arrow&&ya(e.elements.arrow),ue=oe?v==="y"?oe.clientTop||0:oe.clientLeft||0:0,ve=(S=H?.[v])!=null?S:0,x=L+pe-ve-ue,j=L+be-ve,V=$n(p?No(te,x):te,L,p?fs(R,j):R);C[v]=V,T[v]=V-L}if(o){var B,I=v==="x"?Ut:Gt,U=v==="x"?ci:di,q=C[E],J=E==="y"?"height":"width",W=q+g[I],ie=q-g[U],le=[Ut,Gt].indexOf(y)!==-1,se=(B=H?.[E])!=null?B:0,Ae=le?W:q-M[J]-P[J]-se+N.altAxis,je=le?q+M[J]+P[J]-se-N.altAxis:ie,Pe=p&&le?Z1(Ae,q,je):$n(p?Ae:W,q,p?je:ie);C[E]=Pe,T[E]=Pe-q}e.modifiersData[i]=T}}const kx={name:"preventOverflow",enabled:!0,phase:"main",fn:Ix,requiresIfExists:["offset"]};function Bx(r){return{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}}function Px(r){return r===Kt(r)||!li(r)?ed(r):Bx(r)}function Rx(r){var e=r.getBoundingClientRect(),t=cn(e.width)/r.offsetWidth||1,i=cn(e.height)/r.offsetHeight||1;return t!==1||i!==1}function Dx(r,e,t){t===void 0&&(t=!1);var i=li(e),s=li(e)&&Rx(e),n=Wr(e),a=dn(r,s,t),o={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(i||!i&&!t)&&((zi(e)!=="body"||id(n))&&(o=Px(e)),li(e)?(l=dn(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):n&&(l.x=td(n))),{x:a.left+o.scrollLeft-l.x,y:a.top+o.scrollTop-l.y,width:a.width,height:a.height}}function Lx(r){var e=new Map,t=new Set,i=[];r.forEach(function(n){e.set(n.name,n)});function s(n){t.add(n.name);var a=[].concat(n.requires||[],n.requiresIfExists||[]);a.forEach(function(o){if(!t.has(o)){var l=e.get(o);l&&s(l)}}),i.push(n)}return r.forEach(function(n){t.has(n.name)||s(n)}),i}function Ox(r){var e=Lx(r);return K1.reduce(function(t,i){return t.concat(e.filter(function(s){return s.phase===i}))},[])}function Fx(r){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(r())})})),e}}function Nx(r){var e=r.reduce(function(t,i){var s=t[i.name];return t[i.name]=s?Object.assign({},s,i,{options:Object.assign({},s.options,i.options),data:Object.assign({},s.data,i.data)}):i,t},{});return Object.keys(e).map(function(t){return e[t]})}var np={placement:"bottom",modifiers:[],strategy:"absolute"};function ap(){for(var r=arguments.length,e=new Array(r),t=0;t-1}function Jm(r,e){return typeof r=="function"?r.apply(void 0,e):r}function op(r,e){if(e===0)return r;var t;return function(i){clearTimeout(t),t=setTimeout(function(){r(i)},e)}}function zx(r){return r.split(/\s+/).filter(Boolean)}function zs(r){return[].concat(r)}function lp(r,e){r.indexOf(e)===-1&&r.push(e)}function jx(r){return r.filter(function(e,t){return r.indexOf(e)===t})}function Yx(r){return r.split("-")[0]}function Uo(r){return[].slice.call(r)}function hp(r){return Object.keys(r).reduce(function(e,t){return r[t]!==void 0&&(e[t]=r[t]),e},{})}function Zn(){return document.createElement("div")}function al(r){return["Element","Fragment"].some(function(e){return rd(r,e)})}function Xx(r){return rd(r,"NodeList")}function Kx(r){return rd(r,"MouseEvent")}function qx(r){return!!(r&&r._tippy&&r._tippy.reference===r)}function Qx(r){return al(r)?[r]:Xx(r)?Uo(r):Array.isArray(r)?r:Uo(document.querySelectorAll(r))}function oh(r,e){r.forEach(function(t){t&&(t.style.transitionDuration=e+"ms")})}function cp(r,e){r.forEach(function(t){t&&t.setAttribute("data-state",e)})}function $x(r){var e,t=zs(r),i=t[0];return i!=null&&(e=i.ownerDocument)!=null&&e.body?i.ownerDocument:document}function Jx(r,e){var t=e.clientX,i=e.clientY;return r.every(function(s){var n=s.popperRect,a=s.popperState,o=s.props,l=o.interactiveBorder,c=Yx(a.placement),u=a.modifiersData.offset;if(!u)return!0;var h=c==="bottom"?u.top.y:0,d=c==="top"?u.bottom.y:0,p=c==="right"?u.left.x:0,f=c==="left"?u.right.x:0,m=n.top-i+h>l,g=i-n.bottom-d>l,y=n.left-t+p>l,b=t-n.right-f>l;return m||g||y||b})}function lh(r,e,t){var i=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(s){r[i](s,t)})}function dp(r,e){for(var t=e;t;){var i;if(r.contains(t))return!0;t=t.getRootNode==null||(i=t.getRootNode())==null?void 0:i.host}return!1}var Fi={isTouch:!1},up=0;function Zx(){Fi.isTouch||(Fi.isTouch=!0,window.performance&&document.addEventListener("mousemove",Zm))}function Zm(){var r=performance.now();r-up<20&&(Fi.isTouch=!1,document.removeEventListener("mousemove",Zm)),up=r}function e_(){var r=document.activeElement;if(qx(r)){var e=r._tippy;r.blur&&!e.state.isVisible&&r.blur()}}function t_(){document.addEventListener("touchstart",Zx,es),window.addEventListener("blur",e_)}var i_=typeof window<"u"&&typeof document<"u",r_=i_?!!window.msCrypto:!1,s_={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},n_={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},_i=Object.assign({appendTo:$m,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},s_,n_),a_=Object.keys(_i),o_=function(e){var t=Object.keys(e);t.forEach(function(i){_i[i]=e[i]})};function eg(r){var e=r.plugins||[],t=e.reduce(function(i,s){var n=s.name,a=s.defaultValue;if(n){var o;i[n]=r[n]!==void 0?r[n]:(o=_i[n])!=null?o:a}return i},{});return Object.assign({},r,t)}function l_(r,e){var t=e?Object.keys(eg(Object.assign({},_i,{plugins:e}))):a_,i=t.reduce(function(s,n){var a=(r.getAttribute("data-tippy-"+n)||"").trim();if(!a)return s;if(n==="content")s[n]=a;else try{s[n]=JSON.parse(a)}catch{s[n]=a}return s},{});return i}function pp(r,e){var t=Object.assign({},e,{content:Jm(e.content,[r])},e.ignoreAttributes?{}:l_(r,e.plugins));return t.aria=Object.assign({},_i.aria,t.aria),t.aria={expanded:t.aria.expanded==="auto"?e.interactive:t.aria.expanded,content:t.aria.content==="auto"?e.interactive?null:"describedby":t.aria.content},t}var h_=function(){return"innerHTML"};function wc(r,e){r[h_()]=e}function fp(r){var e=Zn();return r===!0?e.className=qm:(e.className=Qm,al(r)?e.appendChild(r):wc(e,r)),e}function mp(r,e){al(e.content)?(wc(r,""),r.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?wc(r,e.content):r.textContent=e.content)}function xc(r){var e=r.firstElementChild,t=Uo(e.children);return{box:e,content:t.find(function(i){return i.classList.contains(Km)}),arrow:t.find(function(i){return i.classList.contains(qm)||i.classList.contains(Qm)}),backdrop:t.find(function(i){return i.classList.contains(Vx)})}}function tg(r){var e=Zn(),t=Zn();t.className=Wx,t.setAttribute("data-state","hidden"),t.setAttribute("tabindex","-1");var i=Zn();i.className=Km,i.setAttribute("data-state","hidden"),mp(i,r.props),e.appendChild(t),t.appendChild(i),s(r.props,r.props);function s(n,a){var o=xc(e),l=o.box,c=o.content,u=o.arrow;a.theme?l.setAttribute("data-theme",a.theme):l.removeAttribute("data-theme"),typeof a.animation=="string"?l.setAttribute("data-animation",a.animation):l.removeAttribute("data-animation"),a.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof a.maxWidth=="number"?a.maxWidth+"px":a.maxWidth,a.role?l.setAttribute("role",a.role):l.removeAttribute("role"),(n.content!==a.content||n.allowHTML!==a.allowHTML)&&mp(c,r.props),a.arrow?u?n.arrow!==a.arrow&&(l.removeChild(u),l.appendChild(fp(a.arrow))):l.appendChild(fp(a.arrow)):u&&l.removeChild(u)}return{popper:e,onUpdate:s}}tg.$$tippy=!0;var c_=1,Xa=[],hh=[];function d_(r,e){var t=pp(r,Object.assign({},_i,eg(hp(e)))),i,s,n,a=!1,o=!1,l=!1,c=!1,u,h,d,p=[],f=op(x,t.interactiveDebounce),m,g=c_++,y=null,b=jx(t.plugins),A={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},v={id:g,reference:r,popper:Zn(),popperInstance:y,props:t,state:A,plugins:b,clearDelayTimeouts:Ae,setProps:je,setContent:Pe,show:Rt,hide:zr,hideWithInteractivity:qt,enable:le,disable:se,unmount:jr,destroy:st};if(!t.render)return v;var E=t.render(v),C=E.popper,M=E.onUpdate;C.setAttribute("data-tippy-root",""),C.id="tippy-"+v.id,v.popper=C,r._tippy=v,C._tippy=v;var P=b.map(function(X){return X.fn(v)}),k=r.hasAttribute("aria-expanded");return oe(),G(),L(),te("onCreate",[v]),t.showOnCreate&&W(),C.addEventListener("mouseenter",function(){v.props.interactive&&v.state.isVisible&&v.clearDelayTimeouts()}),C.addEventListener("mouseleave",function(){v.props.interactive&&v.props.trigger.indexOf("mouseenter")>=0&&w().addEventListener("mousemove",f)}),v;function N(){var X=v.props.touch;return Array.isArray(X)?X:[X,0]}function H(){return N()[0]==="hold"}function T(){var X;return!!((X=v.props.render)!=null&&X.$$tippy)}function S(){return m||r}function w(){var X=S().parentNode;return X?$x(X):document}function F(){return xc(C)}function z(X){return v.state.isMounted&&!v.state.isVisible||Fi.isTouch||u&&u.type==="focus"?0:ah(v.props.delay,X?0:1,_i.delay)}function L(X){X===void 0&&(X=!1),C.style.pointerEvents=v.props.interactive&&!X?"":"none",C.style.zIndex=""+v.props.zIndex}function te(X,fe,_e){if(_e===void 0&&(_e=!0),P.forEach(function(Ne){Ne[X]&&Ne[X].apply(Ne,fe)}),_e){var ze;(ze=v.props)[X].apply(ze,fe)}}function R(){var X=v.props.aria;if(X.content){var fe="aria-"+X.content,_e=C.id,ze=zs(v.props.triggerTarget||r);ze.forEach(function(Ne){var xt=Ne.getAttribute(fe);if(v.state.isVisible)Ne.setAttribute(fe,xt?xt+" "+_e:_e);else{var Dt=xt&&xt.replace(_e,"").trim();Dt?Ne.setAttribute(fe,Dt):Ne.removeAttribute(fe)}})}}function G(){if(!(k||!v.props.aria.expanded)){var X=zs(v.props.triggerTarget||r);X.forEach(function(fe){v.props.interactive?fe.setAttribute("aria-expanded",v.state.isVisible&&fe===S()?"true":"false"):fe.removeAttribute("aria-expanded")})}}function D(){w().removeEventListener("mousemove",f),Xa=Xa.filter(function(X){return X!==f})}function O(X){if(!(Fi.isTouch&&(l||X.type==="mousedown"))){var fe=X.composedPath&&X.composedPath()[0]||X.target;if(!(v.props.interactive&&dp(C,fe))){if(zs(v.props.triggerTarget||r).some(function(_e){return dp(_e,fe)})){if(Fi.isTouch||v.state.isVisible&&v.props.trigger.indexOf("click")>=0)return}else te("onClickOutside",[v,X]);v.props.hideOnClick===!0&&(v.clearDelayTimeouts(),v.hide(),o=!0,setTimeout(function(){o=!1}),v.state.isMounted||ge())}}}function ee(){l=!0}function Q(){l=!1}function K(){var X=w();X.addEventListener("mousedown",O,!0),X.addEventListener("touchend",O,es),X.addEventListener("touchstart",Q,es),X.addEventListener("touchmove",ee,es)}function ge(){var X=w();X.removeEventListener("mousedown",O,!0),X.removeEventListener("touchend",O,es),X.removeEventListener("touchstart",Q,es),X.removeEventListener("touchmove",ee,es)}function Te(X,fe){pe(X,function(){!v.state.isVisible&&C.parentNode&&C.parentNode.contains(C)&&fe()})}function he(X,fe){pe(X,fe)}function pe(X,fe){var _e=F().box;function ze(Ne){Ne.target===_e&&(lh(_e,"remove",ze),fe())}if(X===0)return fe();lh(_e,"remove",h),lh(_e,"add",ze),h=ze}function be(X,fe,_e){_e===void 0&&(_e=!1);var ze=zs(v.props.triggerTarget||r);ze.forEach(function(Ne){Ne.addEventListener(X,fe,_e),p.push({node:Ne,eventType:X,handler:fe,options:_e})})}function oe(){H()&&(be("touchstart",ve,{passive:!0}),be("touchend",j,{passive:!0})),zx(v.props.trigger).forEach(function(X){if(X!=="manual")switch(be(X,ve),X){case"mouseenter":be("mouseleave",j);break;case"focus":be(r_?"focusout":"blur",V);break;case"focusin":be("focusout",V);break}})}function ue(){p.forEach(function(X){var fe=X.node,_e=X.eventType,ze=X.handler,Ne=X.options;fe.removeEventListener(_e,ze,Ne)}),p=[]}function ve(X){var fe,_e=!1;if(!(!v.state.isEnabled||B(X)||o)){var ze=((fe=u)==null?void 0:fe.type)==="focus";u=X,m=X.currentTarget,G(),!v.state.isVisible&&Kx(X)&&Xa.forEach(function(Ne){return Ne(X)}),X.type==="click"&&(v.props.trigger.indexOf("mouseenter")<0||a)&&v.props.hideOnClick!==!1&&v.state.isVisible?_e=!0:W(X),X.type==="click"&&(a=!_e),_e&&!ze&&ie(X)}}function x(X){var fe=X.target,_e=S().contains(fe)||C.contains(fe);if(!(X.type==="mousemove"&&_e)){var ze=J().concat(C).map(function(Ne){var xt,Dt=Ne._tippy,Yi=(xt=Dt.popperInstance)==null?void 0:xt.state;return Yi?{popperRect:Ne.getBoundingClientRect(),popperState:Yi,props:t}:null}).filter(Boolean);Jx(ze,X)&&(D(),ie(X))}}function j(X){var fe=B(X)||v.props.trigger.indexOf("click")>=0&&a;if(!fe){if(v.props.interactive){v.hideWithInteractivity(X);return}ie(X)}}function V(X){v.props.trigger.indexOf("focusin")<0&&X.target!==S()||v.props.interactive&&X.relatedTarget&&C.contains(X.relatedTarget)||ie(X)}function B(X){return Fi.isTouch?H()!==X.type.indexOf("touch")>=0:!1}function I(){U();var X=v.props,fe=X.popperOptions,_e=X.placement,ze=X.offset,Ne=X.getReferenceClientRect,xt=X.moveTransition,Dt=T()?xc(C).arrow:null,Yi=Ne?{getBoundingClientRect:Ne,contextElement:Ne.contextElement||S()}:r,ur={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(va){var Cs=va.state;if(T()){var Lg=F(),bl=Lg.box;["placement","reference-hidden","escaped"].forEach(function(ba){ba==="placement"?bl.setAttribute("data-placement",Cs.placement):Cs.attributes.popper["data-popper-"+ba]?bl.setAttribute("data-"+ba,""):bl.removeAttribute("data-"+ba)}),Cs.attributes.popper={}}}},Qt=[{name:"offset",options:{offset:ze}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!xt}},ur];T()&&Dt&&Qt.push({name:"arrow",options:{element:Dt,padding:3}}),Qt.push.apply(Qt,fe?.modifiers||[]),v.popperInstance=Hx(Yi,C,Object.assign({},fe,{placement:_e,onFirstUpdate:d,modifiers:Qt}))}function U(){v.popperInstance&&(v.popperInstance.destroy(),v.popperInstance=null)}function q(){var X=v.props.appendTo,fe,_e=S();v.props.interactive&&X===$m||X==="parent"?fe=_e.parentNode:fe=Jm(X,[_e]),fe.contains(C)||fe.appendChild(C),v.state.isMounted=!0,I()}function J(){return Uo(C.querySelectorAll("[data-tippy-root]"))}function W(X){v.clearDelayTimeouts(),X&&te("onTrigger",[v,X]),K();var fe=z(!0),_e=N(),ze=_e[0],Ne=_e[1];Fi.isTouch&&ze==="hold"&&Ne&&(fe=Ne),fe?i=setTimeout(function(){v.show()},fe):v.show()}function ie(X){if(v.clearDelayTimeouts(),te("onUntrigger",[v,X]),!v.state.isVisible){ge();return}if(!(v.props.trigger.indexOf("mouseenter")>=0&&v.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(X.type)>=0&&a)){var fe=z(!1);fe?s=setTimeout(function(){v.state.isVisible&&v.hide()},fe):n=requestAnimationFrame(function(){v.hide()})}}function le(){v.state.isEnabled=!0}function se(){v.hide(),v.state.isEnabled=!1}function Ae(){clearTimeout(i),clearTimeout(s),cancelAnimationFrame(n)}function je(X){if(!v.state.isDestroyed){te("onBeforeUpdate",[v,X]),ue();var fe=v.props,_e=pp(r,Object.assign({},fe,hp(X),{ignoreAttributes:!0}));v.props=_e,oe(),fe.interactiveDebounce!==_e.interactiveDebounce&&(D(),f=op(x,_e.interactiveDebounce)),fe.triggerTarget&&!_e.triggerTarget?zs(fe.triggerTarget).forEach(function(ze){ze.removeAttribute("aria-expanded")}):_e.triggerTarget&&r.removeAttribute("aria-expanded"),G(),L(),M&&M(fe,_e),v.popperInstance&&(I(),J().forEach(function(ze){requestAnimationFrame(ze._tippy.popperInstance.forceUpdate)})),te("onAfterUpdate",[v,X])}}function Pe(X){v.setProps({content:X})}function Rt(){var X=v.state.isVisible,fe=v.state.isDestroyed,_e=!v.state.isEnabled,ze=Fi.isTouch&&!v.props.touch,Ne=ah(v.props.duration,0,_i.duration);if(!(X||fe||_e||ze)&&!S().hasAttribute("disabled")&&(te("onShow",[v],!1),v.props.onShow(v)!==!1)){if(v.state.isVisible=!0,T()&&(C.style.visibility="visible"),L(),K(),v.state.isMounted||(C.style.transition="none"),T()){var xt=F(),Dt=xt.box,Yi=xt.content;oh([Dt,Yi],0)}d=function(){var Qt;if(!(!v.state.isVisible||c)){if(c=!0,C.offsetHeight,C.style.transition=v.props.moveTransition,T()&&v.props.animation){var vl=F(),va=vl.box,Cs=vl.content;oh([va,Cs],Ne),cp([va,Cs],"visible")}R(),G(),lp(hh,v),(Qt=v.popperInstance)==null||Qt.forceUpdate(),te("onMount",[v]),v.props.animation&&T()&&he(Ne,function(){v.state.isShown=!0,te("onShown",[v])})}},q()}}function zr(){var X=!v.state.isVisible,fe=v.state.isDestroyed,_e=!v.state.isEnabled,ze=ah(v.props.duration,1,_i.duration);if(!(X||fe||_e)&&(te("onHide",[v],!1),v.props.onHide(v)!==!1)){if(v.state.isVisible=!1,v.state.isShown=!1,c=!1,a=!1,T()&&(C.style.visibility="hidden"),D(),ge(),L(!0),T()){var Ne=F(),xt=Ne.box,Dt=Ne.content;v.props.animation&&(oh([xt,Dt],ze),cp([xt,Dt],"hidden"))}R(),G(),v.props.animation?T()&&Te(ze,v.unmount):v.unmount()}}function qt(X){w().addEventListener("mousemove",f),lp(Xa,f),f(X)}function jr(){v.state.isVisible&&v.hide(),v.state.isMounted&&(U(),J().forEach(function(X){X._tippy.unmount()}),C.parentNode&&C.parentNode.removeChild(C),hh=hh.filter(function(X){return X!==v}),v.state.isMounted=!1,te("onHidden",[v]))}function st(){v.state.isDestroyed||(v.clearDelayTimeouts(),v.unmount(),ue(),delete r._tippy,v.state.isDestroyed=!0,te("onDestroy",[v]))}}function Mt(r,e){e===void 0&&(e={});var t=_i.plugins.concat(e.plugins||[]);t_();var i=Object.assign({},e,{plugins:t}),s=Qx(r),n=s.reduce(function(a,o){var l=o&&d_(o,i);return l&&a.push(l),a},[]);return al(r)?n[0]:n}Mt.defaultProps=_i;Mt.setDefaultProps=o_;Mt.currentInput=Fi;Object.assign({},Gm,{effect:function(e){var t=e.state,i={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,i.popper),t.styles=i,t.elements.arrow&&Object.assign(t.elements.arrow.style,i.arrow)}});Mt.setDefaultProps({render:tg});const u_="modulepreload",p_=function(r){return"/smeditor/"+r},gp={},ui=function(e,t,i){if(!t||t.length===0)return e();const s=document.getElementsByTagName("link");return Promise.all(t.map(n=>{if(n=p_(n),n in gp)return;gp[n]=!0;const a=n.endsWith(".css"),o=a?'[rel="stylesheet"]':"";if(!!i)for(let u=s.length-1;u>=0;u--){const h=s[u];if(h.href===n&&(!a||h.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${n}"]${o}`))return;const c=document.createElement("link");if(c.rel=a?"stylesheet":u_,a||(c.as="script",c.crossOrigin=""),c.href=n,document.head.appendChild(c),a)return new Promise((u,h)=>{c.addEventListener("load",u),c.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${n}`)))})})).then(()=>e()).catch(n=>{const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=n,window.dispatchEvent(a),!a.defaultPrevented)throw n})},Go={INVALID:["seeking position failed.","InvalidStateError"],GONE:["A requested file or directory could not be found at the time an operation was processed.","NotFoundError"],MISMATCH:["The path supplied exists, but was not an entry of requested type.","TypeMismatchError"],MOD_ERR:["The object can not be modified in this way.","InvalidModificationError"],SYNTAX:r=>[`Failed to execute 'write' on 'UnderlyingSinkBase': Invalid params passed. ${r}`,"SyntaxError"],ABORT:["The operation was aborted","AbortError"],SECURITY:["It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources.","SecurityError"],DISALLOWED:["The request is not allowed by the user agent or the platform in the current context.","NotAllowedError"]},f_=r=>typeof r=="object"&&typeof r.type<"u";async function m_(r){var e,t,i;const{FolderHandle:s,FileHandle:n}=await ui(()=>import("./memory-e7c5df82.js"),[]),{FileSystemDirectoryHandle:a}=await ui(()=>Promise.resolve().then(()=>IE),void 0),o=(t=(e=r[0].webkitRelativePath)===null||e===void 0?void 0:e.split("/",1)[0])!==null&&t!==void 0?t:"",l=new s(o,!1);for(let c=0;c(f._entries[m]||(f._entries[m]=new s(m,!1)),f._entries[m]),l);p._entries[d]=new n(u.name,u,!1)}return new a(l)}async function g_(r){const{FileHandle:e}=await ui(()=>import("./memory-e7c5df82.js"),[]),{FileSystemFileHandle:t}=await ui(()=>Promise.resolve().then(()=>gg),void 0);return Array.from(r).map(s=>new t(new e(s.name,s,!1)))}const ig=Object.freeze(Object.defineProperty({__proto__:null,errors:Go,isChunkObject:f_,makeDirHandleFromFileList:m_,makeFileHandlesFromFileList:g_},Symbol.toStringTag,{value:"Module"}));var hs={};/*! howler.js v2.2.4 | (c) 2013-2020, James Simpson of GoldFire Studios | MIT License | howlerjs.com */(function(r){(function(){var e=function(){this.init()};e.prototype={init:function(){var h=this||t;return h._counter=1e3,h._html5AudioPool=[],h.html5PoolSize=10,h._codecs={},h._howls=[],h._muted=!1,h._volume=1,h._canPlayEvent="canplaythrough",h._navigator=typeof window<"u"&&window.navigator?window.navigator:null,h.masterGain=null,h.noAudio=!1,h.usingWebAudio=!0,h.autoSuspend=!0,h.ctx=null,h.autoUnlock=!0,h._setup(),h},volume:function(h){var d=this||t;if(h=parseFloat(h),d.ctx||u(),h!==void 0&&h>=0&&h<=1){if(d._volume=h,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(h,t.ctx.currentTime);for(var p=0;p=0;d--)h._howls[d].unload();return h.usingWebAudio&&h.ctx&&h.ctx.close!==void 0&&(h.ctx.close(),h.ctx=null,u()),h},codecs:function(h){return(this||t)._codecs[h.replace(/^x-/,"")]},_setup:function(){var h=this||t;if(h.state=h.ctx&&h.ctx.state||"suspended",h._autoSuspend(),!h.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;d.oncanplaythrough===void 0&&(h._canPlayEvent="canplay")}catch{h.noAudio=!0}else h.noAudio=!0;try{var d=new Audio;d.muted&&(h.noAudio=!0)}catch{}return h.noAudio||h._setupCodecs(),h},_setupCodecs:function(){var h=this||t,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return h}if(!d||typeof d.canPlayType!="function")return h;var p=d.canPlayType("audio/mpeg;").replace(/^no$/,""),f=h._navigator?h._navigator.userAgent:"",m=f.match(/OPR\/(\d+)/g),g=m&&parseInt(m[0].split("/")[1],10)<33,y=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,b=f.match(/Version\/(.*?) /),A=y&&b&&parseInt(b[1],10)<15;return h._codecs={mp3:!(g||!p&&!d.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!p,opus:!!d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(d.canPlayType('audio/wav; codecs="1"')||d.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!d.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!d.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(d.canPlayType("audio/x-m4a;")||d.canPlayType("audio/m4a;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(d.canPlayType("audio/x-m4b;")||d.canPlayType("audio/m4b;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(d.canPlayType("audio/x-mp4;")||d.canPlayType("audio/mp4;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!(A||!d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!(A||!d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!d.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(d.canPlayType("audio/x-flac;")||d.canPlayType("audio/flac;")).replace(/^no$/,"")},h},_unlockAudio:function(){var h=this||t;if(!h._audioUnlocked&&h.ctx){h._audioUnlocked=!1,h.autoUnlock=!1,h._mobileUnloaded||h.ctx.sampleRate===44100||(h._mobileUnloaded=!0,h.unload()),h._scratchBuffer=h.ctx.createBuffer(1,1,22050);var d=function(p){for(;h._html5AudioPool.length0?y._seek:p._sprite[h][0]/1e3),v=Math.max(0,(p._sprite[h][0]+p._sprite[h][1])/1e3-A),E=1e3*v/Math.abs(y._rate),C=p._sprite[h][0]/1e3,M=(p._sprite[h][0]+p._sprite[h][1])/1e3;y._sprite=h,y._ended=!1;var P=function(){y._paused=!1,y._seek=A,y._start=C,y._stop=M,y._loop=!(!y._loop&&!p._sprite[h][2])};if(A>=M)return void p._ended(y);var k=y._node;if(p._webAudio){var N=function(){p._playLock=!1,P(),p._refreshBuffer(y);var w=y._muted||p._muted?0:y._volume;k.gain.setValueAtTime(w,t.ctx.currentTime),y._playStart=t.ctx.currentTime,k.bufferSource.start===void 0?y._loop?k.bufferSource.noteGrainOn(0,A,86400):k.bufferSource.noteGrainOn(0,A,v):y._loop?k.bufferSource.start(0,A,86400):k.bufferSource.start(0,A,v),E!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),E)),d||setTimeout(function(){p._emit("play",y._id),p._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?N():(p._playLock=!0,p.once("resume",N),p._clearTimer(y._id))}else{var H=function(){k.currentTime=A,k.muted=y._muted||p._muted||t._muted||k.muted,k.volume=y._volume*t.volume(),k.playbackRate=y._rate;try{var w=k.play();if(w&&typeof Promise<"u"&&(w instanceof Promise||typeof w.then=="function")?(p._playLock=!0,P(),w.then(function(){p._playLock=!1,k._unlocked=!0,d?p._loadQueue():p._emit("play",y._id)}).catch(function(){p._playLock=!1,p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),y._ended=!0,y._paused=!0})):d||(p._playLock=!1,P(),p._emit("play",y._id)),k.playbackRate=y._rate,k.paused)return void p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");h!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),E):(p._endTimers[y._id]=function(){p._ended(y),k.removeEventListener("ended",p._endTimers[y._id],!1)},k.addEventListener("ended",p._endTimers[y._id],!1))}catch(F){p._emit("playerror",y._id,F)}};k.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(k.src=p._src,k.load());var T=window&&window.ejecta||!k.readyState&&t._navigator.isCocoonJS;if(k.readyState>=3||T)H();else{p._playLock=!0,p._state="loading";var S=function(){p._state="loaded",H(),k.removeEventListener(t._canPlayEvent,S,!1)};k.addEventListener(t._canPlayEvent,S,!1),p._clearTimer(y._id)}}return y._id},pause:function(h){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(h)}}),d;for(var p=d._getSoundIds(h),f=0;f=0?d=parseInt(f[0],10):h=parseFloat(f[0]):f.length>=2&&(h=parseFloat(f[0]),d=parseInt(f[1],10));var m;if(!(h!==void 0&&h>=0&&h<=1))return m=d?p._soundById(d):p._sounds[0],m?m._volume:0;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"volume",action:function(){p.volume.apply(p,f)}}),p;d===void 0&&(p._volume=h),d=p._getSoundIds(d);for(var g=0;g0?f/v:f),C=Date.now();h._fadeTo=p,h._interval=setInterval(function(){var M=(Date.now()-C)/f;C=Date.now(),b+=A*M,b=Math.round(100*b)/100,b=A<0?Math.max(p,b):Math.min(p,b),y._webAudio?h._volume=b:y.volume(b,h._id,!0),g&&(y._volume=b),(pd&&b>=p)&&(clearInterval(h._interval),h._interval=null,h._fadeTo=null,y.volume(p,h._id),y._emit("fade",h._id))},E)},_stopFade:function(h){var d=this,p=d._soundById(h);return p&&p._interval&&(d._webAudio&&p._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(p._interval),p._interval=null,d.volume(p._fadeTo,h),p._fadeTo=null,d._emit("fade",h)),d},loop:function(){var h,d,p,f=this,m=arguments;if(m.length===0)return f._loop;if(m.length===1){if(typeof m[0]!="boolean")return!!(p=f._soundById(parseInt(m[0],10)))&&p._loop;h=m[0],f._loop=h}else m.length===2&&(h=m[0],d=parseInt(m[1],10));for(var g=f._getSoundIds(d),y=0;y=0?d=parseInt(f[0],10):h=parseFloat(f[0])}else f.length===2&&(h=parseFloat(f[0]),d=parseInt(f[1],10));var y;if(typeof h!="number")return y=p._soundById(d),y?y._rate:p._rate;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"rate",action:function(){p.rate.apply(p,f)}}),p;d===void 0&&(p._rate=h),d=p._getSoundIds(d);for(var b=0;b=0?d=parseInt(f[0],10):p._sounds.length&&(d=p._sounds[0]._id,h=parseFloat(f[0]))}else f.length===2&&(h=parseFloat(f[0]),d=parseInt(f[1],10));if(d===void 0)return 0;if(typeof h=="number"&&(p._state!=="loaded"||p._playLock))return p._queue.push({event:"seek",action:function(){p.seek.apply(p,f)}}),p;var y=p._soundById(d);if(y){if(!(typeof h=="number"&&h>=0)){if(p._webAudio){var b=p.playing(d)?t.ctx.currentTime-y._playStart:0,A=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(A+b*Math.abs(y._rate))}return y._node.currentTime}var v=p.playing(d);v&&p.pause(d,!0),y._seek=h,y._ended=!1,p._clearTimer(d),p._webAudio||!y._node||isNaN(y._node.duration)||(y._node.currentTime=h);var E=function(){v&&p.play(d,!0),p._emit("seek",d)};if(v&&!p._webAudio){var C=function(){p._playLock?setTimeout(C,0):E()};setTimeout(C,0)}else E()}return p},playing:function(h){var d=this;if(typeof h=="number"){var p=d._soundById(h);return!!p&&!p._paused}for(var f=0;f=0&&t._howls.splice(f,1);var m=!0;for(p=0;p=0){m=!1;break}return n&&m&&delete n[h._src],t.noAudio=!1,h._state="unloaded",h._sounds=[],h=null,null},on:function(h,d,p,f){var m=this,g=m["_on"+h];return typeof d=="function"&&g.push(f?{id:p,fn:d,once:f}:{id:p,fn:d}),m},off:function(h,d,p){var f=this,m=f["_on"+h],g=0;if(typeof d=="number"&&(p=d,d=null),d||p)for(g=0;g=0;g--)m[g].id&&m[g].id!==d&&h!=="load"||(setTimeout(function(y){y.call(this,d,p)}.bind(f,m[g].fn),0),m[g].once&&f.off(h,m[g].fn,m[g].id));return f._loadQueue(h),f},_loadQueue:function(h){var d=this;if(d._queue.length>0){var p=d._queue[0];p.event===h&&(d._queue.shift(),d._loadQueue()),h||p.action()}return d},_ended:function(h){var d=this,p=h._sprite;if(!d._webAudio&&h._node&&!h._node.paused&&!h._node.ended&&h._node.currentTime=0;f--){if(p<=d)return;h._sounds[f]._ended&&(h._webAudio&&h._sounds[f]._node&&h._sounds[f]._node.disconnect(0),h._sounds.splice(f,1),p--)}}},_getSoundIds:function(h){var d=this;if(h===void 0){for(var p=[],f=0;f=0;if(!h.bufferSource)return d;if(t._scratchBuffer&&h.bufferSource&&(h.bufferSource.onended=null,h.bufferSource.disconnect(0),p))try{h.bufferSource.buffer=t._scratchBuffer}catch{}return h.bufferSource=null,d},_clearSound:function(h){/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent)||(h.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var s=function(h){this._parent=h,this.init()};s.prototype={init:function(){var h=this,d=h._parent;return h._muted=d._muted,h._loop=d._loop,h._volume=d._volume,h._rate=d._rate,h._seek=0,h._paused=!0,h._ended=!0,h._sprite="__default",h._id=++t._counter,d._sounds.push(h),h.create(),h},create:function(){var h=this,d=h._parent,p=t._muted||h._muted||h._parent._muted?0:h._volume;return d._webAudio?(h._node=t.ctx.createGain===void 0?t.ctx.createGainNode():t.ctx.createGain(),h._node.gain.setValueAtTime(p,t.ctx.currentTime),h._node.paused=!0,h._node.connect(t.masterGain)):t.noAudio||(h._node=t._obtainHtml5Audio(),h._errorFn=h._errorListener.bind(h),h._node.addEventListener("error",h._errorFn,!1),h._loadFn=h._loadListener.bind(h),h._node.addEventListener(t._canPlayEvent,h._loadFn,!1),h._endFn=h._endListener.bind(h),h._node.addEventListener("ended",h._endFn,!1),h._node.src=d._src,h._node.preload=d._preload===!0?"auto":d._preload,h._node.volume=p*t.volume(),h._node.load()),h},reset:function(){var h=this,d=h._parent;return h._muted=d._muted,h._loop=d._loop,h._volume=d._volume,h._rate=d._rate,h._seek=0,h._rateSeek=0,h._paused=!0,h._ended=!0,h._sprite="__default",h._id=++t._counter,h},_errorListener:function(){var h=this;h._parent._emit("loaderror",h._id,h._node.error?h._node.error.code:0),h._node.removeEventListener("error",h._errorFn,!1)},_loadListener:function(){var h=this,d=h._parent;d._duration=Math.ceil(10*h._node.duration)/10,Object.keys(d._sprite).length===0&&(d._sprite={__default:[0,1e3*d._duration]}),d._state!=="loaded"&&(d._state="loaded",d._emit("load"),d._loadQueue()),h._node.removeEventListener(t._canPlayEvent,h._loadFn,!1)},_endListener:function(){var h=this,d=h._parent;d._duration===1/0&&(d._duration=Math.ceil(10*h._node.duration)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=1e3*d._duration),d._ended(h)),h._node.removeEventListener("ended",h._endFn,!1)}};var n={},a=function(h){var d=h._src;if(n[d])return h._duration=n[d].duration,void c(h);if(/^data:[^;]+;base64,/.test(d)){for(var p=atob(d.split(",")[1]),f=new Uint8Array(p.length),m=0;m0?(n[d._src]=m,c(d,m)):p()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(h).then(f).catch(p):t.ctx.decodeAudioData(h,f,p)},c=function(h,d){d&&!h._duration&&(h._duration=d.duration),Object.keys(h._sprite).length===0&&(h._sprite={__default:[0,1e3*h._duration]}),h._state!=="loaded"&&(h._state="loaded",h._emit("load"),h._loadQueue())},u=function(){if(t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var h=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),d=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),p=d?parseInt(d[1],10):null;if(h&&p&&p<9){var f=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!f&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=t.ctx.createGain===void 0?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};r.Howler=t,r.Howl=i,typeof si<"u"?(si.HowlerGlobal=e,si.Howler=t,si.Howl=i,si.Sound=s):typeof window<"u"&&(window.HowlerGlobal=e,window.Howler=t,window.Howl=i,window.Sound=s)})()})(hs);const y_="/smeditor/assets/assist_tick-b8aada2a.ogg",rg="/smeditor/assets/metronome_high-6fa54e52.ogg",sg="/smeditor/assets/metronome_low-4db4e760.ogg",v_="/smeditor/assets/mine-b65ce42d.ogg",ol=[".aac",".mid",".midi",".mp3",".oga",".ogg",".opus",".wav",".webm",".weba",".flac",".aiff"],ts=[".bmp",".gif",".jpeg",".jpg",".png",".tif",".tiff",".webp"];function b_(r){return r.type!="Hold"&&r.type!="Roll"}function Be(r){return r.type=="Hold"||r.type=="Roll"}class A_{cols=[];keyDown(e){this.cols[e]=(this.cols[e]??0)+1}keyUp(e){this.cols[e]=(this.cols[e]??1)-1,this.cols[e]=Math.max(this.cols[e],0)}isPressed(e){return!!this.cols[e]}getHeldCols(){return this.cols.map((e,t)=>t).filter(e=>this.isPressed(e))}reset(){this.cols=[]}}const yp=["audio.rate","chart.snap","chart.CMod","play.timingCollection"];class Ho{static general={spinnerStep:1,smoothAnimations:!0,warnBeforeExit:!0};static chart={CMod:!1,reverse:!1,mousePlacement:!1,zoom:1,speed:250,snap:1,hideWarpedArrows:!1,hideFakedArrows:!1,doSpeedChanges:!0,drawNoteFlash:!0,receptorYPos:-200,maxDrawBeats:20,maxDrawBeatsBack:10,scroll:{scrollSensitivity:1,scrollSnapEveryScroll:!navigator.userAgent.includes("Mac"),invertZoomScroll:!1,invertReverseScroll:!0},waveform:{enabled:!0,antialiasing:!0,color:6316402,opacity:.5,allowFilter:!0,filteredColor:1987134,filteredOpacity:.5,lineHeight:1,speedChanges:!0},timingEventOrder:{left:["LABELS","FAKES","TIMESIGNATURES","DELAYS","WARPS","STOPS","BPMS"],right:["SPEEDS","SCROLLS","TICKCOUNTS","COMBOS","ATTACKS","BGCHANGES","FGCHANGES"]},renderTimingEvent:{BPMS:!0,STOPS:!0,DELAYS:!0,WARPS:!0,FAKES:!0,COMBOS:!0,SPEEDS:!0,LABELS:!0,SCROLLS:!0,TIMESIGNATURES:!0,TICKCOUNTS:!0,BGCHANGES:!0,FGCHANGES:!0,ATTACKS:!0},noteskin:{"dance-single":"default","dance-double":"default","dance-couple":"default","dance-solo":"default","dance-solodouble":"default","dance-threepanel":"default","dance-threedouble":"default"}};static audio={assistTick:!1,metronome:!1,rate:1,masterVolume:1,songVolume:.2,soundEffectVolume:.5,allowFilter:!0};static play={offset:0,effectOffset:0,visualOffset:0,hideBarlines:!1,judgmentTilt:!0,timingCollection:"ITG",timingWindowScale:1,timingWindowAdd:0,defaultTimingCollection:{"dance-single":"ITG","dance-double":"ITG","dance-threepanel":"ITG","dance-threedouble":"ITG","dance-solo":"ITG","dance-solodouble":"ITG"}};static performance={antialiasing:!1,resolution:window.devicePixelRatio};static debug={showFPS:!1,showTimers:!1};static experimental={}}class _ extends Ho{static extractOptions(e,t){return Object.entries(e).reduce((i,s)=>{const n=t?t+".":"";return typeof s[1]=="object"&&!Array.isArray(s[1])?i=i.concat(this.extractOptions(s[1],n+s[0])):(s[0]=n+s[0],i.push([s[0],s[1]])),i},[])}static applyOption(e){if(typeof this.getDefaultOption(e[0])!=typeof e[1])return console.warn("Couldn't load option "+e[0]+": the value "+e[1]+" ("+typeof e[1]+") does not match the type "+typeof this.getDefaultOption(e[0]));const t=e[0].split("."),i=t.pop();let s=this;for(const n of t)if(n in s)s=s[n];else return console.warn("Couldn't load option "+e[0]+": the id doesn't exist");s[i]=e[1]}static getDefaultOption(e){const t=e.split(".");let i=Ho;for(const s of t)if(s in i)i=i[s];else return;if(!(typeof i=="object"&&!Array.isArray(i)))return i}static getOption(e){const t=e.split(".");let i=this;for(const s of t)if(s in i)i=i[s];else return;if(!(typeof i=="object"&&!Array.isArray(i)))return i}static saveOptions(){const e={};for(const t of this.extractOptions(this)){if(yp.includes(t[0]))continue;const i=this.getDefaultOption(t[0]);if(i==null){console.warn("Couldn't save option "+t[0]+": the id doesn't exist");continue}typeof i!=typeof t[1]?(console.warn("Couldn't save option "+t[0]+": the value "+t[1]+" does not match the type "+typeof this.getDefaultOption(t[0])),e[t[0]]=i):e[t[0]]=t[1]}localStorage.setItem("options",JSON.stringify(e))}static loadOptions(){const e=localStorage.getItem("options");if(!e)return;const t=JSON.parse(e);if(typeof t!="object")return console.error("Couldn't load options from storage");for(const i of Object.entries(t))yp.includes(i[0])||this.applyOption(i)}static clearSave(){localStorage.removeItem("options")}}const ng={};for(const r of Object.entries(Ho))ng[r[0]]=JSON.parse(JSON.stringify(r[1]));Object.assign(_,ng);var ti="INUMBER",xn="IOP1",_n="IOP2",En="IOP3",hr="IVAR",xs="IVARNAME",pn="IFUNCALL",ll="IFUNDEF",Ht="IEXPR",sd="IEXPREVAL",Es="IMEMBER",hl="IENDSTATEMENT",fn="IARRAY";function We(r,e){this.type=r,this.value=e??0}We.prototype.toString=function(){switch(this.type){case ti:case xn:case _n:case En:case hr:case xs:case hl:return this.value;case pn:return"CALL "+this.value;case ll:return"DEF "+this.value;case fn:return"ARRAY "+this.value;case Es:return"."+this.value;default:return"Invalid Instruction"}};function cl(r){return new We(xn,r)}function dr(r){return new We(_n,r)}function ag(r){return new We(En,r)}function _c(r,e,t,i,s){for(var n=[],a=[],o,l,c,u,h=0;h1)l=n.pop(),o=n.pop(),u=t[d.value],d=new We(ti,u(o.value,l.value)),n.push(d);else if(p===En&&n.length>2)c=n.pop(),l=n.pop(),o=n.pop(),d.value==="?"?n.push(o.value?l.value:c.value):(u=i[d.value],d=new We(ti,u(o.value,l.value,c.value)),n.push(d));else if(p===xn&&n.length>0)o=n.pop(),u=e[d.value],d=new We(ti,u(o.value)),n.push(d);else if(p===Ht){for(;n.length>0;)a.push(n.shift());a.push(new We(Ht,_c(d.value,e,t,i,s)))}else if(p===Es&&n.length>0)o=n.pop(),n.push(new We(ti,o.value[d.value]));else{for(;n.length>0;)a.push(n.shift());a.push(d)}}for(;n.length>0;)a.push(n.shift());return a}function og(r,e,t){for(var i=[],s=0;s0;)l.unshift(qi(i.pop(),t));if(o=i.pop(),o.apply&&o.call)i.push(o.apply(void 0,l));else throw new Error(o+" is not a function")}else if(p===ll)i.push(function(){for(var m=i.pop(),g=[],y=d.value;y-- >0;)g.unshift(i.pop());var b=i.pop(),A=function(){for(var v=Object.assign({},t),E=0,C=g.length;E0;)l.unshift(i.pop());i.push(l)}else throw new Error("invalid Expression")}if(i.length>1)throw new Error("invalid Expression (parity)");return i[0]===0?0:qi(i[0],t)}function w_(r,e,t){return nd(r)?r:{type:sd,value:function(i){return ns(r.value,e,i)}}}function nd(r){return r&&r.type===sd}function qi(r,e){return nd(r)?r.value(e):r}function ad(r,e){for(var t=[],i,s,n,a,o,l,c=0;c0;)o.unshift(t.pop());a=t.pop(),t.push(a+"("+o.join(", ")+")")}else if(h===ll){for(s=t.pop(),l=u.value,o=[];l-- >0;)o.unshift(t.pop());i=t.pop(),e?t.push("("+i+" = function("+o.join(", ")+") { return "+s+" })"):t.push("("+i+"("+o.join(", ")+") = "+s+")")}else if(h===Es)i=t.pop(),t.push(i+"."+u.value);else if(h===fn){for(l=u.value,o=[];l-- >0;)o.unshift(t.pop());t.push("["+o.join(", ")+"]")}else if(h===Ht)t.push("("+ad(u.value,e)+")");else if(h!==hl)throw new Error("invalid Expression")}return t.length>1&&(e?t=[t.join(",")]:t=[t.join(";")]),String(t[0])}function vp(r){return typeof r=="string"?JSON.stringify(r).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"):r}function Qs(r,e){for(var t=0;t=this.expression.length)return this.newToken(oa,"EOF");if(this.isWhitespace()||this.isComment())return this.next();if(this.isRadixInteger()||this.isNumber()||this.isOperator()||this.isString()||this.isParen()||this.isBracket()||this.isComma()||this.isSemicolon()||this.isNamedOp()||this.isConst()||this.isName())return this.current;this.parseError('Unknown character "'+this.expression.charAt(this.pos)+'"')};ct.prototype.isString=function(){var r=!1,e=this.pos,t=this.expression.charAt(e);if(t==="'"||t==='"')for(var i=this.expression.indexOf(t,e+1);i>=0&&this.pos"9")))break}if(e>r){var i=this.expression.substring(r,e);if(i in this.consts)return this.current=this.newToken(dl,this.consts[i]),this.pos+=i.length,!0}return!1};ct.prototype.isNamedOp=function(){for(var r=this.pos,e=r;e"9")))break}if(e>r){var i=this.expression.substring(r,e);if(this.isOperatorEnabled(i)&&(i in this.binaryOps||i in this.unaryOps||i in this.ternaryOps))return this.current=this.newToken(Qe,i),this.pos+=i.length,!0}return!1};ct.prototype.isName=function(){for(var r=this.pos,e=r,t=!1;e"9"))break}else t=!0}if(t){var s=this.expression.substring(r,e);return this.current=this.newToken(ld,s),this.pos+=s.length,!0}return!1};ct.prototype.isWhitespace=function(){for(var r=!1,e=this.expression.charAt(this.pos);(e===" "||e===" "||e===` `||e==="\r")&&(r=!0,this.pos++,!(this.pos>=this.expression.length));)e=this.expression.charAt(this.pos);return r};var x_=/^[0-9a-f]{4}$/i;ct.prototype.unescape=function(r){var e=r.indexOf("\\");if(e<0)return r;for(var t=r.substring(0,e);e>=0;){var i=r.charAt(++e);switch(i){case"'":t+="'";break;case'"':t+='"';break;case"\\":t+="\\";break;case"/":t+="/";break;case"b":t+="\b";break;case"f":t+="\f";break;case"n":t+=` `;break;case"r":t+="\r";break;case"t":t+=" ";break;case"u":var s=r.substring(e+1,e+5);x_.test(s)||this.parseError("Illegal escape sequence: \\u"+s),t+=String.fromCharCode(parseInt(s,16)),e+=4;break;default:throw this.parseError('Illegal escape sequence: "\\'+i+'"')}++e;var n=r.indexOf("\\",e);t+=r.substring(e,n<0?r.length:n),e=n}return t};ct.prototype.isComment=function(){var r=this.expression.charAt(this.pos);return r==="/"&&this.expression.charAt(this.pos+1)==="*"?(this.pos=this.expression.indexOf("*/",this.pos)+2,this.pos===1&&(this.pos=this.expression.length),!0):!1};ct.prototype.isRadixInteger=function(){var r=this.pos;if(r>=this.expression.length-2||this.expression.charAt(r)!=="0")return!1;++r;var e,t;if(this.expression.charAt(r)==="x")e=16,t=/^[0-9a-f]$/i,++r;else if(this.expression.charAt(r)==="b")e=2,t=/^[01]$/i,++r;else return!1;for(var i=!1,s=r;r="0"&&a<="9"||!s&&a===".");)a==="."?s=!0:n=!0,e++,r=n;if(r&&(i=e),a==="e"||a==="E"){e++;for(var o=!0,l=!1;e="0"&&a<="9")l=!0,o=!1;else break;e++}l||(e=i)}return r?(this.current=this.newToken(dl,parseFloat(this.expression.substring(t,e))),this.pos=e):this.pos=i,r};ct.prototype.isOperator=function(){var r=this.pos,e=this.expression.charAt(this.pos);if(e==="+"||e==="-"||e==="*"||e==="/"||e==="%"||e==="^"||e==="?"||e===":"||e===".")this.current=this.newToken(Qe,e);else if(e==="∙"||e==="•")this.current=this.newToken(Qe,"*");else if(e===">")this.expression.charAt(this.pos+1)==="="?(this.current=this.newToken(Qe,">="),this.pos++):this.current=this.newToken(Qe,">");else if(e==="<")this.expression.charAt(this.pos+1)==="="?(this.current=this.newToken(Qe,"<="),this.pos++):this.current=this.newToken(Qe,"<");else if(e==="|")if(this.expression.charAt(this.pos+1)==="|")this.current=this.newToken(Qe,"||"),this.pos++;else return!1;else if(e==="=")this.expression.charAt(this.pos+1)==="="?(this.current=this.newToken(Qe,"=="),this.pos++):this.current=this.newToken(Qe,e);else if(e==="!")this.expression.charAt(this.pos+1)==="="?(this.current=this.newToken(Qe,"!="),this.pos++):this.current=this.newToken(Qe,e);else return!1;return this.pos++,this.isOperatorEnabled(this.current.value)?!0:(this.pos=r,!1)};ct.prototype.isOperatorEnabled=function(r){return this.parser.isOperatorEnabled(r)};ct.prototype.getCoordinates=function(){var r=0,e,t=-1;do r++,e=this.pos-t,t=this.expression.indexOf(` -`,t+1);while(t>=0&&t"u"?!0:Array.isArray(e)?Qs(e,r.value):typeof e=="function"?e(r):r.value===e};tt.prototype.save=function(){this.savedCurrent=this.current,this.savedNextToken=this.nextToken,this.tokens.save()};tt.prototype.restore=function(){this.tokens.restore(),this.current=this.savedCurrent,this.nextToken=this.savedNextToken};tt.prototype.accept=function(r,e){return this.nextToken.type===r&&this.tokenMatches(this.nextToken,e)?(this.next(),!0):!1};tt.prototype.expect=function(r,e){if(!this.accept(r,e)){var t=this.tokens.getCoordinates();throw new Error("parse error ["+t.line+":"+t.column+"]: Expected "+(e||r))}};tt.prototype.parseAtom=function(r){var e=this.tokens.unaryOps;function t(s){return s.value in e}if(this.accept(ld)||this.accept(Qe,t))r.push(new We(lr,this.current.value));else if(this.accept(dl))r.push(new We(ti,this.current.value));else if(this.accept(lg))r.push(new We(ti,this.current.value));else if(this.accept(hr,"("))this.parseExpression(r),this.expect(hr,")");else if(this.accept(mn,"["))if(this.accept(mn,"]"))r.push(new We(fn,0));else{var i=this.parseArrayList(r);r.push(new We(fn,i))}else throw new Error("unexpected "+this.nextToken)};tt.prototype.parseExpression=function(r){var e=[];this.parseUntilEndStatement(r,e)||(this.parseVariableAssignmentExpression(e),!this.parseUntilEndStatement(r,e)&&this.pushExpression(r,e))};tt.prototype.pushExpression=function(r,e){for(var t=0,i=e.length;t=",">","in"];tt.prototype.parseComparison=function(r){for(this.parseAddSub(r);this.accept(Qe,__);){var e=this.current;this.parseAddSub(r),r.push(cr(e.value))}};var E_=["+","-","||"];tt.prototype.parseAddSub=function(r){for(this.parseTerm(r);this.accept(Qe,E_);){var e=this.current;this.parseTerm(r),r.push(cr(e.value))}};var T_=["*","/","%"];tt.prototype.parseTerm=function(r){for(this.parseFactor(r);this.accept(Qe,T_);){var e=this.current;this.parseFactor(r),r.push(cr(e.value))}};tt.prototype.parseFactor=function(r){var e=this.tokens.unaryOps;function t(s){return s.value in e}if(this.save(),this.accept(Qe,t)){if(this.current.value!=="-"&&this.current.value!=="+"){if(this.nextToken.type===hr&&this.nextToken.value==="("){this.restore(),this.parseExponential(r);return}else if(this.nextToken.type===hd||this.nextToken.type===ul||this.nextToken.type===oa||this.nextToken.type===hr&&this.nextToken.value===")"){this.restore(),this.parseAtom(r);return}}var i=this.current;this.parseFactor(r),r.push(cl(i.value))}else this.parseExponential(r)};tt.prototype.parseExponential=function(r){for(this.parsePostfixExpression(r);this.accept(Qe,"^");)this.parseFactor(r),r.push(cr("^"))};tt.prototype.parsePostfixExpression=function(r){for(this.parseFunctionCall(r);this.accept(Qe,"!");)r.push(cl("!"))};tt.prototype.parseFunctionCall=function(r){var e=this.tokens.unaryOps;function t(n){return n.value in e}if(this.accept(Qe,t)){var i=this.current;this.parseAtom(r),r.push(cl(i.value))}else for(this.parseMemberExpression(r);this.accept(hr,"(");)if(this.accept(hr,")"))r.push(new We(pn,0));else{var s=this.parseArgumentList(r);r.push(new We(pn,s))}};tt.prototype.parseArgumentList=function(r){for(var e=0;!this.accept(hr,")");)for(this.parseExpression(r),++e;this.accept(ul);)this.parseExpression(r),++e;return e};tt.prototype.parseMemberExpression=function(r){for(this.parseAtom(r);this.accept(Qe,".")||this.accept(mn,"[");){var e=this.current;if(e.value==="."){if(!this.allowMemberAccess)throw new Error('unexpected ".", member access is not permitted');this.expect(ld),r.push(new We(Es,this.current.value))}else if(e.value==="["){if(!this.tokens.isOperatorEnabled("["))throw new Error('unexpected "[]", arrays are disabled');this.parseExpression(r),this.expect(mn,"]"),r.push(cr("["))}else throw new Error("unexpected symbol: "+e.value)}};function S_(r,e){return Number(r)+Number(e)}function C_(r,e){return r-e}function M_(r,e){return r*e}function I_(r,e){return r/e}function k_(r,e){return r%e}function B_(r,e){return Array.isArray(r)&&Array.isArray(e)?r.concat(e):""+r+e}function P_(r,e){return r===e}function R_(r,e){return r!==e}function D_(r,e){return r>e}function L_(r,e){return r=e}function F_(r,e){return r<=e}function N_(r,e){return!!(r&&e)}function U_(r,e){return!!(r||e)}function G_(r,e){return Qs(e,r)}function H_(r){return(Math.exp(r)-Math.exp(-r))/2}function W_(r){return(Math.exp(r)+Math.exp(-r))/2}function V_(r){return r===1/0?1:r===-1/0?-1:(Math.exp(r)-Math.exp(-r))/(Math.exp(r)+Math.exp(-r))}function z_(r){return r===-1/0?r:Math.log(r+Math.sqrt(r*r+1))}function j_(r){return Math.log(r+Math.sqrt(r*r-1))}function Y_(r){return Math.log((1+r)/(1-r))/2}function bp(r){return Math.log(r)*Math.LOG10E}function X_(r){return-r}function K_(r){return!r}function q_(r){return r<0?Math.ceil(r):Math.floor(r)}function Q_(r){return Math.random()*(r||1)}function Ap(r){return cd(r+1)}function $_(r){return isFinite(r)&&r===Math.round(r)}var J_=4.7421875,ch=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function cd(r){var e,t;if($_(r)){if(r<=0)return isFinite(r)?1/0:NaN;if(r>171)return 1/0;for(var i=r-2,s=r-1;i>1;)s*=i,i--;return s===0&&(s=1),s}if(r<.5)return Math.PI/(Math.sin(Math.PI*r)*cd(1-r));if(r>=171.35)return 1/0;if(r>85){var n=r*r,a=n*r,o=a*r,l=o*r;return Math.sqrt(2*Math.PI/r)*Math.pow(r/Math.E,r)*(1+1/(12*r)+1/(288*n)-139/(51840*a)-571/(2488320*o)+163879/(209018880*l)+5246819/(75246796800*l*r))}--r,t=ch[0];for(var c=1;c0?(s=i/e,r+=s*s):r+=i}return e===1/0?1/0:e*Math.sqrt(r)}function xp(r,e,t){return r?e:t}function eE(r,e){return typeof e>"u"||+e==0?Math.round(r):(r=+r,e=-+e,isNaN(r)||!(typeof e=="number"&&e%1===0)?NaN:(r=r.toString().split("e"),r=Math.round(+(r[0]+"e"+(r[1]?+r[1]-e:-e))),r=r.toString().split("e"),+(r[0]+"e"+(r[1]?+r[1]+e:e))))}function tE(r,e,t){return t&&(t[r]=e),e}function iE(r,e){return r[e|0]}function rE(r){return arguments.length===1&&Array.isArray(r)?Math.max.apply(Math,r):Math.max.apply(Math,arguments)}function sE(r){return arguments.length===1&&Array.isArray(r)?Math.min.apply(Math,r):Math.min.apply(Math,arguments)}function nE(r,e){if(typeof r!="function")throw new Error("First argument to map is not a function");if(!Array.isArray(e))throw new Error("Second argument to map is not an array");return e.map(function(t,i){return r(t,i)})}function aE(r,e,t){if(typeof r!="function")throw new Error("First argument to fold is not a function");if(!Array.isArray(t))throw new Error("Second argument to fold is not an array");return t.reduce(function(i,s,n){return r(i,s,n)},e)}function oE(r,e){if(typeof r!="function")throw new Error("First argument to filter is not a function");if(!Array.isArray(e))throw new Error("Second argument to filter is not an array");return e.filter(function(t,i){return r(t,i)})}function lE(r,e){if(!(Array.isArray(e)||typeof e=="string"))throw new Error("Second argument to indexOf is not a string or array");return e.indexOf(r)}function hE(r,e){if(!Array.isArray(e))throw new Error("Second argument to join is not an array");return e.join(r)}function cE(r){return(r>0)-(r<0)||+r}var _p=1/3;function dE(r){return r<0?-Math.pow(-r,_p):Math.pow(r,_p)}function uE(r){return Math.exp(r)-1}function pE(r){return Math.log(1+r)}function fE(r){return Math.log(r)/Math.LN2}function Vr(r){this.options=r||{},this.unaryOps={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,sinh:Math.sinh||H_,cosh:Math.cosh||W_,tanh:Math.tanh||V_,asinh:Math.asinh||z_,acosh:Math.acosh||j_,atanh:Math.atanh||Y_,sqrt:Math.sqrt,cbrt:Math.cbrt||dE,log:Math.log,log2:Math.log2||fE,ln:Math.log,lg:Math.log10||bp,log10:Math.log10||bp,expm1:Math.expm1||uE,log1p:Math.log1p||pE,abs:Math.abs,ceil:Math.ceil,floor:Math.floor,round:Math.round,trunc:Math.trunc||q_,"-":X_,"+":Number,exp:Math.exp,not:K_,length:Z_,"!":Ap,sign:Math.sign||cE},this.binaryOps={"+":S_,"-":C_,"*":M_,"/":I_,"%":k_,"^":Math.pow,"||":B_,"==":P_,"!=":R_,">":D_,"<":L_,">=":O_,"<=":F_,and:N_,or:U_,in:G_,"=":tE,"[":iE},this.ternaryOps={"?":xp},this.functions={random:Q_,fac:Ap,min:sE,max:rE,hypot:Math.hypot||wp,pyt:Math.hypot||wp,pow:Math.pow,atan2:Math.atan2,if:xp,gamma:cd,roundTo:eE,map:nE,fold:aE,filter:oE,indexOf:lE,join:hE},this.consts={E:Math.E,PI:Math.PI,true:!0,false:!1}}Vr.prototype.parse=function(r){var e=[],t=new tt(this,new ct(this,r),{allowMemberAccess:this.options.allowMemberAccess});return t.parseExpression(e),t.expect(oa,"EOF"),new Ci(e,this)};Vr.prototype.evaluate=function(r,e){return this.parse(r).evaluate(e)};var cg=new Vr;Vr.parse=function(r){return cg.parse(r)};Vr.evaluate=function(r,e){return cg.parse(r).evaluate(e)};var Ep={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"remainder","^":"power","!":"factorial","<":"comparison",">":"comparison","<=":"comparison",">=":"comparison","==":"comparison","!=":"comparison","||":"concatenate",and:"logical",or:"logical",not:"logical","?":"conditional",":":"conditional","=":"assignment","[":"array","()=":"fndef"};function mE(r){return Ep.hasOwnProperty(r)?Ep[r]:r}Vr.prototype.isOperatorEnabled=function(r){var e=mE(r),t=this.options.operators||{};return!(e in t)||!!t[e]};const yo=[1,1/2,1/3,1/4,1/6,1/8,1/12,1/16,1/24,1/48];function gE(r){for(let e=0;en),r.length==0)return-1;if(e>=t(r[r.length-1])){let n=r.length-1;for(;n>0&&t(r[n-1])==e;)n--;return n}let i=0,s=r.length;for(;i<=s&&i>>1;if(t(r[n])==e){for(;n>0&&t(r[n-1])==e;)n--;return n}t(r[n])e&&(s=n-1)}return Math.max(0,s)}function Ka(r,e,t){if(t=t??(s=>s),r.length==0)return-1;let i=hi(r,e,t);for(;r[i-1]&&t(r[i-1])==e;)i--;return i}function Tp(r,e){return!(Object.keys(r).some(t=>r[t]!=e[t])||Object.keys(e).some(t=>r[t]!=e[t]))}function gn(r){try{return Vr.evaluate(r)}catch{return null}}function Wi(r,e){let t=r.length;if(r.length!=0)for(;t--;)e(r[t],t)&&r[t].destroy()}function Ec(r){return r==""?"":r.slice(0,1).toUpperCase()+r.slice(1).toLowerCase()}function Tc(r){return r.button==2||r.getModifierState("Control")&&ys}function aC(){try{return window.self!==window.top}catch{return!0}}class pl{timingWindowMS;dancePoints;lifeChange;constructor(e,t,i){this.timingWindowMS=e,this.dancePoints=t,this.lifeChange=i}getTimingWindowMS(){return this.timingWindowMS*_.play.timingWindowScale+_.play.timingWindowAdd}}class qa extends pl{target="dropped";constructor(e,t){super(0,e,t)}}class Ps extends pl{noteType;constructor(e,t,i,s){super(t,i,s),this.noteType=e}}const yE="/smeditor/assets/judgmentITG-5390eacd.png",vE="/smeditor/assets/judgmentWaterfall-5bb3f994.png";class rt{static ITG=new rt(yE,["w0","w1","w2","w3","w4","w5","miss"]);static WATERFALL=new rt(vE,["w0","w1","w2","w3","w4","w5","miss"]);texHeight=0;texWidth=0;texture;judgeNames=[];constructor(e,t){this.judgeNames=t,this.loadTex(e)}async loadTex(e){const t=await qs.load(e);this.texture=t,this.texHeight=t.height,this.texWidth=t.width}getTexture(e,t){if(!this.judgeNames.includes(t.id))return;let i=0;const s=this.judgeNames.indexOf(t.id)*this.texHeight/this.judgeNames.length;return e>=0&&(i+=this.texWidth/2),this.texture.frame=new Se(i,s,this.texWidth/2,this.texHeight/this.judgeNames.length),this.texture}}class Qa extends pl{target="mine";constructor(e,t,i){super(e,t,i)}}class vt extends pl{id;name;color;judgmentTexture;constructor(e,t,i,s,n,a,o){super(s,n,a),this.id=e,this.name=t,this.color=i,this.judgmentTexture=o}}const dg=new vt("w0","Fantastic",183528,0,0,0,rt.ITG);class $a extends vt{constructor(e,t,i,s,n){super("miss",e,t,0,i,s,n)}}function Vi(r){return r.color!=null&&r.id!="miss"}function ni(r){return r.color!=null&&r.id=="miss"}function Rr(r){return!!r.noteType}function yn(r){return r.target=="dropped"}function ms(r){return r.target=="mine"}class qe{static COLLECTIONS={ITG:new qe([new vt("w0","Fantastic",2215144,23,5,.008,rt.ITG),new vt("w2","Excellent",14851096,44.5,4,.008,rt.ITG),new vt("w3","Great",6736213,103.5,2,.004,rt.ITG),new vt("w4","Decent",11820287,136.5,0,0,rt.ITG),new vt("w5","Way Off",13206878,181.5,-6,-.05,rt.ITG),new $a("Miss",16724016,-12,-.1,rt.ITG),new Ps("Hold",321.5,5,-.008),new Ps("Roll",351.5,5,-.008),new qa(0,-.08),new Qa(71.5,-6,-.05)],103.5),FA:new qe([new vt("w0","Fantastic",2215144,15,3.5,.008,rt.ITG),new vt("w1","Fantastic",16777215,23,3,.008,rt.ITG),new vt("w2","Excellent",14851096,44.5,2,.008,rt.ITG),new vt("w3","Great",6736213,103.5,1,.004,rt.ITG),new vt("w4","Decent",11820287,136.5,0,0,rt.ITG),new vt("w5","Way Off",13206878,181.5,0,-.05,rt.ITG),new $a("Miss",16724016,0,-.1,rt.ITG),new Ps("Hold",321.5,1,-.008),new Ps("Roll",351.5,1,-.008),new qa(0,-.08),new Qa(71.5,-1,-.05)],103.5),WATERFALL:new qe([new vt("w0","Masterful",16711870,15,10,.008,rt.WATERFALL),new vt("w2","Awesome",16776960,30,9,.008,rt.WATERFALL),new vt("w3","Solid",51200,50,6,.008,rt.WATERFALL),new vt("w4","OK",33023,100,3,.004,rt.WATERFALL),new vt("w5","Fault",8421504,160,0,0,rt.WATERFALL),new $a("Miss",16724016,0,-.1,rt.WATERFALL),new Ps("Hold",300,6,-.008),new Ps("Roll",350,6,-.008),new qa(0,-.08),new Qa(71.5,-3,-.05)],100)};windows=[];holdWindows={};missWindow;droppedWindow;mineWindow;hideLimitMS;constructor(e,t){this.missWindow=new $a("Miss",16724016,-12,-.1,rt.ITG),this.droppedWindow=new qa(0,-.08),this.mineWindow=new Qa(71.5,-1,-.05);for(const i of e)Vi(i)?this.windows.push(i):ni(i)?this.missWindow=i:Rr(i)?this.holdWindows[i.noteType]=i:yn(i)?this.droppedWindow=i:ms(i)&&(this.mineWindow=i);this.windows.sort((i,s)=>i.timingWindowMS-s.timingWindowMS),this.hideLimitMS=t}judgeInput(e){for(const t of this.windows)if(t.getTimingWindowMS()/1e3>=Math.abs(e))return t;return this.missWindow}getHeldJudgement(e){return this.holdWindows[e.type]}getMissJudgment(){return this.missWindow}getDroppedJudgment(){return this.droppedWindow}getMineJudgment(){return this.mineWindow}shouldHideNote(e){return e.id!="miss"&&e.timingWindowMS<=this.hideLimitMS}maxWindowMS(){return this.windows.at(-1)?.getTimingWindowMS()??0}getMaxDancePoints(){return Math.max(...this.windows.map(e=>e.dancePoints),this.missWindow.dancePoints)}getMaxHoldDancePoints(e){return Math.max(this.holdWindows[e].dancePoints??0,this.droppedWindow.dancePoints)}getStandardWindows(){return[...this.windows]}getHoldWindows(){return[...Object.values(this.holdWindows)]}static getCollection(e){return this.COLLECTIONS[e]??this.COLLECTIONS.ITG}static getCollections(){return qe.COLLECTIONS}}class bE{}class Ts extends bE{chordCohesion=new Map;missNoteIndex=0;holdProgress=[];heldCols=new A_;collection=qe.getCollection("ITG");update(e){if(!e.loadedChart||!e.chartView)return;const i=e.chartView.getTimeWithOffset()-this.collection.maxWindowMS()/1e3*_.audio.rate;let s=-1;for(;e.loadedChart.getNotedata()[this.missNoteIndex]&&e.loadedChart.getNotedata()[this.missNoteIndex].second=e.chartView.chart.getSecondsFromBeat(n.beat+n.hold)&&(n.gameplay.hideNote=!0,e.chartView.doJudgment(n,0,this.collection.getHeldJudgement(n)),this.holdProgress.splice(this.holdProgress.indexOf(n),1),e.gameStats?.addHoldDataPoint(n,this.collection.getHeldJudgement(n)))}for(const n of this.heldCols.getHeldCols()){const a=this.getClosestNote(e.loadedChart.getNotedata(),e.chartView.getTimeWithOffset()-this.collection.getMineJudgment().getTimingWindowMS()/2e3,n,["Mine"],this.collection.getMineJudgment().getTimingWindowMS()/2);a&&(a.gameplay.hasHit=!0,a.gameplay.hideNote=!0,e.chartView.doJudgment(a,0,this.collection.getMineJudgment()),e.gameStats?.addDataPoint([a],this.collection.getMineJudgment(),0),e.mine.play())}}endPlay(e){if(!e.loadedChart||!e.chartView)return;this.collection=qe.getCollection(_.play.timingCollection),this.chordCohesion.clear();for(const n of e.loadedChart.getNotedata())n.type=="Mine"||n.fake||(this.chordCohesion.has(n.beat)||this.chordCohesion.set(n.beat,[]),this.chordCohesion.get(n.beat).push(n));const i=e.chartView.getTimeWithOffset()-this.collection.maxWindowMS()/1e3*_.audio.rate;let s=hi(e.loadedChart.getNotedata(),i,n=>n.second)+1;s>=1&&i<=e.loadedChart.getNotedata()[s-1].second&&s--,this.missNoteIndex=s,this.holdProgress=[],this.heldCols.reset()}keyDown(e,t){if(!e.loadedChart||!e.chartView)return;const i=e.chartView.getTimeWithOffset(),s=this.getClosestNote(e.loadedChart.getNotedata(),i,t,["Tap","Hold","Roll"]);this.heldCols.keyDown(t);for(const n of this.holdProgress)n.type=="Roll"&&n.col==t&&(n.gameplay.lastHoldActivation=Date.now());s?this.hitNote(e,s,i):e.chartView.keyDown(t)}keyUp(e,t){if(!e.loadedChart||!e.chartView)return;const i=e.chartView.getTimeWithOffset(),s=this.getClosestNote(e.loadedChart.getNotedata(),i,t,["Lift"]);this.heldCols.keyUp(t),e.chartView.keyUp(t),s&&this.hitNote(e,s,i)}shouldAssistTick(e){return!e.fake&&e.type!="Mine"}hitNote(e,t,i){t.gameplay.hasHit=!0,Be(t)&&(t.gameplay.lastHoldActivation=Date.now(),e.chartView.activateHold(t.col),this.holdProgress.push(t));const s=this.chordCohesion.get(t.beat);if(s.every(n=>n.gameplay.hasHit)){const n=this.collection.judgeInput((i-t.second)/_.audio.rate),a=this.collection.shouldHideNote(n);s.forEach(o=>{e.chartView.doJudgment(o,(i-o.second)/_.audio.rate,n),a&&b_(o)&&(o.gameplay.hideNote=!0)}),e.gameStats?.addDataPoint(s,n,(i-t.second)/_.audio.rate)}}getClosestNote(e,t,i,s,n){n=n??this.collection.maxWindowMS(),n*=_.audio.rate;const a=t-n/1e3,o=t+n/1e3;let l=hi(e,a,u=>u.second)+1;l>=1&&a<=e[l-1].second&&l--;let c;for(;e[l]&&e[l].second<=o;){const u=e[l];if(u.gameplay.hasHit||u.col!=i||u.fake||!s.includes(u.type)){l++;continue}(!c||Math.abs(u.second-t)=i.getTimingWindowMS():!1}}function sr(r,e,t){return r*(1-t)+e*t}function Ai(r,e,t){return(t-r)/(e-r)}function ne(r,e){return Math.round(r*Math.pow(10,e))/Math.pow(10,e)}function Ve(r,e,t){return Math.max(e,Math.min(t,r))}function ug(r){if(r.length==0)return 0;const e=r.length,t=r.reduce((i,s)=>i+s)/e;return Math.sqrt(r.map(i=>Math.pow(i-t,2)).reduce((i,s)=>i+s)/e)}function fl(r){if(r.length==0)return 0;r=[...r],r.sort((t,i)=>t-i);const e=Math.floor(r.length/2);return r.length%2?r[e]:(r[e-1]+r[e])/2}function AE(r){return r.length==0?0:r.reduce((e,t)=>e+t)/r.length}function pg(r,e){return e?pg(e,r%e):e===0?r:NaN}function fg(r,e){return r*e/pg(r,e)}function Sp(r){let e=1;for(let t=0;t({col:c.col,beat:c.beat+c.hold})).sort((c,u)=>c.beat-u.beat),a=e.at(-1),o=a.beat+(Be(a)?a.hold:0);let l=Math.ceil(o/4);o%4==0&&l++;for(let c=0;c=0&&t"u"?!0:Array.isArray(e)?Qs(e,r.value):typeof e=="function"?e(r):r.value===e};tt.prototype.save=function(){this.savedCurrent=this.current,this.savedNextToken=this.nextToken,this.tokens.save()};tt.prototype.restore=function(){this.tokens.restore(),this.current=this.savedCurrent,this.nextToken=this.savedNextToken};tt.prototype.accept=function(r,e){return this.nextToken.type===r&&this.tokenMatches(this.nextToken,e)?(this.next(),!0):!1};tt.prototype.expect=function(r,e){if(!this.accept(r,e)){var t=this.tokens.getCoordinates();throw new Error("parse error ["+t.line+":"+t.column+"]: Expected "+(e||r))}};tt.prototype.parseAtom=function(r){var e=this.tokens.unaryOps;function t(s){return s.value in e}if(this.accept(ld)||this.accept(Qe,t))r.push(new We(hr,this.current.value));else if(this.accept(dl))r.push(new We(ti,this.current.value));else if(this.accept(lg))r.push(new We(ti,this.current.value));else if(this.accept(cr,"("))this.parseExpression(r),this.expect(cr,")");else if(this.accept(mn,"["))if(this.accept(mn,"]"))r.push(new We(fn,0));else{var i=this.parseArrayList(r);r.push(new We(fn,i))}else throw new Error("unexpected "+this.nextToken)};tt.prototype.parseExpression=function(r){var e=[];this.parseUntilEndStatement(r,e)||(this.parseVariableAssignmentExpression(e),!this.parseUntilEndStatement(r,e)&&this.pushExpression(r,e))};tt.prototype.pushExpression=function(r,e){for(var t=0,i=e.length;t=",">","in"];tt.prototype.parseComparison=function(r){for(this.parseAddSub(r);this.accept(Qe,__);){var e=this.current;this.parseAddSub(r),r.push(dr(e.value))}};var E_=["+","-","||"];tt.prototype.parseAddSub=function(r){for(this.parseTerm(r);this.accept(Qe,E_);){var e=this.current;this.parseTerm(r),r.push(dr(e.value))}};var T_=["*","/","%"];tt.prototype.parseTerm=function(r){for(this.parseFactor(r);this.accept(Qe,T_);){var e=this.current;this.parseFactor(r),r.push(dr(e.value))}};tt.prototype.parseFactor=function(r){var e=this.tokens.unaryOps;function t(s){return s.value in e}if(this.save(),this.accept(Qe,t)){if(this.current.value!=="-"&&this.current.value!=="+"){if(this.nextToken.type===cr&&this.nextToken.value==="("){this.restore(),this.parseExponential(r);return}else if(this.nextToken.type===hd||this.nextToken.type===ul||this.nextToken.type===oa||this.nextToken.type===cr&&this.nextToken.value===")"){this.restore(),this.parseAtom(r);return}}var i=this.current;this.parseFactor(r),r.push(cl(i.value))}else this.parseExponential(r)};tt.prototype.parseExponential=function(r){for(this.parsePostfixExpression(r);this.accept(Qe,"^");)this.parseFactor(r),r.push(dr("^"))};tt.prototype.parsePostfixExpression=function(r){for(this.parseFunctionCall(r);this.accept(Qe,"!");)r.push(cl("!"))};tt.prototype.parseFunctionCall=function(r){var e=this.tokens.unaryOps;function t(n){return n.value in e}if(this.accept(Qe,t)){var i=this.current;this.parseAtom(r),r.push(cl(i.value))}else for(this.parseMemberExpression(r);this.accept(cr,"(");)if(this.accept(cr,")"))r.push(new We(pn,0));else{var s=this.parseArgumentList(r);r.push(new We(pn,s))}};tt.prototype.parseArgumentList=function(r){for(var e=0;!this.accept(cr,")");)for(this.parseExpression(r),++e;this.accept(ul);)this.parseExpression(r),++e;return e};tt.prototype.parseMemberExpression=function(r){for(this.parseAtom(r);this.accept(Qe,".")||this.accept(mn,"[");){var e=this.current;if(e.value==="."){if(!this.allowMemberAccess)throw new Error('unexpected ".", member access is not permitted');this.expect(ld),r.push(new We(Es,this.current.value))}else if(e.value==="["){if(!this.tokens.isOperatorEnabled("["))throw new Error('unexpected "[]", arrays are disabled');this.parseExpression(r),this.expect(mn,"]"),r.push(dr("["))}else throw new Error("unexpected symbol: "+e.value)}};function S_(r,e){return Number(r)+Number(e)}function C_(r,e){return r-e}function M_(r,e){return r*e}function I_(r,e){return r/e}function k_(r,e){return r%e}function B_(r,e){return Array.isArray(r)&&Array.isArray(e)?r.concat(e):""+r+e}function P_(r,e){return r===e}function R_(r,e){return r!==e}function D_(r,e){return r>e}function L_(r,e){return r=e}function F_(r,e){return r<=e}function N_(r,e){return!!(r&&e)}function U_(r,e){return!!(r||e)}function G_(r,e){return Qs(e,r)}function H_(r){return(Math.exp(r)-Math.exp(-r))/2}function W_(r){return(Math.exp(r)+Math.exp(-r))/2}function V_(r){return r===1/0?1:r===-1/0?-1:(Math.exp(r)-Math.exp(-r))/(Math.exp(r)+Math.exp(-r))}function z_(r){return r===-1/0?r:Math.log(r+Math.sqrt(r*r+1))}function j_(r){return Math.log(r+Math.sqrt(r*r-1))}function Y_(r){return Math.log((1+r)/(1-r))/2}function bp(r){return Math.log(r)*Math.LOG10E}function X_(r){return-r}function K_(r){return!r}function q_(r){return r<0?Math.ceil(r):Math.floor(r)}function Q_(r){return Math.random()*(r||1)}function Ap(r){return cd(r+1)}function $_(r){return isFinite(r)&&r===Math.round(r)}var J_=4.7421875,ch=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function cd(r){var e,t;if($_(r)){if(r<=0)return isFinite(r)?1/0:NaN;if(r>171)return 1/0;for(var i=r-2,s=r-1;i>1;)s*=i,i--;return s===0&&(s=1),s}if(r<.5)return Math.PI/(Math.sin(Math.PI*r)*cd(1-r));if(r>=171.35)return 1/0;if(r>85){var n=r*r,a=n*r,o=a*r,l=o*r;return Math.sqrt(2*Math.PI/r)*Math.pow(r/Math.E,r)*(1+1/(12*r)+1/(288*n)-139/(51840*a)-571/(2488320*o)+163879/(209018880*l)+5246819/(75246796800*l*r))}--r,t=ch[0];for(var c=1;c0?(s=i/e,r+=s*s):r+=i}return e===1/0?1/0:e*Math.sqrt(r)}function xp(r,e,t){return r?e:t}function eE(r,e){return typeof e>"u"||+e==0?Math.round(r):(r=+r,e=-+e,isNaN(r)||!(typeof e=="number"&&e%1===0)?NaN:(r=r.toString().split("e"),r=Math.round(+(r[0]+"e"+(r[1]?+r[1]-e:-e))),r=r.toString().split("e"),+(r[0]+"e"+(r[1]?+r[1]+e:e))))}function tE(r,e,t){return t&&(t[r]=e),e}function iE(r,e){return r[e|0]}function rE(r){return arguments.length===1&&Array.isArray(r)?Math.max.apply(Math,r):Math.max.apply(Math,arguments)}function sE(r){return arguments.length===1&&Array.isArray(r)?Math.min.apply(Math,r):Math.min.apply(Math,arguments)}function nE(r,e){if(typeof r!="function")throw new Error("First argument to map is not a function");if(!Array.isArray(e))throw new Error("Second argument to map is not an array");return e.map(function(t,i){return r(t,i)})}function aE(r,e,t){if(typeof r!="function")throw new Error("First argument to fold is not a function");if(!Array.isArray(t))throw new Error("Second argument to fold is not an array");return t.reduce(function(i,s,n){return r(i,s,n)},e)}function oE(r,e){if(typeof r!="function")throw new Error("First argument to filter is not a function");if(!Array.isArray(e))throw new Error("Second argument to filter is not an array");return e.filter(function(t,i){return r(t,i)})}function lE(r,e){if(!(Array.isArray(e)||typeof e=="string"))throw new Error("Second argument to indexOf is not a string or array");return e.indexOf(r)}function hE(r,e){if(!Array.isArray(e))throw new Error("Second argument to join is not an array");return e.join(r)}function cE(r){return(r>0)-(r<0)||+r}var _p=1/3;function dE(r){return r<0?-Math.pow(-r,_p):Math.pow(r,_p)}function uE(r){return Math.exp(r)-1}function pE(r){return Math.log(1+r)}function fE(r){return Math.log(r)/Math.LN2}function Vr(r){this.options=r||{},this.unaryOps={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,sinh:Math.sinh||H_,cosh:Math.cosh||W_,tanh:Math.tanh||V_,asinh:Math.asinh||z_,acosh:Math.acosh||j_,atanh:Math.atanh||Y_,sqrt:Math.sqrt,cbrt:Math.cbrt||dE,log:Math.log,log2:Math.log2||fE,ln:Math.log,lg:Math.log10||bp,log10:Math.log10||bp,expm1:Math.expm1||uE,log1p:Math.log1p||pE,abs:Math.abs,ceil:Math.ceil,floor:Math.floor,round:Math.round,trunc:Math.trunc||q_,"-":X_,"+":Number,exp:Math.exp,not:K_,length:Z_,"!":Ap,sign:Math.sign||cE},this.binaryOps={"+":S_,"-":C_,"*":M_,"/":I_,"%":k_,"^":Math.pow,"||":B_,"==":P_,"!=":R_,">":D_,"<":L_,">=":O_,"<=":F_,and:N_,or:U_,in:G_,"=":tE,"[":iE},this.ternaryOps={"?":xp},this.functions={random:Q_,fac:Ap,min:sE,max:rE,hypot:Math.hypot||wp,pyt:Math.hypot||wp,pow:Math.pow,atan2:Math.atan2,if:xp,gamma:cd,roundTo:eE,map:nE,fold:aE,filter:oE,indexOf:lE,join:hE},this.consts={E:Math.E,PI:Math.PI,true:!0,false:!1}}Vr.prototype.parse=function(r){var e=[],t=new tt(this,new ct(this,r),{allowMemberAccess:this.options.allowMemberAccess});return t.parseExpression(e),t.expect(oa,"EOF"),new Ci(e,this)};Vr.prototype.evaluate=function(r,e){return this.parse(r).evaluate(e)};var cg=new Vr;Vr.parse=function(r){return cg.parse(r)};Vr.evaluate=function(r,e){return cg.parse(r).evaluate(e)};var Ep={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"remainder","^":"power","!":"factorial","<":"comparison",">":"comparison","<=":"comparison",">=":"comparison","==":"comparison","!=":"comparison","||":"concatenate",and:"logical",or:"logical",not:"logical","?":"conditional",":":"conditional","=":"assignment","[":"array","()=":"fndef"};function mE(r){return Ep.hasOwnProperty(r)?Ep[r]:r}Vr.prototype.isOperatorEnabled=function(r){var e=mE(r),t=this.options.operators||{};return!(e in t)||!!t[e]};const yo=[1,1/2,1/3,1/4,1/6,1/8,1/12,1/16,1/24,1/48];function gE(r){for(let e=0;en),r.length==0)return-1;if(e>=t(r[r.length-1])){let n=r.length-1;for(;n>0&&t(r[n-1])==e;)n--;return n}let i=0,s=r.length;for(;i<=s&&i>>1;if(t(r[n])==e){for(;n>0&&t(r[n-1])==e;)n--;return n}t(r[n])e&&(s=n-1)}return Math.max(0,s)}function Ka(r,e,t){if(t=t??(s=>s),r.length==0)return-1;let i=hi(r,e,t);for(;r[i-1]&&t(r[i-1])==e;)i--;return i}function Tp(r,e){return!(Object.keys(r).some(t=>r[t]!=e[t])||Object.keys(e).some(t=>r[t]!=e[t]))}function gn(r){try{return Vr.evaluate(r)}catch{return null}}function Wi(r,e){let t=r.length;if(r.length!=0)for(;t--;)e(r[t],t)&&r[t].destroy()}function Ec(r){return r==""?"":r.slice(0,1).toUpperCase()+r.slice(1).toLowerCase()}function Tc(r){return r.button==2||r.getModifierState("Control")&&ys}function aC(){try{return window.self!==window.top}catch{return!0}}class pl{timingWindowMS;dancePoints;lifeChange;constructor(e,t,i){this.timingWindowMS=e,this.dancePoints=t,this.lifeChange=i}getTimingWindowMS(){return this.timingWindowMS*_.play.timingWindowScale+_.play.timingWindowAdd}}class qa extends pl{target="dropped";constructor(e,t){super(0,e,t)}}class Ps extends pl{noteType;constructor(e,t,i,s){super(t,i,s),this.noteType=e}}const yE="/smeditor/assets/judgmentITG-5390eacd.png",vE="/smeditor/assets/judgmentWaterfall-5bb3f994.png";class rt{static ITG=new rt(yE,["w0","w1","w2","w3","w4","w5","miss"]);static WATERFALL=new rt(vE,["w0","w1","w2","w3","w4","w5","miss"]);texHeight=0;texWidth=0;texture;judgeNames=[];constructor(e,t){this.judgeNames=t,this.loadTex(e)}async loadTex(e){const t=await qs.load(e);this.texture=t,this.texHeight=t.height,this.texWidth=t.width}getTexture(e,t){if(!this.judgeNames.includes(t.id))return;let i=0;const s=this.judgeNames.indexOf(t.id)*this.texHeight/this.judgeNames.length;return e>=0&&(i+=this.texWidth/2),this.texture.frame=new Se(i,s,this.texWidth/2,this.texHeight/this.judgeNames.length),this.texture}}class Qa extends pl{target="mine";constructor(e,t,i){super(e,t,i)}}class vt extends pl{id;name;color;judgmentTexture;constructor(e,t,i,s,n,a,o){super(s,n,a),this.id=e,this.name=t,this.color=i,this.judgmentTexture=o}}const dg=new vt("w0","Fantastic",183528,0,0,0,rt.ITG);class $a extends vt{constructor(e,t,i,s,n){super("miss",e,t,0,i,s,n)}}function Vi(r){return r.color!=null&&r.id!="miss"}function ni(r){return r.color!=null&&r.id=="miss"}function Dr(r){return!!r.noteType}function yn(r){return r.target=="dropped"}function ms(r){return r.target=="mine"}class qe{static COLLECTIONS={ITG:new qe([new vt("w0","Fantastic",2215144,23,5,.008,rt.ITG),new vt("w2","Excellent",14851096,44.5,4,.008,rt.ITG),new vt("w3","Great",6736213,103.5,2,.004,rt.ITG),new vt("w4","Decent",11820287,136.5,0,0,rt.ITG),new vt("w5","Way Off",13206878,181.5,-6,-.05,rt.ITG),new $a("Miss",16724016,-12,-.1,rt.ITG),new Ps("Hold",321.5,5,-.008),new Ps("Roll",351.5,5,-.008),new qa(0,-.08),new Qa(71.5,-6,-.05)],103.5),FA:new qe([new vt("w0","Fantastic",2215144,15,3.5,.008,rt.ITG),new vt("w1","Fantastic",16777215,23,3,.008,rt.ITG),new vt("w2","Excellent",14851096,44.5,2,.008,rt.ITG),new vt("w3","Great",6736213,103.5,1,.004,rt.ITG),new vt("w4","Decent",11820287,136.5,0,0,rt.ITG),new vt("w5","Way Off",13206878,181.5,0,-.05,rt.ITG),new $a("Miss",16724016,0,-.1,rt.ITG),new Ps("Hold",321.5,1,-.008),new Ps("Roll",351.5,1,-.008),new qa(0,-.08),new Qa(71.5,-1,-.05)],103.5),WATERFALL:new qe([new vt("w0","Masterful",16711870,15,10,.008,rt.WATERFALL),new vt("w2","Awesome",16776960,30,9,.008,rt.WATERFALL),new vt("w3","Solid",51200,50,6,.008,rt.WATERFALL),new vt("w4","OK",33023,100,3,.004,rt.WATERFALL),new vt("w5","Fault",8421504,160,0,0,rt.WATERFALL),new $a("Miss",16724016,0,-.1,rt.WATERFALL),new Ps("Hold",300,6,-.008),new Ps("Roll",350,6,-.008),new qa(0,-.08),new Qa(71.5,-3,-.05)],100)};windows=[];holdWindows={};missWindow;droppedWindow;mineWindow;hideLimitMS;constructor(e,t){this.missWindow=new $a("Miss",16724016,-12,-.1,rt.ITG),this.droppedWindow=new qa(0,-.08),this.mineWindow=new Qa(71.5,-1,-.05);for(const i of e)Vi(i)?this.windows.push(i):ni(i)?this.missWindow=i:Dr(i)?this.holdWindows[i.noteType]=i:yn(i)?this.droppedWindow=i:ms(i)&&(this.mineWindow=i);this.windows.sort((i,s)=>i.timingWindowMS-s.timingWindowMS),this.hideLimitMS=t}judgeInput(e){for(const t of this.windows)if(t.getTimingWindowMS()/1e3>=Math.abs(e))return t;return this.missWindow}getHeldJudgement(e){return this.holdWindows[e.type]}getMissJudgment(){return this.missWindow}getDroppedJudgment(){return this.droppedWindow}getMineJudgment(){return this.mineWindow}shouldHideNote(e){return e.id!="miss"&&e.timingWindowMS<=this.hideLimitMS}maxWindowMS(){return this.windows.at(-1)?.getTimingWindowMS()??0}getMaxDancePoints(){return Math.max(...this.windows.map(e=>e.dancePoints),this.missWindow.dancePoints)}getMaxHoldDancePoints(e){return Math.max(this.holdWindows[e].dancePoints??0,this.droppedWindow.dancePoints)}getStandardWindows(){return[...this.windows]}getHoldWindows(){return[...Object.values(this.holdWindows)]}static getCollection(e){return this.COLLECTIONS[e]??this.COLLECTIONS.ITG}static getCollections(){return qe.COLLECTIONS}}class bE{}class Ts extends bE{chordCohesion=new Map;missNoteIndex=0;holdProgress=[];heldCols=new A_;collection=qe.getCollection("ITG");update(e){if(!e.loadedChart||!e.chartView)return;const i=e.chartView.getTimeWithOffset()-this.collection.maxWindowMS()/1e3*_.audio.rate;let s=-1;for(;e.loadedChart.getNotedata()[this.missNoteIndex]&&e.loadedChart.getNotedata()[this.missNoteIndex].second=e.chartView.chart.getSecondsFromBeat(n.beat+n.hold)&&(n.gameplay.hideNote=!0,e.chartView.doJudgment(n,0,this.collection.getHeldJudgement(n)),this.holdProgress.splice(this.holdProgress.indexOf(n),1),e.gameStats?.addHoldDataPoint(n,this.collection.getHeldJudgement(n)))}for(const n of this.heldCols.getHeldCols()){const a=this.getClosestNote(e.loadedChart.getNotedata(),e.chartView.getTimeWithOffset()-this.collection.getMineJudgment().getTimingWindowMS()/2e3,n,["Mine"],this.collection.getMineJudgment().getTimingWindowMS()/2);a&&(a.gameplay.hasHit=!0,a.gameplay.hideNote=!0,e.chartView.doJudgment(a,0,this.collection.getMineJudgment()),e.gameStats?.addDataPoint([a],this.collection.getMineJudgment(),0),e.mine.play())}}endPlay(e){if(!e.loadedChart||!e.chartView)return;this.collection=qe.getCollection(_.play.timingCollection),this.chordCohesion.clear();for(const n of e.loadedChart.getNotedata())n.type=="Mine"||n.fake||(this.chordCohesion.has(n.beat)||this.chordCohesion.set(n.beat,[]),this.chordCohesion.get(n.beat).push(n));const i=e.chartView.getTimeWithOffset()-this.collection.maxWindowMS()/1e3*_.audio.rate;let s=hi(e.loadedChart.getNotedata(),i,n=>n.second)+1;s>=1&&i<=e.loadedChart.getNotedata()[s-1].second&&s--,this.missNoteIndex=s,this.holdProgress=[],this.heldCols.reset()}keyDown(e,t){if(!e.loadedChart||!e.chartView)return;const i=e.chartView.getTimeWithOffset(),s=this.getClosestNote(e.loadedChart.getNotedata(),i,t,["Tap","Hold","Roll"]);this.heldCols.keyDown(t);for(const n of this.holdProgress)n.type=="Roll"&&n.col==t&&(n.gameplay.lastHoldActivation=Date.now());s?this.hitNote(e,s,i):e.chartView.keyDown(t)}keyUp(e,t){if(!e.loadedChart||!e.chartView)return;const i=e.chartView.getTimeWithOffset(),s=this.getClosestNote(e.loadedChart.getNotedata(),i,t,["Lift"]);this.heldCols.keyUp(t),e.chartView.keyUp(t),s&&this.hitNote(e,s,i)}shouldAssistTick(e){return!e.fake&&e.type!="Mine"}hitNote(e,t,i){t.gameplay.hasHit=!0,Be(t)&&(t.gameplay.lastHoldActivation=Date.now(),e.chartView.activateHold(t.col),this.holdProgress.push(t));const s=this.chordCohesion.get(t.beat);if(s.every(n=>n.gameplay.hasHit)){const n=this.collection.judgeInput((i-t.second)/_.audio.rate),a=this.collection.shouldHideNote(n);s.forEach(o=>{e.chartView.doJudgment(o,(i-o.second)/_.audio.rate,n),a&&b_(o)&&(o.gameplay.hideNote=!0)}),e.gameStats?.addDataPoint(s,n,(i-t.second)/_.audio.rate)}}getClosestNote(e,t,i,s,n){n=n??this.collection.maxWindowMS(),n*=_.audio.rate;const a=t-n/1e3,o=t+n/1e3;let l=hi(e,a,u=>u.second)+1;l>=1&&a<=e[l-1].second&&l--;let c;for(;e[l]&&e[l].second<=o;){const u=e[l];if(u.gameplay.hasHit||u.col!=i||u.fake||!s.includes(u.type)){l++;continue}(!c||Math.abs(u.second-t)=i.getTimingWindowMS():!1}}function sr(r,e,t){return r*(1-t)+e*t}function Ai(r,e,t){return(t-r)/(e-r)}function ne(r,e){return Math.round(r*Math.pow(10,e))/Math.pow(10,e)}function Ve(r,e,t){return Math.max(e,Math.min(t,r))}function ug(r){if(r.length==0)return 0;const e=r.length,t=r.reduce((i,s)=>i+s)/e;return Math.sqrt(r.map(i=>Math.pow(i-t,2)).reduce((i,s)=>i+s)/e)}function fl(r){if(r.length==0)return 0;r=[...r],r.sort((t,i)=>t-i);const e=Math.floor(r.length/2);return r.length%2?r[e]:(r[e-1]+r[e])/2}function AE(r){return r.length==0?0:r.reduce((e,t)=>e+t)/r.length}function pg(r,e){return e?pg(e,r%e):e===0?r:NaN}function fg(r,e){return r*e/pg(r,e)}function Sp(r){let e=1;for(let t=0;t({col:c.col,beat:c.beat+c.hold})).sort((c,u)=>c.beat-u.beat),a=e.at(-1),o=a.beat+(Be(a)?a.hold:0);let l=Math.ceil(o/4);o%4==0&&l++;for(let c=0;cWo(f.beat))),Sp(d.map(f=>Wo(f.beat)))));for(let f=0;f=t.numCols);h++){const d=a*4+l/o.length*4;let p=c[h];if(p=="{"||p=="["){let f="";for(h++;hn[c]?n[c]=void 0:n[c]1&&t.Jumps++,s+l>2&&t.Hands++,s=0,i=o.beat}if(o.type!="Mine"&&!o.fake&&s++,o.fake){t.Fakes++;continue}switch(o.type){case"Tap":t.Taps++;break;case"Hold":t.Holds++;break;case"Roll":t.Rolls++;break;case"Lift":t.Lifts++;break;case"Mine":t.Mines++;break}Be(o)&&(n[o.col]=o.beat+o.hold)}let a=0;for(let o=0;o1&&t.Jumps++,s+a>2&&t.Hands++,t}getNPSGraph(e,t){const i=e.at(-1);if(!i)return[];let s=i.beat;Be(i)&&(s+=i.hold);const n=[];let a=0;for(;e[a];){const o=Math.floor(t.getMeasure(e[a].beat)),l=t.getBeatFromMeasure(o),c=t.getBeatFromMeasure(o+1),u=t.getSecondsFromBeat(c)-t.getSecondsFromBeat(l);if(u<=.05){for(;e[a]?.beatt+i,0),Ke.gameTypes[e.id]=e,this.priority.push(e)}static getPriority(){return this.priority}static getGameType(e){return Ke.gameTypes[e]}static getTypes(){return this.gameTypes}}Ke.register({id:"dance-single",numCols:4,columnWidths:[64,64,64,64],columnRotations:[0,-90,90,180],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[3,1,2,0],vertical:[0,2,1,3]}});Ke.register({id:"dance-double",numCols:8,columnWidths:[64,64,64,64,64,64,64,64],columnRotations:[0,-90,90,180,0,-90,90,180],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[3,1,2,0,7,5,6,4],vertical:[0,2,1,3,4,6,5,7]}});Ke.register({id:"dance-couple",numCols:8,columnWidths:[64,64,64,64,64,64,64,64],columnRotations:[0,-90,90,180,0,-90,90,180],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[3,1,2,0,7,5,6,4],vertical:[0,2,1,3,4,6,5,7]}});Ke.register({id:"dance-solo",numCols:6,columnWidths:[64,64,64,64,64,64],columnRotations:[0,45,-90,90,135,180],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[5,4,2,3,1,0],vertical:[0,1,3,2,4,5]}});Ke.register({id:"dance-solodouble",numCols:12,columnWidths:[64,64,64,64,64,64,64,64,64,64,64,64],columnRotations:[0,45,-90,90,135,180,0,45,-90,90,135,180],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[5,4,2,3,1,0,11,10,8,9,7,6],vertical:[0,1,3,2,4,5,6,7,9,8,10,11]}});Ke.register({id:"dance-threepanel",numCols:3,columnWidths:[64,64,64],columnRotations:[45,-90,135],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[2,1,0],vertical:[0,1,2]}});Ke.register({id:"dance-threedouble",numCols:6,columnWidths:[64,64,64,64,64,64],columnRotations:[45,-90,135,45,-90,135],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[2,1,0,5,4,3],vertical:[0,1,2,3,4,5]}});function oC(){const r=new URLSearchParams(location.search),e=r.get("flags");if(e!=null){const n=new Set(e.split("").map(a=>TE[a]).filter(a=>a));for(const a of n.values())Ie[a]=!Ie[a]}const t=r.get("url");if(t!=null)try{Ie.url=new URL(t).toString()}catch{Ce.createFormatted("Invalid url "+t,"warn"),Ie.url=null}const i=r.get("chartIndex");if(i!=null)try{Ie.chartIndex=parseInt(i)}catch{Ce.createFormatted("Invalid chartIndex "+i,"warn"),Ie.chartIndex=null}const s=r.get("chartType");s!==null&&(Ke.getGameType(s)?Ie.chartType=s:(Ce.createFormatted("Invalid chartType "+s,"warn"),Ie.chartType=null))}const EE={viewMode:{char:"V",name:"Force view mode (disables record mode)"},menuBar:{char:"M",name:"Hide menu bar"},chartList:{char:"C",name:"Hide chart list (in development)"},barlines:{char:"B",name:"Hide barlines, waveform, and timing boxes"},assist:{char:"A",name:"Disable assist sounds"},recordMode:{char:"R",name:"Disable record mode"},playMode:{char:"P",name:"Disable play mode"},layout:{char:"L",name:"Hide note layout"},status:{char:"S",name:"Hide status bar"},autoPlay:{char:"a",name:"Play automatically"},openWindows:{char:"O",name:"Disable opening windows"},hidePoweredByText:{char:"H",name:'Hide "Powered by SMEditor" text'}},TE=Object.fromEntries(Object.entries(EE).map(([r,e])=>[e.char,r])),Ie={viewMode:!1,menuBar:!0,chartList:!0,barlines:!0,assist:!0,recordMode:!0,playMode:!0,layout:!0,status:!0,autoPlay:!1,hidePoweredByText:!1,openWindows:!0,url:null,chartIndex:null,chartType:null};class Ce{static _view;static messages={};static get view(){return this._view||(this._view=document.getElementById("waterfall"),Ie.menuBar||(this._view.style.top="10px")),this._view}static create(e){if(this.view==null)return;let t=1;if(this.messages[e]&&this.messages[e].type==""){const s=this.messages[e];clearTimeout(s.timeoutID),clearTimeout(s.clearTimeoutID),t=++s.count,this.view.removeChild(s.container)}const i=document.createElement("div");i.innerHTML=e,t>1&&(i.innerHTML+=` (${t})`),i.classList.add("waterfall-item"),Ce.messages[e]={type:"",container:i,timeoutID:setTimeout(()=>{i.classList.add("waterfall-exiting")},5e3),clearTimeoutID:setTimeout(()=>{delete this.messages[e],this.view.removeChild(i)},5500),count:t},this.view.appendChild(i)}static createFormatted(e,t){if(this.view==null)return;let i=1;if(this.messages[e]&&this.messages[e].type==t){const n=this.messages[e];clearTimeout(n.timeoutID),clearTimeout(n.clearTimeoutID),i=++n.count,this.view.removeChild(n.container)}const s=document.createElement("div");s.innerHTML=`
${Ec(t)}:
`+e,i>1&&(s.innerHTML+=` (${i})`),s.classList.add("waterfall-item"),console[t](e),Ce.messages[e]={type:t,container:s,timeoutID:setTimeout(()=>{s.classList.add("waterfall-exiting")},5e3),clearTimeoutID:setTimeout(()=>{delete this.messages[e],this.view.removeChild(s)},5500),count:i},this.view.appendChild(s)}}class $ extends bn{static _instance;static get instance(){return $._instance||($._instance=new $),$._instance}static emit(e,...t){return $.instance.emit(e,...t)}static on(e,t,i){$.instance.on(e,t,i)}static off(e,t,i,s){$.instance.off(e,t,i,s)}}const xi=["Beginner","Easy","Medium","Hard","Challenge","Edit"],Dr=["BPMS","STOPS","WARPS","DELAYS","LABELS","SPEEDS","SCROLLS","TICKCOUNTS","TIMESIGNATURES","COMBOS","FAKES","ATTACKS","BGCHANGES","FGCHANGES"];class mg{gameType=Ke.getPriority()[0];description="";difficulty="Beginner";meter=1;meterF=1;radarValues="0,0,0,0,0";chartName="";chartStyle="";credit="";music;timingData;sm;other_properties={};notedata=[];_notedataStats;_npsGraph;constructor(e,t){if(this.timingData=e.timingData.createChartTimingData(this),this.timingData.reloadCache(),this.sm=e,!t){this.recalculateStats();return}if(e._type=="ssc"){const i=t;for(const n in i)(n=="OFFSET"||Dr.includes(n))&&this.timingData.parse(n,i[n]);this.timingData.reloadCache();const s=Ke.getGameType(i.STEPSTYPE);if(!s)throw Error("Unknown step type "+i.STEPSTYPE);if(this.gameType=s,this.description=i.DESCRIPTION??"",xi.includes(i.DIFFICULTY))this.difficulty=i.DIFFICULTY;else throw Error("Unknown chart difficulty "+i.DIFFICULTY);this.meter=parseInt(i.METER),(!isFinite(this.meter)||this.meter<0)&&(this.meter=0),this.meterF=parseFloat(i.METERF),(!isFinite(this.meterF)||this.meterF<0)&&(this.meterF=this.meter),this.radarValues=i.RADARVALUES??"",this.notedata=s.parser.fromString(i.NOTES,s).map(n=>this.computeNote(n))??[],this.credit=i.CREDIT??"",this.chartName=i.CHARTNAME??"",this.chartStyle=i.CHARTSTYLE??"",this.music=i.MUSIC;for(const n in i)["STEPSTYPE","DESCRIPTION","DIFFICULTY","METER","METERF","RADARVALUES","CREDIT","CHARTNAME","CHARTSTYLE","MUSIC","NOTES","NOTEDATA"].includes(n)||(this.other_properties[n]=i[n])}else{const i=/([\w-]+):[\s ]*([^:]*):[\s ]*(\w+):[\s ]*(\d+):[\s ]*([\d.,]*):[\s ]*([\w\s, ]*)/g.exec(t.trim());if(i!=null){const s=Ke.getGameType(i[1]);if(!s)throw Error("Unknown step type "+i[1]);if(this.gameType=s,this.description=i[2]??"",xi.includes(i[3]))this.difficulty=i[3];else throw Error("Unknown chart difficulty "+i[3]);this.meter=parseInt(i[4]),(!isFinite(this.meter)||this.meter<0)&&(this.meter=0),this.meterF=this.meter,this.radarValues=i[5]??"",this.notedata=s.parser.fromString(i[6],s).map(n=>this.computeNote(n))??[]}else throw Error("Failed to load sm chart!")}this.recalculateStats()}getNotedataStats(){return this._notedataStats}getNPSGraph(){return this._npsGraph}getMaxNPS(){let e=0;for(const t of this._npsGraph)t>e&&(e=t);return e}getSecondsFromBeat(e,t){return this.timingData.getSecondsFromBeat(e,t)}getBeatFromSeconds(e){return this.timingData.getBeatFromSeconds(e)}getBeatFromEffectiveBeat(e){return this.timingData.getBeatFromEffectiveBeat(e)}isBeatWarped(e){return this.timingData.isBeatWarped(e)}isBeatFaked(e){return this.timingData.isBeatFaked(e)}getNoteIndex(e){if(this.notedata.includes(e))return this.notedata.indexOf(e);for(let t=0;ts.beat)+1;return i>=1&&this.notedata[i-1].beat>e.beat&&i--,this.notedata.splice(i,0,t),t}addNote(e,t=!0){const i=this.insertNote(e);return t&&$.emit("chartModified"),i}addNotes(e,t=!0){const i=e.map(s=>this.insertNote(s));return t&&$.emit("chartModified"),i}computeNote(e){return Object.assign(e,{warped:this.timingData.isBeatWarped(e.beat),fake:e.type=="Fake"||this.timingData.isBeatFaked(e.beat),second:this.timingData.getSecondsFromBeat(e.beat),quant:Math.round(Wo(this.timingData.getBeatOfMeasure(e.beat)))})}modifyNote(e,t,i=!0){const s=this.getNoteIndex(e);if(s==-1)return;const n=Object.assign({},this.notedata[s]);this.notedata.splice(s,1),Be(t)||(t.hold=void 0),Object.assign(n,t),this.addNote(n),i&&$.emit("chartModified")}removeNote(e,t=!0){const i=this.getNoteIndex(e);if(i==-1)return;const s=this.notedata.splice(i,1);return t&&$.emit("chartModified"),s[0]}removeNotes(e,t=!0){const i=e.map(s=>{const n=this.getNoteIndex(s);return n==-1?void 0:this.notedata.splice(n,1)[0]}).filter(s=>s!=null);return t&&$.emit("chartModified"),i}setNotedata(e){this.notedata=e,$.emit("chartModified")}getNotedata(){return this.notedata}recalculateNotes(){this.notedata=this.notedata.map(e=>this.computeNote(e))}recalculateStats(){this._notedataStats=this.gameType.parser.getStats(this.notedata),this._npsGraph=this.gameType.parser.getNPSGraph(this.notedata,this.timingData)}getMusicPath(){return this.music??this.sm.properties.MUSIC??""}toString(){return this.difficulty+" "+this.meter}serialize(e){let t="//---------------"+this.gameType.id+" - "+this.description+`--------------- +`);for(let l=0;l=t.numCols);h++){const d=a*4+l/o.length*4;let p=c[h];if(p=="{"||p=="["){let f="";for(h++;hn[c]?n[c]=void 0:n[c]1&&t.Jumps++,s+l>2&&t.Hands++,s=0,i=o.beat}if(o.type!="Mine"&&!o.fake&&s++,o.fake){t.Fakes++;continue}switch(o.type){case"Tap":t.Taps++;break;case"Hold":t.Holds++;break;case"Roll":t.Rolls++;break;case"Lift":t.Lifts++;break;case"Mine":t.Mines++;break}Be(o)&&(n[o.col]=o.beat+o.hold)}let a=0;for(let o=0;o1&&t.Jumps++,s+a>2&&t.Hands++,t}getNPSGraph(e,t){const i=e.at(-1);if(!i)return[];let s=i.beat;Be(i)&&(s+=i.hold);const n=[];let a=0;for(;e[a];){const o=Math.floor(t.getMeasure(e[a].beat)),l=t.getBeatFromMeasure(o),c=t.getBeatFromMeasure(o+1),u=t.getSecondsFromBeat(c)-t.getSecondsFromBeat(l);if(u<=.05){for(;e[a]?.beatt+i,0),Ke.gameTypes[e.id]=e,this.priority.push(e)}static getPriority(){return this.priority}static getGameType(e){return Ke.gameTypes[e]}static getTypes(){return this.gameTypes}}Ke.register({id:"dance-single",numCols:4,columnWidths:[64,64,64,64],columnRotations:[0,-90,90,180],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[3,1,2,0],vertical:[0,2,1,3]}});Ke.register({id:"dance-double",numCols:8,columnWidths:[64,64,64,64,64,64,64,64],columnRotations:[0,-90,90,180,0,-90,90,180],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[3,1,2,0,7,5,6,4],vertical:[0,2,1,3,4,6,5,7]}});Ke.register({id:"dance-couple",numCols:8,columnWidths:[64,64,64,64,64,64,64,64],columnRotations:[0,-90,90,180,0,-90,90,180],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[3,1,2,0,7,5,6,4],vertical:[0,2,1,3,4,6,5,7]}});Ke.register({id:"dance-solo",numCols:6,columnWidths:[64,64,64,64,64,64],columnRotations:[0,45,-90,90,135,180],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[5,4,2,3,1,0],vertical:[0,1,3,2,4,5]}});Ke.register({id:"dance-solodouble",numCols:12,columnWidths:[64,64,64,64,64,64,64,64,64,64,64,64],columnRotations:[0,45,-90,90,135,180,0,45,-90,90,135,180],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[5,4,2,3,1,0,11,10,8,9,7,6],vertical:[0,1,3,2,4,5,6,7,9,8,10,11]}});Ke.register({id:"dance-threepanel",numCols:3,columnWidths:[64,64,64],columnRotations:[45,-90,135],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[2,1,0],vertical:[0,1,2]}});Ke.register({id:"dance-threedouble",numCols:6,columnWidths:[64,64,64,64,64,64],columnRotations:[45,-90,135,45,-90,135],gameLogic:new Ts,parser:new Ss,editNoteTypes:["Tap","Mine","Fake","Lift"],flipColumns:{horizontal:[2,1,0,5,4,3],vertical:[0,1,2,3,4,5]}});function oC(){const r=new URLSearchParams(location.search),e=r.get("flags");if(e!=null){const n=new Set(e.split("").map(a=>TE[a]).filter(a=>a));for(const a of n.values())Ie[a]=!Ie[a]}const t=r.get("url");if(t!=null)try{Ie.url=new URL(t).toString()}catch{Ce.createFormatted("Invalid url "+t,"warn"),Ie.url=null}const i=r.get("chartIndex");if(i!=null)try{Ie.chartIndex=parseInt(i)}catch{Ce.createFormatted("Invalid chartIndex "+i,"warn"),Ie.chartIndex=null}const s=r.get("chartType");s!==null&&(Ke.getGameType(s)?Ie.chartType=s:(Ce.createFormatted("Invalid chartType "+s,"warn"),Ie.chartType=null))}const EE={viewMode:{char:"V",name:"Force view mode (disables record mode)"},menuBar:{char:"M",name:"Hide menu bar"},chartList:{char:"C",name:"Hide chart list (in development)"},barlines:{char:"B",name:"Hide barlines, waveform, and timing boxes"},assist:{char:"A",name:"Disable assist sounds"},recordMode:{char:"R",name:"Disable record mode"},playMode:{char:"P",name:"Disable play mode"},layout:{char:"L",name:"Hide note layout"},status:{char:"S",name:"Hide status bar"},autoPlay:{char:"a",name:"Play automatically"},openWindows:{char:"O",name:"Disable opening windows"},hidePoweredByText:{char:"H",name:'Hide "Powered by SMEditor" text'}},TE=Object.fromEntries(Object.entries(EE).map(([r,e])=>[e.char,r])),Ie={viewMode:!1,menuBar:!0,chartList:!0,barlines:!0,assist:!0,recordMode:!0,playMode:!0,layout:!0,status:!0,autoPlay:!1,hidePoweredByText:!1,openWindows:!0,url:null,chartIndex:null,chartType:null};class Ce{static _view;static messages={};static get view(){return this._view||(this._view=document.getElementById("waterfall"),Ie.menuBar||(this._view.style.top="10px")),this._view}static create(e){if(this.view==null)return;let t=1;if(this.messages[e]&&this.messages[e].type==""){const s=this.messages[e];clearTimeout(s.timeoutID),clearTimeout(s.clearTimeoutID),t=++s.count,this.view.removeChild(s.container)}const i=document.createElement("div");i.innerHTML=e,t>1&&(i.innerHTML+=` (${t})`),i.classList.add("waterfall-item"),Ce.messages[e]={type:"",container:i,timeoutID:setTimeout(()=>{i.classList.add("waterfall-exiting")},5e3),clearTimeoutID:setTimeout(()=>{delete this.messages[e],this.view.removeChild(i)},5500),count:t},this.view.appendChild(i)}static createFormatted(e,t){if(this.view==null)return;let i=1;if(this.messages[e]&&this.messages[e].type==t){const n=this.messages[e];clearTimeout(n.timeoutID),clearTimeout(n.clearTimeoutID),i=++n.count,this.view.removeChild(n.container)}const s=document.createElement("div");s.innerHTML=`
${Ec(t)}:
`+e,i>1&&(s.innerHTML+=` (${i})`),s.classList.add("waterfall-item"),console[t](e),Ce.messages[e]={type:t,container:s,timeoutID:setTimeout(()=>{s.classList.add("waterfall-exiting")},5e3),clearTimeoutID:setTimeout(()=>{delete this.messages[e],this.view.removeChild(s)},5500),count:i},this.view.appendChild(s)}}class $ extends bn{static _instance;static get instance(){return $._instance||($._instance=new $),$._instance}static emit(e,...t){return $.instance.emit(e,...t)}static on(e,t,i){$.instance.on(e,t,i)}static off(e,t,i,s){$.instance.off(e,t,i,s)}}const xi=["Beginner","Easy","Medium","Hard","Challenge","Edit"],ar=["BPMS","STOPS","WARPS","DELAYS","LABELS","SPEEDS","SCROLLS","TICKCOUNTS","TIMESIGNATURES","COMBOS","FAKES","ATTACKS","BGCHANGES","FGCHANGES"];class mg{gameType=Ke.getPriority()[0];description="";difficulty="Beginner";meter=1;meterF=1;radarValues="0,0,0,0,0";chartName="";chartStyle="";credit="";music;timingData;sm;other_properties={};notedata=[];_notedataStats;_npsGraph;constructor(e,t){if(this.timingData=e.timingData.createChartTimingData(this),this.timingData.reloadCache(),this.sm=e,!t){this.recalculateStats();return}if(e._type=="ssc"){const i=t;for(const n in i)(n=="OFFSET"||ar.includes(n))&&this.timingData.parse(n,i[n]);this.timingData.reloadCache();const s=Ke.getGameType(i.STEPSTYPE);if(!s)throw Error("Unknown step type "+i.STEPSTYPE);if(this.gameType=s,this.description=i.DESCRIPTION??"",xi.includes(i.DIFFICULTY))this.difficulty=i.DIFFICULTY;else throw Error("Unknown chart difficulty "+i.DIFFICULTY);this.meter=parseInt(i.METER),(!isFinite(this.meter)||this.meter<0)&&(this.meter=0),this.meterF=parseFloat(i.METERF),(!isFinite(this.meterF)||this.meterF<0)&&(this.meterF=this.meter),this.radarValues=i.RADARVALUES??"",this.notedata=s.parser.fromString(i.NOTES,s).map(n=>this.computeNote(n))??[],this.credit=i.CREDIT??"",this.chartName=i.CHARTNAME??"",this.chartStyle=i.CHARTSTYLE??"",this.music=i.MUSIC;for(const n in i)["STEPSTYPE","DESCRIPTION","DIFFICULTY","METER","METERF","RADARVALUES","CREDIT","CHARTNAME","CHARTSTYLE","MUSIC","NOTES","NOTEDATA"].includes(n)||(this.other_properties[n]=i[n])}else{const i=/([\w-]+):[\s ]*([^:]*):[\s ]*(\w+):[\s ]*(\d+):[\s ]*([\d.,]*):[\s ]*([\w\s, ]*)/g.exec(t.trim());if(i!=null){const s=Ke.getGameType(i[1]);if(!s)throw Error("Unknown step type "+i[1]);if(this.gameType=s,this.description=i[2]??"",xi.includes(i[3]))this.difficulty=i[3];else throw Error("Unknown chart difficulty "+i[3]);this.meter=parseInt(i[4]),(!isFinite(this.meter)||this.meter<0)&&(this.meter=0),this.meterF=this.meter,this.radarValues=i[5]??"",this.notedata=s.parser.fromString(i[6],s).map(n=>this.computeNote(n))??[]}else throw Error("Failed to load sm chart!")}this.recalculateStats()}getNotedataStats(){return this._notedataStats}getNPSGraph(){return this._npsGraph}getMaxNPS(){let e=0;for(const t of this._npsGraph)t>e&&(e=t);return e}getSecondsFromBeat(e,t){return this.timingData.getSecondsFromBeat(e,t)}getBeatFromSeconds(e){return this.timingData.getBeatFromSeconds(e)}getBeatFromEffectiveBeat(e){return this.timingData.getBeatFromEffectiveBeat(e)}isBeatWarped(e){return this.timingData.isBeatWarped(e)}isBeatFaked(e){return this.timingData.isBeatFaked(e)}getNoteIndex(e){if(this.notedata.includes(e))return this.notedata.indexOf(e);for(let t=0;ts.beat)+1;return i>=1&&this.notedata[i-1].beat>e.beat&&i--,this.notedata.splice(i,0,t),t}addNote(e,t=!0){const i=this.insertNote(e);return t&&$.emit("chartModified"),i}addNotes(e,t=!0){const i=e.map(s=>this.insertNote(s));return t&&$.emit("chartModified"),i}computeNote(e){return Object.assign(e,{warped:this.timingData.isBeatWarped(e.beat),fake:e.type=="Fake"||this.timingData.isBeatFaked(e.beat),second:this.timingData.getSecondsFromBeat(e.beat),quant:Math.round(Wo(this.timingData.getBeatOfMeasure(e.beat)))})}modifyNote(e,t,i=!0){const s=this.getNoteIndex(e);if(s==-1)return;const n=Object.assign({},this.notedata[s]);this.notedata.splice(s,1),Be(t)||(t.hold=void 0),Object.assign(n,t),this.addNote(n),i&&$.emit("chartModified")}removeNote(e,t=!0){const i=this.getNoteIndex(e);if(i==-1)return;const s=this.notedata.splice(i,1);return t&&$.emit("chartModified"),s[0]}removeNotes(e,t=!0){const i=e.map(s=>{const n=this.getNoteIndex(s);return n==-1?void 0:this.notedata.splice(n,1)[0]}).filter(s=>s!=null);return t&&$.emit("chartModified"),i}setNotedata(e){this.notedata=e,$.emit("chartModified")}getNotedata(){return this.notedata}recalculateNotes(){this.notedata=this.notedata.map(e=>this.computeNote(e))}recalculateStats(){this._notedataStats=this.gameType.parser.getStats(this.notedata),this._npsGraph=this.gameType.parser.getNPSGraph(this.notedata,this.timingData)}getMusicPath(){return this.music??this.sm.properties.MUSIC??""}toString(){return this.difficulty+" "+this.meter}serialize(e){let t="//---------------"+this.gameType.id+" - "+this.description+`--------------- `;if(e=="sm")t+=`#NOTES: `,t+=` ${this.gameType.id}: `,t+=` ${this.description}: @@ -1183,7 +1183,7 @@ void main(void)\r `;for(const i in this.other_properties)t+=`#${i}:${this.other_properties[i]}; `;this.timingData.usesChartTiming()||(t+=this.timingData.serialize("ssc")),t+=`#NOTES: `}return t+=this.gameType.parser.serialize(this.notedata,this.gameType)+`; -`,t}requiresSSC(){return this.timingData.requiresSSC()}}var He=(r=>(r.SELECT_FILE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAArUlEQVR4nO3YQQ6CQBBE0X8PXKrn9DqGcDNNZC5QhGR2agQk6Z5QL+l9FwULGszMzN6dgB4ogFbOjQTLPzcsniZE/+fy4SHKTgHCQijZFGAALq0GUJ35u+xaDiDg3nqA15YA0bR2HwfYmdxAMLmBYHIDweQGgskNBJMbCCY3EExuIJgO18DY+k/9kGBRfZn57PnTFXgkWFYfDltnFurqESnD6zTWJ794eTMzO44JY84XrlhT/UgAAAAASUVORK5CYII=",r.REVERT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAACY0lEQVR4nO2aTUhVQRiGn1pYSVqLBM0WbQpNuLcoRIhS3AVFEEWLtiEKRRAUghAXidyoRNAf7XPhwqSfRW2jRVw0cpVCBJrR36KIfggqDswFGQY7Z+65986Zbx74tud+73PnnDNnZiAQCAQCgYAFm4BuYCMC2QO8B/4CS8BWBLEb+KTCl+ocQsgbwkc1hJDwHw3hRQjIrxLeewH5/4T3WkAuRnhvBeRihvdSQC5BeO8EtAPvEoT3SkC7RXhvBHQAHyzCR/UWKFahngJTwE01++wBNqQloGgZvtb1HXgInATqyhHw2YEw5dYycMZWxJADAdKqOWCfjYRRyx+8DeytQu0Hjqp/+Q4wv0pPv4DT1ZJQoHa0qZ6/pvmGGsuQgBJb1Kj4Y+jvbKUlFHCHE8BPrb/f6pWZmCsZFIAK+0Xr8Q3QUKmRUMA9jhhuh8u2FxvLoICIa1qf34CmSkgo4Cbr1eRoZa+D5VxwPGMCIi4aJkmkLeES7tKohn6p1+i50Jy2hMO4zSOt31NpXHQAmAb6cZ/zmoAbCKNHE3APYezSBDxDGE2agAWEsV0T8AJhdGoCHiOM45qAuwjjuiZgGGG80gQcQhBdhmX0egTxQBMwiSAOGhZFehHCZrUMtjL8c2ANAqgD7mvho5FwAAE0AE8MaxbRq9B7OoBZQ/himrvILtICXDXsB5Q+fFrxjLXATrX3N602PkxrlS+BbTjMOmBEfZ/HPSQRzep+xNirmMjCQe7BGEGS1mvgGBnhVorBZ4C+ck+J1OLkue3JlEV1NOaCevpnlsaEhyR2ZOHeDgQCgUAA9/kHkepiJFq7BJgAAAAASUVORK5CYII=",r.ADD_FOLDER="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAAvUlEQVRIie2UTQ7CIBBGnz8rb+Mt2hqv4TGMmt4Kexl7gUa3TXBRTAALQqGJJr5kNpR+r8ykwJ9vogJaQDrqlCrwhWeRfAoPrRYo5xRI4OYTpGLkLDMEevl9wXqGzC2wH3uQa8gGOVpUAALoVAmGW+GNKSc44v4XLqmCwgpcqfVeWzNOEisQAYJGfyHkspPARu3vrGCbHrjrQz4oSSiLiL2TuBLZoljKAMEuRQBwxj2rOjX8RcXQioeqBu3Ln4QChU8M4+FlAAAAAElFTkSuQmCC",r.CHEVRON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAAbklEQVRIie2PMQqAMAxFXwfP6qJVPIjYzcOKdUkhQ0BaCoLkLS3k818CjuN8ztApYzIDl7xvmalFsAIZuIFozKPMMrC0CAJwKIkuGVX5KdkmLEm3ci1JSlLKU49yLSmXVG1es0EANvnvInKcP/AA784fpjlWwNQAAAAASUVORK5CYII=",r.EDIT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABOElEQVR4nO2WQUoDMRSGP5duWgpS157BhQuheAR7mOrSuKviPbqQit5CaC9QEOxO2k2XhaJEAhkoZZLpVJy8wPvgrSaB73+TFwKKokjiAngGlsAG+ACegFMy4Ab4AWxJLXw4sZiA+G6ILpnKW1+PZB5ghlDMngHWCMbsEeALIaIm8s1GatSwa1Swbohv4Lxh30oxU2PtoGHfSqGihoE9t1tr7hA+nCayN/RN3B0/RBh15K20EIfIWykh/iJvcxhYlf8PtPOp0M6nQjufCqP3fEJaQA8YH/AXkj6Jy3jJWd5xlbO840T6w6zgAWhTzjFwGZgJEZ0/AlbAeyREwViavONsS6oqRE+avON651jEQrSlyTvuS872FOiQCW+B2yWbEPNAgJW/ncQzAT6BV3+++36wFUVRFAp+AZvenA82VBInAAAAAElFTkSuQmCC",r.ADD_FILE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAABiElEQVRoge2YMU7DMBSGvwQJVO7CwN1YYEFUMAMdYCpHYUMcgg49A3SgEggGE2GskNh5frYr+ZOsppWS93+q9WIbKpWKD4fAHFgBH8BX4NgCt0CbOjiY8M8BYYfGkgwS8wjBs0qsrOKnwH7g/dkl7DkfGh4K+CfsotL7lz3f1SViCjTAnfPbA8oSMQUgg0RsAUgsoSEACSW0BCCRhFRgrA23KHcnqYD9Ijwjg4RU4MJ5RshYSIJ3SAVmwNM/AcfGuyR4h1QAjMQ58EL4cnyQxqO4279T4F0zywYjJlUgN1VgF4jRRkM5Ag5+PgcptY16U+IUajFLiA2RzpJSTqEGuHdqipfXqQT6wkeRSCEwFF4soS3gE14koS2wcGr0bWxEewRtgTf+hm2dmu5u7TW0gLbAFaZl3vA7PdyaLaalboBL++ZSX2R1P7Az+Ah8WtdTjtdV8RFYW9cnFCgxhuRcJ3R0RO18knOdIgQ6iannOkUIpGaLCT96Mrenn2USM+AYuAYeM2epDPINL56D04/lX9sAAAAASUVORK5CYII=",r.MENU_VERTICAL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA+ElEQVR4nO3XS04CQRSF4X+kYx8h0UWIM5vFoIxVdkCgmbMDlSWBsAchLMLWVHI76ZC2pnLgfMlNOqlJn1TdeoCZmZnZSbqNknUPrICfqCXQRcw1sG2EqGsHdBAybAlR1wtCZpkgaUzGUyZIHyFne43ebPg0JuUSeAe+ot6Ai//+KTsWPaCMKhBVAlWj0dP3GMGZqFp2rUptZqaZcyTNlIwyE2SCkOKPpfUNPCBmvBcmhRghqohlNlGcCTtUV8Ac2ER9xEVSyjmwbtm1PtWu8YPMOfKIkNmxPHVfM0GeEWv0bUuIjWLDd+ONXodYAHcIu4kyMzMzOzW/IiF2pLfCTcAAAAAASUVORK5CYII=",r.COPY="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABZklEQVR4nO2YQUoDQRBFHwiDB5AsXCSexYxeIVfwCDlE1hoXuUBuodl4CDGOgSyySrIKGGgZ6EAxTBZOVzc21oPe9OJX/eqqgSkwDMPIiT4wBhbAGjgCTuFsgBnQi5X4JTABDkoJnzvvwJV28nVV3iIn7sSZa1e+mfwrMAKugQv+OBOR+DfwQGYDexAGZPI3wDOwUhxk58/R606BQYiBsRB9Eff3wD7RPOyAsquBhRAaicqnSt4JE3U3/Jq1EKkHFt82p7sP4BYo0KUAhsBSxHrqIiR7+/S1WYm7OvmYDEWsqouAfMY2U9qVb1I0BlvFQNtdTFxIPDOggLMXwGYgCGcthLVQEM5aCGuhIJy1ENZCQbh/3UKb3A3McjfQ87vKbA3gF63zXP+J2/hKuJUoRaxPLdGpEF36IDH2QneNvdCjlvjAb8pSbua2XTdz5ygTmtj6BZc6ff+sVaTtdOX1VStvGIaBOj8GcNhDDTqXrgAAAABJRU5ErkJggg==",r.TRASH="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAABdElEQVRoge2YsU7DMBRFDwxlgb0wlB9BLMDXtFvhE2BAogNDxR+1S+ETEBJiLqVSU6lVGOwoJsQhDnEc0DvSU63c+OXeuElVgyAIddMBBsAUWOqaAH2ttZoj4AmILfWoz2kleyiDNvNJzWjpSgxITUbAEDjUdamPJXo/kMdCpqQGhzn6laFPGvRVmg9Sg90cvWvoiyYM3QArfv5O+64VcG0zuVNwfAHsu+f2whI4yBN2LRNi4B714IUmQnnJxbYCecQV57ngfA3bCvwZJEBoJECGO9R7+9ZRawTzx8XGWutrR83lGl+o+zVadM5v5+ciz0BoJEBoJEBoJEBoJEBoJEBoJECGKPNZVqtM3QFGqD2ckaNWGdlWCY1LgK0x9rG/b/bcWs/K4BLgzRifOMwry6kxfvXQnwfSP9zPwDn1rEQHuNA9k/7jGvp+4xh4x21rvErNgZ6PAKDuus8Qc+DMl/mEHmqJX4BNDaY3utcYj3deEP4rn4hExm+tmh+HAAAAAElFTkSuQmCC",r.IMAGE_FILE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAB8UlEQVRYhd3WTYjNURjH8c9IozRlwUITTbMRNlNWxksWjKxkYbJQY6mUTCKxmDSkZiezm421KQsRFkgpL7Eg2Si3RJOFl5SIzVicc5t7p/9xz//O/5r41el2nnOe83zv8/zPC4usrgLbBPrbXO8DTuHHQgBm8QjvSwZfg0HcxV58L+nfBDDcht9w9P2IO1ie47SkjUCttBMDuIWexQB4gV3YiJutIDoB0AixoRVEpwCyIaoE+BV/Zxvac6zCdlwoclpaIcBt7EN3wdhxrO40wE9cS4wlt3Unv4EslQE4g5nYTlcFkFuCAxjH2dg/hzeY/lsAQ7iH87G/A7sbAPqFe6VWFiC3BDXheF0v7OsBIQOwEvdxpWzwlIouox48Mbe/H0dbF67jU7RvSaw5LVGu3Ax8w9aGti3aTmCPcP0+xdHM9f6o1HXcHQPXoQeF0+9k7I/Efm+BbzIDZQDG4tjLGOwtbph71CwTXkTjZQByS7ACo5jCK1yOgQ9FKMJJOIXDEaZtFWVgDF8iCKxDX4Fvr1CGkXn2BWWg/u8v4mu0vRZKMF8zuIpjGetmA4zGeZcy15zEJukt2aSck/CIkIXPmQB1HcTDKgD2S9zlLfQsZ1IOwIM2gmfrn3oP/J8AqW9gc8Vx1uJd7uSa5qd1VW2iKNhvOK12/OBuEgoAAAAASUVORK5CYII=",r.AUDIO_FILE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAADFElEQVRoge2ZzWsTQQDFf200qVrBUBAURU/aVgTFSvUoXsQqgoIUFDx68SKieBILeujJFhH/AD0VRBD8REHBD/zCIqUm6kG0UqltE0FFqqkedif7Nuymm2bTbWUfLLy8+dj3kpndmQnEiBEjxv+KDuAx8BroBlLR2qkMx4BJ4K9c5yN1FBD1QA9u4+bKVdjXPOA6kAf2h+jRFymgD7fp+yWfK0GztPsKNIbm1ANp4AFus31YoaYbIAG8l7YnwzJbiuVAP26jvVjDCaYfAOCQtB0FFldrthTrgSG5ySTWBFYEDbAHa7zfBBpsLQFkpf2JUFzb2Gbf0HT+C+j0qBc0wFWpd1j0g6K/qc6yg04sw6bjPFYgLwQNcETqZXGGYAoYk7JN5TpZAHRhTZ4/JTf3u4awhpIfggZYhDXOTd1dUnZR9HPlzD8MaNpcA8DKKYxVMonPSN3Lom8V/aNf464KjBewXjLpAKa8AqSAO8AXYIfoLVI3DyRtvQ4YlrIVXjfSZ+5xYH4Ac0HgFaBNtIxt0GBAyraLrpN8rxHrpcJq4b3A7+q9+2IQ+GHztcAWKbstXCfsE+HthmiAhPCJKg1OhZ/ANfm8U/hL4RuFPxfeYogGmGlcEd4uvF/4GuHDwpsMiTKAvpTU6IhwfUiMCm/CA9WsWcrBr99G0b+JnsDZS+RK9IKtF0NG+Qso6ny435dZ1KMMsEr4uPAlOCHyoqdx/BbrRxmgWXhW+FLhOoR03M+KAPuEPxW+Qfhb4cuEjxmiAQrCk9QWC4Hd8vmGcH15vRK+WfigIRrgg/Cj1DZEK84eN4P7F9C10Qvh+rZ+5tXpaWZuMZcE7mI9DvUt3Cp1c7i/xM9S5rmYmw3L6bNS95Lo7aJ/KtdBA3AKeEc0GxrdeXVI2QXRfTc0laDWW8oMzvxM4t6ptVVjXDFTm/oDooe2qTcI+1glB9zCfaySkfahHqsYzOmDLYM5fbRoEPbh7jppN0KND3cNyh2vj5dp54UkcA/4jvfDoabw+oOjZ5p9Rbbg7AAeYT1Fuqn9AjFGjBgxIsA/jvJ6jenUZ2YAAAAASUVORK5CYII=",r.SM_FILE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAcpJREFUeF7tmFGOwkAMQ+H+h95V2S2qqlKcsZ101PADQpPEfnFHgufj5q/nzf0/GkAn4OYE+hG4eQD6EuxHIOER+CFnWJdkbf5vfAEwOoephbiPCoOaN4A/AswWmVpoSZ0ACBN3iNkiUwup7gRAmLhDzBaZWkh1JwDCxB1itsjUQqo7ARAm7hCzRaYWUq1KwJlQxoSr7xuOAsD2x85RPweAbzOh7S+HWACrkKXP9vNWgBoAMjMFwJHhT9+Ngt7DQ2faAXza9vrjZ5suVQIiM60AzoSsg/cxZRMQnWkDgAjZQ2DumuhlF9H30hnZTLj5ycWIbsg+EwUwIgQ16TgH60UAwM0cToiekG4EwNHNTuhKKYXMZ9wBKW53Q2DzUQAzJCFkfgTAlSGEzY8CuCKEIfMMgCtBGDbPArgCBMq8AkAlBNq8CkAFBIl5JYBMCDLzagAZEKTmHQCcEOTmXQAcECzmnQCUEGzm3QAUEKzmMwAwEOzmswCMQEgxnwkgAiHNfDYABEKq+QoAZxDSzVcBOIJQYr4SwBbC8rlMC/qv8CpS/V62+VLqaopMv+oEMNoltQ1AgnHiJp2AiZcnkd4JkGCcuEknYOLlSaT/AqRIb0Fn6qw5AAAAAElFTkSuQmCC",r.UNKNOWN_FILE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAA+UlEQVR4nO2awQqCQBgGv6KeM+rU+1/L7F4RreY/W86ABw/ujsMPImwiIiLSwlh0XZIcit6piaoAY5JbknPNa31OZYAuI1QH6C7Co9zS63cXgQrQTYTqAMOL+9MC+35MdYBjniOgk1AdIOksAhEg6SgCFSDpJAIZIOkgAvkZfHcNmfDvsJkoOHeNlvVbuCbZtzzwbwGSRp/tzM1+nh0t8ILWiZo1MaufAAPQAjQGoAVoDEAL0BiAFqAxAC1AYwBagMYAtACNAWgBGgPQAjQGoAVoDEAL0BiAFqAxAC1AYwBagMYAtADNN84HLHFOqIzVT4ABaAERERGOO8QV911rDPw7AAAAAElFTkSuQmCC",r.MINIMIZE_WINDOW="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAANtJREFUaEPtlbsNwlAQBMcRLQC10QZEiAAi0wa0xqcMdIiICGmejZ60znfPN3OWBzp/hs7fnyzwb4MxEAOSQE5IAtTxGNAIZUEMSIA6HgMaoSyIAQlQx2NAI5QFMSAB6ngMaISyIAYkQB2PAY1QFsSABKjjMaARyoIYkAB1PAY0QlkQAxKgjseARigLysACOAEbYCX75oo/gCuwrwXOwHauyY3njLVAbbNsXDxX3bMWuHd0Ot9gbrXACOzmQtZ4zvuE6iM+fj7ideMBU9XV1VyAQ/4DUyH+tbd7Ay+Srg0YYU5a1gAAAABJRU5ErkJggg==",r.CLOSE_WINDOW="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAA35JREFUaEPtmbfrFUEQxz+/0pwwFNoqmMCcc46olY1/m7U2Ys45IWIuDFiJCYyYC0X5ypwcx93t7O57yIO37c3Ofr8zszvhBujxNdDj+OkT+N8e7HugVzywGtgLPAB2A1+6BHw4sB+YBuwBLoTO8YTQMuAYMNSUXQM2AZ9CyiO/jwBOAAtt3zdgG3CuTU+IwFLgeAl8oesWsA74EAmySVzgTwILKgJBEm0ElpvlhzScegPYCHzMJDEKOAXMbdDzFdgMXKr73kbgFTAhAO4msCHDE6OB08DswDkvgImxBK4ASxzWVTitB947ZMsiYwz8LMc+XeZVsQRGmmvnOQ64a3firUNWIgobWX6OQ/6O6X4XS0DyIqHLNd9x0D076E1AdixwBpjp0HnbdDZ6N/QK6YymF6Lu/IfAGkD3p26NM/AzHOBdoekhUJAov9Ft5z8ClPiqJAT+LDDdAd6da7wEdKaypEgscgB4bCRemux4A68MG1pu8FIUQ0DyyglHgJUhFMATI/HTsulUx56rluU/O2T/isQS0J5hluCUpUNLJLQmhwSBi8AWQInLvVIISPlg4LBZ2H1Yi+Bly7bRRWIqgYLEIXt1ckioRJDlo8GnhlAZrDxxEFibyEA10A7ge+L+pDtQPWuQkVB1GrOUIHfmgO+EBwrAInHACjsPCZXou4AfHuE2mZw7UNYbk621TyWCwi67n+gEASU4hUPRSXmN2pGmKJdAKviCZDaJHALKyuqV1bnlrOvW2SX12KkEOgW+IJ5MIoWASgkVdYsdZlfLqeVpilTEqcd210Epz6gsfxRY4QCvTkovza+GiUOdimgSMR6IqUQL8EUnpWdWWdfT2UWR8BKIAa/+WJav9rBdIeEhoHpHYePpAZrAF+ESQ8LVG4QICLwamNqRRiWIQ+AL8ZhpR5BEG4EY8JpIqJmvHX3U3NaOkWgjoFpfw9XQ8lq+qsc7ldM+NU/b64C0EXgGTAqgj7V8HQnNiELTuedNWNoIKO4V/wqluiXwem2807gmW8gTbSQ0od4KnI/1gOSr/wYKHfct5nPBly+2Ro3VCbU6NYWx5km1K/QKaVN1zK7BlbzzOnQ5Ir/rYpdJCLziXt5pXB4C2qxQ2Qc8NXeG5p+R2P+Ja2Ktx2OK/cpqBa9dXgKF7O9UZN3aF0OgWxiy9PYJZJmvA5v7HuiAEbNU/AEymbExfA8cowAAAABJRU5ErkJggg==",r.SKIP_START="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABEklEQVR4nO3YPy4FURTH8asQFBKvsAeNbQixBxqVxi70lqK2BZUlPKJ50SlQ+Ih4JMZ48+fOTDKT8+2/v3PO5M6deyelIAiCIAiC4A84xgPucZTGhq/Gv5m3zJhhO6OHWWtfgYbuOi7xhlecDelnDYA93Bb0xVB+1gA4wXPRHcr/RZMA7OK6rPAQfil1A3CAx1XF+/T/pSoAW7jCe1XxPvxKVgVgH3d1Cvfh16IsAGu4WG5tjejCb0RJxiZumhbuyk9NKck4z2g+208xgJEvoTT2lzhNYRudzIdsEkeJyRzmJnGcrnEheUoD+T/kPIHClfAFp0P6XV7qd7DRxs32P3+lLIeY47BVSBAEQRAEQZD65ANrrC3m/GFNbwAAAABJRU5ErkJggg==",r.SKIP_END="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABBklEQVR4nO3XPWpCQRTF8RskEBBBy+wgvZuICNlCKgsrt5AqC3m7kGzB3l6tREgnUYt/GHyveJBq7pvRIefXn8sceB9zzURERETk7gBTYAdsgUnskAEwchwiOs/14I1NzIAZcALOwCfwmDnfElPg0B7BCnjJmHcX+MsRWAAPufPWUYHGEnjOmbeOCwR74C1X3hIUaFRAP3XeEhYI1sA4Zd4SFwguwAfQS5G3DAUaX8BT13nLWCCYd503FfgHj9Cl5Jd4XfJntCr1R7Yv+SqxLPUydyzpOv3tXEi8eXeBd+CnXgtjVkJv3legHhJ+KMOosDOPd6m/NWBSl9gAr7c+j4iIiIjdoV+nEzteGs3QogAAAABJRU5ErkJggg==",r.PLAY="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA40lEQVR4nO3YMS5EURQG4ENBr9dKsAMq9qCdLdgBSh1rsIVZAjZhelrTITGf3GIiCsm8mZd593K+7nXnb/7890WklFJKKQ0HGzjGKTajNbj17R770RK8+al8X2IrWuB3TziJhgMUM9xhJ2plMc84i4YDzI2xGzXR3SvOq6lcy3vAQcsBig9cY7vVAMNXrv584qLlAHN7GaAL/ZmVDRXr1tPxkzLH1378f6/RRxwOdvgKAaYtT4lxq2PuBaOokT/8oJkMVo0rPurfcTVoNXaBm+o2/hI/to7KHK6mGlNKKaWUYiFft4ARJbTJcIwAAAAASUVORK5CYII=",r.STOP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAo0lEQVR4nO3YQQrCQAyF4XcQXffsFsGLqdhe4C8BFzLgYiAJFN53gc4/6WYimZmZ2UkAV+AO7OTbgQewVB7+Rb13fKsiIG6+y1oRUPHb/LNVBLSSAwaewCRlo5kcMPAEJikbzeSAgScwSdloJgcMPIFJykYzOWDgCUzSyR/1n4qAWDp1uVUELN+lU7UncEkP+NnOrbG3KTj4FjdfdngzMzNTvgMULRo3zp7/ZwAAAABJRU5ErkJggg==",r.RECORD="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABMElEQVR4nO2XPU7DQBBG3yUo+AniOkgQcQ3ID2ehA4EoKOlDuAmOcgpiOhJ9yNIUlguwE+/YEfOkkSxX39sdz3ohCIIgCIIgaAXBqWAieBdkgi+rzN6NBQP6huBY8CBYC/RHbQSvgjP6gOBKkNcIXq2VYNh1+Ftb0abhy7sx7XLldwlflvDdCcHJlm3zWzsdeQo8txheVo+eo7LOtGla62JnPQSmCcLLauQhME8oMPMQWCYUyDwE2pw+qlS+7wKfHgKLhAIfHgJ7/xGPEwpcewgMEh1k3y4HmUk8JRC4dwlfusCs2pw+gkM3AZM4b6mVNoJL1/CV/6JdLzSTTsKXJIZbtlPRNhf0AcGB4M4mSZ1Vf3Hv+QY3tZHgrThV7bcjt+eZ4MZtVAZBEARBEPwDfgDcyqJBiCPoQAAAAABJRU5ErkJggg==",r.PLAYTEST="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABdklEQVR4nO2XSUoDURCGW0FvoBtbL2AQT+KAwZXgCfQK4srhGA7gQsVFMF5AjyBOOYBiUBK38ZMHDTb60nn1MlWgvn1V/V+6Kp0kiWEYhmEYCgFKwBVQZ3jUswzz0vALwCd6+HCZJAI36KMaGn4KaKGPFjAdIrCJXjZCBM7Qy0mn8OPAO3p5A8aKBBbRT6lIYFvQqALMAClwHREktn6rSOBS0CjN1c1GCMTWXxQJuB0LwlM7KIHXduHnJNN7IODWJs3CV2Pl8wGWQ3a27eP77RN7ExKWfIN3xdbtJWJuQsJOzAFrEjj3Db0L2dnA8NKdlnLrG1yTdPDUd0tF8F548Ql8DVkgFaxg0yfQ6OPAXvdr+AQeB/g93m2/B5/AKaPDkU9gndGh7BOYAJ7RTw2Y/CeQSayim2/vz4g/EofoZa8wfO5v5QH6Pvl9l62jQE5kRclNPHVcmwIJd9hl4Bi4d2/AAQRuZrPczDWXISq8YRiGYRhJ//kBnszTFsS/lqcAAAAASUVORK5CYII=",r.ADD="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB7UlEQVR4nO2ZS07CUBSGCT4GDn2MQHch0YUYjC4EwwLAuRA0LsGIAxUHrkKjC/AxEnBMnXzm6DUhFeJ9tb3EfkmTJoXb/2/a03P+Fgo5OTnOAHPANlAHzoFH4B34UJvsP6hj8pstoBiC8HXgEHjFnBegCZSzEL4GnAAR7kRAB1hNS/weMMQ/A2A3SeELwCnJcyzn8i1+CeiRHtdyTp9XPk3xP9wCiz4MpHHbTKPjKn6f7Knail8B+lmr57vimZdYVedDoW0qvuzpJeWLCNgwMSDtgStXQEldDB9VrGnSmNn0NnHKsZ7JlWetBlB1lc5MWNcHFR0D0u6GauBAx0A3YANnOgZk8AjVwL2OgaFNtflz4d/nsalOfZ2FTeu/9USFeXUa/QsDQ8NFezYmlPibJG6hmX+Iu7NeRusBG6jpGJDQKVQDmzoGiip0Cq2Ze9JO81Ri5spXdbKsNpNoaIkPdKAZGb/tVdwXCkdG4pWB5UCG+oF1bipZZdbqgR0r8WMmJKvMipaT+LEZ+SID8VfAvLOBsXBXAte0uPQW7sZC3jQqU8vblZ9ipJpQdXpzfmANc9O2esG4MpI6L2U7FfExIyXVdkjoZIr8p2EzTydhRBrAiuQ20rPL4KEmu0htsn+njtWkqwziM2tOTmH2+QRxCeic7ZLqUgAAAABJRU5ErkJggg==",r.SPEED="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAACYklEQVR4nO2ZS04bQRCGrcAmu0BWAYM4BCE5R4QQJ+G55bEFEZQLZIEgCYiHcw4QF0hgQWJgazubLyqpIjWOx1M93fNAml8aaTRWd/9/TXVP/eVGo0aNGsEAXgDvgTXgK3ANPAJ/9HrUZ1+AVeCdjGmUDaAJbAO3+OMG2AImyyD+GvgE9AhHF9gHxosivwjcEx9tYCFP4qMadSvOJT00zVoe4z7KWrHJvwTOPCPadMZPeY49lTVjRt6XfKiAfyLC34Rn2rhoafoI+e8Z59iLsWH7cQFMa37LfSiOVWjSXpkPOSrvU1JDhITgwE0TFdGP38BYzNSZiiTgCfmUveKXShqJXkpuz3gej2nkRzWdkj52Ez4CpDzIC0nkD1LGbfoUZj9zIn84gPwI8NkwVuqtEYsAqSqrFHkXcxYB61Qr8i6WLQK+UU3ygiOLADEeoZATbGnQyZEhbVxcWQQ8RKgqB75qI/nzIeu1LQJ6EYqygWe2MfLNIet1SxMgz4xjm6ECHiJUlf+lELBiHNsasl67yE28rFGf0PsY/vnKIkDaIlXFoUWA9HaqiiWLAGk6VRWzZRdzIfhh7uZpx6xq2DCRVwGTaiIowBNfGObreBkaFSHtPnL2xNb5dr3IO6Ze2n15eWLrfL8ymXqdcCEnT+wz34dM5B0R0qssCztB5B3zUcbX+Sxak1ebu9KrLAon0Zq7fWZkrwDyu6buQ4CQeT0ZYuMueMN6iBjTt5H0sfNBR6P+qhDyfUKk1t/MWDtJbbMBvCmceEIBOKeu60iMhzq7nl5yf6m/ibl5W4m/WWvUaDx//AV2V/CQip4uIQAAAABJRU5ErkJggg==",r.UNDO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABeklEQVR4nO3Wv0tXURjH8dtgEuJaoEMSguBQBNUiVGv9D41uTg3S9EWiobGpv6Gh0Mk/IAyKnIxoq8SiEm0Q7IdErzh4S9Hvr6vnDMHzXi/3+Zz3c89zzq2qIAiCIAiCIAiCGixhGaerBmAA19HCAl7jK3bwDR+wgnnM4ipONsnodyF/edWPBCbxEBuas44HuFBCoKsEJupO/5aHJ6lmboFDEvVWuVtvjdzs4H7KyCnwTwIjeKE8zzGWU0A9lGkQu5GGdREzmMI4hnAKo7hcP3uE7R61vuB8ToFufMLttNgGOcOYxvsuddPBcLGkwC/MpQ437tRe3iDu4GeHjM/p65UQ+JjO/aMuvE3uJbztkPWs78FuINDXPdFQYgRvOuTdyy1QSuIMVttkfce53AKlJK7gR5usxyUESkm02uSkQR8sIZBdwu7d8e5AxiZO9Hpx7RgSL3MJJHANW/u6f6vqBW4cQ+JplRm7vzA3cTZ37SAIgiAIgiAIqv+aP0/ezoLd5BjTAAAAAElFTkSuQmCC",r.REDO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABi0lEQVR4nO3WPWsUURSH8Y2oIJKYRhdiEa1SCJqXVvAzuEXMB5B8BEuLiKRIk8pSLC1WSJMqBEIgasoglmKRYBaVFEGEpPAnK7dY193ZndlZWOE87cw59/nfe+alUgmCIAiCIAiCICgILuM+nmADBzjET5zjBB/Ttad4gEs51xjHduqTqzar6V2s45v8fMcL3OlTfq+ltjqo+EzazTL4lXrN9ClfPEAalbU0FmVzjmet49FFvlgATON9hsBXvMIy5nETV5pCuI4FPMYbnGb02cdUhnz+AJhLM9uJXdSap5PzJBfxoUvPoxTEwAFwr4v8JzzMtRP/9r6AR/iSIVs8QBqbTm+YOiYGkW9bp4qtUgOk2X3boXilLPG29a6hUWaA1Q6Fz4ckP57xwOYPgNs4ayuqD0n+KnZyyPcV4HVbwWdMjsDO9w6AW+nr2EpthOR7Bpj1N+8wNkLyPQOM4eWf2zhu/rCVKZ/W2FScH339jeIGLpYtn3o3vyNFaGBpGE5BEARBEARBEFT+S34DOXeCiMi4hZkAAAAASUVORK5CYII=",r.CUT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAACxElEQVR4nO2YvWsUQRiHRwMKKojkQxMUOzWiXbCxU7BQMRFRrCKKtQqXiF8EY+dfYEQrxcZW/QdEbMydWhhQLERR8QPWJIrBmHtk2PdgGXZnZ/d2zyn2gYMQZmZ/M/N+zatURUVFhbcAvcA1oAH8lJ/+exLoUT4DHAZmSeYHMKI8Fr9EOkvebYLQbGwnbxJ4ZU6ENh9lAagB/fKryf+iXC1Jy3JgFHgDfAGOu0x6boirxYwZN8Y0ShC/B6gb3/nsMnHOmNQfM2bAGDNXoPBB4EGCub5yWUDbdJR1DhsIChC+HrgBLCaI15axw2Uh89rOOJjQszaErwIux9x8i4/AKe0PrgteMhbQDnsO6JaTH49x4gs5HfQE8CFB+C8JKGuyLtwHfMOdr1nDKLBXMnpSbrkDbMx6KNEPHLLYYpQ/wIEM624HHlnWewwM5RZufGw/MJ+ygVHHtTYANy2H8hY4Uohw48Pa5u8CTUs9dB5YaXHQK5aDCCQxrihcvCFkCHhquYn3kjGXRRz0KPAuYfyi3EhfqcKNTWhRpyWlJ/EEOAm8sIzRSWpbx4Sb6LCma5+YUJrGjPYr5QvAlpSI0kKH5LNAl/IJYDUwIaE0jt/AdWCt8gmgS1K7TvFx6Ih1D9isfAPYB7xMceJdlvm7gVu64uy08EHgvmsYjZm/ScqDZkfDKOEL7DbwN08ikzW2At8tiWyslESma5yCS4mpjpUSwLDl1KNoQQe9KuYIy+mkK08qp3tzlNPm27tFs61yWl5HWbsSF3160NRzdCWms24gw5PyU9YnZZCjK1HUo34q5VG/s6y2ymy7GzAc/WHCJmZUGjHONeZgQnVVTmOrYZqTy0TdOo+yIMlmwNKVKLu1+Fpqr2Muk3okw7qifaZb+QQwkqG9Pqx8hHATQcrJ+yneMKdJyQ3zEqGm5Unpl9lUVFRUqP/BP5CqMiH1c5cpAAAAAElFTkSuQmCC",r.COPY_WHITE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA2klEQVR4nO2YQQrCMBBFcxBd9yr2qBbBO9mtis0FngS60CiV4JAx9b9tFpmX+WFgQhBCvABsgQMQqccI9MGo+As+nCwE0svTskD0Kh7YWQg8EVoDCTjDP3SAunMiAkegMxFwnBPXdLeFgOecGCwEvOZEYrIQWDy3htL7JGAM6kCG/kAhKEIZilAhKEIZilAhKEIZilAhKEIZilCFCI1Lu8oWOtDPEm93lT8v8AkJFII6sMIIRfy4WQikRasXewuBbl601uYMbL4WeNhQD2lXWaHwKb28WfFCrIw7KN2RSPl95zsAAAAASUVORK5CYII=",r.PASTE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABHklEQVR4nO3ZQUoDQRCF4Ua8gC41rnMVPYSoxzMIgopXEPUWcatiZuH2l4JeTBokdlXsacL7YFYz01PVr1bTKcmOAfaBK+AV+M7XC3Bp91LPgMNc7G+egYPUI2AvF7jJkz2begNc8HfnrYo6AW6AgXoPwDEwAx4d7w/ALTCPFP+B36xYy+vT3vc0YDsfcTRay5KIWHga8IzN2F0eH7vug2utPA2s2XQ/KlV+Xw0Ab1sMYDlFAmdbamIJnDZv4L+hBgpKoPUGogRiUAKF4IYqgdR8BpXAOiWQNEJ10AgVUmNEv68GglACheiOKoFaSiCI6AjvQgID/fjyNGCHC7249jQwz4cLU3sfH5bUNmEnKwv7Pz9B4SvbeXfxIiKphR8IWaCtfT4/XAAAAABJRU5ErkJggg==",r.UPLOAD="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAACXBIWXMAAAsTAAALEwEAmpwYAAACYElEQVR4nO3dO48NcRjH8e+6NbrtCI2Iuyi20aHQigQlXoDE5Q2IUqKgFC0SkbhWVqXyAiRqFHYRbOy6LvHIiZnkSBZnZ2bn9v9+kl8/8/zyzDlnTjIDkiRJktQNa4BbwEfgLfAIOAOMN31gKZgAXgGxQJ5m5WiJ7AE+/GX4eZ4BG2ygegeAz/8Zfp4XwEZLqM5R4PuIw88zDeywhPJOAj8XOfw8r4FdllDMGHCu4OCHMwPstoTFWQ5cqWD4eeaAfZYwmlXAzQqHn+cTsN8S/m01MLkEw8/zFThoCQsbBx4v4fDzfAMOW8Kf1gJPahh+nh/AcUv4bUv2wylqzuCr7QkSNwG8aWD4wyWcJlF7R7ivU1fOkuB9nS8tGPxwzpOIYwXu60RNuZD9Au+tUyXu60RNuQwso2fGshWPjuQasIKeqPq+TtSUG8BKeuBiC4YZBXOJHnjegkFGwQz+3uy86RYMMgpmih44kp1IF4d/qOnhtUGUjCyg28INsICkhRtgAUkLN8ACkhZugAUkLdwAC0hauAEWkLRwAywgaeEGWEDSwg2wgKSFG2ABSQs3wAKSFm6ABSQt3AALSFq4ARaQtHADLCBpUyU24GXTB98H10sUcLXpg++D9cD7AsN/B6xr+uD7YjNwB5gdYfCDB4DcBjY1fdCSJEmSJElSEduB+y160m20OIMZ3QO2UZGd2Rsomj6x6FjmstmV9rAFJxMdzeBlFKWf+TnfghOJjmY+m6EF0NECvARRqoAHVMAPYQoNf7aqD2Gyr1R3s5eiNX1djZZnJvv/emtVw5ckSZJEr/wCliFWxPec8VIAAAAASUVORK5CYII=",r.DOWNLOAD="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAACXBIWXMAAAsTAAALEwEAmpwYAAACWklEQVR4nO3cO2hUURCH8U9FEUEQC0EwhYWIijY2giIIgqj4ADs7Szs7W0tLO0urWEh8VmpjY2WhhY2FhRgRQVTc+IyPkQs3hZKYze4m59xzvh9MExKY85872WX37oIkSZIk5WkMmAB6QMxTze/cALambrqk8N/1Efy/1fzNptTNl2BigPBn6lrq5kvQG2IAH1M3X4IYsuQAui3cAAdQtXADHEDVwg1wAFULN8ABVC3cAAdQtXADHEDVwg1wAFULN8ABVC3cAAdQtXADHEDVwg1wAFULN8ABVC3cAAdQtXADHEDVwg1wAJ12FHg1gis5lrgmgcMUYDKDMGPAekkBHEBiJ4DpDK7mWGB9B45TiCPAlwxCjT7rG3CSwuxvP7UYmdcn4CCF2g28zSDkmKPeA3so3PZMn5a+AXZRic3A8wxCn6kXwBYqsxF4mkH4z9rvo6jSBuBJwvAftz1UbR3wMEH4j4D1qQ+fizXAvSUM/wGwNvWhc7MKuL4E4d8BVqc+bK5WAFcWMfxxYGXqQ+ZuGXBpEcK/DCxPfbguuTDC8C+mPkxXnTf89M4CvwYYxG/gXOrmS3Ea+LGA8H8CZ1I3XZpjwNc+30g5lbrZUh0Apv4T/mfgUOomS7cP+DBL+M3P9qZurhZjwFXgdVvjNb+iKUmSJEmSpLLsaG/n6MLt5ZG4moxutzchj8TOeV6Dt5g1g6k2u6HdN2QGvciau/2GvlGqi5/vikxqus3QAdDRAfgviKEGcJcR8EGYgcLvjepBmPYp1a053gy3+CuDJqObwLZRhS9JkiSJovwByQJHhbd7qEkAAAAASUVORK5CYII=",r.PLUS="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAABaCAYAAAA4qEECAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB1UlEQVR4nO3byUoDURSE4do5D+/g9HgOIILDQvDpVNxonBLwEYygy1DScHUhIumm23v75P/gbMzm3KIWEU4kAAAAALNgQdJ87iWiWpd0IelFktOMJJ1LWsu9XBQ7PwL+OVXg27mX7LtlScM/Qv6aJ0lLuZfts6MpQv6aw9zL9tlNjaCvcy/bZx81gn7PvWyfueagIYL+J6bRBB2KaTRBh2IaTdChmEYTdCim0QQdimk0QYdiGk3QoZhGE3QoptEEHYppNEGHYhpN0J2q7tsO0lXQW4PGueczTm/f7/LWr7rYvC/gsS5kBpI2u7jqJGT9esXa6n32WQENcqFz2mbQowIe5EKnut9uxZykSQEPcqEzSRkRtHoStKb8ecOszlAtOi3gQS50jtv+ejco4FEubB4lrapl1ZdzwtZ3yLeSNtSRRUl7kq7Sv6OesRlLupS0m7IIwzUHDRH0PzGNJuhQTKMJOhTTaIIOxTSaoEMxjSboUEyjCToU02iCDsU0mqBDMY0m6FBMowk6FNNogg5lXKPRr7mX7bPrGkFXF0Ro6KBG0NWZFhpamvKw8i7aLVwOW5Ie/gj5vsurzlmzIukkXddP0jynv1WfoQNzbf5mBAAAAICK9QkSkO5NnQjE8wAAAABJRU5ErkJggg==",r.ADD_EVENT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB4UlEQVR4nO2Xy0oDMRSGi6Ib6UpxpUu1TyC6E19AqW19murWqm+hiDd8A0Vw6WVrpdo3KNjWdT85EHEImWk6kzazyAcDZeYk+f/pOZmTQiEQCAQCgUAgEMgVwDJwC/TwTw+4A9ZGEd8hf3SAJRsD8ubzyrWNgTykTRxdGwO5phAMxDMAXoA6sCW7BjCnrpK6dwC8krN/YABcAatDJ/9fQ8zdqLFeDXwC67bCDWttAG1fBp6AxbTiI+vNA/eTNvAAzBjGzgL7wAXQBH7U1VT3ahITM+5xUgYkbeYN4/aAL8vxZcP4BZt0ympgoOc8MA2cMjonwJQ21+awws5q4NIQn0b8H41RW5ksBgb6VqnSxmqhhHl3tbjSuAw8Gwrv04GBtl7YwFsWA3HNXF2Lk90GBwaEqhZ7iJlvGwNyeDCxpcXJtujKwLkWux0Td2v7mTcdaPT8/0gSbLFOlKZBg45oWrGdfEkOD9J/RyYoJqVaRgM97Vkx8qyrdiY78SMI6Ds00HUqzlKAyxR6H4/KZAEui/jMh4GaQwMVHwZmgJYDA1+mDnVSJsoODOx4ER8RJl1lWo68ilcGpoDjFOIbejvtFekqk2oiQst72gwp7Kr0NrK3q49dX/2WexXTUTQQCBRS8ws6Beac36b8wwAAAABJRU5ErkJggg==",r.SELECT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABdElEQVR4nO2ZUU6DQBCGOUf73LsIRL2mPnglobCaaGNivcDXEKcp0F2Q3S6VZr6kT/+Gf4ZM2d2ZJFEURfm3ABvgBfjhRAGklrUZUIqeOXQzohctn8bzGViHBP+FndqyftvStx66cXjtvJKQN8+EBEygXg/4Pfkk0C6bNq/AnWV9LkFWjhI56k2guUVP5dk2vn0S6JDMDKH+t5BA0S6bKFHG9JearOV3VvOx4cr+irJ4OJ1dStvGNIN/Lt5+/r2tvYoSZUz/scNXbAj1HzvbxIbu2Wl2f0VZPIzccWfwvwfe5E+cLvEz+h66DwzeYWPD79sPSiCXPeBa+0Am5dP4631AUaYCPAKfwAfwkCzNn+5nzESJMqb/LTS2OkSJcoBLJLDHjms+cLzDuvr/uWilo7mb9bpxwc3dZrjgYqw9Xnno5tLt9bUMF/6agJkw4JgyH9gBq8kJyENXTfa9chqaDzjPTlIiQ3ramw/sxdsveEVRlGQODgnFtCEN6s0TAAAAAElFTkSuQmCC",r.EDIT_WHITE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABRklEQVR4nO3WMUoDQRSH8bG0UQTR2jNYWAjiEfQwapm1S8R7WEhEbyHoBQRBO9HGUhDlJwMJhLC7ZCPszsJ85c4MfP/HvLcTQiaTSQbs4Rof+MYzLrEdUgen+FXOewwXUgVFhfh8iK3QU/kpF6HnAZ5Cilg8xFdIFYuFeEtFtKhZq+OqfeNqwaYhfrDbvnW9WNFg70n71vVCU4YVZ85m9gzat27WnEXN2dK1FGf8MKREQ/m0Qiwpn0aIf8r3omHrGGT5ZciV74pc+a7Ile8Kec53CNZwgPESf9junsRl4Ka38hEc9lY+gs2kH2ZTMMJ6KAGr2K/oie4rjxV84r4qxMzecVLyEezMSNWGmEyndOQjOJq7FpUh4vek5CM4L7nbj9gIfQB3FdOlHyHwWhEgNvYopA4e8ILbySPuODZ2116ZTCYTkuIPW58e4VQyzE8AAAAASUVORK5CYII=",r.EYE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAACjklEQVR4nO2YTUuUURTHrcW0mLQPELnIyfGz9E5RIIUIbatNVqsGl1YEvXyAaqeppVKboqxNLyuDXtfRxkqIlNAh+8WBI0wP1/GceV5EuX+4MNznnv/5n3nuuec+p60tIiIiIiIiJYB24CBwBXgEfAbmgCUdczr3UNccALavt+itKmQSqOOH2EwA+4WrSOFbgOPAR7LDB+CYcOctvht4Rn54CuzJS/xJYIH88Rs4lfVev0bxuJo6N1T8XYdTOXGGgV6gCpR1VHVuRNdYcSdVXgC3HM7GgN0Gzi5g3MF7s1Xxg0YHf4BzLfAPAMtGH4Necjmb/xrJ3eIb/Fww+hAth62knVo5LRgL2G8DzgKv9dRa0N9n5Flg/QOjL9HUaSlSL4yES8k9D+wE3jaxmZE1CZuKI7GfN01qoB87hgP/fDPxjUH89yaAew6//auJ3wF8cxD1Juxl21hxOmF7wmErGjtCAdTwoTth/8Zh+yphW3X6roUC+OokaU/YzztsfwWu4x582ZQB1Db6FuoAZlMksZzzRSTxbDCJlajPQTQSOEbliFwLsqaUsB11+O0Lim8oZNNGIik+XYFCNtNCIasbfU6veTsFdjmuEuMB+5JsEdnnmtgyXupcKbB+wujrh2hrKr6BdJ/jMjdgIg37uWj0IVoOecmtp5Jcic+3eBNdNvq45OVfcXIDO+RWWTFwVhzbRnC9JfENSS2fdVbU9WImx2KPNK909OjcqLOHdDt1q0WDkA/sojGUaZ8IOAr8LED4fLJIZhmE7N8nOYp/nKwteQUib+N9hsLfAUdyFx7oGUm9uO/s9axgUdsrewtt7q4STFmDuQxMaSv9u4pc1N+f9NmQii6vq+iIiIiIiE2BfxdHH8YQSpqkAAAAAElFTkSuQmCC",r.WEB="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAACXBIWXMAAAsTAAALEwEAmpwYAAAC70lEQVR4nO2dzWoUQRSFzyLoygiudRlGUB9GBl/KqBjw5x2GYXZZ6kNohODSWQvmZ2WUKw0FQnS6qzK36tyePh/cTajqPuee7qphKiGAEEIIIYQQQgghhBD5PAFwBOAEwCUA2/G6TF5fA3jMfFBuA3gH4HeAphipOu9vAdxiNP9jgAZYkPrQOoT3AUxbsHrTcs2f8rJjG+oXgEctAjgKYNaC1qsWAXwJYNSC1ucWAVwEMGpB67xFADlCvgGYA7iT6imAU8fx1jPfm1I91clpxr3/zOt+tnYYb5nzvcnVU50hAd2TuIlnDuOtYL43OXqqMySgbxnYdxhvBfO9ydFTnW0actdhvBEDyNFTnSEB3Ya1ibnDeCuY702OnuoMCTjt2VS/Ooy3zPne5OqpjmXUOm1Y+6nmA+LXheP75ntTqqc6uU2ZalWHbdCClwKAAqA/haY3gN8I0xLEb4YRSnsAFAD9KbQpvwG7jrH90wWQofunCyBD908XQIbuny6ADN0/XQAZun+6ADJ0/3QBZOj+PQQ8ALBMv8hkhdXNWQGYFWjuu1/p9UYfQNeM7zdovF2r7hr3He+Xe73RB7B0aL6lWjjfbzGFAG6y7NiGOnO+X871FAD+NuGHQ8NKH6DRB7ByfAOWDnonF8DMcRM+cNA7uQCQPm0s0ppb2qCz9OQfOOmdZAAtMQWgAFzRGwAtQSVoCSJj2gMUgCvaA6A9oAQtQeTzANMewD0PMAXAPQ8wBcA9DzAFwD0POHe+Hv1T4NjOA1bO1xt9AK3PA2YFh/Ie5wvVGdt5wND9vM8XqkMXQIbuny6ADN0/XQAZun+6ADJ0/3QBZOj+6QLI0P3TBZCh+6cLIEP37/ldju1Y5Xw5uDUnAYxa0PrUIoCXAYxa0HreIoCHAK4CmLVg9bPwz6a2Qm8B/gngEA3ZA3Ac4KmzIHWcetKUvfQmTHk5ukpPfvPmX98TXqR/XjCF/y1wkbwetlzzhRBCCCGEEEIIIQRGzx/seDvzE8oqSwAAAABJRU5ErkJggg==",r))(He||{});const Cp=globalThis.showDirectoryPicker;async function SE(r={}){if(Cp&&!r._preferPolyfill)return Cp(r);const e=document.createElement("input");e.type="file",e.webkitdirectory=!0,e.multiple=!0,e.style.position="fixed",e.style.top="-100000px",e.style.left="-100000px",document.body.appendChild(e);const{makeDirHandleFromFileList:t}=await ui(()=>Promise.resolve().then(()=>ig),void 0);return new Promise((i,s)=>{e.addEventListener("change",()=>{t(e.files).then(i).catch(s),document.body.removeChild(e)}),e.click()})}const Mp=globalThis.showOpenFilePicker;async function CE(r={}){if(Mp&&!r._preferPolyfill)return Mp(r);const e=document.createElement("input");e.type="file",e.multiple=!!r.multiple,e.accept=(r.accepts||[]).map(i=>[...(i.extensions||[]).map(s=>"."+s),...i.mimeTypes||[]]).flat().join(","),e.style.position="fixed",e.style.top="-100000px",e.style.left="-100000px",document.body.appendChild(e);const{makeFileHandlesFromFileList:t}=await ui(()=>Promise.resolve().then(()=>ig),void 0);return new Promise((i,s)=>{e.addEventListener("change",()=>{t(e.files).then(i).catch(s),document.body.removeChild(e)}),e.click()})}const Ip=globalThis.showSaveFilePicker;async function ME(r={}){if(Ip&&!r._preferPolyfill)return Ip(r);const{FileSystemFileHandle:e}=await ui(()=>Promise.resolve().then(()=>gg),void 0),{FileHandle:t}=await ui(()=>import("./downloader-f4f83111.js"),[]);return new e(new t(r.suggestedName))}const Rs=Symbol("adapter");let dd=class{constructor(e){this.kind=e.kind,this.name=e.name,this[Rs]=e}get isFile(){return this.kind==="file"}get isDirectory(){return this.kind==="directory"}async queryPermission(e={mode:"read"}){const t=this[Rs];if(t.queryPermission)return t.queryPermission(e);if(e.mode==="read")return"granted";if(e.mode==="readwrite")return t.writable?"granted":"denied";throw new TypeError(`Mode ${e.mode} must be 'read' or 'readwrite'`)}async requestPermission(e={mode:"read"}){const t=this[Rs];if(t.requestPermission)return t.requestPermission(e);if(e.mode==="read")return"granted";if(e.mode==="readwrite")return t.writable?"granted":"denied";throw new TypeError(`Mode ${e.mode} must be 'read' or 'readwrite'`)}async isSameEntry(e){return this===e?!0:this.kind!==e.kind||!e[Rs]?!1:await this[Rs].isSameEntry(e[Rs])}};Object.defineProperty(dd.prototype,Symbol.toStringTag,{value:"FileSystemHandle",writable:!1,enumerable:!1,configurable:!0});const dh=Symbol("adapter");let vn=class extends dd{constructor(e){super(e),this.kind="file",this[dh]=e}async createWritable(e={}){const{FileSystemWritableFileStream:t}=await ui(()=>import("./FileSystemWritableFileStream-e4c13ad9.js"),["FileSystemWritableFileStream-e4c13ad9.js","web-streams-ponyfill-4a0f4950.js"]);return new t(await this[dh].createWritable(e))}async getFile(){return this[dh].getFile()}};Object.defineProperty(vn.prototype,Symbol.toStringTag,{value:"FileSystemFileHandle",writable:!1,enumerable:!1,configurable:!0});Object.defineProperties(vn.prototype,{createWritable:{enumerable:!0},getFile:{enumerable:!0}});const gg=Object.freeze(Object.defineProperty({__proto__:null,FileSystemFileHandle:vn,default:vn},Symbol.toStringTag,{value:"Module"})),Ds=Symbol("adapter");class Nr extends dd{constructor(e){super(e),this.kind="directory",this[Ds]=e}async getDirectoryHandle(e,t={}){if(e==="")throw new TypeError("Name can't be an empty string.");if(e==="."||e===".."||e.includes("/"))throw new TypeError("Name contains invalid characters.");return new Nr(await this[Ds].getDirectoryHandle(e,t))}getDirectory(e,t={}){return this.getDirectoryHandle(e,t)}async*entries(){for await(const[e,t]of this[Ds].entries())yield[t.name,t.kind==="file"?new vn(t):new Nr(t)]}async*getEntries(){return this.entries()}async*keys(){for await(const[e]of this[Ds].entries())yield e}async*values(){for await(const[e,t]of this.entries())yield t}async getFileHandle(e,t={}){if(e==="")throw new TypeError("Name can't be an empty string.");if(e==="."||e===".."||e.includes("/"))throw new TypeError("Name contains invalid characters.");return t.create=!!t.create,new vn(await this[Ds].getFileHandle(e,t))}getFile(e,t={}){return this.getFileHandle(e,t)}async removeEntry(e,t={}){if(e==="")throw new TypeError("Name can't be an empty string.");if(e==="."||e===".."||e.includes("/"))throw new TypeError("Name contains invalid characters.");return t.recursive=!!t.recursive,this[Ds].removeEntry(e,t)}async resolve(e){if(await e.isSameEntry(this))return[];const t=[{handle:this,path:[]}];for(;t.length;){let{handle:i,path:s}=t.pop();for await(const n of i.values()){if(await n.isSameEntry(e))return[...s,n.name];n.kind==="directory"&&t.push({handle:n,path:[...s,n.name]})}}return null}[Symbol.asyncIterator](){return this.entries()}}Object.defineProperty(Nr.prototype,Symbol.toStringTag,{value:"FileSystemDirectoryHandle",writable:!1,enumerable:!1,configurable:!0});Object.defineProperties(Nr.prototype,{getDirectoryHandle:{enumerable:!0},entries:{enumerable:!0},getFileHandle:{enumerable:!0},removeEntry:{enumerable:!0}});const IE=Object.freeze(Object.defineProperty({__proto__:null,FileSystemDirectoryHandle:Nr,default:Nr},Symbol.toStringTag,{value:"Module"}));async function kp(r,e={}){var t,i,s,n;if(!r){if(!(!((t=globalThis.navigator)===null||t===void 0)&&t.storage)&&((i=globalThis.location)===null||i===void 0?void 0:i.protocol)==="http:")throw new Error("Native getDirectory not supported in HTTP context. Please use HTTPS instead or provide an adapter.");if(!(!((n=(s=globalThis.navigator)===null||s===void 0?void 0:s.storage)===null||n===void 0)&&n.getDirectory))throw new Error("Native StorageManager.getDirectory() is not supported in current environment. Please provide an adapter instead.");return globalThis.navigator.storage.getDirectory()}const a=await r,o=typeof a=="function"?await a(e):await a.default(e);return new Nr(o)}var uh,ph;const kE={adapter:{cache:!!(globalThis.CacheStorage&&globalThis.caches instanceof CacheStorage),native:typeof((ph=(uh=globalThis.navigator)===null||uh===void 0?void 0:uh.storage)===null||ph===void 0?void 0:ph.getDirectory)=="function",sandbox:typeof window<"u"&&typeof window.webkitRequestFileSystem=="function"}},Bp=r=>typeof r=="object"&&r!=null&&r.nodeType===1,Pp=(r,e)=>(!e||r!=="hidden")&&r!=="visible"&&r!=="clip",fh=(r,e)=>{if(r.clientHeight{const s=(n=>{if(!n.ownerDocument||!n.ownerDocument.defaultView)return null;try{return n.ownerDocument.defaultView.frameElement}catch{return null}})(i);return!!s&&(s.clientHeightne||n>r&&a=e&&o>=t?n-r-i:a>e&&ot?a-e+s:0,BE=r=>{const e=r.parentElement;return e??(r.getRootNode().host||null)},Rp=(r,e)=>{var t,i,s,n;if(typeof document>"u")return[];const{scrollMode:a,block:o,inline:l,boundary:c,skipOverflowHiddenElements:u}=e,h=typeof c=="function"?c:z=>z!==c;if(!Bp(r))throw new TypeError("Invalid target");const d=document.scrollingElement||document.documentElement,p=[];let f=r;for(;Bp(f)&&h(f);){if(f=BE(f),f===d){p.push(f);break}f!=null&&f===document.body&&fh(f)&&!fh(document.documentElement)||f!=null&&fh(f,u)&&p.push(f)}const m=(i=(t=window.visualViewport)==null?void 0:t.width)!=null?i:innerWidth,g=(n=(s=window.visualViewport)==null?void 0:s.height)!=null?n:innerHeight,{scrollX:y,scrollY:b}=window,{height:A,width:v,top:E,right:C,bottom:M,left:P}=r.getBoundingClientRect(),{top:k,right:N,bottom:H,left:T}=(z=>{const L=window.getComputedStyle(z);return{top:parseFloat(L.scrollMarginTop)||0,right:parseFloat(L.scrollMarginRight)||0,bottom:parseFloat(L.scrollMarginBottom)||0,left:parseFloat(L.scrollMarginLeft)||0}})(r);let S=o==="start"||o==="nearest"?E-k:o==="end"?M+H:E+A/2-k+H,w=l==="center"?P+v/2-T+N:l==="end"?C+N:P-T;const F=[];for(let z=0;z=0&&P>=0&&M<=g&&C<=m&&E>=G&&M<=O&&P>=ee&&C<=D)return F;const Q=getComputedStyle(L),K=parseInt(Q.borderLeftWidth,10),ge=parseInt(Q.borderTopWidth,10),Te=parseInt(Q.borderRightWidth,10),he=parseInt(Q.borderBottomWidth,10);let pe=0,be=0;const oe="offsetWidth"in L?L.offsetWidth-L.clientWidth-K-Te:0,ue="offsetHeight"in L?L.offsetHeight-L.clientHeight-ge-he:0,ve="offsetWidth"in L?L.offsetWidth===0?0:R/L.offsetWidth:0,x="offsetHeight"in L?L.offsetHeight===0?0:te/L.offsetHeight:0;if(d===L)pe=o==="start"?S:o==="end"?S-g:o==="nearest"?Ja(b,b+g,g,ge,he,b+S,b+S+A,A):S-g/2,be=l==="start"?w:l==="center"?w-m/2:l==="end"?w-m:Ja(y,y+m,m,K,Te,y+w,y+w+v,v),pe=Math.max(0,pe+b),be=Math.max(0,be+y);else{pe=o==="start"?S-G-ge:o==="end"?S-O+he+ue:o==="nearest"?Ja(G,O,te,ge,he+ue,S,S+A,A):S-(G+te/2)+ue/2,be=l==="start"?w-ee-K:l==="center"?w-(ee+R/2)+oe/2:l==="end"?w-D+Te+oe:Ja(ee,D,R,K,Te+oe,w,w+v,v);const{scrollLeft:j,scrollTop:V}=L;pe=x===0?0:Math.max(0,Math.min(V+pe/x,L.scrollHeight-te/x+ue)),be=ve===0?0:Math.max(0,Math.min(j+be/ve,L.scrollWidth-R/ve+oe)),S+=V-pe,w+=j-be}F.push({el:L,top:pe,left:be})}return F},PE=r=>r===!1?{block:"end",inline:"nearest"}:(e=>e===Object(e)&&Object.keys(e).length!==0)(r)?r:{block:"start",inline:"nearest"};function ea(r,e){if(!r.isConnected||!(s=>{let n=s;for(;n&&n.parentNode;){if(n.parentNode===document)return!0;n=n.parentNode instanceof ShadowRoot?n.parentNode.host:n.parentNode}return!1})(r))return;const t=(s=>{const n=window.getComputedStyle(s);return{top:parseFloat(n.scrollMarginTop)||0,right:parseFloat(n.scrollMarginRight)||0,bottom:parseFloat(n.scrollMarginBottom)||0,left:parseFloat(n.scrollMarginLeft)||0}})(r);if((s=>typeof s=="object"&&typeof s.behavior=="function")(e))return e.behavior(Rp(r,e));const i=typeof e=="boolean"||e==null?void 0:e.behavior;for(const{el:s,top:n,left:a}of Rp(r,PE(e))){const o=n-t.top+t.bottom,l=a-t.left+t.right;s.scroll({top:o,left:l,behavior:i})}}function Zi(r,e){let t=ud(r)[2];return e&&t.slice(-1*e.length)===e&&(t=t.slice(0,t.length-e.length)),t}function jt(r){const e=ud(r),t=e[0];let i=e[1];return!t&&!i?"":(i&&(i=i.slice(0,i.length-1)),t+i)}function Ui(r){return ud(r)[3]}const RE=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/;function ud(r){return RE.exec(r).slice(1)}const{GONE:yg}=Go;FileSystemFileHandle;class pd{_path;kind="file";name;isFile=!0;isDirectory=!1;constructor(e){this._path=e,this.name=new URL(e).pathname.split("/").pop()??""}async getFile(){return fetch(this._path).then(e=>e.blob()).then(e=>new File([e],this.name)).catch(()=>{throw new DOMException(...yg)})}async createWritable(){throw Error("Cannot call createWriteable from a URLFileHandle")}async isSameEntry(e){return FileSystemHandle instanceof pd?e._path==this._path:!1}async queryPermission(){return"granted"}async requestPermission(){return"granted"}}class DE{async handleDropEvent(e,t){throw Error("Cannot call handleDropEvent from a URLFileHandler")}async getDirectoryHandle(e,t,i){throw Error("Cannot call getDirectoryHandle from a URLFileHandler")}async hasFile(e){return fetch(e).then(t=>t.ok).catch(()=>!1)}async getFileHandle(e,t){try{if(!await this.hasFile(e))throw new DOMException(...yg);return new pd(e)}catch(i){console.error("Failed to get file "+e+": "+i);return}}async getFileHandleRelativeTo(e,t){const i=new URL(e);Ui(i.pathname)!=""&&(i.pathname=i.pathname.split("/").slice(0,-1).join("/")),i.pathname+="/"+t;try{return this.getFileHandle(i.toString())}catch(s){console.error("Failed to get relative file "+i+": "+s);return}}async getDirectoryFiles(e){throw Error("Cannot call getDirectoryFiles from a URLFileHandler")}async getDirectoryFolders(e){throw Error("Cannot call getDirectoryFolders from a URLFileHandler")}async writeFile(e,t){throw Error("Cannot save to a URL file!")}getRelativePath(e,t){throw Error("Cannot call getRelativePath from a URLFileHandler")}}function Za(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var vg={exports:{}};/*! +`,t}requiresSSC(){return this.timingData.requiresSSC()}}var He=(r=>(r.SELECT_FILE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAArUlEQVR4nO3YQQ6CQBBE0X8PXKrn9DqGcDNNZC5QhGR2agQk6Z5QL+l9FwULGszMzN6dgB4ogFbOjQTLPzcsniZE/+fy4SHKTgHCQijZFGAALq0GUJ35u+xaDiDg3nqA15YA0bR2HwfYmdxAMLmBYHIDweQGgskNBJMbCCY3EExuIJgO18DY+k/9kGBRfZn57PnTFXgkWFYfDltnFurqESnD6zTWJ794eTMzO44JY84XrlhT/UgAAAAASUVORK5CYII=",r.REVERT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAACY0lEQVR4nO2aTUhVQRiGn1pYSVqLBM0WbQpNuLcoRIhS3AVFEEWLtiEKRRAUghAXidyoRNAf7XPhwqSfRW2jRVw0cpVCBJrR36KIfggqDswFGQY7Z+65986Zbx74tud+73PnnDNnZiAQCAQCgYAFm4BuYCMC2QO8B/4CS8BWBLEb+KTCl+ocQsgbwkc1hJDwHw3hRQjIrxLeewH5/4T3WkAuRnhvBeRihvdSQC5BeO8EtAPvEoT3SkC7RXhvBHQAHyzCR/UWKFahngJTwE01++wBNqQloGgZvtb1HXgInATqyhHw2YEw5dYycMZWxJADAdKqOWCfjYRRyx+8DeytQu0Hjqp/+Q4wv0pPv4DT1ZJQoHa0qZ6/pvmGGsuQgBJb1Kj4Y+jvbKUlFHCHE8BPrb/f6pWZmCsZFIAK+0Xr8Q3QUKmRUMA9jhhuh8u2FxvLoICIa1qf34CmSkgo4Cbr1eRoZa+D5VxwPGMCIi4aJkmkLeES7tKohn6p1+i50Jy2hMO4zSOt31NpXHQAmAb6cZ/zmoAbCKNHE3APYezSBDxDGE2agAWEsV0T8AJhdGoCHiOM45qAuwjjuiZgGGG80gQcQhBdhmX0egTxQBMwiSAOGhZFehHCZrUMtjL8c2ANAqgD7mvho5FwAAE0AE8MaxbRq9B7OoBZQ/himrvILtICXDXsB5Q+fFrxjLXATrX3N602PkxrlS+BbTjMOmBEfZ/HPSQRzep+xNirmMjCQe7BGEGS1mvgGBnhVorBZ4C+ck+J1OLkue3JlEV1NOaCevpnlsaEhyR2ZOHeDgQCgUAA9/kHkepiJFq7BJgAAAAASUVORK5CYII=",r.ADD_FOLDER="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAAvUlEQVRIie2UTQ7CIBBGnz8rb+Mt2hqv4TGMmt4Kexl7gUa3TXBRTAALQqGJJr5kNpR+r8ykwJ9vogJaQDrqlCrwhWeRfAoPrRYo5xRI4OYTpGLkLDMEevl9wXqGzC2wH3uQa8gGOVpUAALoVAmGW+GNKSc44v4XLqmCwgpcqfVeWzNOEisQAYJGfyHkspPARu3vrGCbHrjrQz4oSSiLiL2TuBLZoljKAMEuRQBwxj2rOjX8RcXQioeqBu3Ln4QChU8M4+FlAAAAAElFTkSuQmCC",r.CHEVRON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAAbklEQVRIie2PMQqAMAxFXwfP6qJVPIjYzcOKdUkhQ0BaCoLkLS3k818CjuN8ztApYzIDl7xvmalFsAIZuIFozKPMMrC0CAJwKIkuGVX5KdkmLEm3ci1JSlLKU49yLSmXVG1es0EANvnvInKcP/AA784fpjlWwNQAAAAASUVORK5CYII=",r.EDIT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABOElEQVR4nO2WQUoDMRSGP5duWgpS157BhQuheAR7mOrSuKviPbqQit5CaC9QEOxO2k2XhaJEAhkoZZLpVJy8wPvgrSaB73+TFwKKokjiAngGlsAG+ACegFMy4Ab4AWxJLXw4sZiA+G6ILpnKW1+PZB5ghlDMngHWCMbsEeALIaIm8s1GatSwa1Swbohv4Lxh30oxU2PtoGHfSqGihoE9t1tr7hA+nCayN/RN3B0/RBh15K20EIfIWykh/iJvcxhYlf8PtPOp0M6nQjufCqP3fEJaQA8YH/AXkj6Jy3jJWd5xlbO840T6w6zgAWhTzjFwGZgJEZ0/AlbAeyREwViavONsS6oqRE+avON651jEQrSlyTvuS872FOiQCW+B2yWbEPNAgJW/ncQzAT6BV3+++36wFUVRFAp+AZvenA82VBInAAAAAElFTkSuQmCC",r.ADD_FILE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAABiElEQVRoge2YMU7DMBSGvwQJVO7CwN1YYEFUMAMdYCpHYUMcgg49A3SgEggGE2GskNh5frYr+ZOsppWS93+q9WIbKpWKD4fAHFgBH8BX4NgCt0CbOjiY8M8BYYfGkgwS8wjBs0qsrOKnwH7g/dkl7DkfGh4K+CfsotL7lz3f1SViCjTAnfPbA8oSMQUgg0RsAUgsoSEACSW0BCCRhFRgrA23KHcnqYD9Ijwjg4RU4MJ5RshYSIJ3SAVmwNM/AcfGuyR4h1QAjMQ58EL4cnyQxqO4279T4F0zywYjJlUgN1VgF4jRRkM5Ag5+PgcptY16U+IUajFLiA2RzpJSTqEGuHdqipfXqQT6wkeRSCEwFF4soS3gE14koS2wcGr0bWxEewRtgTf+hm2dmu5u7TW0gLbAFaZl3vA7PdyaLaalboBL++ZSX2R1P7Az+Ah8WtdTjtdV8RFYW9cnFCgxhuRcJ3R0RO18knOdIgQ6iannOkUIpGaLCT96Mrenn2USM+AYuAYeM2epDPINL56D04/lX9sAAAAASUVORK5CYII=",r.MENU_VERTICAL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA+ElEQVR4nO3XS04CQRSF4X+kYx8h0UWIM5vFoIxVdkCgmbMDlSWBsAchLMLWVHI76ZC2pnLgfMlNOqlJn1TdeoCZmZnZSbqNknUPrICfqCXQRcw1sG2EqGsHdBAybAlR1wtCZpkgaUzGUyZIHyFne43ebPg0JuUSeAe+ot6Ai//+KTsWPaCMKhBVAlWj0dP3GMGZqFp2rUptZqaZcyTNlIwyE2SCkOKPpfUNPCBmvBcmhRghqohlNlGcCTtUV8Ac2ER9xEVSyjmwbtm1PtWu8YPMOfKIkNmxPHVfM0GeEWv0bUuIjWLDd+ONXodYAHcIu4kyMzMzOzW/IiF2pLfCTcAAAAAASUVORK5CYII=",r.COPY="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABZklEQVR4nO2YQUoDQRBFHwiDB5AsXCSexYxeIVfwCDlE1hoXuUBuodl4CDGOgSyySrIKGGgZ6EAxTBZOVzc21oPe9OJX/eqqgSkwDMPIiT4wBhbAGjgCTuFsgBnQi5X4JTABDkoJnzvvwJV28nVV3iIn7sSZa1e+mfwrMAKugQv+OBOR+DfwQGYDexAGZPI3wDOwUhxk58/R606BQYiBsRB9Eff3wD7RPOyAsquBhRAaicqnSt4JE3U3/Jq1EKkHFt82p7sP4BYo0KUAhsBSxHrqIiR7+/S1WYm7OvmYDEWsqouAfMY2U9qVb1I0BlvFQNtdTFxIPDOggLMXwGYgCGcthLVQEM5aCGuhIJy1ENZCQbh/3UKb3A3McjfQ87vKbA3gF63zXP+J2/hKuJUoRaxPLdGpEF36IDH2QneNvdCjlvjAb8pSbua2XTdz5ygTmtj6BZc6ff+sVaTtdOX1VStvGIaBOj8GcNhDDTqXrgAAAABJRU5ErkJggg==",r.TRASH="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAABdElEQVRoge2YsU7DMBRFDwxlgb0wlB9BLMDXtFvhE2BAogNDxR+1S+ETEBJiLqVSU6lVGOwoJsQhDnEc0DvSU63c+OXeuElVgyAIddMBBsAUWOqaAH2ttZoj4AmILfWoz2kleyiDNvNJzWjpSgxITUbAEDjUdamPJXo/kMdCpqQGhzn6laFPGvRVmg9Sg90cvWvoiyYM3QArfv5O+64VcG0zuVNwfAHsu+f2whI4yBN2LRNi4B714IUmQnnJxbYCecQV57ngfA3bCvwZJEBoJECGO9R7+9ZRawTzx8XGWutrR83lGl+o+zVadM5v5+ciz0BoJEBoJEBoJEBoJEBoJEBoJECGKPNZVqtM3QFGqD2ckaNWGdlWCY1LgK0x9rG/b/bcWs/K4BLgzRifOMwry6kxfvXQnwfSP9zPwDn1rEQHuNA9k/7jGvp+4xh4x21rvErNgZ6PAKDuus8Qc+DMl/mEHmqJX4BNDaY3utcYj3deEP4rn4hExm+tmh+HAAAAAElFTkSuQmCC",r.IMAGE_FILE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAB8UlEQVRYhd3WTYjNURjH8c9IozRlwUITTbMRNlNWxksWjKxkYbJQY6mUTCKxmDSkZiezm421KQsRFkgpL7Eg2Si3RJOFl5SIzVicc5t7p/9xz//O/5r41el2nnOe83zv8/zPC4usrgLbBPrbXO8DTuHHQgBm8QjvSwZfg0HcxV58L+nfBDDcht9w9P2IO1ie47SkjUCttBMDuIWexQB4gV3YiJutIDoB0AixoRVEpwCyIaoE+BV/Zxvac6zCdlwoclpaIcBt7EN3wdhxrO40wE9cS4wlt3Unv4EslQE4g5nYTlcFkFuCAxjH2dg/hzeY/lsAQ7iH87G/A7sbAPqFe6VWFiC3BDXheF0v7OsBIQOwEvdxpWzwlIouox48Mbe/H0dbF67jU7RvSaw5LVGu3Ax8w9aGti3aTmCPcP0+xdHM9f6o1HXcHQPXoQeF0+9k7I/Efm+BbzIDZQDG4tjLGOwtbph71CwTXkTjZQByS7ACo5jCK1yOgQ9FKMJJOIXDEaZtFWVgDF8iCKxDX4Fvr1CGkXn2BWWg/u8v4mu0vRZKMF8zuIpjGetmA4zGeZcy15zEJukt2aSck/CIkIXPmQB1HcTDKgD2S9zlLfQsZ1IOwIM2gmfrn3oP/J8AqW9gc8Vx1uJd7uSa5qd1VW2iKNhvOK12/OBuEgoAAAAASUVORK5CYII=",r.AUDIO_FILE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAADFElEQVRoge2ZzWsTQQDFf200qVrBUBAURU/aVgTFSvUoXsQqgoIUFDx68SKieBILeujJFhH/AD0VRBD8REHBD/zCIqUm6kG0UqltE0FFqqkedif7Nuymm2bTbWUfLLy8+dj3kpndmQnEiBEjxv+KDuAx8BroBlLR2qkMx4BJ4K9c5yN1FBD1QA9u4+bKVdjXPOA6kAf2h+jRFymgD7fp+yWfK0GztPsKNIbm1ANp4AFus31YoaYbIAG8l7YnwzJbiuVAP26jvVjDCaYfAOCQtB0FFldrthTrgSG5ySTWBFYEDbAHa7zfBBpsLQFkpf2JUFzb2Gbf0HT+C+j0qBc0wFWpd1j0g6K/qc6yg04sw6bjPFYgLwQNcETqZXGGYAoYk7JN5TpZAHRhTZ4/JTf3u4awhpIfggZYhDXOTd1dUnZR9HPlzD8MaNpcA8DKKYxVMonPSN3Lom8V/aNf464KjBewXjLpAKa8AqSAO8AXYIfoLVI3DyRtvQ4YlrIVXjfSZ+5xYH4Ac0HgFaBNtIxt0GBAyraLrpN8rxHrpcJq4b3A7+q9+2IQ+GHztcAWKbstXCfsE+HthmiAhPCJKg1OhZ/ANfm8U/hL4RuFPxfeYogGmGlcEd4uvF/4GuHDwpsMiTKAvpTU6IhwfUiMCm/CA9WsWcrBr99G0b+JnsDZS+RK9IKtF0NG+Qso6ny435dZ1KMMsEr4uPAlOCHyoqdx/BbrRxmgWXhW+FLhOoR03M+KAPuEPxW+Qfhb4cuEjxmiAQrCk9QWC4Hd8vmGcH15vRK+WfigIRrgg/Cj1DZEK84eN4P7F9C10Qvh+rZ+5tXpaWZuMZcE7mI9DvUt3Cp1c7i/xM9S5rmYmw3L6bNS95Lo7aJ/KtdBA3AKeEc0GxrdeXVI2QXRfTc0laDWW8oMzvxM4t6ptVVjXDFTm/oDooe2qTcI+1glB9zCfaySkfahHqsYzOmDLYM5fbRoEPbh7jppN0KND3cNyh2vj5dp54UkcA/4jvfDoabw+oOjZ5p9Rbbg7AAeYT1Fuqn9AjFGjBgxIsA/jvJ6jenUZ2YAAAAASUVORK5CYII=",r.SM_FILE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAcpJREFUeF7tmFGOwkAMQ+H+h95V2S2qqlKcsZ101PADQpPEfnFHgufj5q/nzf0/GkAn4OYE+hG4eQD6EuxHIOER+CFnWJdkbf5vfAEwOoephbiPCoOaN4A/AswWmVpoSZ0ACBN3iNkiUwup7gRAmLhDzBaZWkh1JwDCxB1itsjUQqo7ARAm7hCzRaYWUq1KwJlQxoSr7xuOAsD2x85RPweAbzOh7S+HWACrkKXP9vNWgBoAMjMFwJHhT9+Ngt7DQ2faAXza9vrjZ5suVQIiM60AzoSsg/cxZRMQnWkDgAjZQ2DumuhlF9H30hnZTLj5ycWIbsg+EwUwIgQ16TgH60UAwM0cToiekG4EwNHNTuhKKYXMZ9wBKW53Q2DzUQAzJCFkfgTAlSGEzY8CuCKEIfMMgCtBGDbPArgCBMq8AkAlBNq8CkAFBIl5JYBMCDLzagAZEKTmHQCcEOTmXQAcECzmnQCUEGzm3QAUEKzmMwAwEOzmswCMQEgxnwkgAiHNfDYABEKq+QoAZxDSzVcBOIJQYr4SwBbC8rlMC/qv8CpS/V62+VLqaopMv+oEMNoltQ1AgnHiJp2AiZcnkd4JkGCcuEknYOLlSaT/AqRIb0Fn6qw5AAAAAElFTkSuQmCC",r.UNKNOWN_FILE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAA+UlEQVR4nO2awQqCQBgGv6KeM+rU+1/L7F4RreY/W86ABw/ujsMPImwiIiLSwlh0XZIcit6piaoAY5JbknPNa31OZYAuI1QH6C7Co9zS63cXgQrQTYTqAMOL+9MC+35MdYBjniOgk1AdIOksAhEg6SgCFSDpJAIZIOkgAvkZfHcNmfDvsJkoOHeNlvVbuCbZtzzwbwGSRp/tzM1+nh0t8ILWiZo1MaufAAPQAjQGoAVoDEAL0BiAFqAxAC1AYwBagMYAtACNAWgBGgPQAjQGoAVoDEAL0BiAFqAxAC1AYwBagMYAtADNN84HLHFOqIzVT4ABaAERERGOO8QV911rDPw7AAAAAElFTkSuQmCC",r.MINIMIZE_WINDOW="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAANtJREFUaEPtlbsNwlAQBMcRLQC10QZEiAAi0wa0xqcMdIiICGmejZ60znfPN3OWBzp/hs7fnyzwb4MxEAOSQE5IAtTxGNAIZUEMSIA6HgMaoSyIAQlQx2NAI5QFMSAB6ngMaISyIAYkQB2PAY1QFsSABKjjMaARyoIYkAB1PAY0QlkQAxKgjseARigLysACOAEbYCX75oo/gCuwrwXOwHauyY3njLVAbbNsXDxX3bMWuHd0Ot9gbrXACOzmQtZ4zvuE6iM+fj7ideMBU9XV1VyAQ/4DUyH+tbd7Ay+Srg0YYU5a1gAAAABJRU5ErkJggg==",r.CLOSE_WINDOW="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAA35JREFUaEPtmbfrFUEQxz+/0pwwFNoqmMCcc46olY1/m7U2Ys45IWIuDFiJCYyYC0X5ypwcx93t7O57yIO37c3Ofr8zszvhBujxNdDj+OkT+N8e7HugVzywGtgLPAB2A1+6BHw4sB+YBuwBLoTO8YTQMuAYMNSUXQM2AZ9CyiO/jwBOAAtt3zdgG3CuTU+IwFLgeAl8oesWsA74EAmySVzgTwILKgJBEm0ElpvlhzScegPYCHzMJDEKOAXMbdDzFdgMXKr73kbgFTAhAO4msCHDE6OB08DswDkvgImxBK4ASxzWVTitB947ZMsiYwz8LMc+XeZVsQRGmmvnOQ64a3firUNWIgobWX6OQ/6O6X4XS0DyIqHLNd9x0D076E1AdixwBpjp0HnbdDZ6N/QK6YymF6Lu/IfAGkD3p26NM/AzHOBdoekhUJAov9Ft5z8ClPiqJAT+LDDdAd6da7wEdKaypEgscgB4bCRemux4A68MG1pu8FIUQ0DyyglHgJUhFMATI/HTsulUx56rluU/O2T/isQS0J5hluCUpUNLJLQmhwSBi8AWQInLvVIISPlg4LBZ2H1Yi+Bly7bRRWIqgYLEIXt1ckioRJDlo8GnhlAZrDxxEFibyEA10A7ge+L+pDtQPWuQkVB1GrOUIHfmgO+EBwrAInHACjsPCZXou4AfHuE2mZw7UNYbk621TyWCwi67n+gEASU4hUPRSXmN2pGmKJdAKviCZDaJHALKyuqV1bnlrOvW2SX12KkEOgW+IJ5MIoWASgkVdYsdZlfLqeVpilTEqcd210Epz6gsfxRY4QCvTkovza+GiUOdimgSMR6IqUQL8EUnpWdWWdfT2UWR8BKIAa/+WJav9rBdIeEhoHpHYePpAZrAF+ESQ8LVG4QICLwamNqRRiWIQ+AL8ZhpR5BEG4EY8JpIqJmvHX3U3NaOkWgjoFpfw9XQ8lq+qsc7ldM+NU/b64C0EXgGTAqgj7V8HQnNiELTuedNWNoIKO4V/wqluiXwem2807gmW8gTbSQ0od4KnI/1gOSr/wYKHfct5nPBly+2Ro3VCbU6NYWx5km1K/QKaVN1zK7BlbzzOnQ5Ir/rYpdJCLziXt5pXB4C2qxQ2Qc8NXeG5p+R2P+Ja2Ktx2OK/cpqBa9dXgKF7O9UZN3aF0OgWxiy9PYJZJmvA5v7HuiAEbNU/AEymbExfA8cowAAAABJRU5ErkJggg==",r.SKIP_START="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABEklEQVR4nO3YPy4FURTH8asQFBKvsAeNbQixBxqVxi70lqK2BZUlPKJ50SlQ+Ih4JMZ48+fOTDKT8+2/v3PO5M6deyelIAiCIAiC4A84xgPucZTGhq/Gv5m3zJhhO6OHWWtfgYbuOi7xhlecDelnDYA93Bb0xVB+1gA4wXPRHcr/RZMA7OK6rPAQfil1A3CAx1XF+/T/pSoAW7jCe1XxPvxKVgVgH3d1Cvfh16IsAGu4WG5tjejCb0RJxiZumhbuyk9NKck4z2g+208xgJEvoTT2lzhNYRudzIdsEkeJyRzmJnGcrnEheUoD+T/kPIHClfAFp0P6XV7qd7DRxs32P3+lLIeY47BVSBAEQRAEQZD65ANrrC3m/GFNbwAAAABJRU5ErkJggg==",r.SKIP_END="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABBklEQVR4nO3XPWpCQRTF8RskEBBBy+wgvZuICNlCKgsrt5AqC3m7kGzB3l6tREgnUYt/GHyveJBq7pvRIefXn8sceB9zzURERETk7gBTYAdsgUnskAEwchwiOs/14I1NzIAZcALOwCfwmDnfElPg0B7BCnjJmHcX+MsRWAAPufPWUYHGEnjOmbeOCwR74C1X3hIUaFRAP3XeEhYI1sA4Zd4SFwguwAfQS5G3DAUaX8BT13nLWCCYd503FfgHj9Cl5Jd4XfJntCr1R7Yv+SqxLPUydyzpOv3tXEi8eXeBd+CnXgtjVkJv3legHhJ+KMOosDOPd6m/NWBSl9gAr7c+j4iIiIjdoV+nEzteGs3QogAAAABJRU5ErkJggg==",r.PLAY="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA40lEQVR4nO3YMS5EURQG4ENBr9dKsAMq9qCdLdgBSh1rsIVZAjZhelrTITGf3GIiCsm8mZd593K+7nXnb/7890WklFJKKQ0HGzjGKTajNbj17R770RK8+al8X2IrWuB3TziJhgMUM9xhJ2plMc84i4YDzI2xGzXR3SvOq6lcy3vAQcsBig9cY7vVAMNXrv584qLlAHN7GaAL/ZmVDRXr1tPxkzLH1378f6/RRxwOdvgKAaYtT4lxq2PuBaOokT/8oJkMVo0rPurfcTVoNXaBm+o2/hI/to7KHK6mGlNKKaWUYiFft4ARJbTJcIwAAAAASUVORK5CYII=",r.STOP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAo0lEQVR4nO3YQQrCQAyF4XcQXffsFsGLqdhe4C8BFzLgYiAJFN53gc4/6WYimZmZ2UkAV+AO7OTbgQewVB7+Rb13fKsiIG6+y1oRUPHb/LNVBLSSAwaewCRlo5kcMPAEJikbzeSAgScwSdloJgcMPIFJykYzOWDgCUzSyR/1n4qAWDp1uVUELN+lU7UncEkP+NnOrbG3KTj4FjdfdngzMzNTvgMULRo3zp7/ZwAAAABJRU5ErkJggg==",r.RECORD="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABMElEQVR4nO2XPU7DQBBG3yUo+AniOkgQcQ3ID2ehA4EoKOlDuAmOcgpiOhJ9yNIUlguwE+/YEfOkkSxX39sdz3ohCIIgCIIgaAXBqWAieBdkgi+rzN6NBQP6huBY8CBYC/RHbQSvgjP6gOBKkNcIXq2VYNh1+Ftb0abhy7sx7XLldwlflvDdCcHJlm3zWzsdeQo8txheVo+eo7LOtGla62JnPQSmCcLLauQhME8oMPMQWCYUyDwE2pw+qlS+7wKfHgKLhAIfHgJ7/xGPEwpcewgMEh1k3y4HmUk8JRC4dwlfusCs2pw+gkM3AZM4b6mVNoJL1/CV/6JdLzSTTsKXJIZbtlPRNhf0AcGB4M4mSZ1Vf3Hv+QY3tZHgrThV7bcjt+eZ4MZtVAZBEARBEPwDfgDcyqJBiCPoQAAAAABJRU5ErkJggg==",r.PLAYTEST="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABdklEQVR4nO2XSUoDURCGW0FvoBtbL2AQT+KAwZXgCfQK4srhGA7gQsVFMF5AjyBOOYBiUBK38ZMHDTb60nn1MlWgvn1V/V+6Kp0kiWEYhmEYCgFKwBVQZ3jUswzz0vALwCd6+HCZJAI36KMaGn4KaKGPFjAdIrCJXjZCBM7Qy0mn8OPAO3p5A8aKBBbRT6lIYFvQqALMAClwHREktn6rSOBS0CjN1c1GCMTWXxQJuB0LwlM7KIHXduHnJNN7IODWJs3CV2Pl8wGWQ3a27eP77RN7ExKWfIN3xdbtJWJuQsJOzAFrEjj3Db0L2dnA8NKdlnLrG1yTdPDUd0tF8F548Ql8DVkgFaxg0yfQ6OPAXvdr+AQeB/g93m2/B5/AKaPDkU9gndGh7BOYAJ7RTw2Y/CeQSayim2/vz4g/EofoZa8wfO5v5QH6Pvl9l62jQE5kRclNPHVcmwIJd9hl4Bi4d2/AAQRuZrPczDWXISq8YRiGYRhJ//kBnszTFsS/lqcAAAAASUVORK5CYII=",r.ADD="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB7UlEQVR4nO2ZS07CUBSGCT4GDn2MQHch0YUYjC4EwwLAuRA0LsGIAxUHrkKjC/AxEnBMnXzm6DUhFeJ9tb3EfkmTJoXb/2/a03P+Fgo5OTnOAHPANlAHzoFH4B34UJvsP6hj8pstoBiC8HXgEHjFnBegCZSzEL4GnAAR7kRAB1hNS/weMMQ/A2A3SeELwCnJcyzn8i1+CeiRHtdyTp9XPk3xP9wCiz4MpHHbTKPjKn6f7Knail8B+lmr57vimZdYVedDoW0qvuzpJeWLCNgwMSDtgStXQEldDB9VrGnSmNn0NnHKsZ7JlWetBlB1lc5MWNcHFR0D0u6GauBAx0A3YANnOgZk8AjVwL2OgaFNtflz4d/nsalOfZ2FTeu/9USFeXUa/QsDQ8NFezYmlPibJG6hmX+Iu7NeRusBG6jpGJDQKVQDmzoGiip0Cq2Ze9JO81Ri5spXdbKsNpNoaIkPdKAZGb/tVdwXCkdG4pWB5UCG+oF1bipZZdbqgR0r8WMmJKvMipaT+LEZ+SID8VfAvLOBsXBXAte0uPQW7sZC3jQqU8vblZ9ipJpQdXpzfmANc9O2esG4MpI6L2U7FfExIyXVdkjoZIr8p2EzTydhRBrAiuQ20rPL4KEmu0htsn+njtWkqwziM2tOTmH2+QRxCeic7ZLqUgAAAABJRU5ErkJggg==",r.SPEED="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAACYklEQVR4nO2ZS04bQRCGrcAmu0BWAYM4BCE5R4QQJ+G55bEFEZQLZIEgCYiHcw4QF0hgQWJgazubLyqpIjWOx1M93fNAml8aaTRWd/9/TXVP/eVGo0aNGsEAXgDvgTXgK3ANPAJ/9HrUZ1+AVeCdjGmUDaAJbAO3+OMG2AImyyD+GvgE9AhHF9gHxosivwjcEx9tYCFP4qMadSvOJT00zVoe4z7KWrHJvwTOPCPadMZPeY49lTVjRt6XfKiAfyLC34Rn2rhoafoI+e8Z59iLsWH7cQFMa37LfSiOVWjSXpkPOSrvU1JDhITgwE0TFdGP38BYzNSZiiTgCfmUveKXShqJXkpuz3gej2nkRzWdkj52Ez4CpDzIC0nkD1LGbfoUZj9zIn84gPwI8NkwVuqtEYsAqSqrFHkXcxYB61Qr8i6WLQK+UU3ygiOLADEeoZATbGnQyZEhbVxcWQQ8RKgqB75qI/nzIeu1LQJ6EYqygWe2MfLNIet1SxMgz4xjm6ECHiJUlf+lELBiHNsasl67yE28rFGf0PsY/vnKIkDaIlXFoUWA9HaqiiWLAGk6VRWzZRdzIfhh7uZpx6xq2DCRVwGTaiIowBNfGObreBkaFSHtPnL2xNb5dr3IO6Ze2n15eWLrfL8ymXqdcCEnT+wz34dM5B0R0qssCztB5B3zUcbX+Sxak1ebu9KrLAon0Zq7fWZkrwDyu6buQ4CQeT0ZYuMueMN6iBjTt5H0sfNBR6P+qhDyfUKk1t/MWDtJbbMBvCmceEIBOKeu60iMhzq7nl5yf6m/ibl5W4m/WWvUaDx//AV2V/CQip4uIQAAAABJRU5ErkJggg==",r.UNDO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABeklEQVR4nO3Wv0tXURjH8dtgEuJaoEMSguBQBNUiVGv9D41uTg3S9EWiobGpv6Gh0Mk/IAyKnIxoq8SiEm0Q7IdErzh4S9Hvr6vnDMHzXi/3+Zz3c89zzq2qIAiCIAiCIAiCGixhGaerBmAA19HCAl7jK3bwDR+wgnnM4ipONsnodyF/edWPBCbxEBuas44HuFBCoKsEJupO/5aHJ6lmboFDEvVWuVtvjdzs4H7KyCnwTwIjeKE8zzGWU0A9lGkQu5GGdREzmMI4hnAKo7hcP3uE7R61vuB8ToFufMLttNgGOcOYxvsuddPBcLGkwC/MpQ437tRe3iDu4GeHjM/p65UQ+JjO/aMuvE3uJbztkPWs78FuINDXPdFQYgRvOuTdyy1QSuIMVttkfce53AKlJK7gR5usxyUESkm02uSkQR8sIZBdwu7d8e5AxiZO9Hpx7RgSL3MJJHANW/u6f6vqBW4cQ+JplRm7vzA3cTZ37SAIgiAIgiAIqv+aP0/ezoLd5BjTAAAAAElFTkSuQmCC",r.REDO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABi0lEQVR4nO3WPWsUURSH8Y2oIJKYRhdiEa1SCJqXVvAzuEXMB5B8BEuLiKRIk8pSLC1WSJMqBEIgasoglmKRYBaVFEGEpPAnK7dY193ZndlZWOE87cw59/nfe+alUgmCIAiCIAiCICgILuM+nmADBzjET5zjBB/Ttad4gEs51xjHduqTqzar6V2s45v8fMcL3OlTfq+ltjqo+EzazTL4lXrN9ClfPEAalbU0FmVzjmet49FFvlgATON9hsBXvMIy5nETV5pCuI4FPMYbnGb02cdUhnz+AJhLM9uJXdSap5PzJBfxoUvPoxTEwAFwr4v8JzzMtRP/9r6AR/iSIVs8QBqbTm+YOiYGkW9bp4qtUgOk2X3boXilLPG29a6hUWaA1Q6Fz4ckP57xwOYPgNs4ayuqD0n+KnZyyPcV4HVbwWdMjsDO9w6AW+nr2EpthOR7Bpj1N+8wNkLyPQOM4eWf2zhu/rCVKZ/W2FScH339jeIGLpYtn3o3vyNFaGBpGE5BEARBEARBEFT+S34DOXeCiMi4hZkAAAAASUVORK5CYII=",r.CUT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAACxElEQVR4nO2YvWsUQRiHRwMKKojkQxMUOzWiXbCxU7BQMRFRrCKKtQqXiF8EY+dfYEQrxcZW/QdEbMydWhhQLERR8QPWJIrBmHtk2PdgGXZnZ/d2zyn2gYMQZmZ/M/N+zatURUVFhbcAvcA1oAH8lJ/+exLoUT4DHAZmSeYHMKI8Fr9EOkvebYLQbGwnbxJ4ZU6ENh9lAagB/fKryf+iXC1Jy3JgFHgDfAGOu0x6boirxYwZN8Y0ShC/B6gb3/nsMnHOmNQfM2bAGDNXoPBB4EGCub5yWUDbdJR1DhsIChC+HrgBLCaI15axw2Uh89rOOJjQszaErwIux9x8i4/AKe0PrgteMhbQDnsO6JaTH49x4gs5HfQE8CFB+C8JKGuyLtwHfMOdr1nDKLBXMnpSbrkDbMx6KNEPHLLYYpQ/wIEM624HHlnWewwM5RZufGw/MJ+ygVHHtTYANy2H8hY4Uohw48Pa5u8CTUs9dB5YaXHQK5aDCCQxrihcvCFkCHhquYn3kjGXRRz0KPAuYfyi3EhfqcKNTWhRpyWlJ/EEOAm8sIzRSWpbx4Sb6LCma5+YUJrGjPYr5QvAlpSI0kKH5LNAl/IJYDUwIaE0jt/AdWCt8gmgS1K7TvFx6Ih1D9isfAPYB7xMceJdlvm7gVu64uy08EHgvmsYjZm/ScqDZkfDKOEL7DbwN08ikzW2At8tiWyslESma5yCS4mpjpUSwLDl1KNoQQe9KuYIy+mkK08qp3tzlNPm27tFs61yWl5HWbsSF3160NRzdCWms24gw5PyU9YnZZCjK1HUo34q5VG/s6y2ymy7GzAc/WHCJmZUGjHONeZgQnVVTmOrYZqTy0TdOo+yIMlmwNKVKLu1+Fpqr2Muk3okw7qifaZb+QQwkqG9Pqx8hHATQcrJ+yneMKdJyQ3zEqGm5Unpl9lUVFRUqP/BP5CqMiH1c5cpAAAAAElFTkSuQmCC",r.COPY_WHITE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA2klEQVR4nO2YQQrCMBBFcxBd9yr2qBbBO9mtis0FngS60CiV4JAx9b9tFpmX+WFgQhBCvABsgQMQqccI9MGo+As+nCwE0svTskD0Kh7YWQg8EVoDCTjDP3SAunMiAkegMxFwnBPXdLeFgOecGCwEvOZEYrIQWDy3htL7JGAM6kCG/kAhKEIZilAhKEIZilAhKEIZilAhKEIZilCFCI1Lu8oWOtDPEm93lT8v8AkJFII6sMIIRfy4WQikRasXewuBbl601uYMbL4WeNhQD2lXWaHwKb28WfFCrIw7KN2RSPl95zsAAAAASUVORK5CYII=",r.PASTE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABHklEQVR4nO3ZQUoDQRCF4Ua8gC41rnMVPYSoxzMIgopXEPUWcatiZuH2l4JeTBokdlXsacL7YFYz01PVr1bTKcmOAfaBK+AV+M7XC3Bp91LPgMNc7G+egYPUI2AvF7jJkz2begNc8HfnrYo6AW6AgXoPwDEwAx4d7w/ALTCPFP+B36xYy+vT3vc0YDsfcTRay5KIWHga8IzN2F0eH7vug2utPA2s2XQ/KlV+Xw0Ab1sMYDlFAmdbamIJnDZv4L+hBgpKoPUGogRiUAKF4IYqgdR8BpXAOiWQNEJ10AgVUmNEv68GglACheiOKoFaSiCI6AjvQgID/fjyNGCHC7249jQwz4cLU3sfH5bUNmEnKwv7Pz9B4SvbeXfxIiKphR8IWaCtfT4/XAAAAABJRU5ErkJggg==",r.UPLOAD="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAACXBIWXMAAAsTAAALEwEAmpwYAAACYElEQVR4nO3dO48NcRjH8e+6NbrtCI2Iuyi20aHQigQlXoDE5Q2IUqKgFC0SkbhWVqXyAiRqFHYRbOy6LvHIiZnkSBZnZ2bn9v9+kl8/8/zyzDlnTjIDkiRJktQNa4BbwEfgLfAIOAOMN31gKZgAXgGxQJ5m5WiJ7AE+/GX4eZ4BG2ygegeAz/8Zfp4XwEZLqM5R4PuIw88zDeywhPJOAj8XOfw8r4FdllDMGHCu4OCHMwPstoTFWQ5cqWD4eeaAfZYwmlXAzQqHn+cTsN8S/m01MLkEw8/zFThoCQsbBx4v4fDzfAMOW8Kf1gJPahh+nh/AcUv4bUv2wylqzuCr7QkSNwG8aWD4wyWcJlF7R7ivU1fOkuB9nS8tGPxwzpOIYwXu60RNuZD9Au+tUyXu60RNuQwso2fGshWPjuQasIKeqPq+TtSUG8BKeuBiC4YZBXOJHnjegkFGwQz+3uy86RYMMgpmih44kp1IF4d/qOnhtUGUjCyg28INsICkhRtgAUkLN8ACkhZugAUkLdwAC0hauAEWkLRwAywgaeEGWEDSwg2wgKSFG2ABSQs3wAKSFm6ABSQt3AALSFq4ARaQtHADLCBpUyU24GXTB98H10sUcLXpg++D9cD7AsN/B6xr+uD7YjNwB5gdYfCDB4DcBjY1fdCSJEmSJElSEduB+y160m20OIMZ3QO2UZGd2Rsomj6x6FjmstmV9rAFJxMdzeBlFKWf+TnfghOJjmY+m6EF0NECvARRqoAHVMAPYQoNf7aqD2Gyr1R3s5eiNX1djZZnJvv/emtVw5ckSZJEr/wCliFWxPec8VIAAAAASUVORK5CYII=",r.DOWNLOAD="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAACXBIWXMAAAsTAAALEwEAmpwYAAACWklEQVR4nO3cO2hUURCH8U9FEUEQC0EwhYWIijY2giIIgqj4ADs7Szs7W0tLO0urWEh8VmpjY2WhhY2FhRgRQVTc+IyPkQs3hZKYze4m59xzvh9MExKY85872WX37oIkSZIk5WkMmAB6QMxTze/cALambrqk8N/1Efy/1fzNptTNl2BigPBn6lrq5kvQG2IAH1M3X4IYsuQAui3cAAdQtXADHEDVwg1wAFULN8ABVC3cAAdQtXADHEDVwg1wAFULN8ABVC3cAAdQtXADHEDVwg1wAFULN8ABVC3cAAdQtXADHEDVwg1wAJ12FHg1gis5lrgmgcMUYDKDMGPAekkBHEBiJ4DpDK7mWGB9B45TiCPAlwxCjT7rG3CSwuxvP7UYmdcn4CCF2g28zSDkmKPeA3so3PZMn5a+AXZRic3A8wxCn6kXwBYqsxF4mkH4z9rvo6jSBuBJwvAftz1UbR3wMEH4j4D1qQ+fizXAvSUM/wGwNvWhc7MKuL4E4d8BVqc+bK5WAFcWMfxxYGXqQ+ZuGXBpEcK/DCxPfbguuTDC8C+mPkxXnTf89M4CvwYYxG/gXOrmS3Ea+LGA8H8CZ1I3XZpjwNc+30g5lbrZUh0Apv4T/mfgUOomS7cP+DBL+M3P9qZurhZjwFXgdVvjNb+iKUmSJEmSpLLsaG/n6MLt5ZG4moxutzchj8TOeV6Dt5g1g6k2u6HdN2QGvciau/2GvlGqi5/vikxqus3QAdDRAfgviKEGcJcR8EGYgcLvjepBmPYp1a053gy3+CuDJqObwLZRhS9JkiSJovwByQJHhbd7qEkAAAAASUVORK5CYII=",r.PLUS="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAABaCAYAAAA4qEECAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB1UlEQVR4nO3byUoDURSE4do5D+/g9HgOIILDQvDpVNxonBLwEYygy1DScHUhIumm23v75P/gbMzm3KIWEU4kAAAAALNgQdJ87iWiWpd0IelFktOMJJ1LWsu9XBQ7PwL+OVXg27mX7LtlScM/Qv6aJ0lLuZfts6MpQv6aw9zL9tlNjaCvcy/bZx81gn7PvWyfueagIYL+J6bRBB2KaTRBh2IaTdChmEYTdCim0QQdimk0QYdiGk3QoZhGE3QoptEEHYppNEGHYhpN0J2q7tsO0lXQW4PGueczTm/f7/LWr7rYvC/gsS5kBpI2u7jqJGT9esXa6n32WQENcqFz2mbQowIe5EKnut9uxZykSQEPcqEzSRkRtHoStKb8ecOszlAtOi3gQS50jtv+ejco4FEubB4lrapl1ZdzwtZ3yLeSNtSRRUl7kq7Sv6OesRlLupS0m7IIwzUHDRH0PzGNJuhQTKMJOhTTaIIOxTSaoEMxjSboUEyjCToU02iCDsU0mqBDMY0m6FBMowk6FNNogg5lXKPRr7mX7bPrGkFXF0Ro6KBG0NWZFhpamvKw8i7aLVwOW5Ie/gj5vsurzlmzIukkXddP0jynv1WfoQNzbf5mBAAAAICK9QkSkO5NnQjE8wAAAABJRU5ErkJggg==",r.ADD_EVENT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB4UlEQVR4nO2Xy0oDMRSGi6Ib6UpxpUu1TyC6E19AqW19murWqm+hiDd8A0Vw6WVrpdo3KNjWdT85EHEImWk6kzazyAcDZeYk+f/pOZmTQiEQCAQCgUAgEMgVwDJwC/TwTw+4A9ZGEd8hf3SAJRsD8ubzyrWNgTykTRxdGwO5phAMxDMAXoA6sCW7BjCnrpK6dwC8krN/YABcAatDJ/9fQ8zdqLFeDXwC67bCDWttAG1fBp6AxbTiI+vNA/eTNvAAzBjGzgL7wAXQBH7U1VT3ahITM+5xUgYkbeYN4/aAL8vxZcP4BZt0ympgoOc8MA2cMjonwJQ21+awws5q4NIQn0b8H41RW5ksBgb6VqnSxmqhhHl3tbjSuAw8Gwrv04GBtl7YwFsWA3HNXF2Lk90GBwaEqhZ7iJlvGwNyeDCxpcXJtujKwLkWux0Td2v7mTcdaPT8/0gSbLFOlKZBg45oWrGdfEkOD9J/RyYoJqVaRgM97Vkx8qyrdiY78SMI6Ds00HUqzlKAyxR6H4/KZAEui/jMh4GaQwMVHwZmgJYDA1+mDnVSJsoODOx4ER8RJl1lWo68ilcGpoDjFOIbejvtFekqk2oiQst72gwp7Kr0NrK3q49dX/2WexXTUTQQCBRS8ws6Beac36b8wwAAAABJRU5ErkJggg==",r.SELECT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABdElEQVR4nO2ZUU6DQBCGOUf73LsIRL2mPnglobCaaGNivcDXEKcp0F2Q3S6VZr6kT/+Gf4ZM2d2ZJFEURfm3ABvgBfjhRAGklrUZUIqeOXQzohctn8bzGViHBP+FndqyftvStx66cXjtvJKQN8+EBEygXg/4Pfkk0C6bNq/AnWV9LkFWjhI56k2guUVP5dk2vn0S6JDMDKH+t5BA0S6bKFHG9JearOV3VvOx4cr+irJ4OJ1dStvGNIN/Lt5+/r2tvYoSZUz/scNXbAj1HzvbxIbu2Wl2f0VZPIzccWfwvwfe5E+cLvEz+h66DwzeYWPD79sPSiCXPeBa+0Am5dP4631AUaYCPAKfwAfwkCzNn+5nzESJMqb/LTS2OkSJcoBLJLDHjms+cLzDuvr/uWilo7mb9bpxwc3dZrjgYqw9Xnno5tLt9bUMF/6agJkw4JgyH9gBq8kJyENXTfa9chqaDzjPTlIiQ3ramw/sxdsveEVRlGQODgnFtCEN6s0TAAAAAElFTkSuQmCC",r.EDIT_WHITE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABRklEQVR4nO3WMUoDQRSH8bG0UQTR2jNYWAjiEfQwapm1S8R7WEhEbyHoBQRBO9HGUhDlJwMJhLC7ZCPszsJ85c4MfP/HvLcTQiaTSQbs4Rof+MYzLrEdUgen+FXOewwXUgVFhfh8iK3QU/kpF6HnAZ5Cilg8xFdIFYuFeEtFtKhZq+OqfeNqwaYhfrDbvnW9WNFg70n71vVCU4YVZ85m9gzat27WnEXN2dK1FGf8MKREQ/m0Qiwpn0aIf8r3omHrGGT5ZciV74pc+a7Ile8Kec53CNZwgPESf9junsRl4Ka38hEc9lY+gs2kH2ZTMMJ6KAGr2K/oie4rjxV84r4qxMzecVLyEezMSNWGmEyndOQjOJq7FpUh4vek5CM4L7nbj9gIfQB3FdOlHyHwWhEgNvYopA4e8ILbySPuODZ2116ZTCYTkuIPW58e4VQyzE8AAAAASUVORK5CYII=",r.EYE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAACjklEQVR4nO2YTUuUURTHrcW0mLQPELnIyfGz9E5RIIUIbatNVqsGl1YEvXyAaqeppVKboqxNLyuDXtfRxkqIlNAh+8WBI0wP1/GceV5EuX+4MNznnv/5n3nuuec+p60tIiIiIiIiJYB24CBwBXgEfAbmgCUdczr3UNccALavt+itKmQSqOOH2EwA+4WrSOFbgOPAR7LDB+CYcOctvht4Rn54CuzJS/xJYIH88Rs4lfVev0bxuJo6N1T8XYdTOXGGgV6gCpR1VHVuRNdYcSdVXgC3HM7GgN0Gzi5g3MF7s1Xxg0YHf4BzLfAPAMtGH4Necjmb/xrJ3eIb/Fww+hAth62knVo5LRgL2G8DzgKv9dRa0N9n5Flg/QOjL9HUaSlSL4yES8k9D+wE3jaxmZE1CZuKI7GfN01qoB87hgP/fDPxjUH89yaAew6//auJ3wF8cxD1Juxl21hxOmF7wmErGjtCAdTwoTth/8Zh+yphW3X6roUC+OokaU/YzztsfwWu4x582ZQB1Db6FuoAZlMksZzzRSTxbDCJlajPQTQSOEbliFwLsqaUsB11+O0Lim8oZNNGIik+XYFCNtNCIasbfU6veTsFdjmuEuMB+5JsEdnnmtgyXupcKbB+wujrh2hrKr6BdJ/jMjdgIg37uWj0IVoOecmtp5Jcic+3eBNdNvq45OVfcXIDO+RWWTFwVhzbRnC9JfENSS2fdVbU9WImx2KPNK909OjcqLOHdDt1q0WDkA/sojGUaZ8IOAr8LED4fLJIZhmE7N8nOYp/nKwteQUib+N9hsLfAUdyFx7oGUm9uO/s9axgUdsrewtt7q4STFmDuQxMaSv9u4pc1N+f9NmQii6vq+iIiIiIiE2BfxdHH8YQSpqkAAAAAElFTkSuQmCC",r.WEB="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAACXBIWXMAAAsTAAALEwEAmpwYAAAC70lEQVR4nO2dzWoUQRSFzyLoygiudRlGUB9GBl/KqBjw5x2GYXZZ6kNohODSWQvmZ2WUKw0FQnS6qzK36tyePh/cTajqPuee7qphKiGAEEIIIYQQQgghhBD5PAFwBOAEwCUA2/G6TF5fA3jMfFBuA3gH4HeAphipOu9vAdxiNP9jgAZYkPrQOoT3AUxbsHrTcs2f8rJjG+oXgEctAjgKYNaC1qsWAXwJYNSC1ucWAVwEMGpB67xFADlCvgGYA7iT6imAU8fx1jPfm1I91clpxr3/zOt+tnYYb5nzvcnVU50hAd2TuIlnDuOtYL43OXqqMySgbxnYdxhvBfO9ydFTnW0actdhvBEDyNFTnSEB3Ya1ibnDeCuY702OnuoMCTjt2VS/Ooy3zPne5OqpjmXUOm1Y+6nmA+LXheP75ntTqqc6uU2ZalWHbdCClwKAAqA/haY3gN8I0xLEb4YRSnsAFAD9KbQpvwG7jrH90wWQofunCyBD908XQIbuny6ADN0/XQAZun+6ADJ0/3QBZOj+PQQ8ALBMv8hkhdXNWQGYFWjuu1/p9UYfQNeM7zdovF2r7hr3He+Xe73RB7B0aL6lWjjfbzGFAG6y7NiGOnO+X871FAD+NuGHQ8NKH6DRB7ByfAOWDnonF8DMcRM+cNA7uQCQPm0s0ppb2qCz9OQfOOmdZAAtMQWgAFzRGwAtQSVoCSJj2gMUgCvaA6A9oAQtQeTzANMewD0PMAXAPQ8wBcA9DzAFwD0POHe+Hv1T4NjOA1bO1xt9AK3PA2YFh/Ie5wvVGdt5wND9vM8XqkMXQIbuny6ADN0/XQAZun+6ADJ0/3QBZOj+6QLI0P3TBZCh+6cLIEP37/ldju1Y5Xw5uDUnAYxa0PrUIoCXAYxa0HreIoCHAK4CmLVg9bPwz6a2Qm8B/gngEA3ZA3Ac4KmzIHWcetKUvfQmTHk5ukpPfvPmX98TXqR/XjCF/y1wkbwetlzzhRBCCCGEEEIIIQRGzx/seDvzE8oqSwAAAABJRU5ErkJggg==",r))(He||{});const Cp=globalThis.showDirectoryPicker;async function SE(r={}){if(Cp&&!r._preferPolyfill)return Cp(r);const e=document.createElement("input");e.type="file",e.webkitdirectory=!0,e.multiple=!0,e.style.position="fixed",e.style.top="-100000px",e.style.left="-100000px",document.body.appendChild(e);const{makeDirHandleFromFileList:t}=await ui(()=>Promise.resolve().then(()=>ig),void 0);return new Promise((i,s)=>{e.addEventListener("change",()=>{t(e.files).then(i).catch(s),document.body.removeChild(e)}),e.click()})}const Mp=globalThis.showOpenFilePicker;async function CE(r={}){if(Mp&&!r._preferPolyfill)return Mp(r);const e=document.createElement("input");e.type="file",e.multiple=!!r.multiple,e.accept=(r.accepts||[]).map(i=>[...(i.extensions||[]).map(s=>"."+s),...i.mimeTypes||[]]).flat().join(","),e.style.position="fixed",e.style.top="-100000px",e.style.left="-100000px",document.body.appendChild(e);const{makeFileHandlesFromFileList:t}=await ui(()=>Promise.resolve().then(()=>ig),void 0);return new Promise((i,s)=>{e.addEventListener("change",()=>{t(e.files).then(i).catch(s),document.body.removeChild(e)}),e.click()})}const Ip=globalThis.showSaveFilePicker;async function ME(r={}){if(Ip&&!r._preferPolyfill)return Ip(r);const{FileSystemFileHandle:e}=await ui(()=>Promise.resolve().then(()=>gg),void 0),{FileHandle:t}=await ui(()=>import("./downloader-a9f86f42.js"),[]);return new e(new t(r.suggestedName))}const Rs=Symbol("adapter");let dd=class{constructor(e){this.kind=e.kind,this.name=e.name,this[Rs]=e}get isFile(){return this.kind==="file"}get isDirectory(){return this.kind==="directory"}async queryPermission(e={mode:"read"}){const t=this[Rs];if(t.queryPermission)return t.queryPermission(e);if(e.mode==="read")return"granted";if(e.mode==="readwrite")return t.writable?"granted":"denied";throw new TypeError(`Mode ${e.mode} must be 'read' or 'readwrite'`)}async requestPermission(e={mode:"read"}){const t=this[Rs];if(t.requestPermission)return t.requestPermission(e);if(e.mode==="read")return"granted";if(e.mode==="readwrite")return t.writable?"granted":"denied";throw new TypeError(`Mode ${e.mode} must be 'read' or 'readwrite'`)}async isSameEntry(e){return this===e?!0:this.kind!==e.kind||!e[Rs]?!1:await this[Rs].isSameEntry(e[Rs])}};Object.defineProperty(dd.prototype,Symbol.toStringTag,{value:"FileSystemHandle",writable:!1,enumerable:!1,configurable:!0});const dh=Symbol("adapter");let vn=class extends dd{constructor(e){super(e),this.kind="file",this[dh]=e}async createWritable(e={}){const{FileSystemWritableFileStream:t}=await ui(()=>import("./FileSystemWritableFileStream-e4c13ad9.js"),["FileSystemWritableFileStream-e4c13ad9.js","web-streams-ponyfill-4a0f4950.js"]);return new t(await this[dh].createWritable(e))}async getFile(){return this[dh].getFile()}};Object.defineProperty(vn.prototype,Symbol.toStringTag,{value:"FileSystemFileHandle",writable:!1,enumerable:!1,configurable:!0});Object.defineProperties(vn.prototype,{createWritable:{enumerable:!0},getFile:{enumerable:!0}});const gg=Object.freeze(Object.defineProperty({__proto__:null,FileSystemFileHandle:vn,default:vn},Symbol.toStringTag,{value:"Module"})),Ds=Symbol("adapter");class Nr extends dd{constructor(e){super(e),this.kind="directory",this[Ds]=e}async getDirectoryHandle(e,t={}){if(e==="")throw new TypeError("Name can't be an empty string.");if(e==="."||e===".."||e.includes("/"))throw new TypeError("Name contains invalid characters.");return new Nr(await this[Ds].getDirectoryHandle(e,t))}getDirectory(e,t={}){return this.getDirectoryHandle(e,t)}async*entries(){for await(const[e,t]of this[Ds].entries())yield[t.name,t.kind==="file"?new vn(t):new Nr(t)]}async*getEntries(){return this.entries()}async*keys(){for await(const[e]of this[Ds].entries())yield e}async*values(){for await(const[e,t]of this.entries())yield t}async getFileHandle(e,t={}){if(e==="")throw new TypeError("Name can't be an empty string.");if(e==="."||e===".."||e.includes("/"))throw new TypeError("Name contains invalid characters.");return t.create=!!t.create,new vn(await this[Ds].getFileHandle(e,t))}getFile(e,t={}){return this.getFileHandle(e,t)}async removeEntry(e,t={}){if(e==="")throw new TypeError("Name can't be an empty string.");if(e==="."||e===".."||e.includes("/"))throw new TypeError("Name contains invalid characters.");return t.recursive=!!t.recursive,this[Ds].removeEntry(e,t)}async resolve(e){if(await e.isSameEntry(this))return[];const t=[{handle:this,path:[]}];for(;t.length;){let{handle:i,path:s}=t.pop();for await(const n of i.values()){if(await n.isSameEntry(e))return[...s,n.name];n.kind==="directory"&&t.push({handle:n,path:[...s,n.name]})}}return null}[Symbol.asyncIterator](){return this.entries()}}Object.defineProperty(Nr.prototype,Symbol.toStringTag,{value:"FileSystemDirectoryHandle",writable:!1,enumerable:!1,configurable:!0});Object.defineProperties(Nr.prototype,{getDirectoryHandle:{enumerable:!0},entries:{enumerable:!0},getFileHandle:{enumerable:!0},removeEntry:{enumerable:!0}});const IE=Object.freeze(Object.defineProperty({__proto__:null,FileSystemDirectoryHandle:Nr,default:Nr},Symbol.toStringTag,{value:"Module"}));async function kp(r,e={}){var t,i,s,n;if(!r){if(!(!((t=globalThis.navigator)===null||t===void 0)&&t.storage)&&((i=globalThis.location)===null||i===void 0?void 0:i.protocol)==="http:")throw new Error("Native getDirectory not supported in HTTP context. Please use HTTPS instead or provide an adapter.");if(!(!((n=(s=globalThis.navigator)===null||s===void 0?void 0:s.storage)===null||n===void 0)&&n.getDirectory))throw new Error("Native StorageManager.getDirectory() is not supported in current environment. Please provide an adapter instead.");return globalThis.navigator.storage.getDirectory()}const a=await r,o=typeof a=="function"?await a(e):await a.default(e);return new Nr(o)}var uh,ph;const kE={adapter:{cache:!!(globalThis.CacheStorage&&globalThis.caches instanceof CacheStorage),native:typeof((ph=(uh=globalThis.navigator)===null||uh===void 0?void 0:uh.storage)===null||ph===void 0?void 0:ph.getDirectory)=="function",sandbox:typeof window<"u"&&typeof window.webkitRequestFileSystem=="function"}},Bp=r=>typeof r=="object"&&r!=null&&r.nodeType===1,Pp=(r,e)=>(!e||r!=="hidden")&&r!=="visible"&&r!=="clip",fh=(r,e)=>{if(r.clientHeight{const s=(n=>{if(!n.ownerDocument||!n.ownerDocument.defaultView)return null;try{return n.ownerDocument.defaultView.frameElement}catch{return null}})(i);return!!s&&(s.clientHeightne||n>r&&a=e&&o>=t?n-r-i:a>e&&ot?a-e+s:0,BE=r=>{const e=r.parentElement;return e??(r.getRootNode().host||null)},Rp=(r,e)=>{var t,i,s,n;if(typeof document>"u")return[];const{scrollMode:a,block:o,inline:l,boundary:c,skipOverflowHiddenElements:u}=e,h=typeof c=="function"?c:z=>z!==c;if(!Bp(r))throw new TypeError("Invalid target");const d=document.scrollingElement||document.documentElement,p=[];let f=r;for(;Bp(f)&&h(f);){if(f=BE(f),f===d){p.push(f);break}f!=null&&f===document.body&&fh(f)&&!fh(document.documentElement)||f!=null&&fh(f,u)&&p.push(f)}const m=(i=(t=window.visualViewport)==null?void 0:t.width)!=null?i:innerWidth,g=(n=(s=window.visualViewport)==null?void 0:s.height)!=null?n:innerHeight,{scrollX:y,scrollY:b}=window,{height:A,width:v,top:E,right:C,bottom:M,left:P}=r.getBoundingClientRect(),{top:k,right:N,bottom:H,left:T}=(z=>{const L=window.getComputedStyle(z);return{top:parseFloat(L.scrollMarginTop)||0,right:parseFloat(L.scrollMarginRight)||0,bottom:parseFloat(L.scrollMarginBottom)||0,left:parseFloat(L.scrollMarginLeft)||0}})(r);let S=o==="start"||o==="nearest"?E-k:o==="end"?M+H:E+A/2-k+H,w=l==="center"?P+v/2-T+N:l==="end"?C+N:P-T;const F=[];for(let z=0;z=0&&P>=0&&M<=g&&C<=m&&E>=G&&M<=O&&P>=ee&&C<=D)return F;const Q=getComputedStyle(L),K=parseInt(Q.borderLeftWidth,10),ge=parseInt(Q.borderTopWidth,10),Te=parseInt(Q.borderRightWidth,10),he=parseInt(Q.borderBottomWidth,10);let pe=0,be=0;const oe="offsetWidth"in L?L.offsetWidth-L.clientWidth-K-Te:0,ue="offsetHeight"in L?L.offsetHeight-L.clientHeight-ge-he:0,ve="offsetWidth"in L?L.offsetWidth===0?0:R/L.offsetWidth:0,x="offsetHeight"in L?L.offsetHeight===0?0:te/L.offsetHeight:0;if(d===L)pe=o==="start"?S:o==="end"?S-g:o==="nearest"?Ja(b,b+g,g,ge,he,b+S,b+S+A,A):S-g/2,be=l==="start"?w:l==="center"?w-m/2:l==="end"?w-m:Ja(y,y+m,m,K,Te,y+w,y+w+v,v),pe=Math.max(0,pe+b),be=Math.max(0,be+y);else{pe=o==="start"?S-G-ge:o==="end"?S-O+he+ue:o==="nearest"?Ja(G,O,te,ge,he+ue,S,S+A,A):S-(G+te/2)+ue/2,be=l==="start"?w-ee-K:l==="center"?w-(ee+R/2)+oe/2:l==="end"?w-D+Te+oe:Ja(ee,D,R,K,Te+oe,w,w+v,v);const{scrollLeft:j,scrollTop:V}=L;pe=x===0?0:Math.max(0,Math.min(V+pe/x,L.scrollHeight-te/x+ue)),be=ve===0?0:Math.max(0,Math.min(j+be/ve,L.scrollWidth-R/ve+oe)),S+=V-pe,w+=j-be}F.push({el:L,top:pe,left:be})}return F},PE=r=>r===!1?{block:"end",inline:"nearest"}:(e=>e===Object(e)&&Object.keys(e).length!==0)(r)?r:{block:"start",inline:"nearest"};function ea(r,e){if(!r.isConnected||!(s=>{let n=s;for(;n&&n.parentNode;){if(n.parentNode===document)return!0;n=n.parentNode instanceof ShadowRoot?n.parentNode.host:n.parentNode}return!1})(r))return;const t=(s=>{const n=window.getComputedStyle(s);return{top:parseFloat(n.scrollMarginTop)||0,right:parseFloat(n.scrollMarginRight)||0,bottom:parseFloat(n.scrollMarginBottom)||0,left:parseFloat(n.scrollMarginLeft)||0}})(r);if((s=>typeof s=="object"&&typeof s.behavior=="function")(e))return e.behavior(Rp(r,e));const i=typeof e=="boolean"||e==null?void 0:e.behavior;for(const{el:s,top:n,left:a}of Rp(r,PE(e))){const o=n-t.top+t.bottom,l=a-t.left+t.right;s.scroll({top:o,left:l,behavior:i})}}function Zi(r,e){let t=ud(r)[2];return e&&t.slice(-1*e.length)===e&&(t=t.slice(0,t.length-e.length)),t}function jt(r){const e=ud(r),t=e[0];let i=e[1];return!t&&!i?"":(i&&(i=i.slice(0,i.length-1)),t+i)}function Ui(r){return ud(r)[3]}const RE=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/;function ud(r){return RE.exec(r).slice(1)}const{GONE:yg}=Go;FileSystemFileHandle;class pd{_path;kind="file";name;isFile=!0;isDirectory=!1;constructor(e){this._path=e,this.name=new URL(e).pathname.split("/").pop()??""}async getFile(){return fetch(this._path).then(e=>e.blob()).then(e=>new File([e],this.name)).catch(()=>{throw new DOMException(...yg)})}async createWritable(){throw Error("Cannot call createWriteable from a URLFileHandle")}async isSameEntry(e){return FileSystemHandle instanceof pd?e._path==this._path:!1}async queryPermission(){return"granted"}async requestPermission(){return"granted"}}class DE{async handleDropEvent(e,t){throw Error("Cannot call handleDropEvent from a URLFileHandler")}async getDirectoryHandle(e,t,i){throw Error("Cannot call getDirectoryHandle from a URLFileHandler")}async hasFile(e){return fetch(e).then(t=>t.ok).catch(()=>!1)}async getFileHandle(e,t){try{if(!await this.hasFile(e))throw new DOMException(...yg);return new pd(e)}catch(i){console.error("Failed to get file "+e+": "+i);return}}async getFileHandleRelativeTo(e,t){const i=new URL(e);Ui(i.pathname)!=""&&(i.pathname=i.pathname.split("/").slice(0,-1).join("/")),i.pathname+="/"+t;try{return this.getFileHandle(i.toString())}catch(s){console.error("Failed to get relative file "+i+": "+s);return}}async getDirectoryFiles(e){throw Error("Cannot call getDirectoryFiles from a URLFileHandler")}async getDirectoryFolders(e){throw Error("Cannot call getDirectoryFolders from a URLFileHandler")}async writeFile(e,t){throw Error("Cannot save to a URL file!")}getRelativePath(e,t){throw Error("Cannot call getRelativePath from a URLFileHandler")}}function Za(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var vg={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files @@ -1194,10 +1194,10 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */(function(r,e){(function(t){r.exports=t()})(function(){return function t(i,s,n){function a(c,u){if(!s[c]){if(!i[c]){var h=typeof Za=="function"&&Za;if(!u&&h)return h(c,!0);if(o)return o(c,!0);var d=new Error("Cannot find module '"+c+"'");throw d.code="MODULE_NOT_FOUND",d}var p=s[c]={exports:{}};i[c][0].call(p.exports,function(f){var m=i[c][1][f];return a(m||f)},p,p.exports,t,i,s,n)}return s[c].exports}for(var o=typeof Za=="function"&&Za,l=0;l>2,p=(3&c)<<4|u>>4,f=1>6:64,m=2>4,u=(15&d)<<4|(p=o.indexOf(l.charAt(m++)))>>2,h=(3&p)<<6|(f=o.indexOf(l.charAt(m++))),b[g++]=c,p!==64&&(b[g++]=u),f!==64&&(b[g++]=h);return b}},{"./support":30,"./utils":32}],2:[function(t,i,s){var n=t("./external"),a=t("./stream/DataWorker"),o=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function c(u,h,d,p,f){this.compressedSize=u,this.uncompressedSize=h,this.crc32=d,this.compression=p,this.compressedContent=f}c.prototype={getContentWorker:function(){var u=new a(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),h=this;return u.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new a(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(u,h,d){return u.pipe(new o).pipe(new l("uncompressedSize")).pipe(h.compressWorker(d)).pipe(new l("compressedSize")).withStreamInfo("compression",h)},i.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,i,s){var n=t("./stream/GenericWorker");s.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},s.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,i,s){var n=t("./utils"),a=function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var u=0;u<8;u++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l}();i.exports=function(o,l){return o!==void 0&&o.length?n.getTypeOf(o)!=="string"?function(c,u,h,d){var p=a,f=d+h;c^=-1;for(var m=d;m>>8^p[255&(c^u[m])];return-1^c}(0|l,o,o.length,0):function(c,u,h,d){var p=a,f=d+h;c^=-1;for(var m=d;m>>8^p[255&(c^u.charCodeAt(m))];return-1^c}(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(t,i,s){s.base64=!1,s.binary=!1,s.dir=!1,s.createFolders=!0,s.date=null,s.compression=null,s.compressionOptions=null,s.comment=null,s.unixPermissions=null,s.dosPermissions=null},{}],6:[function(t,i,s){var n=null;n=typeof Promise<"u"?Promise:t("lie"),i.exports={Promise:n}},{lie:37}],7:[function(t,i,s){var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=t("pako"),o=t("./utils"),l=t("./stream/GenericWorker"),c=n?"uint8array":"array";function u(h,d){l.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=d,this.meta={}}s.magic="\b\0",o.inherits(u,l),u.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(c,h.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(d){h.push({data:d,meta:h.meta})}},s.compressWorker=function(h){return new u("Deflate",h)},s.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,i,s){function n(p,f){var m,g="";for(m=0;m>>=8;return g}function a(p,f,m,g,y,b){var A,v,E=p.file,C=p.compression,M=b!==c.utf8encode,P=o.transformTo("string",b(E.name)),k=o.transformTo("string",c.utf8encode(E.name)),N=E.comment,H=o.transformTo("string",b(N)),T=o.transformTo("string",c.utf8encode(N)),S=k.length!==E.name.length,w=T.length!==N.length,F="",z="",L="",te=E.dir,R=E.date,G={crc32:0,compressedSize:0,uncompressedSize:0};f&&!m||(G.crc32=p.crc32,G.compressedSize=p.compressedSize,G.uncompressedSize=p.uncompressedSize);var D=0;f&&(D|=8),M||!S&&!w||(D|=2048);var O=0,ee=0;te&&(O|=16),y==="UNIX"?(ee=798,O|=function(K,ge){var Te=K;return K||(Te=ge?16893:33204),(65535&Te)<<16}(E.unixPermissions,te)):(ee=20,O|=function(K){return 63&(K||0)}(E.dosPermissions)),A=R.getUTCHours(),A<<=6,A|=R.getUTCMinutes(),A<<=5,A|=R.getUTCSeconds()/2,v=R.getUTCFullYear()-1980,v<<=4,v|=R.getUTCMonth()+1,v<<=5,v|=R.getUTCDate(),S&&(z=n(1,1)+n(u(P),4)+k,F+="up"+n(z.length,2)+z),w&&(L=n(1,1)+n(u(H),4)+T,F+="uc"+n(L.length,2)+L);var Q="";return Q+=` -\0`,Q+=n(D,2),Q+=C.magic,Q+=n(A,2),Q+=n(v,2),Q+=n(G.crc32,4),Q+=n(G.compressedSize,4),Q+=n(G.uncompressedSize,4),Q+=n(P.length,2),Q+=n(F.length,2),{fileRecord:h.LOCAL_FILE_HEADER+Q+P+F,dirRecord:h.CENTRAL_FILE_HEADER+n(ee,2)+Q+n(H.length,2)+"\0\0\0\0"+n(O,4)+n(g,4)+P+F+H}}var o=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),u=t("../crc32"),h=t("../signature");function d(p,f,m,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=f,this.zipPlatform=m,this.encodeFileName=g,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(d,l),d.prototype.push=function(p){var f=p.meta.percent||0,m=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,l.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:m?(f+100*(m-g-1))/m:100}}))},d.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var f=this.streamFiles&&!p.file.dir;if(f){var m=a(p,f,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},d.prototype.closedSource=function(p){this.accumulate=!1;var f=this.streamFiles&&!p.file.dir,m=a(p,f,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),f)this.push({data:function(g){return h.DATA_DESCRIPTOR+n(g.crc32,4)+n(g.compressedSize,4)+n(g.uncompressedSize,4)}(p),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},d.prototype.flush=function(){for(var p=this.bytesWritten,f=0;f=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=o,c},readString:function(o){return n.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},i.exports=a},{"../utils":32}],19:[function(t,i,s){var n=t("./Uint8ArrayReader");function a(o){n.call(this,o)}t("../utils").inherits(a,n),a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,i,s){var n=t("./DataReader");function a(o){n.call(this,o)}t("../utils").inherits(a,n),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./DataReader":18}],21:[function(t,i,s){var n=t("./ArrayReader");function a(o){n.call(this,o)}t("../utils").inherits(a,n),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(t,i,s){var n=t("../utils"),a=t("../support"),o=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),u=t("./Uint8ArrayReader");i.exports=function(h){var d=n.getTypeOf(h);return n.checkSupport(d),d!=="string"||a.uint8array?d==="nodebuffer"?new c(h):a.uint8array?new u(n.transformTo("uint8array",h)):new o(n.transformTo("array",h)):new l(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,i,s){s.LOCAL_FILE_HEADER="PK",s.CENTRAL_FILE_HEADER="PK",s.CENTRAL_DIRECTORY_END="PK",s.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",s.ZIP64_CENTRAL_DIRECTORY_END="PK",s.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,i,s){var n=t("./GenericWorker"),a=t("../utils");function o(l){n.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,n),o.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},i.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(t,i,s){var n=t("./GenericWorker"),a=t("../crc32");function o(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(o,n),o.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,i,s){var n=t("../utils"),a=t("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}n.inherits(o,a),o.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}a.prototype.processChunk.call(this,l)},i.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(t,i,s){var n=t("../utils"),a=t("./GenericWorker");function o(l){a.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=n.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}n.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(t,i,s){function n(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var l=0;l "+a:a}},i.exports=n},{}],29:[function(t,i,s){var n=t("../utils"),a=t("./ConvertWorker"),o=t("./GenericWorker"),l=t("../base64"),c=t("../support"),u=t("../external"),h=null;if(c.nodestream)try{h=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function d(f,m){return new u.Promise(function(g,y){var b=[],A=f._internalType,v=f._outputType,E=f._mimeType;f.on("data",function(C,M){b.push(C),m&&m(M)}).on("error",function(C){b=[],y(C)}).on("end",function(){try{var C=function(M,P,k){switch(M){case"blob":return n.newBlob(n.transformTo("arraybuffer",P),k);case"base64":return l.encode(P);default:return n.transformTo(M,P)}}(v,function(M,P){var k,N=0,H=null,T=0;for(k=0;k"u")s.blob=!1;else{var n=new ArrayBuffer(0);try{s.blob=new Blob([n],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(n),s.blob=a.getBlob("application/zip").size===0}catch{s.blob=!1}}}try{s.nodestream=!!t("readable-stream").Readable}catch{s.nodestream=!1}},{"readable-stream":16}],31:[function(t,i,s){for(var n=t("./utils"),a=t("./support"),o=t("./nodejsUtils"),l=t("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function h(){l.call(this,"utf-8 decode"),this.leftOver=null}function d(){l.call(this,"utf-8 encode")}s.utf8encode=function(p){return a.nodebuffer?o.newBufferFrom(p,"utf-8"):function(f){var m,g,y,b,A,v=f.length,E=0;for(b=0;b>>6:(g<65536?m[A++]=224|g>>>12:(m[A++]=240|g>>>18,m[A++]=128|g>>>12&63),m[A++]=128|g>>>6&63),m[A++]=128|63&g);return m}(p)},s.utf8decode=function(p){return a.nodebuffer?n.transformTo("nodebuffer",p).toString("utf-8"):function(f){var m,g,y,b,A=f.length,v=new Array(2*A);for(m=g=0;m>10&1023,v[g++]=56320|1023&y)}return v.length!==g&&(v.subarray?v=v.subarray(0,g):v.length=g),n.applyFromCharCode(v)}(p=n.transformTo(a.uint8array?"uint8array":"array",p))},n.inherits(h,l),h.prototype.processChunk=function(p){var f=n.transformTo(a.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var m=f;(f=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),f.set(m,this.leftOver.length)}else f=this.leftOver.concat(f);this.leftOver=null}var g=function(b,A){var v;for((A=A||b.length)>b.length&&(A=b.length),v=A-1;0<=v&&(192&b[v])==128;)v--;return v<0||v===0?A:v+c[b[v]]>A?v:A}(f),y=f;g!==f.length&&(a.uint8array?(y=f.subarray(0,g),this.leftOver=f.subarray(g,f.length)):(y=f.slice(0,g),this.leftOver=f.slice(g,f.length))),this.push({data:s.utf8decode(y),meta:p.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=h,n.inherits(d,l),d.prototype.processChunk=function(p){this.push({data:s.utf8encode(p.data),meta:p.meta})},s.Utf8EncodeWorker=d},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,i,s){var n=t("./support"),a=t("./base64"),o=t("./nodejsUtils"),l=t("./external");function c(m){return m}function u(m,g){for(var y=0;y>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=n(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var f,m,g,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4>>6:(p<65536?d[g++]=224|p>>>12:(d[g++]=240|p>>>18,d[g++]=128|p>>>12&63),d[g++]=128|p>>>6&63),d[g++]=128|63&p);return d},s.buf2binstring=function(h){return u(h,h.length)},s.binstring2buf=function(h){for(var d=new n.Buf8(h.length),p=0,f=d.length;p>10&1023,b[f++]=56320|1023&m)}return u(b,f)},s.utf8border=function(h,d){var p;for((d=d||h.length)>h.length&&(d=h.length),p=d-1;0<=p&&(192&h[p])==128;)p--;return p<0||p===0?d:p+l[h[p]]>d?p:d}},{"./common":41}],43:[function(t,i,s){i.exports=function(n,a,o,l){for(var c=65535&n|0,u=n>>>16&65535|0,h=0;o!==0;){for(o-=h=2e3>>1:a>>>1;o[l]=a}return o}();i.exports=function(a,o,l,c){var u=n,h=c+l;a^=-1;for(var d=c;d>>8^u[255&(a^o[d])];return-1^a}},{}],46:[function(t,i,s){var n,a=t("../utils/common"),o=t("./trees"),l=t("./adler32"),c=t("./crc32"),u=t("./messages"),h=0,d=4,p=0,f=-2,m=-1,g=4,y=2,b=8,A=9,v=286,E=30,C=19,M=2*v+1,P=15,k=3,N=258,H=N+k+1,T=42,S=113,w=1,F=2,z=3,L=4;function te(x,j){return x.msg=u[j],j}function R(x){return(x<<1)-(4x.avail_out&&(V=x.avail_out),V!==0&&(a.arraySet(x.output,j.pending_buf,j.pending_out,V,x.next_out),x.next_out+=V,j.pending_out+=V,x.total_out+=V,x.avail_out-=V,j.pending-=V,j.pending===0&&(j.pending_out=0))}function O(x,j){o._tr_flush_block(x,0<=x.block_start?x.block_start:-1,x.strstart-x.block_start,j),x.block_start=x.strstart,D(x.strm)}function ee(x,j){x.pending_buf[x.pending++]=j}function Q(x,j){x.pending_buf[x.pending++]=j>>>8&255,x.pending_buf[x.pending++]=255&j}function K(x,j){var V,B,I=x.max_chain_length,U=x.strstart,q=x.prev_length,J=x.nice_match,W=x.strstart>x.w_size-H?x.strstart-(x.w_size-H):0,ie=x.window,le=x.w_mask,se=x.prev,Ae=x.strstart+N,je=ie[U+q-1],Pe=ie[U+q];x.prev_length>=x.good_match&&(I>>=2),J>x.lookahead&&(J=x.lookahead);do if(ie[(V=j)+q]===Pe&&ie[V+q-1]===je&&ie[V]===ie[U]&&ie[++V]===ie[U+1]){U+=2,V++;do;while(ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&UW&&--I!=0);return q<=x.lookahead?q:x.lookahead}function ge(x){var j,V,B,I,U,q,J,W,ie,le,se=x.w_size;do{if(I=x.window_size-x.lookahead-x.strstart,x.strstart>=se+(se-H)){for(a.arraySet(x.window,x.window,se,se,0),x.match_start-=se,x.strstart-=se,x.block_start-=se,j=V=x.hash_size;B=x.head[--j],x.head[j]=se<=B?B-se:0,--V;);for(j=V=se;B=x.prev[--j],x.prev[j]=se<=B?B-se:0,--V;);I+=se}if(x.strm.avail_in===0)break;if(q=x.strm,J=x.window,W=x.strstart+x.lookahead,ie=I,le=void 0,le=q.avail_in,ie=k)for(U=x.strstart-x.insert,x.ins_h=x.window[U],x.ins_h=(x.ins_h<=k&&(x.ins_h=(x.ins_h<=k)if(B=o._tr_tally(x,x.strstart-x.match_start,x.match_length-k),x.lookahead-=x.match_length,x.match_length<=x.max_lazy_match&&x.lookahead>=k){for(x.match_length--;x.strstart++,x.ins_h=(x.ins_h<=k&&(x.ins_h=(x.ins_h<=k&&x.match_length<=x.prev_length){for(I=x.strstart+x.lookahead-k,B=o._tr_tally(x,x.strstart-1-x.prev_match,x.prev_length-k),x.lookahead-=x.prev_length-1,x.prev_length-=2;++x.strstart<=I&&(x.ins_h=(x.ins_h<x.pending_buf_size-5&&(V=x.pending_buf_size-5);;){if(x.lookahead<=1){if(ge(x),x.lookahead===0&&j===h)return w;if(x.lookahead===0)break}x.strstart+=x.lookahead,x.lookahead=0;var B=x.block_start+V;if((x.strstart===0||x.strstart>=B)&&(x.lookahead=x.strstart-B,x.strstart=B,O(x,!1),x.strm.avail_out===0)||x.strstart-x.block_start>=x.w_size-H&&(O(x,!1),x.strm.avail_out===0))return w}return x.insert=0,j===d?(O(x,!0),x.strm.avail_out===0?z:L):(x.strstart>x.block_start&&(O(x,!1),x.strm.avail_out),w)}),new pe(4,4,8,4,Te),new pe(4,5,16,8,Te),new pe(4,6,32,32,Te),new pe(4,4,16,16,he),new pe(8,16,32,32,he),new pe(8,16,128,128,he),new pe(8,32,128,256,he),new pe(32,128,258,1024,he),new pe(32,258,258,4096,he)],s.deflateInit=function(x,j){return ve(x,j,b,15,8,0)},s.deflateInit2=ve,s.deflateReset=ue,s.deflateResetKeep=oe,s.deflateSetHeader=function(x,j){return x&&x.state?x.state.wrap!==2?f:(x.state.gzhead=j,p):f},s.deflate=function(x,j){var V,B,I,U;if(!x||!x.state||5>8&255),ee(B,B.gzhead.time>>16&255),ee(B,B.gzhead.time>>24&255),ee(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ee(B,255&B.gzhead.os),B.gzhead.extra&&B.gzhead.extra.length&&(ee(B,255&B.gzhead.extra.length),ee(B,B.gzhead.extra.length>>8&255)),B.gzhead.hcrc&&(x.adler=c(x.adler,B.pending_buf,B.pending,0)),B.gzindex=0,B.status=69):(ee(B,0),ee(B,0),ee(B,0),ee(B,0),ee(B,0),ee(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ee(B,3),B.status=S);else{var q=b+(B.w_bits-8<<4)<<8;q|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(q|=32),q+=31-q%31,B.status=S,Q(B,q),B.strstart!==0&&(Q(B,x.adler>>>16),Q(B,65535&x.adler)),x.adler=1}if(B.status===69)if(B.gzhead.extra){for(I=B.pending;B.gzindex<(65535&B.gzhead.extra.length)&&(B.pending!==B.pending_buf_size||(B.gzhead.hcrc&&B.pending>I&&(x.adler=c(x.adler,B.pending_buf,B.pending-I,I)),D(x),I=B.pending,B.pending!==B.pending_buf_size));)ee(B,255&B.gzhead.extra[B.gzindex]),B.gzindex++;B.gzhead.hcrc&&B.pending>I&&(x.adler=c(x.adler,B.pending_buf,B.pending-I,I)),B.gzindex===B.gzhead.extra.length&&(B.gzindex=0,B.status=73)}else B.status=73;if(B.status===73)if(B.gzhead.name){I=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>I&&(x.adler=c(x.adler,B.pending_buf,B.pending-I,I)),D(x),I=B.pending,B.pending===B.pending_buf_size)){U=1;break}U=B.gzindexI&&(x.adler=c(x.adler,B.pending_buf,B.pending-I,I)),U===0&&(B.gzindex=0,B.status=91)}else B.status=91;if(B.status===91)if(B.gzhead.comment){I=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>I&&(x.adler=c(x.adler,B.pending_buf,B.pending-I,I)),D(x),I=B.pending,B.pending===B.pending_buf_size)){U=1;break}U=B.gzindexI&&(x.adler=c(x.adler,B.pending_buf,B.pending-I,I)),U===0&&(B.status=103)}else B.status=103;if(B.status===103&&(B.gzhead.hcrc?(B.pending+2>B.pending_buf_size&&D(x),B.pending+2<=B.pending_buf_size&&(ee(B,255&x.adler),ee(B,x.adler>>8&255),x.adler=0,B.status=S)):B.status=S),B.pending!==0){if(D(x),x.avail_out===0)return B.last_flush=-1,p}else if(x.avail_in===0&&R(j)<=R(V)&&j!==d)return te(x,-5);if(B.status===666&&x.avail_in!==0)return te(x,-5);if(x.avail_in!==0||B.lookahead!==0||j!==h&&B.status!==666){var J=B.strategy===2?function(W,ie){for(var le;;){if(W.lookahead===0&&(ge(W),W.lookahead===0)){if(ie===h)return w;break}if(W.match_length=0,le=o._tr_tally(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++,le&&(O(W,!1),W.strm.avail_out===0))return w}return W.insert=0,ie===d?(O(W,!0),W.strm.avail_out===0?z:L):W.last_lit&&(O(W,!1),W.strm.avail_out===0)?w:F}(B,j):B.strategy===3?function(W,ie){for(var le,se,Ae,je,Pe=W.window;;){if(W.lookahead<=N){if(ge(W),W.lookahead<=N&&ie===h)return w;if(W.lookahead===0)break}if(W.match_length=0,W.lookahead>=k&&0W.lookahead&&(W.match_length=W.lookahead)}if(W.match_length>=k?(le=o._tr_tally(W,1,W.match_length-k),W.lookahead-=W.match_length,W.strstart+=W.match_length,W.match_length=0):(le=o._tr_tally(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++),le&&(O(W,!1),W.strm.avail_out===0))return w}return W.insert=0,ie===d?(O(W,!0),W.strm.avail_out===0?z:L):W.last_lit&&(O(W,!1),W.strm.avail_out===0)?w:F}(B,j):n[B.level].func(B,j);if(J!==z&&J!==L||(B.status=666),J===w||J===z)return x.avail_out===0&&(B.last_flush=-1),p;if(J===F&&(j===1?o._tr_align(B):j!==5&&(o._tr_stored_block(B,0,0,!1),j===3&&(G(B.head),B.lookahead===0&&(B.strstart=0,B.block_start=0,B.insert=0))),D(x),x.avail_out===0))return B.last_flush=-1,p}return j!==d?p:B.wrap<=0?1:(B.wrap===2?(ee(B,255&x.adler),ee(B,x.adler>>8&255),ee(B,x.adler>>16&255),ee(B,x.adler>>24&255),ee(B,255&x.total_in),ee(B,x.total_in>>8&255),ee(B,x.total_in>>16&255),ee(B,x.total_in>>24&255)):(Q(B,x.adler>>>16),Q(B,65535&x.adler)),D(x),0=V.w_size&&(U===0&&(G(V.head),V.strstart=0,V.block_start=0,V.insert=0),ie=new a.Buf8(V.w_size),a.arraySet(ie,j,le-V.w_size,V.w_size,0),j=ie,le=V.w_size),q=x.avail_in,J=x.next_in,W=x.input,x.avail_in=le,x.next_in=0,x.input=j,ge(V);V.lookahead>=k;){for(B=V.strstart,I=V.lookahead-(k-1);V.ins_h=(V.ins_h<>>=k=P>>>24,A-=k,(k=P>>>16&255)===0)F[u++]=65535&P;else{if(!(16&k)){if(!(64&k)){P=v[(65535&P)+(b&(1<>>=k,A-=k),A<15&&(b+=w[l++]<>>=k=P>>>24,A-=k,!(16&(k=P>>>16&255))){if(!(64&k)){P=E[(65535&P)+(b&(1<>>=k,A-=k,(k=u-h)>3,b&=(1<<(A-=N<<3))-1,n.next_in=l,n.next_out=u,n.avail_in=l>>24&255)+(T>>>8&65280)+((65280&T)<<8)+((255&T)<<24)}function b(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function A(T){var S;return T&&T.state?(S=T.state,T.total_in=T.total_out=S.total=0,T.msg="",S.wrap&&(T.adler=1&S.wrap),S.mode=f,S.last=0,S.havedict=0,S.dmax=32768,S.head=null,S.hold=0,S.bits=0,S.lencode=S.lendyn=new n.Buf32(m),S.distcode=S.distdyn=new n.Buf32(g),S.sane=1,S.back=-1,d):p}function v(T){var S;return T&&T.state?((S=T.state).wsize=0,S.whave=0,S.wnext=0,A(T)):p}function E(T,S){var w,F;return T&&T.state?(F=T.state,S<0?(w=0,S=-S):(w=1+(S>>4),S<48&&(S&=15)),S&&(S<8||15=L.wsize?(n.arraySet(L.window,S,w-L.wsize,L.wsize,0),L.wnext=0,L.whave=L.wsize):(F<(z=L.wsize-L.wnext)&&(z=F),n.arraySet(L.window,S,w-F,z,L.wnext),(F-=z)?(n.arraySet(L.window,S,w-F,F,0),L.wnext=F,L.whave=L.wsize):(L.wnext+=z,L.wnext===L.wsize&&(L.wnext=0),L.whave>>8&255,w.check=o(w.check,U,2,0),O=D=0,w.mode=2;break}if(w.flags=0,w.head&&(w.head.done=!1),!(1&w.wrap)||(((255&D)<<8)+(D>>8))%31){T.msg="incorrect header check",w.mode=30;break}if((15&D)!=8){T.msg="unknown compression method",w.mode=30;break}if(O-=4,x=8+(15&(D>>>=4)),w.wbits===0)w.wbits=x;else if(x>w.wbits){T.msg="invalid window size",w.mode=30;break}w.dmax=1<>8&1),512&w.flags&&(U[0]=255&D,U[1]=D>>>8&255,w.check=o(w.check,U,2,0)),O=D=0,w.mode=3;case 3:for(;O<32;){if(R===0)break e;R--,D+=F[L++]<>>8&255,U[2]=D>>>16&255,U[3]=D>>>24&255,w.check=o(w.check,U,4,0)),O=D=0,w.mode=4;case 4:for(;O<16;){if(R===0)break e;R--,D+=F[L++]<>8),512&w.flags&&(U[0]=255&D,U[1]=D>>>8&255,w.check=o(w.check,U,2,0)),O=D=0,w.mode=5;case 5:if(1024&w.flags){for(;O<16;){if(R===0)break e;R--,D+=F[L++]<>>8&255,w.check=o(w.check,U,2,0)),O=D=0}else w.head&&(w.head.extra=null);w.mode=6;case 6:if(1024&w.flags&&(R<(K=w.length)&&(K=R),K&&(w.head&&(x=w.head.extra_len-w.length,w.head.extra||(w.head.extra=new Array(w.head.extra_len)),n.arraySet(w.head.extra,F,L,K,x)),512&w.flags&&(w.check=o(w.check,F,K,L)),R-=K,L+=K,w.length-=K),w.length))break e;w.length=0,w.mode=7;case 7:if(2048&w.flags){if(R===0)break e;for(K=0;x=F[L+K++],w.head&&x&&w.length<65536&&(w.head.name+=String.fromCharCode(x)),x&&K>9&1,w.head.done=!0),T.adler=w.check=0,w.mode=12;break;case 10:for(;O<32;){if(R===0)break e;R--,D+=F[L++]<>>=7&O,O-=7&O,w.mode=27;break}for(;O<3;){if(R===0)break e;R--,D+=F[L++]<>>=1)){case 0:w.mode=14;break;case 1:if(N(w),w.mode=20,S!==6)break;D>>>=2,O-=2;break e;case 2:w.mode=17;break;case 3:T.msg="invalid block type",w.mode=30}D>>>=2,O-=2;break;case 14:for(D>>>=7&O,O-=7&O;O<32;){if(R===0)break e;R--,D+=F[L++]<>>16^65535)){T.msg="invalid stored block lengths",w.mode=30;break}if(w.length=65535&D,O=D=0,w.mode=15,S===6)break e;case 15:w.mode=16;case 16:if(K=w.length){if(R>>=5,O-=5,w.ndist=1+(31&D),D>>>=5,O-=5,w.ncode=4+(15&D),D>>>=4,O-=4,286>>=3,O-=3}for(;w.have<19;)w.lens[q[w.have++]]=0;if(w.lencode=w.lendyn,w.lenbits=7,V={bits:w.lenbits},j=c(0,w.lens,0,19,w.lencode,0,w.work,V),w.lenbits=V.bits,j){T.msg="invalid code lengths set",w.mode=30;break}w.have=0,w.mode=19;case 19:for(;w.have>>16&255,be=65535&I,!((he=I>>>24)<=O);){if(R===0)break e;R--,D+=F[L++]<>>=he,O-=he,w.lens[w.have++]=be;else{if(be===16){for(B=he+2;O>>=he,O-=he,w.have===0){T.msg="invalid bit length repeat",w.mode=30;break}x=w.lens[w.have-1],K=3+(3&D),D>>>=2,O-=2}else if(be===17){for(B=he+3;O>>=he)),D>>>=3,O-=3}else{for(B=he+7;O>>=he)),D>>>=7,O-=7}if(w.have+K>w.nlen+w.ndist){T.msg="invalid bit length repeat",w.mode=30;break}for(;K--;)w.lens[w.have++]=x}}if(w.mode===30)break;if(w.lens[256]===0){T.msg="invalid code -- missing end-of-block",w.mode=30;break}if(w.lenbits=9,V={bits:w.lenbits},j=c(u,w.lens,0,w.nlen,w.lencode,0,w.work,V),w.lenbits=V.bits,j){T.msg="invalid literal/lengths set",w.mode=30;break}if(w.distbits=6,w.distcode=w.distdyn,V={bits:w.distbits},j=c(h,w.lens,w.nlen,w.ndist,w.distcode,0,w.work,V),w.distbits=V.bits,j){T.msg="invalid distances set",w.mode=30;break}if(w.mode=20,S===6)break e;case 20:w.mode=21;case 21:if(6<=R&&258<=G){T.next_out=te,T.avail_out=G,T.next_in=L,T.avail_in=R,w.hold=D,w.bits=O,l(T,Q),te=T.next_out,z=T.output,G=T.avail_out,L=T.next_in,F=T.input,R=T.avail_in,D=w.hold,O=w.bits,w.mode===12&&(w.back=-1);break}for(w.back=0;pe=(I=w.lencode[D&(1<>>16&255,be=65535&I,!((he=I>>>24)<=O);){if(R===0)break e;R--,D+=F[L++]<>oe)])>>>16&255,be=65535&I,!(oe+(he=I>>>24)<=O);){if(R===0)break e;R--,D+=F[L++]<>>=oe,O-=oe,w.back+=oe}if(D>>>=he,O-=he,w.back+=he,w.length=be,pe===0){w.mode=26;break}if(32&pe){w.back=-1,w.mode=12;break}if(64&pe){T.msg="invalid literal/length code",w.mode=30;break}w.extra=15&pe,w.mode=22;case 22:if(w.extra){for(B=w.extra;O>>=w.extra,O-=w.extra,w.back+=w.extra}w.was=w.length,w.mode=23;case 23:for(;pe=(I=w.distcode[D&(1<>>16&255,be=65535&I,!((he=I>>>24)<=O);){if(R===0)break e;R--,D+=F[L++]<>oe)])>>>16&255,be=65535&I,!(oe+(he=I>>>24)<=O);){if(R===0)break e;R--,D+=F[L++]<>>=oe,O-=oe,w.back+=oe}if(D>>>=he,O-=he,w.back+=he,64&pe){T.msg="invalid distance code",w.mode=30;break}w.offset=be,w.extra=15&pe,w.mode=24;case 24:if(w.extra){for(B=w.extra;O>>=w.extra,O-=w.extra,w.back+=w.extra}if(w.offset>w.dmax){T.msg="invalid distance too far back",w.mode=30;break}w.mode=25;case 25:if(G===0)break e;if(K=Q-G,w.offset>K){if((K=w.offset-K)>w.whave&&w.sane){T.msg="invalid distance too far back",w.mode=30;break}ge=K>w.wnext?(K-=w.wnext,w.wsize-K):w.wnext-K,K>w.length&&(K=w.length),Te=w.window}else Te=z,ge=te-w.offset,K=w.length;for(GM?(k=ge[Te+g[S]],O[ee+g[S]]):(k=96,0),b=1<>te)+(A-=b)]=P<<24|k<<16|N|0,A!==0;);for(b=1<>=1;if(b!==0?(D&=b-1,D+=b):D=0,S++,--Q[T]==0){if(T===F)break;T=h[d+g[S]]}if(z>>7)]}function ee(I,U){I.pending_buf[I.pending++]=255&U,I.pending_buf[I.pending++]=U>>>8&255}function Q(I,U,q){I.bi_valid>y-q?(I.bi_buf|=U<>y-I.bi_valid,I.bi_valid+=q-y):(I.bi_buf|=U<>>=1,q<<=1,0<--U;);return q>>>1}function Te(I,U,q){var J,W,ie=new Array(g+1),le=0;for(J=1;J<=g;J++)ie[J]=le=le+q[J-1]<<1;for(W=0;W<=U;W++){var se=I[2*W+1];se!==0&&(I[2*W]=ge(ie[se]++,se))}}function he(I){var U;for(U=0;U>1;1<=q;q--)oe(I,ie,q);for(W=Ae;q=I.heap[1],I.heap[1]=I.heap[I.heap_len--],oe(I,ie,1),J=I.heap[1],I.heap[--I.heap_max]=q,I.heap[--I.heap_max]=J,ie[2*W]=ie[2*q]+ie[2*J],I.depth[W]=(I.depth[q]>=I.depth[J]?I.depth[q]:I.depth[J])+1,ie[2*q+1]=ie[2*J+1]=W,I.heap[1]=W++,oe(I,ie,1),2<=I.heap_len;);I.heap[--I.heap_max]=I.heap[1],function(Pe,Rt){var zr,qt,jr,st,X,fe,_e=Rt.dyn_tree,ze=Rt.max_code,Ne=Rt.stat_desc.static_tree,xt=Rt.stat_desc.has_stree,Dt=Rt.stat_desc.extra_bits,Yi=Rt.stat_desc.extra_base,dr=Rt.stat_desc.max_length,Qt=0;for(st=0;st<=g;st++)Pe.bl_count[st]=0;for(_e[2*Pe.heap[Pe.heap_max]+1]=0,zr=Pe.heap_max+1;zr>=7;W>>=1)if(1&je&&se.dyn_ltree[2*Ae]!==0)return a;if(se.dyn_ltree[18]!==0||se.dyn_ltree[20]!==0||se.dyn_ltree[26]!==0)return o;for(Ae=32;Ae>>3,(ie=I.static_len+3+7>>>3)<=W&&(W=ie)):W=ie=q+5,q+4<=W&&U!==-1?B(I,U,q,J):I.strategy===4||ie===W?(Q(I,2+(J?1:0),3),ue(I,H,T)):(Q(I,4+(J?1:0),3),function(se,Ae,je,Pe){var Rt;for(Q(se,Ae-257,5),Q(se,je-1,5),Q(se,Pe-4,4),Rt=0;Rt>>8&255,I.pending_buf[I.d_buf+2*I.last_lit+1]=255&U,I.pending_buf[I.l_buf+I.last_lit]=255&q,I.last_lit++,U===0?I.dyn_ltree[2*q]++:(I.matches++,U--,I.dyn_ltree[2*(w[q]+h+1)]++,I.dyn_dtree[2*O(U)]++),I.last_lit===I.lit_bufsize-1},s._tr_align=function(I){Q(I,2,3),K(I,A,H),function(U){U.bi_valid===16?(ee(U,U.bi_buf),U.bi_buf=0,U.bi_valid=0):8<=U.bi_valid&&(U.pending_buf[U.pending++]=255&U.bi_buf,U.bi_buf>>=8,U.bi_valid-=8)}(I)}},{"../utils/common":41}],53:[function(t,i,s){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,i,s){(function(n){(function(a,o){if(!a.setImmediate){var l,c,u,h,d=1,p={},f=!1,m=a.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(a);g=g&&g.setTimeout?g:a,l={}.toString.call(a.process)==="[object process]"?function(v){process.nextTick(function(){b(v)})}:function(){if(a.postMessage&&!a.importScripts){var v=!0,E=a.onmessage;return a.onmessage=function(){v=!1},a.postMessage("","*"),a.onmessage=E,v}}()?(h="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",A,!1):a.attachEvent("onmessage",A),function(v){a.postMessage(h+v,"*")}):a.MessageChannel?((u=new MessageChannel).port1.onmessage=function(v){b(v.data)},function(v){u.port2.postMessage(v)}):m&&"onreadystatechange"in m.createElement("script")?(c=m.documentElement,function(v){var E=m.createElement("script");E.onreadystatechange=function(){b(v),E.onreadystatechange=null,c.removeChild(E),E=null},c.appendChild(E)}):function(v){setTimeout(b,0,v)},g.setImmediate=function(v){typeof v!="function"&&(v=new Function(""+v));for(var E=new Array(arguments.length-1),C=0;C"u"?n===void 0?this:n:self)}).call(this,typeof si<"u"?si:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(vg);var LE=vg.exports;const OE=da(LE),$i=class $i{static async writeHandle(e,t){const i=this.workID++,s=new Promise((o,l)=>this.map.set(i,[o,l])),n=new TextEncoder,a=typeof t=="string"?n.encode(t):await t.arrayBuffer();return this.worker.postMessage([i,e,a],[a]),s}};Ms($i,"worker",new Worker(new URL("/smeditor/assets/SafariFileWorker-557e53c3.js",self.location),{type:"module"})),Ms($i,"workID",0),Ms($i,"map",new Map),$i.worker.onmessage=e=>{const t=e.data;t.success?$i.map.get(t.id)[0]():$i.map.get(t.id)[1](t.reason),$i.map.delete(t.id)};let Sc=$i;class FE{_root;async getRoot(){return this._root||(kE.adapter.native?await kp().then(e=>this._root=e):await kp(ui(()=>import("./memory-ba8edfa0.js"),[])).then(e=>this._root=e)),this._root}async uploadHandle(e,t){let i;if(typeof t=="string"){const s=await this.getDirectoryHandle(t,{create:!0});if(!s)return;i=s}else i=t??await this.getRoot();if(e.kind=="file"){const s=await i.getFileHandle(e.name,{create:!0});await this.writeFile(s,await e.getFile())}else{const s=await i.getDirectoryHandle(e.name,{create:!0}),n=[];for await(const a of e.values())n.push(this.uploadHandle(a,s));await Promise.all(n)}}async uploadFiles(e,t){let i;if(typeof t=="string"){const s=await this.getDirectoryHandle(t,{create:!0});if(!s)return;i=s}else i=t??await this.getRoot();if(e.isFile){const s=e;if(s.name==".DS_Store")return;s.file(async n=>{const a=await i.getFileHandle(n.name,{create:!0});await this.writeHandle(a,n)})}else if(e.isDirectory){const s=e.createReader(),n=await i.getDirectoryHandle(e.name,{create:!0});for await(const a of n.values())await n.removeEntry(a.name,{recursive:!0});s.readEntries(async a=>{const o=[];for(let l=0;li!="."&&i!="");t.indexOf("..")>-1;){const i=t.indexOf("..");if(i==0)throw Error("Path"+t.join("/")+"is invalid!");t.splice(i-1,2)}return t.join("/")}async zipDirectory(e,t){const i=t??new OE,s=Ui(e)==""?e:jt(e),n=await this.getDirectoryHandle(s);if(n){for(const a of await this.getDirectoryFiles(n))i.file(a.name,await a.getFile());for(const a of await this.getDirectoryFolders(n)){const o=i.folder(a.name);if(!o){console.error("Failed to zip folder "+e+"/"+a.name);continue}await this.zipDirectory(e+"/"+a.name,o)}return i}}async saveDirectory(e){const t=Ui(e)==""?e:jt(e);Ce.create("Exporting "+t+".zip");const i=await ME({_preferPolyfill:!1,suggestedName:`${t}.zip`,types:[{accept:{"application/zip":[".zip"]}}],excludeAcceptAllOption:!1}),s=await this.zipDirectory(e);s&&await s.generateAsync({type:"blob"}).then(async n=>{await this.writeHandle(i,n)})}async renameFile(e,t){if(e!=t)try{const i=await this.getDirectoryHandle(jt(e)),s=await this.getDirectoryHandle(jt(t),{create:!0}),n=await this.getFileHandle(e);if(!i||!s||!n)return;await this.copyToHandle(s,n,Zi(t)),await i.removeEntry(Zi(e))}catch(i){console.error(i)}}async renameDirectory(e,t){if(!t.startsWith(e))try{const i=await this.getDirectoryHandle(jt(e)),s=await this.getDirectoryHandle(jt(t),{create:!0}),n=await this.getDirectoryHandle(e);if(!i||!s||!n)return;await this.copyToHandle(s,n,Zi(t)),await i.removeEntry(Zi(e),{recursive:!0})}catch(i){console.error(i)}}async copyToHandle(e,t,i){try{if(t.kind=="directory"){const s=await e.getDirectoryHandle(i??t.name,{create:!0}),n=[];for await(const a of t.values())n.push(this.copyToHandle(s,a));await Promise.all(n)}else{const s=await t.getFile(),n=await e.getFileHandle(i??t.name,{create:!0});await this.writeHandle(n,s)}}catch(s){console.error(s)}}getRelativePath(e,t){const i=e.split("/"),s=t.split("/"),n=Math.min(i.length,s.length);let a=n;for(let l=0;limport("./NodeFileHandler-b249bb9f.js"),[])).NodeFileHandler:new FE}static getStandardHandler(){return this.standardHandler}static getHandler(e){return e!==void 0&&e.startsWith("https://")||e?.startsWith("http://")?this.urlHandler:this.standardHandler}static handleDropEvent(e,t){return this.getHandler().handleDropEvent(e,t)}static getDirectoryHandle(e,t){return Re.getHandler(e).getDirectoryHandle(e,t)}static hasFile(e){return Re.getHandler(e).hasFile(e)}static getFileHandle(e,t){return Re.getHandler(e).getFileHandle(e,t)}static getFileHandleRelativeTo(e,t){return Re.getHandler(e).getFileHandleRelativeTo(e,t)}static getDirectoryFiles(e){return Re.getHandler(typeof e=="string"?e:void 0).getDirectoryFiles(e)}static getDirectoryFolders(e){return Re.getHandler(typeof e=="string"?e:void 0).getDirectoryFolders(e)}static writeFile(e,t){return Re.getHandler(typeof e=="string"?e:void 0).writeFile(e,t)}static getRelativePath(e,t){return Re.getHandler().getRelativePath(e,t)}}class Pt{windowManager;options;windowElement;viewElement;constructor(e){this.options=e;const t=document.createElement("div"),i=document.createElement("div"),s=document.createElement("div"),n=document.createElement("div");if(t.appendChild(s),t.appendChild(i),t.style.width=e.width+"px",t.style.left=window.innerWidth/2-e.width/2+"px",t.style.top=window.innerHeight/2-e.height/2+"px",t.classList.add("unselectable","window"),e.win_id&&(t.dataset.win_id=e.win_id),i.classList.add("view"),i.style.height=e.height+"px",i.style.width=e.width+"px",s.classList.add("navbar"),s.appendChild(n),!e.disableClose){const a=document.createElement("img"),o=document.createElement("img");a.classList.add("unselectable"),a.draggable=!1,a.src=He.MINIMIZE_WINDOW,a.onclick=()=>{i.style.height!="0px"?i.style.height="0px":i.style.height=e.height+"px",this.clampPosition()},o.classList.add("unselectable"),o.draggable=!1,o.src=He.CLOSE_WINDOW,o.onclick=()=>this.closeWindow(),s.appendChild(a),s.appendChild(o)}n.innerText=e.title,n.classList.add("title"),t.addEventListener("mousedown",()=>this.focus()),e.blocking&&(window.addEventListener("mousedown",this.block,!0),document.getElementById("blocker").style.display="block",t.dataset.blocking="block"),n.addEventListener("mousedown",()=>{window.addEventListener("mousemove",this.handleDrag),window.addEventListener("mouseup",()=>window.removeEventListener("mousemove",this.handleDrag))}),this.focus(),t.classList.add("focused"),this.windowElement=t,this.viewElement=i}addToManager(e){this.windowManager=e,e.view.appendChild(this.windowElement),this.focus()}onClose(){}closeWindow(){this.windowManager&&(this.onClose(),this.windowManager.removeWindow(this),this.windowElement.classList.add("exiting"),window.removeEventListener("mousedown",this.block,!0),this.options.blocking&&this.windowManager.windows.filter(e=>e.options.blocking).length==0&&(document.getElementById("blocker").style.display="none"),setTimeout(()=>this.windowManager.view.removeChild(this.windowElement),40))}focus(){if(this.windowManager==null)return;this.windowManager.unfocusAll(),this.windowElement.classList.add("focused");const e=Array.from(this.windowManager.view.children).map(t=>t).filter(t=>t!=this.windowElement);e.sort((t,i)=>parseInt(t.style.zIndex)-parseInt(i.style.zIndex)),e.push(this.windowElement);for(let t=0;t{!e.target||this.windowElement.contains(e.target)||(e.stopImmediatePropagation(),e.preventDefault())};handleDrag=e=>{const t=parseInt(this.windowElement.style.left.slice(0,-2))+e.movementX,i=parseInt(this.windowElement.style.top.slice(0,-2))+e.movementY;this.windowElement.style.left=t+"px",this.windowElement.style.top=i+"px",this.clampPosition()};clampPosition(){if(this.windowManager==null)return;const e=parseInt(this.windowElement.style.left.slice(0,-2)),t=parseInt(this.windowElement.style.top.slice(0,-2)),i=this.windowManager.app.view.getBoundingClientRect();this.windowElement.style.left=Ve(e,i.left,i.width-this.windowElement.clientWidth+i.left)+"px",this.windowElement.style.top=Ve(t,i.top,i.height-this.windowElement.clientHeight+i.top)+"px"}}class ml extends Pt{app;dirOptions;fileDropPath="";draggedElement;draggedCopy;keyHandler;dropHandler;mouseHandler;dragHandler;constructor(e,t,i){super({title:t.title,width:500,height:400,disableClose:t.disableClose,win_id:"file_selector"+Math.random(),blocking:!0}),this.app=e,this.dirOptions=t,t.accepted_file_types||=[],this.keyHandler=this.handleKeyEvent.bind(this),this.dropHandler=this.handleDropEvent.bind(this),this.mouseHandler=this.handleMouseEvent.bind(this),this.dragHandler=this.handleDragEvent.bind(this),this.initView().then(()=>{i&&this.selectPath(i),t.onload?.()})}async initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("menu-options");const i=document.createElement("div");i.classList.add("menu-left");const s=document.createElement("div");s.classList.add("menu-right"),t.appendChild(i),t.appendChild(s);const n=document.createElement("button");n.innerText="Cancel",n.onclick=()=>{window.removeEventListener("keydown",this.keyHandler,!0),window.removeEventListener("drop",this.dropHandler,!0),this.closeWindow()};const a=document.createElement("button");a.innerText="Select",a.classList.add("confirm"),a.onclick=()=>this.confirmFile(),a.disabled=!0,i.appendChild(n),s.appendChild(a);const o=document.createElement("div");o.classList.add("dir-selector"),o.onclick=y=>{y.target==o&&this.selectElement(void 0)};const l=document.createElement("div");l.classList.add("file-options");const c=document.createElement("button"),u=document.createElement("img");u.src=He.ADD_FILE,u.classList.add("icon"),c.appendChild(u),c.appendChild(document.createTextNode("Upload files")),l.appendChild(c),c.onclick=async()=>{const y=this.fileDropPath,b=await CE({_preferPolyfill:!1,excludeAcceptAllOption:!1,multiple:!0}),v=this.viewElement.querySelector(".info.selected")?.dataset.path??"",E=[];for(const C of b)E.push(Re.getStandardHandler().uploadHandle(C,v));await Promise.all(E),await this.refreshDirectory(y),this.getAcceptableFile(y).then(C=>this.selectPath(C))};const h=document.createElement("button"),d=document.createElement("img");d.src=He.ADD_FOLDER,d.classList.add("icon"),h.appendChild(d),h.appendChild(document.createTextNode("Upload folder")),l.appendChild(h),h.onclick=async()=>{const y=this.fileDropPath,b=await SE({_preferPolyfill:!1}),v=this.viewElement.querySelector(".info.selected")?.dataset.path??"";await Re.getStandardHandler().uploadHandle(b,v),await this.refreshDirectory(y),this.getAcceptableFile(y==""?b.name:y+"/"+b.name).then(E=>this.selectPath(E))};const p=document.createElement("button");p.classList.add("rename");const f=document.createElement("img");f.src=He.EDIT,f.classList.add("icon"),p.appendChild(f),p.appendChild(document.createTextNode("Rename")),p.disabled=!0,p.onclick=()=>{const y=this.viewElement.querySelector(".info.selected");y?.dataset.path&&this.startEditing(y.querySelector("textarea"))},l.appendChild(p);const m=document.createElement("button");m.classList.add("delete");const g=document.createElement("img");g.src=He.TRASH,g.classList.add("icon"),m.appendChild(g),m.appendChild(document.createTextNode("Delete")),m.disabled=!0,m.onclick=()=>{const y=this.viewElement.querySelector(".info.selected"),b=y?.dataset.path;if(!b)return;const A=y.parentElement.classList.contains("folder");Re.getStandardHandler()[A?"removeDirectory":"removeFile"](b).then(()=>{const v=this.getElement(b);v&&(v.parentElement?.remove(),m.disabled=!0,p.disabled=!0)})},l.appendChild(m),e.appendChild(o),e.appendChild(l),e.appendChild(t),this.viewElement.appendChild(e),window.addEventListener("keydown",this.keyHandler,!0),window.addEventListener("drop",this.dropHandler,!0),window.addEventListener("mousemove",this.dragHandler,!0),this.viewElement.addEventListener("dragover",this.mouseHandler),await this.createDiv("").then(y=>o.replaceChildren(...y))}async expand(e){if(!e.parentElement.classList.contains("folder"))return;e.parentElement.classList.remove("collapsed");const t=e.nextSibling;await this.createDiv(e.dataset.path).then(i=>{t.replaceChildren(...i)})}collapse(e){if(!e.parentElement.classList.contains("folder"))return;e.parentElement.classList.add("collapsed"),e.nextSibling.replaceChildren()}selectElement(e){if(this.viewElement.querySelector(".info.selected")?.classList.remove("selected"),!e){this.viewElement.querySelector(".delete").disabled=!0,this.viewElement.querySelector(".rename").disabled=!0;return}e.classList.add("selected"),ea(e,{scrollMode:"if-needed",block:"nearest",inline:"nearest"});const t=this.viewElement.querySelector("button.confirm"),i=e.dataset.path;t.disabled=!0,i&&(t.disabled=!this.acceptableFileType(i),this.viewElement.querySelector(".delete").disabled=!1,this.viewElement.querySelector(".rename").disabled=!1)}async createDiv(e){const t=await Re.getStandardHandler().getDirectoryFolders(e);let i=await Re.getStandardHandler().getDirectoryFiles(e);return t.sort((s,n)=>s.name.toLowerCase().localeCompare(n.name.toLowerCase())),i.sort((s,n)=>s.name.toLowerCase().localeCompare(n.name.toLowerCase())),i=i.filter(s=>Ui(s.name)!=".crswap"),t.map(s=>this.createBaseElement(e,s)).concat(i.map(s=>this.createBaseElement(e,s)))}createBaseElement(e,t){e!=""&&(e+="/");const i=document.createElement("div");i.classList.add("item");const s=document.createElement("div");if(s.classList.add("info"),i.appendChild(s),t.kind=="directory"){const a=document.createElement("img");a.classList.add("icon"),a.classList.add("folder-icon"),a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAAbklEQVRIie2PMQqAMAxFXwfP6qJVPIjYzcOKdUkhQ0BaCoLkLS3k818CjuN8ztApYzIDl7xvmalFsAIZuIFozKPMMrC0CAJwKIkuGVX5KdkmLEm3ci1JSlLKU49yLSmXVG1es0EANvnvInKcP/AA784fpjlWwNQAAAAASUVORK5CYII=",s.appendChild(a);const o=document.createElement("div");o.classList.add("children"),i.appendChild(o),i.classList.add("folder"),i.classList.add("collapsed"),s.addEventListener("click",l=>{const c=l.target;c?.classList.contains("options-icon")||c.tagName=="TEXTAREA"&&!c.disabled||(i.classList.contains("collapsed")?this.expand(s):this.collapse(s))})}else{this.acceptableFileType(t.name)||s.classList.add("disabled");const a=document.createElement("img");a.src=this.getIcon(t.name),a.classList.add("icon"),s.appendChild(a)}s.dataset.path=e+t.name;const n=document.createElement("textarea");return n.rows=1,n.disabled=!0,n.autocomplete="off",n.autocapitalize="off",n.spellcheck=!1,n.innerText=t.name,n.style.pointerEvents="none",n.classList.add("title"),s.appendChild(n),s.addEventListener("click",()=>this.selectElement(s)),s.addEventListener("mousedown",()=>this.startDragging(s)),s.ondblclick=()=>this.confirmFile(),i}confirmFile(){const t=this.viewElement.querySelector(".info.selected")?.dataset.path;t&&this.acceptableFileType(t)&&(this.dirOptions.callback?.(t),window.removeEventListener("keydown",this.keyHandler,!0),window.removeEventListener("drop",this.dropHandler,!0),window.removeEventListener("mousemove",this.dragHandler,!0),this.closeWindow())}acceptableFileType(e){return this.dirOptions.accepted_file_types.length==0||this.dirOptions.accepted_file_types.includes(Ui(e))}getIcon(e){const t=Ui(e);return t==""&&!e.startsWith(".")?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAAY0lEQVRIiWNgGAWDCXgwMDA8ZmBg+I8DN1BqwSM8hlPFEpgh2EA4AwPDbyIc8B/qUA9SLSDHEpItIBagmMNEBQPxglELRi0YtQDVgsdQmpiiAB9GNgsFeDAQV6KSXdiNgoEBAG+iU6T/ixEpAAAAAElFTkSuQmCC":ts.includes(t)?He.IMAGE_FILE:ol.includes(t)?He.AUDIO_FILE:[".sm",".ssc"].includes(t)?He.SM_FILE:He.UNKNOWN_FILE}startEditing(e){const t=e.value,i=!!e.parentElement?.parentElement?.classList.contains("folder"),s=e.parentElement?.dataset.path??"",n=jt(s);e.value=s.split("/").at(-1)??"",window.removeEventListener("keydown",this.keyHandler,!0),e.disabled=!1,e.style.pointerEvents="",e.focus(),e.addEventListener("keypress",a=>{a.code=="Enter"&&(a.preventDefault(),a.stopImmediatePropagation(),e.blur())},!0),e.addEventListener("blur",async()=>{if(window.addEventListener("keydown",this.keyHandler,!0),e.disabled=!0,e.style.pointerEvents="none",e.value.startsWith(".")){e.value=t;return}e.value=e.value.replaceAll("/","");const a=n==""?e.value:n+"/"+e.value;a!=s&&(e.parentElement.dataset.path=a,await Re.getStandardHandler()[i?"renameDirectory":"renameFile"](s,a),this.refreshDirectory(n),e.value.length>32&&(e.value=e.value.slice(0,32)+"..."))})}async refreshDirectory(e){const t=this.viewElement.querySelector(".dir-selector");if(!t)return;let i=t.querySelector("div[data-path='"+this.escapeSelector(e)+"']")?.nextSibling;if(e==""&&(i=t),!i)return;const s=Array.from(i.parentElement.querySelectorAll(".folder:not(.collapsed)")).map(n=>n.children[0].dataset.path);await this.createDiv(e).then(n=>i.replaceChildren(...n)),await Promise.all(s.map(n=>this.expand(t.querySelector("div[data-path='"+this.escapeSelector(n)+"']"))))}getElement(e){const t=this.viewElement.querySelector(".dir-selector");return t?t.querySelector("div[data-path='"+this.escapeSelector(e)+"']"):null}async getAcceptableFile(e){const t=await Re.getStandardHandler().getDirectoryHandle(e);if(!t)return;const i=[{path:e,handle:t}];for(;i.length>0;){const s=i.shift(),n=s.handle;for await(const a of n.values()){const o=s.path==""?"":s.path+"/";if(a.kind=="directory")i.push({path:o+a.name,handle:a});else if(this.acceptableFileType(a.name))return o+a.name}}}async selectPath(e){if(!e)return;const t=this.viewElement.querySelector(".dir-selector");if(!t)return;const i=e.split("/");i.pop();const s=[];for(;i.length>0;){s.push(i.shift());const a=t.querySelector("div[data-path='"+this.escapeSelector(s.join("/"))+"']");if(!a)return;await this.expand(a)}const n=t.querySelector("div[data-path='"+this.escapeSelector(e)+"']");n&&this.selectElement(n)}handleKeyEvent(e){if(!this.windowElement.classList.contains("focused"))return;const t=this.viewElement.querySelector(".info.selected");if(t==null){if(e.code.startsWith("Arrow")){const i=this.viewElement.querySelector(".info");i&&this.selectElement(i)}return}if(e.code=="ArrowUp"){e.preventDefault(),e.stopImmediatePropagation();const i=t.parentElement;let s=i.previousSibling?.querySelector(".info");s&&!s.parentElement.classList.contains("collapsed")&&s.parentElement.classList.contains("folder")&&(s=s.parentElement.querySelector(".children").lastChild.querySelector(".info")),!s&&i.parentElement.classList.contains("children")&&(s=i.parentElement.parentElement.querySelector(".info")),s&&(this.selectElement(s),ea(s,{scrollMode:"if-needed",block:"nearest",inline:"nearest"}))}if(e.code=="ArrowDown"){e.preventDefault(),e.stopImmediatePropagation();const i=t.parentElement;let s;i.classList.contains("folder")&&!i.classList.contains("collapsed")&&(s=i.querySelector(".children").children[0].querySelector(".info")),s||(s=t.parentElement.nextSibling?.querySelector(".info")),!s&&i.parentElement.classList.contains("children")&&(s=i.parentElement.parentElement.nextSibling.querySelector(".info")),s&&(this.selectElement(s),ea(s,{scrollMode:"if-needed",block:"nearest",inline:"nearest"}))}if(e.code=="ArrowLeft"&&(e.preventDefault(),e.stopImmediatePropagation(),this.collapse(t)),e.code=="ArrowRight"&&(e.preventDefault(),e.stopImmediatePropagation(),this.expand(t)),e.code=="Enter"&&(e.preventDefault(),e.stopImmediatePropagation(),t.parentElement?.querySelector(".title")&&this.startEditing(t.parentElement?.querySelector(".title"))),e.code=="Delete"||e.code=="Backspace"){const i=this.viewElement.querySelector(".info.selected"),s=i?.dataset.path;if(!s)return;const n=i.parentElement.classList.contains("folder");Re.getStandardHandler()[n?"removeDirectory":"removeFile"](s).then(()=>{const a=this.getElement(s);a&&(a.parentElement?.remove(),this.viewElement.querySelector(".delete").disabled=!0,this.viewElement.querySelector(".rename").disabled=!0)})}}startDragging(e){const t=e;t.totalMovementX=0,t.totalMovementY=0,this.draggedElement=t;const i=()=>{this.stopDragging(),window.removeEventListener("mouseup",i)};window.addEventListener("mouseup",i)}handleDragEvent(e){if(this.draggedElement){if(this.draggedElement.totalMovementX+=e.movementX,this.draggedElement.totalMovementY+=e.movementY,!this.draggedCopy)if(Math.abs(this.draggedElement.totalMovementX)+Math.abs(this.draggedElement.totalMovementY)>8){this.viewElement.addEventListener("mousemove",this.mouseHandler),this.draggedCopy=this.draggedElement.parentElement.cloneNode(!0),this.draggedCopy.style.position="fixed";const t=this.draggedElement.getBoundingClientRect();this.draggedCopy.style.top=t.top+this.draggedElement.totalMovementY+"px",this.draggedCopy.style.left=t.left+this.draggedElement.totalMovementX+"px",this.draggedCopy.style.width=t.width+"px",this.draggedCopy.style.boxShadow="3px 3px 3px #222",this.draggedCopy.querySelector(".children")&&this.draggedCopy.removeChild(this.draggedCopy.querySelector(".children")),this.viewElement.appendChild(this.draggedCopy)}else return;this.draggedCopy.style.top=parseFloat(this.draggedCopy.style.top.slice(0,-2))+e.movementY+"px",this.draggedCopy.style.left=parseFloat(this.draggedCopy.style.left.slice(0,-2))+e.movementX+"px"}}async stopDragging(){if(this.draggedCopy){this.draggedCopy.remove(),this.viewElement.removeEventListener("mousemove",this.mouseHandler);const e=this.draggedCopy.classList.contains("folder"),t=this.draggedElement.dataset.path,i=this.fileDropPath==""?Zi(this.draggedElement.dataset.path):this.fileDropPath+"/"+Zi(this.draggedElement.dataset.path);t!=i&&await Re.getStandardHandler()[e?"renameDirectory":"renameFile"](t,i),await this.refreshDirectory(jt(t)),await this.refreshDirectory(jt(i)),this.viewElement.querySelector(".outlined")?.classList.remove("outlined"),this.fileDropPath=""}this.draggedCopy=void 0,this.draggedElement=void 0}handleDropEvent(e){e.preventDefault(),e.stopImmediatePropagation(),this.viewElement.querySelector(".outlined")?.classList.remove("outlined"),e.target.closest(".dir-selector")&&Re.getStandardHandler().handleDropEvent(e,this.fileDropPath).then(async t=>{await this.refreshDirectory(this.fileDropPath),this.getAcceptableFile(t??this.fileDropPath).then(i=>this.selectPath(i)),this.fileDropPath=""})}handleMouseEvent(e){const t=this.viewElement.querySelector(".dir-selector");let i=Array.from(t.querySelectorAll("div.item.folder"));const s=this.viewElement.querySelector(".outlined");i=i.filter(n=>!n.parentElement.closest(".collapsed")),i.reverse(),i.push(t);for(const n of i){const a=n.getBoundingClientRect();if(e.clientX>=a.x&&e.clientX<=a.x+a.width&&e.clientY>=a.y&&e.clientY<=a.y+a.height){s!=n&&s?.classList.remove("outlined");const o=n.querySelector(".info");this.fileDropPath=o?.dataset.path??"",n.classList.contains("dir-selector")&&(this.fileDropPath=""),n.classList.add("outlined");return}}this.viewElement.querySelector(".outlined")?.classList.remove("outlined"),this.fileDropPath=""}escapeSelector(e){return e.replaceAll(/'/g,"\\'")}}class ht{items=[];itemIndex=0;limit=0;app;static instance;constructor(e){this.app=e,ht.instance||(ht.instance=this)}run(e){e.action(this.app),this.items.splice(this.itemIndex,this.items.length-this.itemIndex,e),this.itemIndex++}undo(){this.items[this.itemIndex-1]&&(this.items[this.itemIndex-1].undo(this.app),this.itemIndex--,$.emit("undo"))}redo(){this.items[this.itemIndex]&&(this.items[this.itemIndex].redo?this.items[this.itemIndex].redo(this.app):this.items[this.itemIndex].action(this.app),this.itemIndex++,$.emit("redo"))}reset(){this.itemIndex=0,this.items=[]}canUndo(){return this.itemIndex>0}canRedo(){return this.itemIndex!=this.items.length}setLimit(){this.limit=this.itemIndex}isDirty(){return this.itemIndex!=this.limit}}function bg(){const r=document.createElement("div");return r.spellcheck=!1,r.contentEditable="true",r.classList.add("inlineEdit"),r.onkeydown=e=>{e.key=="Enter"&&r.blur()},r}function eo(r,e){return{title:r,element:t=>{const i=bg();return i.onblur=()=>{const s=t[e];ht.instance.run({action:()=>{t[e]=i.innerText},undo:()=>{t[e]=s}}),i.scrollLeft=0},i.innerText=t[e],i}}}const NE={name:eo("Name","chartName"),credit:eo("Artist","credit"),style:eo("Style","chartStyle"),description:eo("Description","description"),music:{title:"Music File",element:(r,e)=>{const t=document.createElement("div");t.classList.add("flex-row","flex-column-gap","flex-static","hide-buttons");const i=()=>{if(s.innerText==(r.music??e.chartManager.loadedSM.properties.MUSIC??""))return;const c=e.chartManager.chartAudio.isPlaying();if(s.innerText==""||s.innerText==e.chartManager.loadedSM.properties.MUSIC){r.music=void 0,s.innerText=e.chartManager.loadedSM.properties.MUSIC+"",e.chartManager.loadAudio(),c&&e.chartManager.chartAudio.play();return}const u=r.music;ht.instance.run({action:()=>r.music=s.innerText==e.chartManager.loadedSM.properties.MUSIC?void 0:s.innerText,undo:()=>r.music=u}),e.chartManager.loadAudio(),c&&e.chartManager.chartAudio.play()},s=bg();s.style.flex="1",s.onblur=i,s.innerText=r.music??e.chartManager.loadedSM.properties.MUSIC??"";const n=document.createElement("button");n.onclick=()=>{const c=e.chartManager.smPath.split("/").slice(0,-1).join("/");if(window.nw){const u=document.createElement("input");u.type="file",u.accept="audio/*",u.onchange=()=>{s.innerText=Re.getRelativePath(c,u.value),i()},u.click()}else e.windowManager.openWindow(new ml(e,{title:"Select an audio file...",accepted_file_types:ol,disableClose:!0,callback:u=>{s.innerText=Re.getRelativePath(c,u),i()}},c+"/"+(r.music??e.chartManager.loadedSM.properties.MUSIC??"")))};const a=document.createElement("img");a.classList.add("icon"),a.style.height="12px",a.src=He.SELECT_FILE,n.appendChild(a);const o=document.createElement("button");o.onclick=()=>{s.innerText!=(e.chartManager.loadedSM.properties.MUSIC??"")&&(s.innerText=e.chartManager.loadedSM.properties.MUSIC??"",i())};const l=document.createElement("img");return l.classList.add("icon"),l.style.height="12px",l.src=He.REVERT,o.appendChild(l),t.appendChild(s),t.appendChild(n),t.appendChild(o),t}}};class pi{view;items=[];selectedItem;onChangeHandlers=[];static create(e,t){return new pi(document.createElement("div"),e,t)}constructor(e,t,i){this.view=e,e.classList.add("dropdown"),this.items=t??[],this.selectedItem=i??this.items[0];const s=document.createElement("div");s.classList.add("dropdown-selected");const n=document.createElement("div");n.classList.add("dropdown-items"),n.style.height="",s.onclick=()=>{if(!s.classList.contains("disabled")){if(this.items.length==0){n.style.height="";return}this.createDropdown(),n.style.height==""?(n.style.width=Math.max(n.scrollWidth,s.clientWidth)+"px",n.style.height=n.scrollHeight+"px",Array.from(n.children).forEach((a,o)=>{a.style.animationDelay=o*.02+"s"})):n.style.height=""}},window.addEventListener("click",a=>{const o=a.target;(!o.closest(".dropdown")||o.closest(".dropdown")!=e)&&(n.style.height="")}),this.view.appendChild(s),this.view.appendChild(n),this.setSelected()}onChange(e){this.onChangeHandlers.push(e)}removeHandler(e){this.onChangeHandlers.includes(e)&&this.onChangeHandlers.splice(this.onChangeHandlers.indexOf(e),1)}getItems(){return this.items}setItems(e){this.items=e,e.includes(this.selectedItem)||(this.selectedItem=this.items[0],this.setSelected())}setSelected(e){this.selectedItem=e??this.selectedItem;const t=this.view.querySelector(".dropdown-selected");t.innerText=this.selectedItem?this.selectedItem+"":""}closeDropdown(){const e=this.view.querySelector(".dropdown-items");e&&(e.style.height="")}get value(){return this.selectedItem}get disabled(){return this.view.querySelector(".dropdown-selected").classList.contains("disabled")}set disabled(e){e?this.view.querySelector(".dropdown-selected").classList.add("disabled"):this.view.querySelector(".dropdown-selected").classList.remove("disabled")}createDropdown(){const e=this.view.querySelector(".dropdown-items"),t=this.items.map((i,s)=>{const n=document.createElement("div");return n.classList.add("dropdown-item"),n.innerText=i+"",n.onclick=()=>{e.style.height="",this.selectedItem!=i&&(this.setSelected(i),this.onChangeHandlers.forEach(a=>a(i,s)))},n});e.replaceChildren(...t)}}class fd extends Pt{app;buttonOptions;message;resolve;resolved=new Promise(e=>this.resolve=e);constructor(e,t,i,s){super({title:t,width:300,height:100,disableClose:!0,win_id:"confirm",blocking:!0}),this.app=e,this.message=i,this.buttonOptions=s,this.initView()}initView(){this.viewElement.replaceChildren(),this.viewElement.classList.add("confirmation");const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("label"),t.innerText=this.message,e.appendChild(t);const i=document.createElement("div");i.classList.add("menu-options"),this.buttonOptions.forEach(s=>{const n=document.createElement("button");n.innerText=s.label,n.onclick=()=>{s.callback?.(),this.resolve?.(s.label),this.closeWindow()},s.type!="default"&&n.classList.add(s.type),i.append(n)}),e.appendChild(i),this.viewElement.appendChild(e)}}class Ag extends Pt{app;gameType;chartList;chartInfo;gameTypeDropdown;smLoadHandler=()=>{this.gameTypeDropdown.setItems(Ke.getPriority().map(e=>{const t=this.app.chartManager.loadedSM?.charts[e.id]??[];return e.id+" ("+t.length+")"})),this.gameTypeDropdown.setSelected(this.gameType.id+" ("+(this.app.chartManager.loadedSM?.charts[this.gameType.id]??[]).length+") "),this.gameType=this.app.chartManager.loadedChart?.gameType??this.gameType,this.loadCharts()};constructor(e,t){super({title:"Chart List",width:500,height:400,win_id:"chart_list"}),this.app=e,this.gameType=t??e.chartManager.loadedChart?.gameType??Ke.getPriority()[0],this.initView(),$.on("smLoadedAfter",this.smLoadHandler)}initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("chart-view-type-wrapper");const i=document.createElement("div");i.classList.add("chart-view-type-label"),i.innerText="Game Type:",this.gameTypeDropdown=pi.create(Ke.getPriority().map(n=>{const a=this.app.chartManager.loadedSM?.charts[n.id]??[];return n.id+" ("+a.length+")"}),this.gameType.id+" ("+(this.app.chartManager.loadedSM?.charts[this.gameType.id]??[]).length+") "),this.gameTypeDropdown.onChange(n=>{this.gameType=Ke.getGameType(n.split(" ")[0])??this.gameType,this.loadCharts()}),t.appendChild(i),t.appendChild(this.gameTypeDropdown.view);const s=document.createElement("div");s.classList.add("chart-view-scroller"),e.appendChild(t),e.appendChild(s),this.chartList=document.createElement("div"),this.chartList.classList.add("chart-list"),this.chartInfo=document.createElement("div"),this.chartInfo.classList.add("chart-info"),s.appendChild(this.chartList),s.appendChild(this.chartInfo),this.viewElement.appendChild(e),this.loadCharts()}onClose(){$.off("smLoadedAfter",this.smLoadHandler)}loadCharts(){const e=this.app.chartManager.loadedSM?.charts[this.gameType.id]??[],t=[];this.gameTypeDropdown.setItems(Ke.getPriority().map(a=>{const o=this.app.chartManager.loadedSM?.charts[a.id]??[];return a.id+" ("+o.length+")"})),this.gameTypeDropdown.setSelected(this.gameType.id+" ("+(this.app.chartManager.loadedSM?.charts[this.gameType.id]??[]).length+") "),e.forEach(a=>{const o=document.createElement("div");o.classList.add("chart-list-item"),o.chart=a,this.app.chartManager.loadedChart==a&&o.classList.add("selected"),o.onclick=()=>{o.chart!=this.app.chartManager.loadedChart&&(this.app.chartManager.loadChart(o.chart),this.chartList.querySelectorAll(".selected").forEach(d=>d.classList.remove("selected")),o.classList.add("selected"))},o.onmouseenter=()=>{this.loadChartDetails(o.chart)},o.onmouseleave=()=>{this.loadChartDetails()};const l=document.createElement("div");l.innerText=a.meter+"",l.classList.add("title",a.difficulty);const c=document.createElement("div");c.classList.add("chart-list-info");const u=document.createElement("div");u.innerText=a.credit,u.classList.add("title","chart-credit");const h=document.createElement("div");h.innerText=a.getNotedata().length+"",h.classList.add("title","chart-step-count"),c.appendChild(u),c.appendChild(h),o.appendChild(l),o.appendChild(c),t.push(o)});const i=document.createElement("div");i.classList.add("chart-list-item");const s=document.createElement("div");s.innerText="+",s.classList.add("title");const n=document.createElement("div");n.classList.add("chart-list-info"),n.innerText="New Blank Chart",i.appendChild(s),i.appendChild(n),i.onclick=()=>{const a=new mg(this.app.chartManager.loadedSM);a.gameType=this.gameType,this.app.chartManager.loadedSM.addChart(a),this.app.chartManager.loadChart(a),this.loadCharts()},this.chartList.replaceChildren(...t,i),this.loadChartDetails()}loadChartDetails(e){if(e=e??this.app.chartManager.loadedChart,e?.gameType.id!=this.gameType.id){this.chartInfo.replaceChildren();return}if(!e)return;const t=()=>this.app.chartManager.loadedSM.charts[e.gameType.id].sort((m,g)=>xi.indexOf(m.difficulty)==xi.indexOf(g.difficulty)?m.meter-g.meter:xi.indexOf(m.difficulty)-xi.indexOf(g.difficulty)),i=document.createElement("div");i.classList.add("chart-info-main");const s=pi.create(xi,e.difficulty);s.view.classList.add("no-border","white"),s.onChange(m=>{const g=e.difficulty;ht.instance.run({action:()=>{e.difficulty=m,t(),this.loadCharts()},undo:()=>{e.difficulty=g,t(),this.loadCharts()}})});const n=document.createElement("div");n.spellcheck=!1,n.contentEditable="true",n.classList.add("inlineEdit","chart-meter"),n.onkeydown=m=>{m.key=="Enter"&&n.blur()},n.onblur=()=>{let m=gn(n.innerText);if(m===null){n.innerText=e?.meter+"";return}m=Math.round(Ve(1,m,2**31-1));const g=e.meter;ht.instance.run({action:()=>{e.meter=m,e.meterF=m,t(),this.loadCharts()},undo:()=>{e.meter=g,e.meterF=g,t(),this.loadCharts()}}),n.scrollLeft=0},n.innerText=e.meter+"";const a=document.createElement("div");a.classList.add("chart-properties"),i.appendChild(s.view),i.appendChild(n),Object.values(NE).forEach(m=>{const g=document.createElement("div");g.classList.add("label"),g.innerText=m.title;const y=m.element(e,this.app);m.title=="Artist"&&y.addEventListener("blur",()=>this.loadCharts()),a.appendChild(g),a.appendChild(y)});const o=e.getNotedataStats(),l=document.createElement("div");l.classList.add("chart-info-grid-item");const c=document.createElement("div");c.innerText="Peak NPS",c.classList.add("title","chart-info-grid-label");const u=document.createElement("div");u.innerText=e.getMaxNPS().toFixed(2)+"",u.classList.add("title","chart-info-grid-count"),l.appendChild(c),l.appendChild(u);const h=document.createElement("div");h.classList.add("chart-info-grid"),Object.entries(o).forEach(m=>{const g=document.createElement("div");g.classList.add("chart-info-grid-item");const y=document.createElement("div");y.innerText=m[0],y.classList.add("title","chart-info-grid-label");const b=document.createElement("div");b.innerText=m[1]+"",b.classList.add("title","chart-info-grid-count"),g.appendChild(y),g.appendChild(b),h.appendChild(g)});const d=document.createElement("div");d.classList.add("menu-options");const p=document.createElement("button");p.innerText="Duplicate Chart",p.onclick=()=>{const m=Object.assign(Object.create(Object.getPrototypeOf(e)),e);m.setNotedata(e.getNotedata().map(g=>e.computeNote(g))??[]),this.app.chartManager.loadedSM.addChart(m),this.app.chartManager.loadChart(m),this.loadCharts()},d.append(p);const f=document.createElement("button");f.innerText="Delete Chart",f.onclick=()=>{this.app.windowManager.openWindow(new fd(this.app,"Delete chart","Are you sure you want to delete this chart?",[{type:"default",label:"Cancel"},{type:"delete",label:"Delete",callback:()=>{this.app.chartManager.loadedSM.removeChart(e)&&(this.app.chartManager.loadChart(),this.gameType=this.app.chartManager.loadedChart?.gameType??this.gameType,this.loadCharts())}}]))},f.classList.add("delete"),d.append(f),this.chartInfo.replaceChildren(i,a,l,h,d)}}const UE="/smeditor/assets/highpass-d9d7cfcb.svg",GE="/smeditor/assets/highshelf-11ccf64e.svg",HE="/smeditor/assets/lowpass-ff013247.svg",WE="/smeditor/assets/lowshelf-2b031328.svg",VE="/smeditor/assets/peaking-eec48769.svg";var zE=4,jE=.001,YE=1e-7,XE=10,Wn=11,to=1/(Wn-1),KE=typeof Float32Array=="function";function wg(r,e){return 1-3*e+3*r}function xg(r,e){return 3*e-6*r}function _g(r){return 3*r}function Vo(r,e,t){return((wg(e,t)*r+xg(e,t))*r+_g(e))*r}function Eg(r,e,t){return 3*wg(e,t)*r*r+2*xg(e,t)*r+_g(e)}function qE(r,e,t,i,s){var n,a,o=0;do a=e+(t-e)/2,n=Vo(a,i,s)-r,n>0?t=a:e=a;while(Math.abs(n)>YE&&++o=jE?QE(l,p,e,i):f===0?p:qE(l,c,c+to,e,i)}return function(c){return c===0?0:c===1?1:Vo(o(c),t,s)}};const Yt=da(JE),ZE=Yt(0,0,1,1);function Dp(r,e){const t=e?e.split("."):[];for(;t.length&&r;){const i=t.shift(),s=new RegExp("(.+)\\[([0-9]*)\\]").exec(i);if(s!==null&&s.length==3){const n={arrName:s[1],arrIndex:s[2]};r[n.arrName]!==void 0?r=r[n.arrName][n.arrIndex]:r=void 0;continue}r=r[i]}return r}function eT(r,e,t){const i=e?e.split("."):[];for(;i.length&&r;){const s=i.shift(),n=new RegExp("(.+)\\[([0-9]*)\\]").exec(s);if(n!==null&&n.length==3){const a={arrName:n[1],arrIndex:n[2]};r[a.arrName]!==void 0&&i.length===0&&(r[a.arrName][a.arrIndex]=t);continue}r[s]===void 0&&(r[s]={}),i.length===0&&(r[s]=t),r=r[s]}return r}const _r=class _r{static updateObject(e,t,i){const s=Object.keys(t).sort((o,l)=>parseFloat(o)-parseFloat(l));let n="0";for(let o=s.length-2;o>=0;o--)if(parseFloat(s[o])<=i){n=s[o];break}let a="1";for(let o=1;oi){a=s[o];break}Object.keys(t[0]).forEach(o=>{let l=t[n][o],c=t[a][o];l==="inherit"&&(t[n][o]=Dp(e,o),l=t[n][o]),c==="inherit"&&(t[a][o]=Dp(e,o),c=t[a][o]);const u=l+(i-parseFloat(n))/(parseFloat(a)-parseFloat(n))*(c-l);eT(e,o,u)})}static stop(e,t=null){e!==void 0&&(t!==null&&this.animations.get(e)?.obj&&!this.animations.get(e).obj.destroyed&&this.updateObject(this.animations.get(e).obj,this.animations.get(e).animation,t),this.animations.delete(e))}static animate(e,t,i,s,n=()=>{},a){return a||=`${++this._id}`,this.animations.set(a,{obj:e,animation:t,speed:1/(60*i),progress:0,curve:s!==void 0?s:ZE,onend:n}),a}};Ms(_r,"animations",new Map),Ms(_r,"_id",0),Ft.shared.add(e=>{for(const[t,i]of _r.animations.entries())i.obj._destroyed?_r.stop(t):(i.progress=Math.min(1,i.progress+i.speed*e),_r.updateObject(i.obj,i.animation,i.curve(i.progress)),i.progress>=1&&(i.onend(i.obj),_r.stop(t,1)))});let It=_r;const mh=[{frequency:20,Q:.71},{frequency:75,gain:0},{frequency:100,gain:0,Q:.6},{frequency:250,gain:0,Q:.3},{frequency:1040,gain:0,Q:.41},{frequency:2500,gain:0,Q:.2},{frequency:7500,gain:0},{frequency:2e4,Q:.71}],Lp=[{freq:20,label:"20"},{freq:30,label:"30"},{freq:40,label:"40"},{freq:50,label:"50"},{freq:60,label:"60"},{freq:70,label:""},{freq:80,label:"80"},{freq:90,label:""},{freq:100,label:"100"},{freq:200,label:"200"},{freq:300,label:"300"},{freq:400,label:"400"},{freq:500,label:"500"},{freq:600,label:"600"},{freq:700,label:""},{freq:800,label:"800"},{freq:900,label:""},{freq:1e3,label:"1k"},{freq:2e3,label:"2k"},{freq:3e3,label:"3k"},{freq:4e3,label:"4k"},{freq:5e3,label:"5k"},{freq:6e3,label:"6k"},{freq:7e3,label:""},{freq:8e3,label:"8k"},{freq:9e3,label:""},{freq:1e4,label:"10k"},{freq:15e3,label:""},{freq:2e4,label:"20k"}],js=0,Ys=0,gs=1200,_t=400,zo=new Array(gs).fill(0).map((r,e)=>md(e)),tT=new Float32Array(zo);function jo(r){return Math.log(r/20)/Math.log(1102.5)*gs}function md(r){return Math.pow(1102.5,r/gs)*20}function as(r){return-r*6+_t/2}function Op(r){return-(r-_t/2)/6}class iT extends Pt{app;cachedReponse=new Array(gs).fill(0);onAudioLoad=this.onAudio.bind(this);points=[];icons;info;trackedFilter=null;constructor(e){super({title:"Audio Equalizer",width:600,height:245,win_id:"audio-eq"}),this.app=e,this.initView(),this.onAudioLoad(),$.on("audioLoaded",this.onAudioLoad)}destroy(){$.off("audioLoaded",this.onAudioLoad)}initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("eq-container");const t=document.createElement("div");t.classList.add("icon-container"),this.app.chartManager.chartAudio.getFilters().forEach((A,v)=>{const E=document.createElementNS("http://www.w3.org/2000/svg","svg");fetch(new URL(Object.assign({"../../../assets/svg/highpass.svg":UE,"../../../assets/svg/highshelf.svg":GE,"../../../assets/svg/lowpass.svg":HE,"../../../assets/svg/lowshelf.svg":WE,"../../../assets/svg/peaking.svg":VE})[`../../../assets/svg/${A.type}.svg`],self.location).href).then(C=>C.text()).then(C=>{const k=new DOMParser().parseFromString(C,"image/svg+xml").getElementsByTagName("svg")[0];for(const{name:N,value:H}of k.attributes)E.getAttribute(N)||E.setAttribute(N,H);E.replaceChildren(...k.children)}),E.setAttribute("fill",is[v]),E.classList.add("eq-icon"),E.style.backgroundColor=`${is[v]}40`,E.setAttribute("width","36px"),E.setAttribute("height","24px"),E.onclick=()=>{this.app.chartManager.chartAudio.getFilter(v).enabled?this.app.chartManager.chartAudio.disableFilter(v):this.app.chartManager.chartAudio.enableFilter(v),this.endTrack(),this.updateIcons()},E.onmouseenter=()=>this.points[v].highlight(),E.onmouseleave=()=>this.points[v].unhighlight(),t.appendChild(E)}),this.icons=t,this.updateIcons();const i=document.createElement("canvas");i.style.width="600px",i.style.height="200px",i.onmousedown=A=>{const v=this.points.filter(E=>E.hitTest(A.offsetX*2,A.offsetY*2)).at(-1);this.endTrack(),v?.mouseDown(A)};const s=document.createElement("div");s.classList.add("eq-info-container");const n=document.createElement("div");n.classList.add("eq-info");const a=document.createElement("div");a.innerText="Type",a.classList.add("eq-info-label");const o=document.createElement("div");o.classList.add("eq-info-value"),n.replaceChildren(a,o);const l=document.createElement("div");l.classList.add("eq-info");const c=document.createElement("div");c.innerText="Frequency",c.classList.add("eq-info-label");const u=document.createElement("div");u.contentEditable="false",u.classList.add("eq-info-value","inlineEdit"),l.replaceChildren(c,u),this.setupInput(u,"frequency",20,22050," Hz");const h=document.createElement("div");h.classList.add("eq-info");const d=document.createElement("div");d.innerText="Gain",d.classList.add("eq-info-label");const p=document.createElement("div");p.contentEditable="false",p.classList.add("eq-info-value","inlineEdit"),h.replaceChildren(d,p),this.setupInput(p,"gain",-24,24," dB",1);const f=document.createElement("div");f.classList.add("eq-info");const m=document.createElement("div");m.innerText="Q",m.classList.add("eq-info-label");const g=document.createElement("div");g.contentEditable="false",g.classList.add("eq-info-value","inlineEdit"),f.replaceChildren(m,g),this.setupInput(g,"Q",1e-4,1e3,"",4);const y=document.createElement("div");y.classList.add("eq-reset","disabled"),y.innerText="Reset",y.onclick=()=>{if(this.trackedFilter==null)for(let A=0;A{o=this.app.chartManager.chartAudio.getFilter(this.trackedFilter)[t].value,e.innerText=ne(o,a)+"",this.selectText(e)},e.onkeydown=l=>{if(l.key=="Enter"){e.blur();return}if(l.key=="Tab"){const u=[...e.parentElement.parentElement.children],h=u.indexOf(e.parentElement);for(let d=1;d{const c=gn(e.innerText);c!==null&&(this.app.chartManager.chartAudio.updateFilter(this.trackedFilter,{[t]:Ve(c,i,s)}),this.points[this.trackedFilter].refreshPoint(),this.getResponse())})},e.onblur=()=>{gn(e.innerText)===null&&(this.app.chartManager.chartAudio.updateFilter(this.trackedFilter,{[t]:Ve(o,i,s)}),this.points[this.trackedFilter].refreshPoint(),this.getResponse()),e.innerText=ne(this.app.chartManager.chartAudio.getFilter(this.trackedFilter)[t].value,a)+n}}onAudio(){this.points=this.app.chartManager.chartAudio.getFilters().map((e,t)=>new rT(this,t)),this.getResponse(),this.updateIcons(),this.endTrack()}getResponse(){this.cachedReponse=this.app.chartManager.chartAudio.getFrequencyResponse(zo)}drawEQ(e){const t=e.getContext("2d");t.canvas.width=1200,t.canvas.height=400;const i=()=>{this.app.chartManager.chartAudio&&(t.fillStyle="rgb(11, 14, 26)",t.fillRect(0,0,e.width,e.height),t.fillStyle="rgb(0, 50, 150)",this.drawFrequencies(t,this.app.chartManager.chartAudio.getFrequencyData()),this.app.chartManager.chartAudio.hasFilters()&&(t.fillStyle="rgba(200, 200, 200, 0.2)",this.drawFrequencies(t,this.app.chartManager.chartAudio.getFilteredFrequencyData())),t.fillStyle="rgba(200, 200, 200, 0.5)",this.drawResponse(t),t.fillStyle="rgba(0, 100, 150, 0.5)",t.font="22px Assistant",this.drawGrid(t),this.points.forEach(s=>s.draw(t)),e.closest("#windows")&&requestAnimationFrame(i))};return i}drawFrequencies(e,t){for(let i=0;i{this.app.chartManager.chartAudio.getFilter(t).enabled?e.classList.remove("disabled"):e.classList.add("disabled")}),this.getResponse()}trackFilter(e){this.trackedFilter=e;const t=this.app.chartManager.chartAudio.getFilter(e),[i,s,n,a]=[...this.info.children].map(o=>o.children[1]);i.innerText=t.type,s.innerText=Math.round(t.frequency.value)+" Hz",n.innerText=t.type.endsWith("pass")?"-":ne(t.gain.value,1)+" dB",a.innerText=t.type.endsWith("shelf")?"-":ne(t.Q.value,2)+"",i.style.color=is[e],s.style.color=is[e],n.style.color=is[e],a.style.color=is[e],s.contentEditable="true",n.contentEditable=`${!t.type.endsWith("pass")}`,a.contentEditable=`${!t.type.endsWith("shelf")}`}endTrack(){setTimeout(()=>{this.trackedFilter=null,this.points.forEach(n=>n.unhighlight());const[e,t,i,s]=[...this.info.children].map(n=>n.children[1]);e.innerText="",t.innerText="",i.innerText="",s.innerText="",t.contentEditable="false",i.contentEditable="false",s.contentEditable="false"})}}const io=16,is=["#a3001b","#a34f00","#d6d606","#19c402","#02c4ba","#022fc4","#5602c4","#c402b4"];class rT{filterIndex;window;dragging=!1;x=0;y=0;type;response=new Float32Array(zo.length);_empty=new Float32Array(zo.length);highlighted=!1;pointSize=.4;constructor(e,t){this.filterIndex=t,this.window=e,this.type=this.window.app.chartManager.chartAudio.getFilter(t).type,this.x=jo(this.window.app.chartManager.chartAudio.getFilter(t).frequency.value??10),this.getY()}hitTest(e,t){return(e-this.x)*(e-this.x)+(t-this.y)*(t-this.y)<=io*io}canChangeGain(){return this.type=="lowshelf"||this.type=="highshelf"||this.type=="peaking"}canChangeQ(){return!this.type.endsWith("shelf")}getY(){this.type.endsWith("shelf")?this.y=as(this.window.app.chartManager.chartAudio.getFilter(this.filterIndex).gain.value/2):this.canChangeGain()?this.y=as(this.window.app.chartManager.chartAudio.getFilter(this.filterIndex).gain.value??0):this.y=_t/2}getGain(){if(this.canChangeGain())return this.type.endsWith("shelf")?Op(this.y)*2:Op(this.y)}mouseDown(e){this.calcResponse(),this.dragging=!0,this.highlighted=!0,this.window.app.chartManager.chartAudio.getFilter(this.filterIndex).enabled||(this.window.app.chartManager.chartAudio.enableFilter(this.filterIndex),this.window.updateIcons());const t=this.x,i=this.y,s=e.clientX,n=e.clientY,a=l=>{this.x=(l.clientX-s)*2+t,this.canChangeGain()?this.y=(l.clientY-n)*2+i:this.y=_t/2,this.x=Ve(this.x,0,gs),this.y=Ve(this.y,this.type.endsWith("shelf")?_t/4:as(24),this.type.endsWith("shelf")?3*_t/4:as(-24)),this.window.app.chartManager.chartAudio.updateFilter(this.filterIndex,{frequency:md(this.x),gain:this.getGain()}),this.window.getResponse(),this.window.trackFilter(this.filterIndex),this.calcResponse()};this.window.trackFilter(this.filterIndex);const o=()=>{It.animate(this,{0:{pointSize:"inherit"},1:{pointSize:.3}},.3,Yt(.11,.71,.41,.86),()=>{},`eq-point${this.filterIndex}`),this.dragging=!1,window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",o)};It.animate(this,{0:{pointSize:"inherit"},1:{pointSize:.9}},.3,Yt(.11,.71,.41,.86),()=>{},`eq-point${this.filterIndex}`),window.addEventListener("mousemove",a),window.addEventListener("mouseup",o)}calcResponse(){this.window.app.chartManager.chartAudio.getFilter(this.filterIndex).getFrequencyResponse(tT,this.response,this._empty)}draw(e){const t=this.highlighted||this.window.app.chartManager.chartAudio.getFilter(this.filterIndex).enabled?is[this.filterIndex]:"#888888";if(e.fillStyle=t+"60",this.dragging)for(let i=0;i{navigator.clipboard.writeText(s.innerText)}),this.outputDiv=s;const n=document.createElement("div");n.classList.add("export-section-label"),n.innerText="Include",i.appendChild(n),Object.keys(this.exportOptions.include).forEach(o=>{const l=document.createElement("input");l.type="checkbox",l.checked=this.exportOptions.include[o],l.onchange=()=>{this.exportOptions.include[o]=l.checked,this.export()};const c=document.createElement("div");c.classList.add("export-label"),c.innerText=o;const u=document.createElement("div");u.replaceChildren(l,c),u.classList.add("export-option"),i.appendChild(u)});const a=document.createElement("div");a.classList.add("export-section-label"),a.innerText="Options",i.appendChild(a),Object.keys(this.exportOptions.options).forEach(o=>{const l=document.createElement("input");l.type="checkbox",l.checked=this.exportOptions.options[o],l.onchange=()=>{this.exportOptions.options[o]=l.checked,this.export()};const c=document.createElement("div");c.classList.add("export-label"),c.innerText=sT[o];const u=document.createElement("div");u.replaceChildren(l,c),u.classList.add("export-option"),i.appendChild(u)}),t.replaceChildren(i,s),e.appendChild(t),this.viewElement.appendChild(e)}export(){let e=`{ +\0`,Q+=n(D,2),Q+=C.magic,Q+=n(A,2),Q+=n(v,2),Q+=n(G.crc32,4),Q+=n(G.compressedSize,4),Q+=n(G.uncompressedSize,4),Q+=n(P.length,2),Q+=n(F.length,2),{fileRecord:h.LOCAL_FILE_HEADER+Q+P+F,dirRecord:h.CENTRAL_FILE_HEADER+n(ee,2)+Q+n(H.length,2)+"\0\0\0\0"+n(O,4)+n(g,4)+P+F+H}}var o=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),u=t("../crc32"),h=t("../signature");function d(p,f,m,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=f,this.zipPlatform=m,this.encodeFileName=g,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(d,l),d.prototype.push=function(p){var f=p.meta.percent||0,m=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,l.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:m?(f+100*(m-g-1))/m:100}}))},d.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var f=this.streamFiles&&!p.file.dir;if(f){var m=a(p,f,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},d.prototype.closedSource=function(p){this.accumulate=!1;var f=this.streamFiles&&!p.file.dir,m=a(p,f,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),f)this.push({data:function(g){return h.DATA_DESCRIPTOR+n(g.crc32,4)+n(g.compressedSize,4)+n(g.uncompressedSize,4)}(p),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},d.prototype.flush=function(){for(var p=this.bytesWritten,f=0;f=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=o,c},readString:function(o){return n.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},i.exports=a},{"../utils":32}],19:[function(t,i,s){var n=t("./Uint8ArrayReader");function a(o){n.call(this,o)}t("../utils").inherits(a,n),a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,i,s){var n=t("./DataReader");function a(o){n.call(this,o)}t("../utils").inherits(a,n),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./DataReader":18}],21:[function(t,i,s){var n=t("./ArrayReader");function a(o){n.call(this,o)}t("../utils").inherits(a,n),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(t,i,s){var n=t("../utils"),a=t("../support"),o=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),u=t("./Uint8ArrayReader");i.exports=function(h){var d=n.getTypeOf(h);return n.checkSupport(d),d!=="string"||a.uint8array?d==="nodebuffer"?new c(h):a.uint8array?new u(n.transformTo("uint8array",h)):new o(n.transformTo("array",h)):new l(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,i,s){s.LOCAL_FILE_HEADER="PK",s.CENTRAL_FILE_HEADER="PK",s.CENTRAL_DIRECTORY_END="PK",s.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",s.ZIP64_CENTRAL_DIRECTORY_END="PK",s.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,i,s){var n=t("./GenericWorker"),a=t("../utils");function o(l){n.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,n),o.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},i.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(t,i,s){var n=t("./GenericWorker"),a=t("../crc32");function o(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(o,n),o.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,i,s){var n=t("../utils"),a=t("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}n.inherits(o,a),o.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}a.prototype.processChunk.call(this,l)},i.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(t,i,s){var n=t("../utils"),a=t("./GenericWorker");function o(l){a.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=n.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}n.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(t,i,s){function n(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var l=0;l "+a:a}},i.exports=n},{}],29:[function(t,i,s){var n=t("../utils"),a=t("./ConvertWorker"),o=t("./GenericWorker"),l=t("../base64"),c=t("../support"),u=t("../external"),h=null;if(c.nodestream)try{h=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function d(f,m){return new u.Promise(function(g,y){var b=[],A=f._internalType,v=f._outputType,E=f._mimeType;f.on("data",function(C,M){b.push(C),m&&m(M)}).on("error",function(C){b=[],y(C)}).on("end",function(){try{var C=function(M,P,k){switch(M){case"blob":return n.newBlob(n.transformTo("arraybuffer",P),k);case"base64":return l.encode(P);default:return n.transformTo(M,P)}}(v,function(M,P){var k,N=0,H=null,T=0;for(k=0;k"u")s.blob=!1;else{var n=new ArrayBuffer(0);try{s.blob=new Blob([n],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(n),s.blob=a.getBlob("application/zip").size===0}catch{s.blob=!1}}}try{s.nodestream=!!t("readable-stream").Readable}catch{s.nodestream=!1}},{"readable-stream":16}],31:[function(t,i,s){for(var n=t("./utils"),a=t("./support"),o=t("./nodejsUtils"),l=t("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function h(){l.call(this,"utf-8 decode"),this.leftOver=null}function d(){l.call(this,"utf-8 encode")}s.utf8encode=function(p){return a.nodebuffer?o.newBufferFrom(p,"utf-8"):function(f){var m,g,y,b,A,v=f.length,E=0;for(b=0;b>>6:(g<65536?m[A++]=224|g>>>12:(m[A++]=240|g>>>18,m[A++]=128|g>>>12&63),m[A++]=128|g>>>6&63),m[A++]=128|63&g);return m}(p)},s.utf8decode=function(p){return a.nodebuffer?n.transformTo("nodebuffer",p).toString("utf-8"):function(f){var m,g,y,b,A=f.length,v=new Array(2*A);for(m=g=0;m>10&1023,v[g++]=56320|1023&y)}return v.length!==g&&(v.subarray?v=v.subarray(0,g):v.length=g),n.applyFromCharCode(v)}(p=n.transformTo(a.uint8array?"uint8array":"array",p))},n.inherits(h,l),h.prototype.processChunk=function(p){var f=n.transformTo(a.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var m=f;(f=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),f.set(m,this.leftOver.length)}else f=this.leftOver.concat(f);this.leftOver=null}var g=function(b,A){var v;for((A=A||b.length)>b.length&&(A=b.length),v=A-1;0<=v&&(192&b[v])==128;)v--;return v<0||v===0?A:v+c[b[v]]>A?v:A}(f),y=f;g!==f.length&&(a.uint8array?(y=f.subarray(0,g),this.leftOver=f.subarray(g,f.length)):(y=f.slice(0,g),this.leftOver=f.slice(g,f.length))),this.push({data:s.utf8decode(y),meta:p.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=h,n.inherits(d,l),d.prototype.processChunk=function(p){this.push({data:s.utf8encode(p.data),meta:p.meta})},s.Utf8EncodeWorker=d},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,i,s){var n=t("./support"),a=t("./base64"),o=t("./nodejsUtils"),l=t("./external");function c(m){return m}function u(m,g){for(var y=0;y>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=n(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var f,m,g,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4>>6:(p<65536?d[g++]=224|p>>>12:(d[g++]=240|p>>>18,d[g++]=128|p>>>12&63),d[g++]=128|p>>>6&63),d[g++]=128|63&p);return d},s.buf2binstring=function(h){return u(h,h.length)},s.binstring2buf=function(h){for(var d=new n.Buf8(h.length),p=0,f=d.length;p>10&1023,b[f++]=56320|1023&m)}return u(b,f)},s.utf8border=function(h,d){var p;for((d=d||h.length)>h.length&&(d=h.length),p=d-1;0<=p&&(192&h[p])==128;)p--;return p<0||p===0?d:p+l[h[p]]>d?p:d}},{"./common":41}],43:[function(t,i,s){i.exports=function(n,a,o,l){for(var c=65535&n|0,u=n>>>16&65535|0,h=0;o!==0;){for(o-=h=2e3>>1:a>>>1;o[l]=a}return o}();i.exports=function(a,o,l,c){var u=n,h=c+l;a^=-1;for(var d=c;d>>8^u[255&(a^o[d])];return-1^a}},{}],46:[function(t,i,s){var n,a=t("../utils/common"),o=t("./trees"),l=t("./adler32"),c=t("./crc32"),u=t("./messages"),h=0,d=4,p=0,f=-2,m=-1,g=4,y=2,b=8,A=9,v=286,E=30,C=19,M=2*v+1,P=15,k=3,N=258,H=N+k+1,T=42,S=113,w=1,F=2,z=3,L=4;function te(x,j){return x.msg=u[j],j}function R(x){return(x<<1)-(4x.avail_out&&(V=x.avail_out),V!==0&&(a.arraySet(x.output,j.pending_buf,j.pending_out,V,x.next_out),x.next_out+=V,j.pending_out+=V,x.total_out+=V,x.avail_out-=V,j.pending-=V,j.pending===0&&(j.pending_out=0))}function O(x,j){o._tr_flush_block(x,0<=x.block_start?x.block_start:-1,x.strstart-x.block_start,j),x.block_start=x.strstart,D(x.strm)}function ee(x,j){x.pending_buf[x.pending++]=j}function Q(x,j){x.pending_buf[x.pending++]=j>>>8&255,x.pending_buf[x.pending++]=255&j}function K(x,j){var V,B,I=x.max_chain_length,U=x.strstart,q=x.prev_length,J=x.nice_match,W=x.strstart>x.w_size-H?x.strstart-(x.w_size-H):0,ie=x.window,le=x.w_mask,se=x.prev,Ae=x.strstart+N,je=ie[U+q-1],Pe=ie[U+q];x.prev_length>=x.good_match&&(I>>=2),J>x.lookahead&&(J=x.lookahead);do if(ie[(V=j)+q]===Pe&&ie[V+q-1]===je&&ie[V]===ie[U]&&ie[++V]===ie[U+1]){U+=2,V++;do;while(ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&ie[++U]===ie[++V]&&UW&&--I!=0);return q<=x.lookahead?q:x.lookahead}function ge(x){var j,V,B,I,U,q,J,W,ie,le,se=x.w_size;do{if(I=x.window_size-x.lookahead-x.strstart,x.strstart>=se+(se-H)){for(a.arraySet(x.window,x.window,se,se,0),x.match_start-=se,x.strstart-=se,x.block_start-=se,j=V=x.hash_size;B=x.head[--j],x.head[j]=se<=B?B-se:0,--V;);for(j=V=se;B=x.prev[--j],x.prev[j]=se<=B?B-se:0,--V;);I+=se}if(x.strm.avail_in===0)break;if(q=x.strm,J=x.window,W=x.strstart+x.lookahead,ie=I,le=void 0,le=q.avail_in,ie=k)for(U=x.strstart-x.insert,x.ins_h=x.window[U],x.ins_h=(x.ins_h<=k&&(x.ins_h=(x.ins_h<=k)if(B=o._tr_tally(x,x.strstart-x.match_start,x.match_length-k),x.lookahead-=x.match_length,x.match_length<=x.max_lazy_match&&x.lookahead>=k){for(x.match_length--;x.strstart++,x.ins_h=(x.ins_h<=k&&(x.ins_h=(x.ins_h<=k&&x.match_length<=x.prev_length){for(I=x.strstart+x.lookahead-k,B=o._tr_tally(x,x.strstart-1-x.prev_match,x.prev_length-k),x.lookahead-=x.prev_length-1,x.prev_length-=2;++x.strstart<=I&&(x.ins_h=(x.ins_h<x.pending_buf_size-5&&(V=x.pending_buf_size-5);;){if(x.lookahead<=1){if(ge(x),x.lookahead===0&&j===h)return w;if(x.lookahead===0)break}x.strstart+=x.lookahead,x.lookahead=0;var B=x.block_start+V;if((x.strstart===0||x.strstart>=B)&&(x.lookahead=x.strstart-B,x.strstart=B,O(x,!1),x.strm.avail_out===0)||x.strstart-x.block_start>=x.w_size-H&&(O(x,!1),x.strm.avail_out===0))return w}return x.insert=0,j===d?(O(x,!0),x.strm.avail_out===0?z:L):(x.strstart>x.block_start&&(O(x,!1),x.strm.avail_out),w)}),new pe(4,4,8,4,Te),new pe(4,5,16,8,Te),new pe(4,6,32,32,Te),new pe(4,4,16,16,he),new pe(8,16,32,32,he),new pe(8,16,128,128,he),new pe(8,32,128,256,he),new pe(32,128,258,1024,he),new pe(32,258,258,4096,he)],s.deflateInit=function(x,j){return ve(x,j,b,15,8,0)},s.deflateInit2=ve,s.deflateReset=ue,s.deflateResetKeep=oe,s.deflateSetHeader=function(x,j){return x&&x.state?x.state.wrap!==2?f:(x.state.gzhead=j,p):f},s.deflate=function(x,j){var V,B,I,U;if(!x||!x.state||5>8&255),ee(B,B.gzhead.time>>16&255),ee(B,B.gzhead.time>>24&255),ee(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ee(B,255&B.gzhead.os),B.gzhead.extra&&B.gzhead.extra.length&&(ee(B,255&B.gzhead.extra.length),ee(B,B.gzhead.extra.length>>8&255)),B.gzhead.hcrc&&(x.adler=c(x.adler,B.pending_buf,B.pending,0)),B.gzindex=0,B.status=69):(ee(B,0),ee(B,0),ee(B,0),ee(B,0),ee(B,0),ee(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ee(B,3),B.status=S);else{var q=b+(B.w_bits-8<<4)<<8;q|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(q|=32),q+=31-q%31,B.status=S,Q(B,q),B.strstart!==0&&(Q(B,x.adler>>>16),Q(B,65535&x.adler)),x.adler=1}if(B.status===69)if(B.gzhead.extra){for(I=B.pending;B.gzindex<(65535&B.gzhead.extra.length)&&(B.pending!==B.pending_buf_size||(B.gzhead.hcrc&&B.pending>I&&(x.adler=c(x.adler,B.pending_buf,B.pending-I,I)),D(x),I=B.pending,B.pending!==B.pending_buf_size));)ee(B,255&B.gzhead.extra[B.gzindex]),B.gzindex++;B.gzhead.hcrc&&B.pending>I&&(x.adler=c(x.adler,B.pending_buf,B.pending-I,I)),B.gzindex===B.gzhead.extra.length&&(B.gzindex=0,B.status=73)}else B.status=73;if(B.status===73)if(B.gzhead.name){I=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>I&&(x.adler=c(x.adler,B.pending_buf,B.pending-I,I)),D(x),I=B.pending,B.pending===B.pending_buf_size)){U=1;break}U=B.gzindexI&&(x.adler=c(x.adler,B.pending_buf,B.pending-I,I)),U===0&&(B.gzindex=0,B.status=91)}else B.status=91;if(B.status===91)if(B.gzhead.comment){I=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>I&&(x.adler=c(x.adler,B.pending_buf,B.pending-I,I)),D(x),I=B.pending,B.pending===B.pending_buf_size)){U=1;break}U=B.gzindexI&&(x.adler=c(x.adler,B.pending_buf,B.pending-I,I)),U===0&&(B.status=103)}else B.status=103;if(B.status===103&&(B.gzhead.hcrc?(B.pending+2>B.pending_buf_size&&D(x),B.pending+2<=B.pending_buf_size&&(ee(B,255&x.adler),ee(B,x.adler>>8&255),x.adler=0,B.status=S)):B.status=S),B.pending!==0){if(D(x),x.avail_out===0)return B.last_flush=-1,p}else if(x.avail_in===0&&R(j)<=R(V)&&j!==d)return te(x,-5);if(B.status===666&&x.avail_in!==0)return te(x,-5);if(x.avail_in!==0||B.lookahead!==0||j!==h&&B.status!==666){var J=B.strategy===2?function(W,ie){for(var le;;){if(W.lookahead===0&&(ge(W),W.lookahead===0)){if(ie===h)return w;break}if(W.match_length=0,le=o._tr_tally(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++,le&&(O(W,!1),W.strm.avail_out===0))return w}return W.insert=0,ie===d?(O(W,!0),W.strm.avail_out===0?z:L):W.last_lit&&(O(W,!1),W.strm.avail_out===0)?w:F}(B,j):B.strategy===3?function(W,ie){for(var le,se,Ae,je,Pe=W.window;;){if(W.lookahead<=N){if(ge(W),W.lookahead<=N&&ie===h)return w;if(W.lookahead===0)break}if(W.match_length=0,W.lookahead>=k&&0W.lookahead&&(W.match_length=W.lookahead)}if(W.match_length>=k?(le=o._tr_tally(W,1,W.match_length-k),W.lookahead-=W.match_length,W.strstart+=W.match_length,W.match_length=0):(le=o._tr_tally(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++),le&&(O(W,!1),W.strm.avail_out===0))return w}return W.insert=0,ie===d?(O(W,!0),W.strm.avail_out===0?z:L):W.last_lit&&(O(W,!1),W.strm.avail_out===0)?w:F}(B,j):n[B.level].func(B,j);if(J!==z&&J!==L||(B.status=666),J===w||J===z)return x.avail_out===0&&(B.last_flush=-1),p;if(J===F&&(j===1?o._tr_align(B):j!==5&&(o._tr_stored_block(B,0,0,!1),j===3&&(G(B.head),B.lookahead===0&&(B.strstart=0,B.block_start=0,B.insert=0))),D(x),x.avail_out===0))return B.last_flush=-1,p}return j!==d?p:B.wrap<=0?1:(B.wrap===2?(ee(B,255&x.adler),ee(B,x.adler>>8&255),ee(B,x.adler>>16&255),ee(B,x.adler>>24&255),ee(B,255&x.total_in),ee(B,x.total_in>>8&255),ee(B,x.total_in>>16&255),ee(B,x.total_in>>24&255)):(Q(B,x.adler>>>16),Q(B,65535&x.adler)),D(x),0=V.w_size&&(U===0&&(G(V.head),V.strstart=0,V.block_start=0,V.insert=0),ie=new a.Buf8(V.w_size),a.arraySet(ie,j,le-V.w_size,V.w_size,0),j=ie,le=V.w_size),q=x.avail_in,J=x.next_in,W=x.input,x.avail_in=le,x.next_in=0,x.input=j,ge(V);V.lookahead>=k;){for(B=V.strstart,I=V.lookahead-(k-1);V.ins_h=(V.ins_h<>>=k=P>>>24,A-=k,(k=P>>>16&255)===0)F[u++]=65535&P;else{if(!(16&k)){if(!(64&k)){P=v[(65535&P)+(b&(1<>>=k,A-=k),A<15&&(b+=w[l++]<>>=k=P>>>24,A-=k,!(16&(k=P>>>16&255))){if(!(64&k)){P=E[(65535&P)+(b&(1<>>=k,A-=k,(k=u-h)>3,b&=(1<<(A-=N<<3))-1,n.next_in=l,n.next_out=u,n.avail_in=l>>24&255)+(T>>>8&65280)+((65280&T)<<8)+((255&T)<<24)}function b(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function A(T){var S;return T&&T.state?(S=T.state,T.total_in=T.total_out=S.total=0,T.msg="",S.wrap&&(T.adler=1&S.wrap),S.mode=f,S.last=0,S.havedict=0,S.dmax=32768,S.head=null,S.hold=0,S.bits=0,S.lencode=S.lendyn=new n.Buf32(m),S.distcode=S.distdyn=new n.Buf32(g),S.sane=1,S.back=-1,d):p}function v(T){var S;return T&&T.state?((S=T.state).wsize=0,S.whave=0,S.wnext=0,A(T)):p}function E(T,S){var w,F;return T&&T.state?(F=T.state,S<0?(w=0,S=-S):(w=1+(S>>4),S<48&&(S&=15)),S&&(S<8||15=L.wsize?(n.arraySet(L.window,S,w-L.wsize,L.wsize,0),L.wnext=0,L.whave=L.wsize):(F<(z=L.wsize-L.wnext)&&(z=F),n.arraySet(L.window,S,w-F,z,L.wnext),(F-=z)?(n.arraySet(L.window,S,w-F,F,0),L.wnext=F,L.whave=L.wsize):(L.wnext+=z,L.wnext===L.wsize&&(L.wnext=0),L.whave>>8&255,w.check=o(w.check,U,2,0),O=D=0,w.mode=2;break}if(w.flags=0,w.head&&(w.head.done=!1),!(1&w.wrap)||(((255&D)<<8)+(D>>8))%31){T.msg="incorrect header check",w.mode=30;break}if((15&D)!=8){T.msg="unknown compression method",w.mode=30;break}if(O-=4,x=8+(15&(D>>>=4)),w.wbits===0)w.wbits=x;else if(x>w.wbits){T.msg="invalid window size",w.mode=30;break}w.dmax=1<>8&1),512&w.flags&&(U[0]=255&D,U[1]=D>>>8&255,w.check=o(w.check,U,2,0)),O=D=0,w.mode=3;case 3:for(;O<32;){if(R===0)break e;R--,D+=F[L++]<>>8&255,U[2]=D>>>16&255,U[3]=D>>>24&255,w.check=o(w.check,U,4,0)),O=D=0,w.mode=4;case 4:for(;O<16;){if(R===0)break e;R--,D+=F[L++]<>8),512&w.flags&&(U[0]=255&D,U[1]=D>>>8&255,w.check=o(w.check,U,2,0)),O=D=0,w.mode=5;case 5:if(1024&w.flags){for(;O<16;){if(R===0)break e;R--,D+=F[L++]<>>8&255,w.check=o(w.check,U,2,0)),O=D=0}else w.head&&(w.head.extra=null);w.mode=6;case 6:if(1024&w.flags&&(R<(K=w.length)&&(K=R),K&&(w.head&&(x=w.head.extra_len-w.length,w.head.extra||(w.head.extra=new Array(w.head.extra_len)),n.arraySet(w.head.extra,F,L,K,x)),512&w.flags&&(w.check=o(w.check,F,K,L)),R-=K,L+=K,w.length-=K),w.length))break e;w.length=0,w.mode=7;case 7:if(2048&w.flags){if(R===0)break e;for(K=0;x=F[L+K++],w.head&&x&&w.length<65536&&(w.head.name+=String.fromCharCode(x)),x&&K>9&1,w.head.done=!0),T.adler=w.check=0,w.mode=12;break;case 10:for(;O<32;){if(R===0)break e;R--,D+=F[L++]<>>=7&O,O-=7&O,w.mode=27;break}for(;O<3;){if(R===0)break e;R--,D+=F[L++]<>>=1)){case 0:w.mode=14;break;case 1:if(N(w),w.mode=20,S!==6)break;D>>>=2,O-=2;break e;case 2:w.mode=17;break;case 3:T.msg="invalid block type",w.mode=30}D>>>=2,O-=2;break;case 14:for(D>>>=7&O,O-=7&O;O<32;){if(R===0)break e;R--,D+=F[L++]<>>16^65535)){T.msg="invalid stored block lengths",w.mode=30;break}if(w.length=65535&D,O=D=0,w.mode=15,S===6)break e;case 15:w.mode=16;case 16:if(K=w.length){if(R>>=5,O-=5,w.ndist=1+(31&D),D>>>=5,O-=5,w.ncode=4+(15&D),D>>>=4,O-=4,286>>=3,O-=3}for(;w.have<19;)w.lens[q[w.have++]]=0;if(w.lencode=w.lendyn,w.lenbits=7,V={bits:w.lenbits},j=c(0,w.lens,0,19,w.lencode,0,w.work,V),w.lenbits=V.bits,j){T.msg="invalid code lengths set",w.mode=30;break}w.have=0,w.mode=19;case 19:for(;w.have>>16&255,be=65535&I,!((he=I>>>24)<=O);){if(R===0)break e;R--,D+=F[L++]<>>=he,O-=he,w.lens[w.have++]=be;else{if(be===16){for(B=he+2;O>>=he,O-=he,w.have===0){T.msg="invalid bit length repeat",w.mode=30;break}x=w.lens[w.have-1],K=3+(3&D),D>>>=2,O-=2}else if(be===17){for(B=he+3;O>>=he)),D>>>=3,O-=3}else{for(B=he+7;O>>=he)),D>>>=7,O-=7}if(w.have+K>w.nlen+w.ndist){T.msg="invalid bit length repeat",w.mode=30;break}for(;K--;)w.lens[w.have++]=x}}if(w.mode===30)break;if(w.lens[256]===0){T.msg="invalid code -- missing end-of-block",w.mode=30;break}if(w.lenbits=9,V={bits:w.lenbits},j=c(u,w.lens,0,w.nlen,w.lencode,0,w.work,V),w.lenbits=V.bits,j){T.msg="invalid literal/lengths set",w.mode=30;break}if(w.distbits=6,w.distcode=w.distdyn,V={bits:w.distbits},j=c(h,w.lens,w.nlen,w.ndist,w.distcode,0,w.work,V),w.distbits=V.bits,j){T.msg="invalid distances set",w.mode=30;break}if(w.mode=20,S===6)break e;case 20:w.mode=21;case 21:if(6<=R&&258<=G){T.next_out=te,T.avail_out=G,T.next_in=L,T.avail_in=R,w.hold=D,w.bits=O,l(T,Q),te=T.next_out,z=T.output,G=T.avail_out,L=T.next_in,F=T.input,R=T.avail_in,D=w.hold,O=w.bits,w.mode===12&&(w.back=-1);break}for(w.back=0;pe=(I=w.lencode[D&(1<>>16&255,be=65535&I,!((he=I>>>24)<=O);){if(R===0)break e;R--,D+=F[L++]<>oe)])>>>16&255,be=65535&I,!(oe+(he=I>>>24)<=O);){if(R===0)break e;R--,D+=F[L++]<>>=oe,O-=oe,w.back+=oe}if(D>>>=he,O-=he,w.back+=he,w.length=be,pe===0){w.mode=26;break}if(32&pe){w.back=-1,w.mode=12;break}if(64&pe){T.msg="invalid literal/length code",w.mode=30;break}w.extra=15&pe,w.mode=22;case 22:if(w.extra){for(B=w.extra;O>>=w.extra,O-=w.extra,w.back+=w.extra}w.was=w.length,w.mode=23;case 23:for(;pe=(I=w.distcode[D&(1<>>16&255,be=65535&I,!((he=I>>>24)<=O);){if(R===0)break e;R--,D+=F[L++]<>oe)])>>>16&255,be=65535&I,!(oe+(he=I>>>24)<=O);){if(R===0)break e;R--,D+=F[L++]<>>=oe,O-=oe,w.back+=oe}if(D>>>=he,O-=he,w.back+=he,64&pe){T.msg="invalid distance code",w.mode=30;break}w.offset=be,w.extra=15&pe,w.mode=24;case 24:if(w.extra){for(B=w.extra;O>>=w.extra,O-=w.extra,w.back+=w.extra}if(w.offset>w.dmax){T.msg="invalid distance too far back",w.mode=30;break}w.mode=25;case 25:if(G===0)break e;if(K=Q-G,w.offset>K){if((K=w.offset-K)>w.whave&&w.sane){T.msg="invalid distance too far back",w.mode=30;break}ge=K>w.wnext?(K-=w.wnext,w.wsize-K):w.wnext-K,K>w.length&&(K=w.length),Te=w.window}else Te=z,ge=te-w.offset,K=w.length;for(GM?(k=ge[Te+g[S]],O[ee+g[S]]):(k=96,0),b=1<>te)+(A-=b)]=P<<24|k<<16|N|0,A!==0;);for(b=1<>=1;if(b!==0?(D&=b-1,D+=b):D=0,S++,--Q[T]==0){if(T===F)break;T=h[d+g[S]]}if(z>>7)]}function ee(I,U){I.pending_buf[I.pending++]=255&U,I.pending_buf[I.pending++]=U>>>8&255}function Q(I,U,q){I.bi_valid>y-q?(I.bi_buf|=U<>y-I.bi_valid,I.bi_valid+=q-y):(I.bi_buf|=U<>>=1,q<<=1,0<--U;);return q>>>1}function Te(I,U,q){var J,W,ie=new Array(g+1),le=0;for(J=1;J<=g;J++)ie[J]=le=le+q[J-1]<<1;for(W=0;W<=U;W++){var se=I[2*W+1];se!==0&&(I[2*W]=ge(ie[se]++,se))}}function he(I){var U;for(U=0;U>1;1<=q;q--)oe(I,ie,q);for(W=Ae;q=I.heap[1],I.heap[1]=I.heap[I.heap_len--],oe(I,ie,1),J=I.heap[1],I.heap[--I.heap_max]=q,I.heap[--I.heap_max]=J,ie[2*W]=ie[2*q]+ie[2*J],I.depth[W]=(I.depth[q]>=I.depth[J]?I.depth[q]:I.depth[J])+1,ie[2*q+1]=ie[2*J+1]=W,I.heap[1]=W++,oe(I,ie,1),2<=I.heap_len;);I.heap[--I.heap_max]=I.heap[1],function(Pe,Rt){var zr,qt,jr,st,X,fe,_e=Rt.dyn_tree,ze=Rt.max_code,Ne=Rt.stat_desc.static_tree,xt=Rt.stat_desc.has_stree,Dt=Rt.stat_desc.extra_bits,Yi=Rt.stat_desc.extra_base,ur=Rt.stat_desc.max_length,Qt=0;for(st=0;st<=g;st++)Pe.bl_count[st]=0;for(_e[2*Pe.heap[Pe.heap_max]+1]=0,zr=Pe.heap_max+1;zr>=7;W>>=1)if(1&je&&se.dyn_ltree[2*Ae]!==0)return a;if(se.dyn_ltree[18]!==0||se.dyn_ltree[20]!==0||se.dyn_ltree[26]!==0)return o;for(Ae=32;Ae>>3,(ie=I.static_len+3+7>>>3)<=W&&(W=ie)):W=ie=q+5,q+4<=W&&U!==-1?B(I,U,q,J):I.strategy===4||ie===W?(Q(I,2+(J?1:0),3),ue(I,H,T)):(Q(I,4+(J?1:0),3),function(se,Ae,je,Pe){var Rt;for(Q(se,Ae-257,5),Q(se,je-1,5),Q(se,Pe-4,4),Rt=0;Rt>>8&255,I.pending_buf[I.d_buf+2*I.last_lit+1]=255&U,I.pending_buf[I.l_buf+I.last_lit]=255&q,I.last_lit++,U===0?I.dyn_ltree[2*q]++:(I.matches++,U--,I.dyn_ltree[2*(w[q]+h+1)]++,I.dyn_dtree[2*O(U)]++),I.last_lit===I.lit_bufsize-1},s._tr_align=function(I){Q(I,2,3),K(I,A,H),function(U){U.bi_valid===16?(ee(U,U.bi_buf),U.bi_buf=0,U.bi_valid=0):8<=U.bi_valid&&(U.pending_buf[U.pending++]=255&U.bi_buf,U.bi_buf>>=8,U.bi_valid-=8)}(I)}},{"../utils/common":41}],53:[function(t,i,s){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,i,s){(function(n){(function(a,o){if(!a.setImmediate){var l,c,u,h,d=1,p={},f=!1,m=a.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(a);g=g&&g.setTimeout?g:a,l={}.toString.call(a.process)==="[object process]"?function(v){process.nextTick(function(){b(v)})}:function(){if(a.postMessage&&!a.importScripts){var v=!0,E=a.onmessage;return a.onmessage=function(){v=!1},a.postMessage("","*"),a.onmessage=E,v}}()?(h="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",A,!1):a.attachEvent("onmessage",A),function(v){a.postMessage(h+v,"*")}):a.MessageChannel?((u=new MessageChannel).port1.onmessage=function(v){b(v.data)},function(v){u.port2.postMessage(v)}):m&&"onreadystatechange"in m.createElement("script")?(c=m.documentElement,function(v){var E=m.createElement("script");E.onreadystatechange=function(){b(v),E.onreadystatechange=null,c.removeChild(E),E=null},c.appendChild(E)}):function(v){setTimeout(b,0,v)},g.setImmediate=function(v){typeof v!="function"&&(v=new Function(""+v));for(var E=new Array(arguments.length-1),C=0;C"u"?n===void 0?this:n:self)}).call(this,typeof si<"u"?si:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(vg);var LE=vg.exports;const OE=da(LE),$i=class $i{static async writeHandle(e,t){const i=this.workID++,s=new Promise((o,l)=>this.map.set(i,[o,l])),n=new TextEncoder,a=typeof t=="string"?n.encode(t):await t.arrayBuffer();return this.worker.postMessage([i,e,a],[a]),s}};Ms($i,"worker",new Worker(new URL("/smeditor/assets/SafariFileWorker-557e53c3.js",self.location),{type:"module"})),Ms($i,"workID",0),Ms($i,"map",new Map),$i.worker.onmessage=e=>{const t=e.data;t.success?$i.map.get(t.id)[0]():$i.map.get(t.id)[1](t.reason),$i.map.delete(t.id)};let Sc=$i;class FE{_root;async getRoot(){return this._root||(kE.adapter.native?await kp().then(e=>this._root=e):await kp(ui(()=>import("./memory-e7c5df82.js"),[])).then(e=>this._root=e)),this._root}async uploadHandle(e,t){let i;if(typeof t=="string"){const s=await this.getDirectoryHandle(t,{create:!0});if(!s)return;i=s}else i=t??await this.getRoot();if(e.kind=="file"){const s=await i.getFileHandle(e.name,{create:!0});await this.writeFile(s,await e.getFile())}else{const s=await i.getDirectoryHandle(e.name,{create:!0}),n=[];for await(const a of e.values())n.push(this.uploadHandle(a,s));await Promise.all(n)}}async uploadFiles(e,t){let i;if(typeof t=="string"){const s=await this.getDirectoryHandle(t,{create:!0});if(!s)return;i=s}else i=t??await this.getRoot();if(e.isFile){const s=e;if(s.name==".DS_Store")return;s.file(async n=>{const a=await i.getFileHandle(n.name,{create:!0});await this.writeHandle(a,n)})}else if(e.isDirectory){const s=e.createReader(),n=await i.getDirectoryHandle(e.name,{create:!0});for await(const a of n.values())await n.removeEntry(a.name,{recursive:!0});s.readEntries(async a=>{const o=[];for(let l=0;li!="."&&i!="");t.indexOf("..")>-1;){const i=t.indexOf("..");if(i==0)throw Error("Path"+t.join("/")+"is invalid!");t.splice(i-1,2)}return t.join("/")}async zipDirectory(e,t){const i=t??new OE,s=Ui(e)==""?e:jt(e),n=await this.getDirectoryHandle(s);if(n){for(const a of await this.getDirectoryFiles(n))i.file(a.name,await a.getFile());for(const a of await this.getDirectoryFolders(n)){const o=i.folder(a.name);if(!o){console.error("Failed to zip folder "+e+"/"+a.name);continue}await this.zipDirectory(e+"/"+a.name,o)}return i}}async saveDirectory(e){const t=Ui(e)==""?e:jt(e);Ce.create("Exporting "+t+".zip");const i=await ME({_preferPolyfill:!1,suggestedName:`${t}.zip`,types:[{accept:{"application/zip":[".zip"]}}],excludeAcceptAllOption:!1}),s=await this.zipDirectory(e);s&&await s.generateAsync({type:"blob"}).then(async n=>{await this.writeHandle(i,n)})}async renameFile(e,t){if(e!=t)try{const i=await this.getDirectoryHandle(jt(e)),s=await this.getDirectoryHandle(jt(t),{create:!0}),n=await this.getFileHandle(e);if(!i||!s||!n)return;await this.copyToHandle(s,n,Zi(t)),await i.removeEntry(Zi(e))}catch(i){console.error(i)}}async renameDirectory(e,t){if(!t.startsWith(e))try{const i=await this.getDirectoryHandle(jt(e)),s=await this.getDirectoryHandle(jt(t),{create:!0}),n=await this.getDirectoryHandle(e);if(!i||!s||!n)return;await this.copyToHandle(s,n,Zi(t)),await i.removeEntry(Zi(e),{recursive:!0})}catch(i){console.error(i)}}async copyToHandle(e,t,i){try{if(t.kind=="directory"){const s=await e.getDirectoryHandle(i??t.name,{create:!0}),n=[];for await(const a of t.values())n.push(this.copyToHandle(s,a));await Promise.all(n)}else{const s=await t.getFile(),n=await e.getFileHandle(i??t.name,{create:!0});await this.writeHandle(n,s)}}catch(s){console.error(s)}}getRelativePath(e,t){const i=e.split("/"),s=t.split("/"),n=Math.min(i.length,s.length);let a=n;for(let l=0;limport("./NodeFileHandler-32fac6e8.js"),[])).NodeFileHandler:new FE}static getStandardHandler(){return this.standardHandler}static getHandler(e){return e!==void 0&&e.startsWith("https://")||e?.startsWith("http://")?this.urlHandler:this.standardHandler}static handleDropEvent(e,t){return this.getHandler().handleDropEvent(e,t)}static getDirectoryHandle(e,t){return Re.getHandler(e).getDirectoryHandle(e,t)}static hasFile(e){return Re.getHandler(e).hasFile(e)}static getFileHandle(e,t){return Re.getHandler(e).getFileHandle(e,t)}static getFileHandleRelativeTo(e,t){return Re.getHandler(e).getFileHandleRelativeTo(e,t)}static getDirectoryFiles(e){return Re.getHandler(typeof e=="string"?e:void 0).getDirectoryFiles(e)}static getDirectoryFolders(e){return Re.getHandler(typeof e=="string"?e:void 0).getDirectoryFolders(e)}static writeFile(e,t){return Re.getHandler(typeof e=="string"?e:void 0).writeFile(e,t)}static getRelativePath(e,t){return Re.getHandler().getRelativePath(e,t)}}class Pt{windowManager;options;windowElement;viewElement;constructor(e){this.options=e;const t=document.createElement("div"),i=document.createElement("div"),s=document.createElement("div"),n=document.createElement("div");if(t.appendChild(s),t.appendChild(i),t.style.width=e.width+"px",t.style.left=window.innerWidth/2-e.width/2+"px",t.style.top=window.innerHeight/2-e.height/2+"px",t.classList.add("unselectable","window"),e.win_id&&(t.dataset.win_id=e.win_id),i.classList.add("view"),i.style.height=e.height+"px",i.style.width=e.width+"px",s.classList.add("navbar"),s.appendChild(n),!e.disableClose){const a=document.createElement("img"),o=document.createElement("img");a.classList.add("unselectable"),a.draggable=!1,a.src=He.MINIMIZE_WINDOW,a.onclick=()=>{i.style.height!="0px"?i.style.height="0px":i.style.height=e.height+"px",this.clampPosition()},o.classList.add("unselectable"),o.draggable=!1,o.src=He.CLOSE_WINDOW,o.onclick=()=>this.closeWindow(),s.appendChild(a),s.appendChild(o)}n.innerText=e.title,n.classList.add("title"),t.addEventListener("mousedown",()=>this.focus()),e.blocking&&(window.addEventListener("mousedown",this.block,!0),document.getElementById("blocker").style.display="block",t.dataset.blocking="block"),n.addEventListener("mousedown",()=>{window.addEventListener("mousemove",this.handleDrag),window.addEventListener("mouseup",()=>window.removeEventListener("mousemove",this.handleDrag))}),this.focus(),t.classList.add("focused"),this.windowElement=t,this.viewElement=i}addToManager(e){this.windowManager=e,e.view.appendChild(this.windowElement),this.focus()}onClose(){}closeWindow(){this.windowManager&&(this.onClose(),this.windowManager.removeWindow(this),this.windowElement.classList.add("exiting"),window.removeEventListener("mousedown",this.block,!0),this.options.blocking&&this.windowManager.windows.filter(e=>e.options.blocking).length==0&&(document.getElementById("blocker").style.display="none"),setTimeout(()=>this.windowManager.view.removeChild(this.windowElement),40))}focus(){if(this.windowManager==null)return;this.windowManager.unfocusAll(),this.windowElement.classList.add("focused");const e=Array.from(this.windowManager.view.children).map(t=>t).filter(t=>t!=this.windowElement);e.sort((t,i)=>parseInt(t.style.zIndex)-parseInt(i.style.zIndex)),e.push(this.windowElement);for(let t=0;t{!e.target||this.windowElement.contains(e.target)||(e.stopImmediatePropagation(),e.preventDefault())};handleDrag=e=>{const t=parseInt(this.windowElement.style.left.slice(0,-2))+e.movementX,i=parseInt(this.windowElement.style.top.slice(0,-2))+e.movementY;this.windowElement.style.left=t+"px",this.windowElement.style.top=i+"px",this.clampPosition()};clampPosition(){if(this.windowManager==null)return;const e=parseInt(this.windowElement.style.left.slice(0,-2)),t=parseInt(this.windowElement.style.top.slice(0,-2)),i=this.windowManager.app.view.getBoundingClientRect();this.windowElement.style.left=Ve(e,i.left,i.width-this.windowElement.clientWidth+i.left)+"px",this.windowElement.style.top=Ve(t,i.top,i.height-this.windowElement.clientHeight+i.top)+"px"}}class ml extends Pt{app;dirOptions;fileDropPath="";draggedElement;draggedCopy;keyHandler;dropHandler;mouseHandler;dragHandler;constructor(e,t,i){super({title:t.title,width:500,height:400,disableClose:t.disableClose,win_id:"file_selector"+Math.random(),blocking:!0}),this.app=e,this.dirOptions=t,t.accepted_file_types||=[],this.keyHandler=this.handleKeyEvent.bind(this),this.dropHandler=this.handleDropEvent.bind(this),this.mouseHandler=this.handleMouseEvent.bind(this),this.dragHandler=this.handleDragEvent.bind(this),this.initView().then(()=>{i&&this.selectPath(i),t.onload?.()})}async initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("menu-options");const i=document.createElement("div");i.classList.add("menu-left");const s=document.createElement("div");s.classList.add("menu-right"),t.appendChild(i),t.appendChild(s);const n=document.createElement("button");n.innerText="Cancel",n.onclick=()=>{window.removeEventListener("keydown",this.keyHandler,!0),window.removeEventListener("drop",this.dropHandler,!0),this.closeWindow()};const a=document.createElement("button");a.innerText="Select",a.classList.add("confirm"),a.onclick=()=>this.confirmFile(),a.disabled=!0,i.appendChild(n),s.appendChild(a);const o=document.createElement("div");o.classList.add("dir-selector"),o.onclick=y=>{y.target==o&&this.selectElement(void 0)};const l=document.createElement("div");l.classList.add("file-options");const c=document.createElement("button"),u=document.createElement("img");u.src=He.ADD_FILE,u.classList.add("icon"),c.appendChild(u),c.appendChild(document.createTextNode("Upload files")),l.appendChild(c),c.onclick=async()=>{const y=this.fileDropPath,b=await CE({_preferPolyfill:!1,excludeAcceptAllOption:!1,multiple:!0}),v=this.viewElement.querySelector(".info.selected")?.dataset.path??"",E=[];for(const C of b)E.push(Re.getStandardHandler().uploadHandle(C,v));await Promise.all(E),await this.refreshDirectory(y),this.getAcceptableFile(y).then(C=>this.selectPath(C))};const h=document.createElement("button"),d=document.createElement("img");d.src=He.ADD_FOLDER,d.classList.add("icon"),h.appendChild(d),h.appendChild(document.createTextNode("Upload folder")),l.appendChild(h),h.onclick=async()=>{const y=this.fileDropPath,b=await SE({_preferPolyfill:!1}),v=this.viewElement.querySelector(".info.selected")?.dataset.path??"";await Re.getStandardHandler().uploadHandle(b,v),await this.refreshDirectory(y),this.getAcceptableFile(y==""?b.name:y+"/"+b.name).then(E=>this.selectPath(E))};const p=document.createElement("button");p.classList.add("rename");const f=document.createElement("img");f.src=He.EDIT,f.classList.add("icon"),p.appendChild(f),p.appendChild(document.createTextNode("Rename")),p.disabled=!0,p.onclick=()=>{const y=this.viewElement.querySelector(".info.selected");y?.dataset.path&&this.startEditing(y.querySelector("textarea"))},l.appendChild(p);const m=document.createElement("button");m.classList.add("delete");const g=document.createElement("img");g.src=He.TRASH,g.classList.add("icon"),m.appendChild(g),m.appendChild(document.createTextNode("Delete")),m.disabled=!0,m.onclick=()=>{const y=this.viewElement.querySelector(".info.selected"),b=y?.dataset.path;if(!b)return;const A=y.parentElement.classList.contains("folder");Re.getStandardHandler()[A?"removeDirectory":"removeFile"](b).then(()=>{const v=this.getElement(b);v&&(v.parentElement?.remove(),m.disabled=!0,p.disabled=!0)})},l.appendChild(m),e.appendChild(o),e.appendChild(l),e.appendChild(t),this.viewElement.appendChild(e),window.addEventListener("keydown",this.keyHandler,!0),window.addEventListener("drop",this.dropHandler,!0),window.addEventListener("mousemove",this.dragHandler,!0),this.viewElement.addEventListener("dragover",this.mouseHandler),await this.createDiv("").then(y=>o.replaceChildren(...y))}async expand(e){if(!e.parentElement.classList.contains("folder"))return;e.parentElement.classList.remove("collapsed");const t=e.nextSibling;await this.createDiv(e.dataset.path).then(i=>{t.replaceChildren(...i)})}collapse(e){if(!e.parentElement.classList.contains("folder"))return;e.parentElement.classList.add("collapsed"),e.nextSibling.replaceChildren()}selectElement(e){if(this.viewElement.querySelector(".info.selected")?.classList.remove("selected"),!e){this.viewElement.querySelector(".delete").disabled=!0,this.viewElement.querySelector(".rename").disabled=!0;return}e.classList.add("selected"),ea(e,{scrollMode:"if-needed",block:"nearest",inline:"nearest"});const t=this.viewElement.querySelector("button.confirm"),i=e.dataset.path;t.disabled=!0,i&&(t.disabled=!this.acceptableFileType(i),this.viewElement.querySelector(".delete").disabled=!1,this.viewElement.querySelector(".rename").disabled=!1)}async createDiv(e){const t=await Re.getStandardHandler().getDirectoryFolders(e);let i=await Re.getStandardHandler().getDirectoryFiles(e);return t.sort((s,n)=>s.name.toLowerCase().localeCompare(n.name.toLowerCase())),i.sort((s,n)=>s.name.toLowerCase().localeCompare(n.name.toLowerCase())),i=i.filter(s=>Ui(s.name)!=".crswap"),t.map(s=>this.createBaseElement(e,s)).concat(i.map(s=>this.createBaseElement(e,s)))}createBaseElement(e,t){e!=""&&(e+="/");const i=document.createElement("div");i.classList.add("item");const s=document.createElement("div");if(s.classList.add("info"),i.appendChild(s),t.kind=="directory"){const a=document.createElement("img");a.classList.add("icon"),a.classList.add("folder-icon"),a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAAbklEQVRIie2PMQqAMAxFXwfP6qJVPIjYzcOKdUkhQ0BaCoLkLS3k818CjuN8ztApYzIDl7xvmalFsAIZuIFozKPMMrC0CAJwKIkuGVX5KdkmLEm3ci1JSlLKU49yLSmXVG1es0EANvnvInKcP/AA784fpjlWwNQAAAAASUVORK5CYII=",s.appendChild(a);const o=document.createElement("div");o.classList.add("children"),i.appendChild(o),i.classList.add("folder"),i.classList.add("collapsed"),s.addEventListener("click",l=>{const c=l.target;c?.classList.contains("options-icon")||c.tagName=="TEXTAREA"&&!c.disabled||(i.classList.contains("collapsed")?this.expand(s):this.collapse(s))})}else{this.acceptableFileType(t.name)||s.classList.add("disabled");const a=document.createElement("img");a.src=this.getIcon(t.name),a.classList.add("icon"),s.appendChild(a)}s.dataset.path=e+t.name;const n=document.createElement("textarea");return n.rows=1,n.disabled=!0,n.autocomplete="off",n.autocapitalize="off",n.spellcheck=!1,n.innerText=t.name,n.style.pointerEvents="none",n.classList.add("title"),s.appendChild(n),s.addEventListener("click",()=>this.selectElement(s)),s.addEventListener("mousedown",()=>this.startDragging(s)),s.ondblclick=()=>this.confirmFile(),i}confirmFile(){const t=this.viewElement.querySelector(".info.selected")?.dataset.path;t&&this.acceptableFileType(t)&&(this.dirOptions.callback?.(t),window.removeEventListener("keydown",this.keyHandler,!0),window.removeEventListener("drop",this.dropHandler,!0),window.removeEventListener("mousemove",this.dragHandler,!0),this.closeWindow())}acceptableFileType(e){return this.dirOptions.accepted_file_types.length==0||this.dirOptions.accepted_file_types.includes(Ui(e))}getIcon(e){const t=Ui(e);return t==""&&!e.startsWith(".")?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAAY0lEQVRIiWNgGAWDCXgwMDA8ZmBg+I8DN1BqwSM8hlPFEpgh2EA4AwPDbyIc8B/qUA9SLSDHEpItIBagmMNEBQPxglELRi0YtQDVgsdQmpiiAB9GNgsFeDAQV6KSXdiNgoEBAG+iU6T/ixEpAAAAAElFTkSuQmCC":ts.includes(t)?He.IMAGE_FILE:ol.includes(t)?He.AUDIO_FILE:[".sm",".ssc"].includes(t)?He.SM_FILE:He.UNKNOWN_FILE}startEditing(e){const t=e.value,i=!!e.parentElement?.parentElement?.classList.contains("folder"),s=e.parentElement?.dataset.path??"",n=jt(s);e.value=s.split("/").at(-1)??"",window.removeEventListener("keydown",this.keyHandler,!0),e.disabled=!1,e.style.pointerEvents="",e.focus(),e.addEventListener("keypress",a=>{a.code=="Enter"&&(a.preventDefault(),a.stopImmediatePropagation(),e.blur())},!0),e.addEventListener("blur",async()=>{if(window.addEventListener("keydown",this.keyHandler,!0),e.disabled=!0,e.style.pointerEvents="none",e.value.startsWith(".")){e.value=t;return}e.value=e.value.replaceAll("/","");const a=n==""?e.value:n+"/"+e.value;a!=s&&(e.parentElement.dataset.path=a,await Re.getStandardHandler()[i?"renameDirectory":"renameFile"](s,a),this.refreshDirectory(n),e.value.length>32&&(e.value=e.value.slice(0,32)+"..."))})}async refreshDirectory(e){const t=this.viewElement.querySelector(".dir-selector");if(!t)return;let i=t.querySelector("div[data-path='"+this.escapeSelector(e)+"']")?.nextSibling;if(e==""&&(i=t),!i)return;const s=Array.from(i.parentElement.querySelectorAll(".folder:not(.collapsed)")).map(n=>n.children[0].dataset.path);await this.createDiv(e).then(n=>i.replaceChildren(...n)),await Promise.all(s.map(n=>this.expand(t.querySelector("div[data-path='"+this.escapeSelector(n)+"']"))))}getElement(e){const t=this.viewElement.querySelector(".dir-selector");return t?t.querySelector("div[data-path='"+this.escapeSelector(e)+"']"):null}async getAcceptableFile(e){const t=await Re.getStandardHandler().getDirectoryHandle(e);if(!t)return;const i=[{path:e,handle:t}];for(;i.length>0;){const s=i.shift(),n=s.handle;for await(const a of n.values()){const o=s.path==""?"":s.path+"/";if(a.kind=="directory")i.push({path:o+a.name,handle:a});else if(this.acceptableFileType(a.name))return o+a.name}}}async selectPath(e){if(!e)return;const t=this.viewElement.querySelector(".dir-selector");if(!t)return;const i=e.split("/");i.pop();const s=[];for(;i.length>0;){s.push(i.shift());const a=t.querySelector("div[data-path='"+this.escapeSelector(s.join("/"))+"']");if(!a)return;await this.expand(a)}const n=t.querySelector("div[data-path='"+this.escapeSelector(e)+"']");n&&this.selectElement(n)}handleKeyEvent(e){if(!this.windowElement.classList.contains("focused"))return;const t=this.viewElement.querySelector(".info.selected");if(t==null){if(e.code.startsWith("Arrow")){const i=this.viewElement.querySelector(".info");i&&this.selectElement(i)}return}if(e.code=="ArrowUp"){e.preventDefault(),e.stopImmediatePropagation();const i=t.parentElement;let s=i.previousSibling?.querySelector(".info");s&&!s.parentElement.classList.contains("collapsed")&&s.parentElement.classList.contains("folder")&&(s=s.parentElement.querySelector(".children").lastChild.querySelector(".info")),!s&&i.parentElement.classList.contains("children")&&(s=i.parentElement.parentElement.querySelector(".info")),s&&(this.selectElement(s),ea(s,{scrollMode:"if-needed",block:"nearest",inline:"nearest"}))}if(e.code=="ArrowDown"){e.preventDefault(),e.stopImmediatePropagation();const i=t.parentElement;let s;i.classList.contains("folder")&&!i.classList.contains("collapsed")&&(s=i.querySelector(".children").children[0].querySelector(".info")),s||(s=t.parentElement.nextSibling?.querySelector(".info")),!s&&i.parentElement.classList.contains("children")&&(s=i.parentElement.parentElement.nextSibling.querySelector(".info")),s&&(this.selectElement(s),ea(s,{scrollMode:"if-needed",block:"nearest",inline:"nearest"}))}if(e.code=="ArrowLeft"&&(e.preventDefault(),e.stopImmediatePropagation(),this.collapse(t)),e.code=="ArrowRight"&&(e.preventDefault(),e.stopImmediatePropagation(),this.expand(t)),e.code=="Enter"&&(e.preventDefault(),e.stopImmediatePropagation(),t.parentElement?.querySelector(".title")&&this.startEditing(t.parentElement?.querySelector(".title"))),e.code=="Delete"||e.code=="Backspace"){const i=this.viewElement.querySelector(".info.selected"),s=i?.dataset.path;if(!s)return;const n=i.parentElement.classList.contains("folder");Re.getStandardHandler()[n?"removeDirectory":"removeFile"](s).then(()=>{const a=this.getElement(s);a&&(a.parentElement?.remove(),this.viewElement.querySelector(".delete").disabled=!0,this.viewElement.querySelector(".rename").disabled=!0)})}}startDragging(e){const t=e;t.totalMovementX=0,t.totalMovementY=0,this.draggedElement=t;const i=()=>{this.stopDragging(),window.removeEventListener("mouseup",i)};window.addEventListener("mouseup",i)}handleDragEvent(e){if(this.draggedElement){if(this.draggedElement.totalMovementX+=e.movementX,this.draggedElement.totalMovementY+=e.movementY,!this.draggedCopy)if(Math.abs(this.draggedElement.totalMovementX)+Math.abs(this.draggedElement.totalMovementY)>8){this.viewElement.addEventListener("mousemove",this.mouseHandler),this.draggedCopy=this.draggedElement.parentElement.cloneNode(!0),this.draggedCopy.style.position="fixed";const t=this.draggedElement.getBoundingClientRect();this.draggedCopy.style.top=t.top+this.draggedElement.totalMovementY+"px",this.draggedCopy.style.left=t.left+this.draggedElement.totalMovementX+"px",this.draggedCopy.style.width=t.width+"px",this.draggedCopy.style.boxShadow="3px 3px 3px #222",this.draggedCopy.querySelector(".children")&&this.draggedCopy.removeChild(this.draggedCopy.querySelector(".children")),this.viewElement.appendChild(this.draggedCopy)}else return;this.draggedCopy.style.top=parseFloat(this.draggedCopy.style.top.slice(0,-2))+e.movementY+"px",this.draggedCopy.style.left=parseFloat(this.draggedCopy.style.left.slice(0,-2))+e.movementX+"px"}}async stopDragging(){if(this.draggedCopy){this.draggedCopy.remove(),this.viewElement.removeEventListener("mousemove",this.mouseHandler);const e=this.draggedCopy.classList.contains("folder"),t=this.draggedElement.dataset.path,i=this.fileDropPath==""?Zi(this.draggedElement.dataset.path):this.fileDropPath+"/"+Zi(this.draggedElement.dataset.path);t!=i&&await Re.getStandardHandler()[e?"renameDirectory":"renameFile"](t,i),await this.refreshDirectory(jt(t)),await this.refreshDirectory(jt(i)),this.viewElement.querySelector(".outlined")?.classList.remove("outlined"),this.fileDropPath=""}this.draggedCopy=void 0,this.draggedElement=void 0}handleDropEvent(e){e.preventDefault(),e.stopImmediatePropagation(),this.viewElement.querySelector(".outlined")?.classList.remove("outlined"),e.target.closest(".dir-selector")&&Re.getStandardHandler().handleDropEvent(e,this.fileDropPath).then(async t=>{await this.refreshDirectory(this.fileDropPath),this.getAcceptableFile(t??this.fileDropPath).then(i=>this.selectPath(i)),this.fileDropPath=""})}handleMouseEvent(e){const t=this.viewElement.querySelector(".dir-selector");let i=Array.from(t.querySelectorAll("div.item.folder"));const s=this.viewElement.querySelector(".outlined");i=i.filter(n=>!n.parentElement.closest(".collapsed")),i.reverse(),i.push(t);for(const n of i){const a=n.getBoundingClientRect();if(e.clientX>=a.x&&e.clientX<=a.x+a.width&&e.clientY>=a.y&&e.clientY<=a.y+a.height){s!=n&&s?.classList.remove("outlined");const o=n.querySelector(".info");this.fileDropPath=o?.dataset.path??"",n.classList.contains("dir-selector")&&(this.fileDropPath=""),n.classList.add("outlined");return}}this.viewElement.querySelector(".outlined")?.classList.remove("outlined"),this.fileDropPath=""}escapeSelector(e){return e.replaceAll(/'/g,"\\'")}}class ht{items=[];itemIndex=0;limit=0;app;static instance;constructor(e){this.app=e,ht.instance||(ht.instance=this)}run(e){e.action(this.app),this.items.splice(this.itemIndex,this.items.length-this.itemIndex,e),this.itemIndex++}undo(){this.items[this.itemIndex-1]&&(this.items[this.itemIndex-1].undo(this.app),this.itemIndex--,$.emit("undo"))}redo(){this.items[this.itemIndex]&&(this.items[this.itemIndex].redo?this.items[this.itemIndex].redo(this.app):this.items[this.itemIndex].action(this.app),this.itemIndex++,$.emit("redo"))}reset(){this.itemIndex=0,this.items=[]}canUndo(){return this.itemIndex>0}canRedo(){return this.itemIndex!=this.items.length}setLimit(){this.limit=this.itemIndex}isDirty(){return this.itemIndex!=this.limit}}function bg(){const r=document.createElement("div");return r.spellcheck=!1,r.contentEditable="true",r.classList.add("inlineEdit"),r.onkeydown=e=>{e.key=="Enter"&&r.blur()},r}function eo(r,e){return{title:r,element:t=>{const i=bg();return i.onblur=()=>{const s=t[e];ht.instance.run({action:()=>{t[e]=i.innerText},undo:()=>{t[e]=s}}),i.scrollLeft=0},i.innerText=t[e],i}}}const NE={name:eo("Name","chartName"),credit:eo("Artist","credit"),style:eo("Style","chartStyle"),description:eo("Description","description"),music:{title:"Music File",element:(r,e)=>{const t=document.createElement("div");t.classList.add("flex-row","flex-column-gap","flex-static","hide-buttons");const i=()=>{if(s.innerText==(r.music??e.chartManager.loadedSM.properties.MUSIC??""))return;const c=e.chartManager.chartAudio.isPlaying();if(s.innerText==""||s.innerText==e.chartManager.loadedSM.properties.MUSIC){r.music=void 0,s.innerText=e.chartManager.loadedSM.properties.MUSIC+"",e.chartManager.loadAudio(),c&&e.chartManager.chartAudio.play();return}const u=r.music;ht.instance.run({action:()=>r.music=s.innerText==e.chartManager.loadedSM.properties.MUSIC?void 0:s.innerText,undo:()=>r.music=u}),e.chartManager.loadAudio(),c&&e.chartManager.chartAudio.play()},s=bg();s.style.flex="1",s.onblur=i,s.innerText=r.music??e.chartManager.loadedSM.properties.MUSIC??"";const n=document.createElement("button");n.onclick=()=>{const c=e.chartManager.smPath.split("/").slice(0,-1).join("/");if(window.nw){const u=document.createElement("input");u.type="file",u.accept="audio/*",u.onchange=()=>{s.innerText=Re.getRelativePath(c,u.value),i()},u.click()}else e.windowManager.openWindow(new ml(e,{title:"Select an audio file...",accepted_file_types:ol,disableClose:!0,callback:u=>{s.innerText=Re.getRelativePath(c,u),i()}},c+"/"+(r.music??e.chartManager.loadedSM.properties.MUSIC??"")))};const a=document.createElement("img");a.classList.add("icon"),a.style.height="12px",a.src=He.SELECT_FILE,n.appendChild(a);const o=document.createElement("button");o.onclick=()=>{s.innerText!=(e.chartManager.loadedSM.properties.MUSIC??"")&&(s.innerText=e.chartManager.loadedSM.properties.MUSIC??"",i())};const l=document.createElement("img");return l.classList.add("icon"),l.style.height="12px",l.src=He.REVERT,o.appendChild(l),t.appendChild(s),t.appendChild(n),t.appendChild(o),t}}};class pi{view;items=[];selectedItem;onChangeHandlers=[];static create(e,t){return new pi(document.createElement("div"),e,t)}constructor(e,t,i){this.view=e,e.classList.add("dropdown"),this.items=t??[],this.selectedItem=i??this.items[0];const s=document.createElement("div");s.classList.add("dropdown-selected");const n=document.createElement("div");n.classList.add("dropdown-items"),n.style.height="",s.onclick=()=>{if(!s.classList.contains("disabled")){if(this.items.length==0){n.style.height="";return}this.createDropdown(),n.style.height==""?(n.style.width=Math.max(n.scrollWidth,s.clientWidth)+"px",n.style.height=n.scrollHeight+"px",Array.from(n.children).forEach((a,o)=>{a.style.animationDelay=o*.02+"s"})):n.style.height=""}},window.addEventListener("click",a=>{const o=a.target;(!o.closest(".dropdown")||o.closest(".dropdown")!=e)&&(n.style.height="")}),this.view.appendChild(s),this.view.appendChild(n),this.setSelected()}onChange(e){this.onChangeHandlers.push(e)}removeHandler(e){this.onChangeHandlers.includes(e)&&this.onChangeHandlers.splice(this.onChangeHandlers.indexOf(e),1)}getItems(){return this.items}setItems(e){this.items=e,e.includes(this.selectedItem)||(this.selectedItem=this.items[0],this.setSelected())}setSelected(e){this.selectedItem=e??this.selectedItem;const t=this.view.querySelector(".dropdown-selected");t.innerText=this.selectedItem?this.selectedItem+"":""}closeDropdown(){const e=this.view.querySelector(".dropdown-items");e&&(e.style.height="")}get value(){return this.selectedItem}get disabled(){return this.view.querySelector(".dropdown-selected").classList.contains("disabled")}set disabled(e){e?this.view.querySelector(".dropdown-selected").classList.add("disabled"):this.view.querySelector(".dropdown-selected").classList.remove("disabled")}createDropdown(){const e=this.view.querySelector(".dropdown-items"),t=this.items.map((i,s)=>{const n=document.createElement("div");return n.classList.add("dropdown-item"),n.innerText=i+"",n.onclick=()=>{e.style.height="",this.selectedItem!=i&&(this.setSelected(i),this.onChangeHandlers.forEach(a=>a(i,s)))},n});e.replaceChildren(...t)}}class fd extends Pt{app;buttonOptions;message;resolve;resolved=new Promise(e=>this.resolve=e);constructor(e,t,i,s){super({title:t,width:300,height:100,disableClose:!0,win_id:"confirm",blocking:!0}),this.app=e,this.message=i,this.buttonOptions=s,this.initView()}initView(){this.viewElement.replaceChildren(),this.viewElement.classList.add("confirmation");const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("label"),t.innerText=this.message,e.appendChild(t);const i=document.createElement("div");i.classList.add("menu-options"),this.buttonOptions.forEach(s=>{const n=document.createElement("button");n.innerText=s.label,n.onclick=()=>{s.callback?.(),this.resolve?.(s.label),this.closeWindow()},s.type!="default"&&n.classList.add(s.type),i.append(n)}),e.appendChild(i),this.viewElement.appendChild(e)}}class Ag extends Pt{app;gameType;chartList;chartInfo;gameTypeDropdown;smLoadHandler=()=>{this.gameTypeDropdown.setItems(Ke.getPriority().map(e=>{const t=this.app.chartManager.loadedSM?.charts[e.id]??[];return e.id+" ("+t.length+")"})),this.gameTypeDropdown.setSelected(this.gameType.id+" ("+(this.app.chartManager.loadedSM?.charts[this.gameType.id]??[]).length+") "),this.gameType=this.app.chartManager.loadedChart?.gameType??this.gameType,this.loadCharts()};constructor(e,t){super({title:"Chart List",width:500,height:400,win_id:"chart_list"}),this.app=e,this.gameType=t??e.chartManager.loadedChart?.gameType??Ke.getPriority()[0],this.initView(),$.on("smLoadedAfter",this.smLoadHandler)}initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("chart-view-type-wrapper");const i=document.createElement("div");i.classList.add("chart-view-type-label"),i.innerText="Game Type:",this.gameTypeDropdown=pi.create(Ke.getPriority().map(n=>{const a=this.app.chartManager.loadedSM?.charts[n.id]??[];return n.id+" ("+a.length+")"}),this.gameType.id+" ("+(this.app.chartManager.loadedSM?.charts[this.gameType.id]??[]).length+") "),this.gameTypeDropdown.onChange(n=>{this.gameType=Ke.getGameType(n.split(" ")[0])??this.gameType,this.loadCharts()}),t.appendChild(i),t.appendChild(this.gameTypeDropdown.view);const s=document.createElement("div");s.classList.add("chart-view-scroller"),e.appendChild(t),e.appendChild(s),this.chartList=document.createElement("div"),this.chartList.classList.add("chart-list"),this.chartInfo=document.createElement("div"),this.chartInfo.classList.add("chart-info"),s.appendChild(this.chartList),s.appendChild(this.chartInfo),this.viewElement.appendChild(e),this.loadCharts()}onClose(){$.off("smLoadedAfter",this.smLoadHandler)}loadCharts(){const e=this.app.chartManager.loadedSM?.charts[this.gameType.id]??[],t=[];this.gameTypeDropdown.setItems(Ke.getPriority().map(a=>{const o=this.app.chartManager.loadedSM?.charts[a.id]??[];return a.id+" ("+o.length+")"})),this.gameTypeDropdown.setSelected(this.gameType.id+" ("+(this.app.chartManager.loadedSM?.charts[this.gameType.id]??[]).length+") "),e.forEach(a=>{const o=document.createElement("div");o.classList.add("chart-list-item"),o.chart=a,this.app.chartManager.loadedChart==a&&o.classList.add("selected"),o.onclick=()=>{o.chart!=this.app.chartManager.loadedChart&&(this.app.chartManager.loadChart(o.chart),this.chartList.querySelectorAll(".selected").forEach(d=>d.classList.remove("selected")),o.classList.add("selected"))},o.onmouseenter=()=>{this.loadChartDetails(o.chart)},o.onmouseleave=()=>{this.loadChartDetails()};const l=document.createElement("div");l.innerText=a.meter+"",l.classList.add("title",a.difficulty);const c=document.createElement("div");c.classList.add("chart-list-info");const u=document.createElement("div");u.innerText=a.credit,u.classList.add("title","chart-credit");const h=document.createElement("div");h.innerText=a.getNotedata().length+"",h.classList.add("title","chart-step-count"),c.appendChild(u),c.appendChild(h),o.appendChild(l),o.appendChild(c),t.push(o)});const i=document.createElement("div");i.classList.add("chart-list-item");const s=document.createElement("div");s.innerText="+",s.classList.add("title");const n=document.createElement("div");n.classList.add("chart-list-info"),n.innerText="New Blank Chart",i.appendChild(s),i.appendChild(n),i.onclick=()=>{const a=new mg(this.app.chartManager.loadedSM);a.gameType=this.gameType,this.app.chartManager.loadedSM.addChart(a),this.app.chartManager.loadChart(a),this.loadCharts()},this.chartList.replaceChildren(...t,i),this.loadChartDetails()}loadChartDetails(e){if(e=e??this.app.chartManager.loadedChart,e?.gameType.id!=this.gameType.id){this.chartInfo.replaceChildren();return}if(!e)return;const t=()=>this.app.chartManager.loadedSM.charts[e.gameType.id].sort((m,g)=>xi.indexOf(m.difficulty)==xi.indexOf(g.difficulty)?m.meter-g.meter:xi.indexOf(m.difficulty)-xi.indexOf(g.difficulty)),i=document.createElement("div");i.classList.add("chart-info-main");const s=pi.create(xi,e.difficulty);s.view.classList.add("no-border","white"),s.onChange(m=>{const g=e.difficulty;ht.instance.run({action:()=>{e.difficulty=m,t(),this.loadCharts()},undo:()=>{e.difficulty=g,t(),this.loadCharts()}})});const n=document.createElement("div");n.spellcheck=!1,n.contentEditable="true",n.classList.add("inlineEdit","chart-meter"),n.onkeydown=m=>{m.key=="Enter"&&n.blur()},n.onblur=()=>{let m=gn(n.innerText);if(m===null){n.innerText=e?.meter+"";return}m=Math.round(Ve(1,m,2**31-1));const g=e.meter;ht.instance.run({action:()=>{e.meter=m,e.meterF=m,t(),this.loadCharts()},undo:()=>{e.meter=g,e.meterF=g,t(),this.loadCharts()}}),n.scrollLeft=0},n.innerText=e.meter+"";const a=document.createElement("div");a.classList.add("chart-properties"),i.appendChild(s.view),i.appendChild(n),Object.values(NE).forEach(m=>{const g=document.createElement("div");g.classList.add("label"),g.innerText=m.title;const y=m.element(e,this.app);m.title=="Artist"&&y.addEventListener("blur",()=>this.loadCharts()),a.appendChild(g),a.appendChild(y)});const o=e.getNotedataStats(),l=document.createElement("div");l.classList.add("chart-info-grid-item");const c=document.createElement("div");c.innerText="Peak NPS",c.classList.add("title","chart-info-grid-label");const u=document.createElement("div");u.innerText=e.getMaxNPS().toFixed(2)+"",u.classList.add("title","chart-info-grid-count"),l.appendChild(c),l.appendChild(u);const h=document.createElement("div");h.classList.add("chart-info-grid"),Object.entries(o).forEach(m=>{const g=document.createElement("div");g.classList.add("chart-info-grid-item");const y=document.createElement("div");y.innerText=m[0],y.classList.add("title","chart-info-grid-label");const b=document.createElement("div");b.innerText=m[1]+"",b.classList.add("title","chart-info-grid-count"),g.appendChild(y),g.appendChild(b),h.appendChild(g)});const d=document.createElement("div");d.classList.add("menu-options");const p=document.createElement("button");p.innerText="Duplicate Chart",p.onclick=()=>{const m=Object.assign(Object.create(Object.getPrototypeOf(e)),e);m.setNotedata(e.getNotedata().map(g=>e.computeNote(g))??[]),this.app.chartManager.loadedSM.addChart(m),this.app.chartManager.loadChart(m),this.loadCharts()},d.append(p);const f=document.createElement("button");f.innerText="Delete Chart",f.onclick=()=>{this.app.windowManager.openWindow(new fd(this.app,"Delete chart","Are you sure you want to delete this chart?",[{type:"default",label:"Cancel"},{type:"delete",label:"Delete",callback:()=>{this.app.chartManager.loadedSM.removeChart(e)&&(this.app.chartManager.loadChart(),this.gameType=this.app.chartManager.loadedChart?.gameType??this.gameType,this.loadCharts())}}]))},f.classList.add("delete"),d.append(f),this.chartInfo.replaceChildren(i,a,l,h,d)}}const UE="/smeditor/assets/highpass-d9d7cfcb.svg",GE="/smeditor/assets/highshelf-11ccf64e.svg",HE="/smeditor/assets/lowpass-ff013247.svg",WE="/smeditor/assets/lowshelf-2b031328.svg",VE="/smeditor/assets/peaking-eec48769.svg";var zE=4,jE=.001,YE=1e-7,XE=10,Wn=11,to=1/(Wn-1),KE=typeof Float32Array=="function";function wg(r,e){return 1-3*e+3*r}function xg(r,e){return 3*e-6*r}function _g(r){return 3*r}function Vo(r,e,t){return((wg(e,t)*r+xg(e,t))*r+_g(e))*r}function Eg(r,e,t){return 3*wg(e,t)*r*r+2*xg(e,t)*r+_g(e)}function qE(r,e,t,i,s){var n,a,o=0;do a=e+(t-e)/2,n=Vo(a,i,s)-r,n>0?t=a:e=a;while(Math.abs(n)>YE&&++o=jE?QE(l,p,e,i):f===0?p:qE(l,c,c+to,e,i)}return function(c){return c===0?0:c===1?1:Vo(o(c),t,s)}};const Yt=da(JE),ZE=Yt(0,0,1,1);function Dp(r,e){const t=e?e.split("."):[];for(;t.length&&r;){const i=t.shift(),s=new RegExp("(.+)\\[([0-9]*)\\]").exec(i);if(s!==null&&s.length==3){const n={arrName:s[1],arrIndex:s[2]};r[n.arrName]!==void 0?r=r[n.arrName][n.arrIndex]:r=void 0;continue}r=r[i]}return r}function eT(r,e,t){const i=e?e.split("."):[];for(;i.length&&r;){const s=i.shift(),n=new RegExp("(.+)\\[([0-9]*)\\]").exec(s);if(n!==null&&n.length==3){const a={arrName:n[1],arrIndex:n[2]};r[a.arrName]!==void 0&&i.length===0&&(r[a.arrName][a.arrIndex]=t);continue}r[s]===void 0&&(r[s]={}),i.length===0&&(r[s]=t),r=r[s]}return r}const Er=class Er{static updateObject(e,t,i){const s=Object.keys(t).sort((o,l)=>parseFloat(o)-parseFloat(l));let n="0";for(let o=s.length-2;o>=0;o--)if(parseFloat(s[o])<=i){n=s[o];break}let a="1";for(let o=1;oi){a=s[o];break}Object.keys(t[0]).forEach(o=>{let l=t[n][o],c=t[a][o];l==="inherit"&&(t[n][o]=Dp(e,o),l=t[n][o]),c==="inherit"&&(t[a][o]=Dp(e,o),c=t[a][o]);const u=l+(i-parseFloat(n))/(parseFloat(a)-parseFloat(n))*(c-l);eT(e,o,u)})}static stop(e,t=null){e!==void 0&&(t!==null&&this.animations.get(e)?.obj&&!this.animations.get(e).obj.destroyed&&this.updateObject(this.animations.get(e).obj,this.animations.get(e).animation,t),this.animations.delete(e))}static animate(e,t,i,s,n=()=>{},a){return a||=`${++this._id}`,this.animations.set(a,{obj:e,animation:t,speed:1/(60*i),progress:0,curve:s!==void 0?s:ZE,onend:n}),a}};Ms(Er,"animations",new Map),Ms(Er,"_id",0),Ft.shared.add(e=>{for(const[t,i]of Er.animations.entries())i.obj._destroyed?Er.stop(t):(i.progress=Math.min(1,i.progress+i.speed*e),Er.updateObject(i.obj,i.animation,i.curve(i.progress)),i.progress>=1&&(i.onend(i.obj),Er.stop(t,1)))});let It=Er;const mh=[{frequency:20,Q:.71},{frequency:75,gain:0},{frequency:100,gain:0,Q:.6},{frequency:250,gain:0,Q:.3},{frequency:1040,gain:0,Q:.41},{frequency:2500,gain:0,Q:.2},{frequency:7500,gain:0},{frequency:2e4,Q:.71}],Lp=[{freq:20,label:"20"},{freq:30,label:"30"},{freq:40,label:"40"},{freq:50,label:"50"},{freq:60,label:"60"},{freq:70,label:""},{freq:80,label:"80"},{freq:90,label:""},{freq:100,label:"100"},{freq:200,label:"200"},{freq:300,label:"300"},{freq:400,label:"400"},{freq:500,label:"500"},{freq:600,label:"600"},{freq:700,label:""},{freq:800,label:"800"},{freq:900,label:""},{freq:1e3,label:"1k"},{freq:2e3,label:"2k"},{freq:3e3,label:"3k"},{freq:4e3,label:"4k"},{freq:5e3,label:"5k"},{freq:6e3,label:"6k"},{freq:7e3,label:""},{freq:8e3,label:"8k"},{freq:9e3,label:""},{freq:1e4,label:"10k"},{freq:15e3,label:""},{freq:2e4,label:"20k"}],js=0,Ys=0,gs=1200,_t=400,zo=new Array(gs).fill(0).map((r,e)=>md(e)),tT=new Float32Array(zo);function jo(r){return Math.log(r/20)/Math.log(1102.5)*gs}function md(r){return Math.pow(1102.5,r/gs)*20}function as(r){return-r*6+_t/2}function Op(r){return-(r-_t/2)/6}class iT extends Pt{app;cachedReponse=new Array(gs).fill(0);onAudioLoad=this.onAudio.bind(this);points=[];icons;info;trackedFilter=null;constructor(e){super({title:"Audio Equalizer",width:600,height:245,win_id:"audio-eq"}),this.app=e,this.initView(),this.onAudioLoad(),$.on("audioLoaded",this.onAudioLoad)}destroy(){$.off("audioLoaded",this.onAudioLoad)}initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("eq-container");const t=document.createElement("div");t.classList.add("icon-container"),this.app.chartManager.chartAudio.getFilters().forEach((A,v)=>{const E=document.createElementNS("http://www.w3.org/2000/svg","svg");fetch(new URL(Object.assign({"../../../assets/svg/highpass.svg":UE,"../../../assets/svg/highshelf.svg":GE,"../../../assets/svg/lowpass.svg":HE,"../../../assets/svg/lowshelf.svg":WE,"../../../assets/svg/peaking.svg":VE})[`../../../assets/svg/${A.type}.svg`],self.location).href).then(C=>C.text()).then(C=>{const k=new DOMParser().parseFromString(C,"image/svg+xml").getElementsByTagName("svg")[0];for(const{name:N,value:H}of k.attributes)E.getAttribute(N)||E.setAttribute(N,H);E.replaceChildren(...k.children)}),E.setAttribute("fill",is[v]),E.classList.add("eq-icon"),E.style.backgroundColor=`${is[v]}40`,E.setAttribute("width","36px"),E.setAttribute("height","24px"),E.onclick=()=>{this.app.chartManager.chartAudio.getFilter(v).enabled?this.app.chartManager.chartAudio.disableFilter(v):this.app.chartManager.chartAudio.enableFilter(v),this.endTrack(),this.updateIcons()},E.onmouseenter=()=>this.points[v].highlight(),E.onmouseleave=()=>this.points[v].unhighlight(),t.appendChild(E)}),this.icons=t,this.updateIcons();const i=document.createElement("canvas");i.style.width="600px",i.style.height="200px",i.onmousedown=A=>{const v=this.points.filter(E=>E.hitTest(A.offsetX*2,A.offsetY*2)).at(-1);this.endTrack(),v?.mouseDown(A)};const s=document.createElement("div");s.classList.add("eq-info-container");const n=document.createElement("div");n.classList.add("eq-info");const a=document.createElement("div");a.innerText="Type",a.classList.add("eq-info-label");const o=document.createElement("div");o.classList.add("eq-info-value"),n.replaceChildren(a,o);const l=document.createElement("div");l.classList.add("eq-info");const c=document.createElement("div");c.innerText="Frequency",c.classList.add("eq-info-label");const u=document.createElement("div");u.contentEditable="false",u.classList.add("eq-info-value","inlineEdit"),l.replaceChildren(c,u),this.setupInput(u,"frequency",20,22050," Hz");const h=document.createElement("div");h.classList.add("eq-info");const d=document.createElement("div");d.innerText="Gain",d.classList.add("eq-info-label");const p=document.createElement("div");p.contentEditable="false",p.classList.add("eq-info-value","inlineEdit"),h.replaceChildren(d,p),this.setupInput(p,"gain",-24,24," dB",1);const f=document.createElement("div");f.classList.add("eq-info");const m=document.createElement("div");m.innerText="Q",m.classList.add("eq-info-label");const g=document.createElement("div");g.contentEditable="false",g.classList.add("eq-info-value","inlineEdit"),f.replaceChildren(m,g),this.setupInput(g,"Q",1e-4,1e3,"",4);const y=document.createElement("div");y.classList.add("eq-reset","disabled"),y.innerText="Reset",y.onclick=()=>{if(this.trackedFilter==null)for(let A=0;A{o=this.app.chartManager.chartAudio.getFilter(this.trackedFilter)[t].value,e.innerText=ne(o,a)+"",this.selectText(e)},e.onkeydown=l=>{if(l.key=="Enter"){e.blur();return}if(l.key=="Tab"){const u=[...e.parentElement.parentElement.children],h=u.indexOf(e.parentElement);for(let d=1;d{const c=gn(e.innerText);c!==null&&(this.app.chartManager.chartAudio.updateFilter(this.trackedFilter,{[t]:Ve(c,i,s)}),this.points[this.trackedFilter].refreshPoint(),this.getResponse())})},e.onblur=()=>{gn(e.innerText)===null&&(this.app.chartManager.chartAudio.updateFilter(this.trackedFilter,{[t]:Ve(o,i,s)}),this.points[this.trackedFilter].refreshPoint(),this.getResponse()),e.innerText=ne(this.app.chartManager.chartAudio.getFilter(this.trackedFilter)[t].value,a)+n}}onAudio(){this.points=this.app.chartManager.chartAudio.getFilters().map((e,t)=>new rT(this,t)),this.getResponse(),this.updateIcons(),this.endTrack()}getResponse(){this.cachedReponse=this.app.chartManager.chartAudio.getFrequencyResponse(zo)}drawEQ(e){const t=e.getContext("2d");t.canvas.width=1200,t.canvas.height=400;const i=()=>{this.app.chartManager.chartAudio&&(t.fillStyle="rgb(11, 14, 26)",t.fillRect(0,0,e.width,e.height),t.fillStyle="rgb(0, 50, 150)",this.drawFrequencies(t,this.app.chartManager.chartAudio.getFrequencyData()),this.app.chartManager.chartAudio.hasFilters()&&(t.fillStyle="rgba(200, 200, 200, 0.2)",this.drawFrequencies(t,this.app.chartManager.chartAudio.getFilteredFrequencyData())),t.fillStyle="rgba(200, 200, 200, 0.5)",this.drawResponse(t),t.fillStyle="rgba(0, 100, 150, 0.5)",t.font="22px Assistant",this.drawGrid(t),this.points.forEach(s=>s.draw(t)),e.closest("#windows")&&requestAnimationFrame(i))};return i}drawFrequencies(e,t){for(let i=0;i{this.app.chartManager.chartAudio.getFilter(t).enabled?e.classList.remove("disabled"):e.classList.add("disabled")}),this.getResponse()}trackFilter(e){this.trackedFilter=e;const t=this.app.chartManager.chartAudio.getFilter(e),[i,s,n,a]=[...this.info.children].map(o=>o.children[1]);i.innerText=t.type,s.innerText=Math.round(t.frequency.value)+" Hz",n.innerText=t.type.endsWith("pass")?"-":ne(t.gain.value,1)+" dB",a.innerText=t.type.endsWith("shelf")?"-":ne(t.Q.value,2)+"",i.style.color=is[e],s.style.color=is[e],n.style.color=is[e],a.style.color=is[e],s.contentEditable="true",n.contentEditable=`${!t.type.endsWith("pass")}`,a.contentEditable=`${!t.type.endsWith("shelf")}`}endTrack(){setTimeout(()=>{this.trackedFilter=null,this.points.forEach(n=>n.unhighlight());const[e,t,i,s]=[...this.info.children].map(n=>n.children[1]);e.innerText="",t.innerText="",i.innerText="",s.innerText="",t.contentEditable="false",i.contentEditable="false",s.contentEditable="false"})}}const io=16,is=["#a3001b","#a34f00","#d6d606","#19c402","#02c4ba","#022fc4","#5602c4","#c402b4"];class rT{filterIndex;window;dragging=!1;x=0;y=0;type;response=new Float32Array(zo.length);_empty=new Float32Array(zo.length);highlighted=!1;pointSize=.4;constructor(e,t){this.filterIndex=t,this.window=e,this.type=this.window.app.chartManager.chartAudio.getFilter(t).type,this.x=jo(this.window.app.chartManager.chartAudio.getFilter(t).frequency.value??10),this.getY()}hitTest(e,t){return(e-this.x)*(e-this.x)+(t-this.y)*(t-this.y)<=io*io}canChangeGain(){return this.type=="lowshelf"||this.type=="highshelf"||this.type=="peaking"}canChangeQ(){return!this.type.endsWith("shelf")}getY(){this.type.endsWith("shelf")?this.y=as(this.window.app.chartManager.chartAudio.getFilter(this.filterIndex).gain.value/2):this.canChangeGain()?this.y=as(this.window.app.chartManager.chartAudio.getFilter(this.filterIndex).gain.value??0):this.y=_t/2}getGain(){if(this.canChangeGain())return this.type.endsWith("shelf")?Op(this.y)*2:Op(this.y)}mouseDown(e){this.calcResponse(),this.dragging=!0,this.highlighted=!0,this.window.app.chartManager.chartAudio.getFilter(this.filterIndex).enabled||(this.window.app.chartManager.chartAudio.enableFilter(this.filterIndex),this.window.updateIcons());const t=this.x,i=this.y,s=e.clientX,n=e.clientY,a=l=>{this.x=(l.clientX-s)*2+t,this.canChangeGain()?this.y=(l.clientY-n)*2+i:this.y=_t/2,this.x=Ve(this.x,0,gs),this.y=Ve(this.y,this.type.endsWith("shelf")?_t/4:as(24),this.type.endsWith("shelf")?3*_t/4:as(-24)),this.window.app.chartManager.chartAudio.updateFilter(this.filterIndex,{frequency:md(this.x),gain:this.getGain()}),this.window.getResponse(),this.window.trackFilter(this.filterIndex),this.calcResponse()};this.window.trackFilter(this.filterIndex);const o=()=>{It.animate(this,{0:{pointSize:"inherit"},1:{pointSize:.3}},.3,Yt(.11,.71,.41,.86),()=>{},`eq-point${this.filterIndex}`),this.dragging=!1,window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",o)};It.animate(this,{0:{pointSize:"inherit"},1:{pointSize:.9}},.3,Yt(.11,.71,.41,.86),()=>{},`eq-point${this.filterIndex}`),window.addEventListener("mousemove",a),window.addEventListener("mouseup",o)}calcResponse(){this.window.app.chartManager.chartAudio.getFilter(this.filterIndex).getFrequencyResponse(tT,this.response,this._empty)}draw(e){const t=this.highlighted||this.window.app.chartManager.chartAudio.getFilter(this.filterIndex).enabled?is[this.filterIndex]:"#888888";if(e.fillStyle=t+"60",this.dragging)for(let i=0;i{navigator.clipboard.writeText(s.innerText)}),this.outputDiv=s;const n=document.createElement("div");n.classList.add("export-section-label"),n.innerText="Include",i.appendChild(n),Object.keys(this.exportOptions.include).forEach(o=>{const l=document.createElement("input");l.type="checkbox",l.checked=this.exportOptions.include[o],l.onchange=()=>{this.exportOptions.include[o]=l.checked,this.export()};const c=document.createElement("div");c.classList.add("export-label"),c.innerText=o;const u=document.createElement("div");u.replaceChildren(l,c),u.classList.add("export-option"),i.appendChild(u)});const a=document.createElement("div");a.classList.add("export-section-label"),a.innerText="Options",i.appendChild(a),Object.keys(this.exportOptions.options).forEach(o=>{const l=document.createElement("input");l.type="checkbox",l.checked=this.exportOptions.options[o],l.onchange=()=>{this.exportOptions.options[o]=l.checked,this.export()};const c=document.createElement("div");c.classList.add("export-label"),c.innerText=sT[o];const u=document.createElement("div");u.replaceChildren(l,c),u.classList.add("export-option"),i.appendChild(u)}),t.replaceChildren(i,s),e.appendChild(t),this.viewElement.appendChild(e)}export(){let e=`{ `+this.selection.map(t=>{let i=" {";return this.exportOptions.include.Beat&&(i+=this.padNum(t.beat)+","),this.exportOptions.include.Second&&(i+=this.padNum(t.second)+","),this.exportOptions.include.Column&&(this.exportOptions.options.columnOneBased?i+=t.col+1+",":i+=t.col+","),this.exportOptions.include.Type&&(i+='"'+t.type+'",'),this.exportOptions.include.Quantization&&(i+=t.quant+","),this.exportOptions.include.Length&&Be(t)&&(this.exportOptions.options.lengthAsNumberIndex?i+=this.padNum(t.hold)+",":i+="length="+this.padNum(t.hold)+","),i.endsWith(",")&&(i=i.slice(0,-1)),i+="}",i}).join(`, `)+` -}`;this.exportOptions.options.minify&&(e=e.replaceAll(/\s/g,"")),this.outputDiv.innerText=e}padNum(e){return this.exportOptions.options.padNumbers?(Math.round(e*1e3)/1e3).toFixed(3):Math.round(e*1e3)/1e3}}const Tr={"dance-single":[{label:"Left",keys:["Left","A"]},{label:"Down",keys:["Down","S"]},{label:"Up",keys:["Up","W"]},{label:"Right",keys:["Right","D"]}],"dance-double":[{label:"P1 Left",keys:["Left"]},{label:"P1 Down",keys:["Down"]},{label:"P1 Up",keys:["Up"]},{label:"P1 Right",keys:["Right"]},{label:"P2 Left",keys:["A"]},{label:"P2 Down",keys:["S"]},{label:"P2 Up",keys:["W"]},{label:"P2 Right",keys:["D"]}],"dance-couple":[{label:"P1 Left",keys:["Left"]},{label:"P1 Down",keys:["Down"]},{label:"P1 Up",keys:["Up"]},{label:"P1 Right",keys:["Right"]},{label:"P2 Left",keys:["A"]},{label:"P2 Down",keys:["S"]},{label:"P2 Up",keys:["W"]},{label:"P2 Right",keys:["D"]}],"dance-solo":[{label:"Left",keys:["Left","A"]},{label:"UpLeft",keys:["Q"]},{label:"Down",keys:["Down","S"]},{label:"Up",keys:["Up","W"]},{label:"UpRight",keys:["E"]},{label:"Right",keys:["Right","D"]}],"dance-solodouble":[{label:"P1 Left",keys:["A"]},{label:"P1 UpLeft",keys:["Q"]},{label:"P1 Down",keys:["S"]},{label:"P1 Up",keys:["W"]},{label:"P1 UpRight",keys:["E"]},{label:"P1 Right",keys:["D"]},{label:"P2 Left",keys:["J"]},{label:"P2 UpLeft",keys:["U"]},{label:"P2 Down",keys:["K"]},{label:"P2 Up",keys:["I"]},{label:"P2 UpRight",keys:["O"]},{label:"P2 Right",keys:["L"]}],"dance-threepanel":[{label:"UpLeft",keys:["Left","Q"]},{label:"Down",keys:["Down","S"]},{label:"UpRight",keys:["Right","E"]}],"dance-threedouble":[{label:"P1 UpLeft",keys:["Left"]},{label:"P1 Down",keys:["Down"]},{label:"P1 UpRight",keys:["Right"]},{label:"P2 UpLeft",keys:["Q"]},{label:"P2 Down",keys:["S"]},{label:"P2 UpRight",keys:["E"]}]};class $e{static app;static userKeybinds=new Map;static userGameplayKeybinds=new Map;static load(e){this.app=e;try{this.loadKeybinds()}catch(t){console.error("Failed to load user keybinds!"),console.error(t.stack),this.userKeybinds.clear(),this.userGameplayKeybinds.clear()}window.addEventListener("keydown",t=>this.checkKey(t,"keydown")),window.addEventListener("keyup",t=>this.checkKey(t,"keyup"))}static checkKey(e,t){if(e.target.classList.contains("inlineEdit")||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLInputElement||["Meta","Control","Shift","Alt"].includes(e.key))return;const i=[];for(let a=0;a(o[u]??c.keys).some(h=>s==h));if(l!=-1){if(e.preventDefault(),this.app.windowManager.getFocusedWindow()?.options?.win_id=="keybind_options"||this.app.windowManager.isBlocked())return;this.app.chartManager[t=="keydown"?"judgeCol":"judgeColUp"](l);return}}const n=Object.keys(dt).filter(a=>{for(const o of this.getCombosForKeybind(a))if(this.compareModifiers(o.mods,i)&&o.key==s)return!0;return!1}).map(a=>dt[a]);if(n.length>0){if(n.every(a=>a.preventDefault!=!1)&&e.preventDefault(),this.app.windowManager.getFocusedWindow()?.options?.win_id=="keybind_options"||this.app.windowManager.isBlocked())return;for(const a of n){let o=a.disabled;if(o instanceof Function&&(o=o(this.app)),!o&&!(a.disableRepeat&&e.repeat)){t=="keydown"?a.callback(this.app):a.callbackKeyUp?.(this.app);return}}}}static getKeyNameFromCode(e){let t=e;return t.startsWith("Digit")&&(t=t.slice(5)),t.startsWith("Key")&&(t=t.slice(3)),t in zp&&(t=zp[t]),t}static getKeybindString(e){return e in dt?dt[e].combos.map(i=>this.getComboString(i)).join(" / "):(console.warn("Couldn't find keybind with id "+e),"")}static getComboString(e){const t=vo.filter(i=>e.mods.includes(i)).map(i=>_T[i]).join("");return t+(t!=""?" ":"")+e.key}static getCombosForKeybind(e){return e in dt?this.userKeybinds.get(e)??dt[e].combos:(console.log("Couldn't find keybind with id "+e),[])}static getKeysForGameType(e){const t=Ke.getGameType(e);return t?new Array(t.numCols).fill(null).map((i,s)=>this.userGameplayKeybinds.get(e)?.[s]??Tr[e]?.[s].keys??[]):(console.log("Couldn't find game type with id "+e),[])}static compareModifiers(e,t){if(e.length!=t.length)return!1;for(const i of vo)if((e.includes(i)?1:0)+(t.includes(i)?1:0)==1)return!1;return!0}static compareCombos(e,t){return e.key==t.key&&this.compareModifiers(e.mods,t.mods)}static loadKeybinds(){const e=localStorage.getItem("keybinds");if(e){const i=JSON.parse(e);if(typeof i!="object")return console.error("Couldn't load keybinds from storage");for(const[s,n]of Object.entries(i)){if(!(s in dt)){console.warn("Couldn't load keybind "+s+": key doesn't exist");continue}Array.isArray(n)||console.warn("Couldn't load keybind "+s+": value is not an array"),this.userKeybinds.set(s,n.filter(a=>typeof a.key!="string"||!Array.isArray(a.mods)?(console.warn("Couldn't load keycombo for keybind "+s+": "+JSON.stringify(a)),!1):!0))}}const t=localStorage.getItem("keybindsGP");if(t){const i=JSON.parse(t);if(typeof i!="object")return console.error("Couldn't load gameplay keybinds from storage");for(const[s,n]of Object.entries(i)){if(!Ke.getGameType(s)){console.warn("Couldn't load gameplay keybinds for gameType "+s+": gameType doesn't exist");continue}Array.isArray(n)||console.warn("Couldn't load gameplay keybind "+s+": value is not an array"),this.userGameplayKeybinds.set(s,n.map((a,o)=>!Array.isArray(a)&&a!==null?(console.warn("Couldn't load gameplay keys for type "+s+" col "+o+": "+JSON.stringify(a)),null):a))}}}static clearSave(){localStorage.removeItem("keybinds"),localStorage.removeItem("keybindsGP")}static setKeybind(e,t){this.userKeybinds.has(e)||this.userKeybinds.set(e,[...dt[e].combos]),this.userKeybinds.get(e)?.push(t),this.checkIsDefault(e),this.saveKeybinds()}static removeKeybind(e,t){this.userKeybinds.has(e)||this.userKeybinds.set(e,[...dt[e].combos]),this.userKeybinds.set(e,this.userKeybinds.get(e).filter(i=>!this.compareCombos(i,t))),this.checkIsDefault(e),this.saveKeybinds()}static revertKeybind(e){this.userKeybinds.delete(e),this.saveKeybinds()}static revertGameplayKeybind(e,t){this.userGameplayKeybinds.has(e)&&(this.userGameplayKeybinds.get(e)[t]=null,this.userGameplayKeybinds.get(e).every(i=>i===null)&&this.userGameplayKeybinds.delete(e)),this.saveKeybinds()}static setGameplayKeybind(e,t,i){this.userGameplayKeybinds.has(e)||this.userGameplayKeybinds.set(e,new Array(Ke.getGameType(e).numCols).fill(null)),this.userGameplayKeybinds.get(e)[t]==null&&(this.userGameplayKeybinds.get(e)[t]=[...Tr[e]?.[t].keys??[]]),this.userGameplayKeybinds.get(e)[t].push(i),this.checkIsDefaultGameplay(e,t),this.saveKeybinds()}static removeGameplayKeybind(e,t,i){this.userGameplayKeybinds.has(e)||this.userGameplayKeybinds.set(e,new Array(Ke.getGameType(e).numCols).fill(null)),this.userGameplayKeybinds.get(e)[t]==null&&(this.userGameplayKeybinds.get(e)[t]=[...Tr[e]?.[t].keys??[]]),this.userGameplayKeybinds.get(e)[t]=this.userGameplayKeybinds.get(e)[t].filter(s=>s!=i),this.checkIsDefaultGameplay(e,t),this.saveKeybinds()}static checkIsDefault(e){if(!this.userKeybinds.has(e))return!0;const t=this.userKeybinds.get(e),i=[...dt[e].combos];return t.length!=i.length?!1:t.map(s=>this.getComboString(s)).sort().join("∆")==i.map(s=>this.getComboString(s)).sort().join("∆")?(this.userKeybinds.delete(e),!0):!1}static checkIsDefaultGameplay(e,t){if(!this.userGameplayKeybinds.has(e)||this.userGameplayKeybinds.get(e)[t]===null)return!0;const i=this.userGameplayKeybinds.get(e)[t],s=[...Tr[e]?.[t].keys??[]];return i.length!=s.length?!1:i.sort().join("∆")==s.sort().join("∆")?(this.userGameplayKeybinds.get(e)[t]=null,this.userGameplayKeybinds.get(e).every(n=>n===null)&&this.userGameplayKeybinds.delete(e),!0):!1}static saveKeybinds(){const e={};for(const[i,s]of this.userKeybinds.entries())e[i]=s;localStorage.setItem("keybinds",JSON.stringify(e));const t={};for(const[i,s]of this.userGameplayKeybinds.entries())t[i]=s;localStorage.setItem("keybindsGP",JSON.stringify(t))}}class Tg extends Pt{app;allowMods;callback;combo={mods:[],key:""};conflictCheck;listener;constructor(e,t,i,s){super({title:"",width:300,height:168,disableClose:!0,win_id:"keyComboSelector",blocking:!0}),this.app=e,this.allowMods=t,this.callback=i,this.conflictCheck=s??(()=>[]),this.initView()}initView(){this.viewElement.replaceChildren(),this.viewElement.classList.add("confirmation");const e=document.createElement("div");e.classList.add("padding"),e.style.gap="8px";const t=document.createElement("div");t.classList.add("label"),t.innerText="Input a key combo and select Ok when finished.",e.appendChild(t);const i=document.createElement("input");i.type="text",i.disabled=!0,i.style.fontSize="18px",i.style.height="24px",i.style.flex="0",i.style.textAlign="center",e.appendChild(i);const s=document.createElement("div");s.classList.add("detail"),s.innerText="No conflicts",s.style.flex="1",e.appendChild(s);const n=document.createElement("div");n.classList.add("menu-options");const a=document.createElement("button");a.innerText="Ok",a.onclick=()=>{this.callback(this.combo),this.closeWindow()},a.classList.add("confirm"),a.disabled=!0;const o=document.createElement("button");o.innerText="Cancel",o.onclick=()=>{this.closeWindow()},n.append(a),n.append(o),e.appendChild(n),this.viewElement.appendChild(e),this.listener=l=>{if(["Meta","Control","Shift","Alt","Escape"].includes(l.key))return;if(this.combo.key=$e.getKeyNameFromCode(l.code),this.allowMods){const u=[];for(let h=0;h=3?s.innerText=`Conflicts with ${c.length} keybinds`:c.length>=1?s.innerText=`Conflicts with ${c.join(",")}`:s.innerText="No conflicts"),l.preventDefault()},window.addEventListener("keydown",this.listener)}onClose(){window.removeEventListener("keydown",this.listener)}}class aT extends Pt{app;observer;conflictMap=this.calculateConflicts();constructor(e){super({title:"Gameplay Keybind Options",width:600,height:400,disableClose:!1,win_id:"gameplay_keybind_options",blocking:!1}),this.app=e,this.initView()}initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("pref-container");const i=document.createElement("div");i.classList.add("pref-scrollers");const s=document.createElement("div");s.classList.add("pref-section-scroller");const n=document.createElement("div");n.classList.add("pref-option-scroller"),i.replaceChildren(s,n),this.observer=new IntersectionObserver(a=>{a.forEach(o=>{const l=o.target.dataset.id,c=s.querySelector(`.pref-section[data-id=${l}]`);c&&(o.intersectionRatio>0?c.classList.add("selected"):c.classList.remove("selected"))})},{}),t.replaceChildren(i),s.replaceChildren(...this.createSections()),n.replaceChildren(...this.createOptions()),e.appendChild(t),this.viewElement.appendChild(e)}createSections(){return Object.keys(Ke.getTypes()).map(e=>this.createEmptySection(e))}createOptions(){return Object.keys(Ke.getTypes()).map(e=>{const t=new Array(Ke.getTypes()[e].numCols).fill(null).map((n,a)=>this.createKeybindItem(e,a)),i=document.createElement("div");i.classList.add("pref-group"),i.dataset.id=e;const s=document.createElement("div");return s.classList.add("pref-group-label"),s.innerText=e,i.replaceChildren(s,...t),this.observer.observe(i),i})}createEmptySection(e){const t=document.createElement("div");return t.classList.add("pref-section"),t.dataset.id=e,t.innerText=e,t.onclick=()=>{t.parentElement.parentElement.querySelector(`.pref-group[data-id=${e}]`).scrollIntoView()},t}createKeybindItem(e,t){const i=document.createElement("div");i.classList.add("pref-keybind"),i.dataset.id=e+"-"+t,i.onclick=o=>{o.target.classList.contains("pref-keybind-combo")||o.target.tagName=="IMG"||this.app.windowManager.openWindow(new Tg(this.app,!1,l=>{$e.setGameplayKeybind(e,t,l.key),this.conflictMap=this.calculateConflicts(),i.replaceWith(this.createKeybindItem(e,t))},l=>{const c=this.conflictMap.get(e)?.get(l.key)?.map(u=>Tr[u[0]]?.[u[1]].label??"Column "+u[1])??[];return c.includes(Tr[e]?.[t].label??"Column "+t)?"self":c}))};const s=document.createElement("div");s.classList.add("pref-keybind-label"),s.innerText=Tr[e]?.[t].label??"Column "+t;const n=document.createElement("img");n.src=He.REVERT,n.style.width="12px",n.addEventListener("click",()=>{$e.revertGameplayKeybind(e,t),this.conflictMap=this.calculateConflicts(),i.replaceWith(this.createKeybindItem(e,t))}),n.style.display=$e.checkIsDefaultGameplay(e,t)?"none":"block";const a=document.createElement("div");return a.classList.add("pref-keybind-combos"),a.replaceChildren(...$e.getKeysForGameType(e)[t].map(o=>{const l=document.createElement("button");return l.classList.add("pref-keybind-combo"),l.innerText=o,this.conflictMap.get(e).get(o).length>1&&l.classList.add("conflict"),l.onclick=()=>{$e.removeGameplayKeybind(e,t,o),this.conflictMap=this.calculateConflicts(),i.replaceWith(this.createKeybindItem(e,t))},l})),i.replaceChildren(s,n,a),i}calculateConflicts(){const e=new Map;Object.keys(Ke.getTypes()).forEach(t=>{const i=new Map;$e.getKeysForGameType(t).forEach((s,n)=>{s.forEach((a,o)=>{i.has(a)||i.set(a,[]),i.get(a).push([t,n,o])})}),e.set(t,i)}),[...this.viewElement.querySelectorAll(".pref-keybind-combo.conflict")].forEach(t=>t.classList.remove("conflict"));for(const t of e.values())for(const i of t.values())i.length!=1&&i.forEach(s=>{const n=this.viewElement.querySelector(`.pref-keybind[data-id=${s[0]}-${s[1]}] .pref-keybind-combos`);n?.children[s[2]]&&n.children[s[2]].classList.add("conflict")});return e}onClose(){this.observer?.disconnect()}}const Vn={file:{type:"menu",title:"File",options:[{type:"selection",id:"newSong"},{type:"selection",id:"openSong"},{type:"separator"},{type:"selection",id:"save"},{type:"selection",id:"export"}]},edit:{type:"menu",title:"Edit",options:[{type:"selection",id:"cut"},{type:"selection",id:"copy"},{type:"selection",id:"paste"},{type:"separator"},{type:"selection",id:"undo"},{type:"selection",id:"redo"},{type:"separator"},{type:"checkbox",id:"mousePlacement",checked:()=>_.chart.mousePlacement}]},view:{type:"menu",title:"View",options:[{type:"dropdown",title:"Cursor",options:[{type:"selection",id:"cursorUp"},{type:"selection",id:"cursorDown"},{type:"separator"},{type:"selection",id:"previousNote"},{type:"selection",id:"nextNote"},{type:"separator"},{type:"selection",id:"previousMeasure"},{type:"selection",id:"nextMeasure"},{type:"separator"},{type:"selection",id:"jumpChartStart"},{type:"selection",id:"jumpChartEnd"},{type:"separator"},{type:"selection",id:"jumpSongStart"},{type:"selection",id:"jumpSongEnd"}]},{type:"dropdown",title:"Snap",options:[{type:"selection",id:"decreaseSnap"},{type:"selection",id:"increaseSnap"}]},{type:"dropdown",title:"Scroll",options:[{type:"checkbox",id:"XMod",checked:()=>!_.chart.CMod},{type:"checkbox",id:"CMod",checked:()=>_.chart.CMod},{type:"separator"},{type:"selection",id:"increaseScrollSpeed"},{type:"selection",id:"decreaseScrollSpeed"}]},{type:"dropdown",title:"Zoom",options:[{type:"selection",id:"zoomIn"},{type:"selection",id:"zoomOut"},{type:"separator"},{type:"selection",id:"zoomDefault"}]},{type:"dropdown",title:"Waveform",options:[{type:"checkbox",id:"renderWaveform",checked:()=>_.chart.waveform.enabled},{type:"selection",id:"waveformOptions"}]},{type:"separator"},{type:"selection",id:"playMode"},{type:"selection",id:"playModeStart"},{type:"separator"},{type:"selection",id:"recordMode"},{type:"selection",id:"recordModeStart"},{type:"separator"},{type:"checkbox",id:"hideWarpedArrows",checked:()=>_.chart.hideWarpedArrows},{type:"checkbox",id:"hideFakedArrows",checked:()=>_.chart.hideFakedArrows},{type:"checkbox",id:"doSpeedChanges",checked:()=>_.chart.doSpeedChanges}]},chart:{type:"menu",title:"Chart",options:[{type:"selection",id:"openChart"},{type:"separator"},{type:"selection",id:"songProperties"},{type:"separator"},{type:"selection",id:"timingDataRow"}]},selection:{type:"menu",title:"Selection",options:[{type:"dropdown",title:"Convert",options:[{type:"selection",id:"convertHoldsRolls"},{type:"selection",id:"convertRollsHolds"},{type:"selection",id:"swapHoldsRolls"},{type:"separator"},{type:"selection",id:"convertHoldsTaps"},{type:"selection",id:"convertTapsMines"},{type:"selection",id:"convertTapsLifts"},{type:"selection",id:"convertTapsFakes"}]},{type:"dropdown",title:"Mirror",options:[{type:"selection",id:"mirrorHorizontally"},{type:"selection",id:"mirrorVertically"},{type:"selection",id:"mirrorBoth"}]},{type:"dropdown",title:"Stretch",options:[{type:"selection",id:"expand2to1"},{type:"selection",id:"expand3to2"},{type:"selection",id:"expand4to3"},{type:"separator"},{type:"selection",id:"compress1to2"},{type:"selection",id:"compress2to3"},{type:"selection",id:"compress3to4"}]},{type:"dropdown",title:"Quantize",options:[{type:"selection",id:"quantize4th"},{type:"selection",id:"quantize8th"},{type:"selection",id:"quantize12th"},{type:"selection",id:"quantize16th"},{type:"selection",id:"quantize24th"},{type:"selection",id:"quantize32nd"},{type:"selection",id:"quantize48th"},{type:"selection",id:"quantize96th"}]},{type:"separator"},{type:"selection",id:"setSongPreview"},{type:"separator"},{type:"selection",id:"exportNotedata"},{type:"separator"},{type:"selection",id:"selectAll"}]},audio:{type:"menu",title:"Audio",options:[{type:"selection",id:"adjustOffset"},{type:"checkbox",id:"assistTick",checked:()=>_.audio.assistTick&&Ie.assist},{type:"checkbox",id:"metronome",checked:()=>_.audio.metronome&&Ie.assist},{type:"separator"},{type:"dropdown",title:()=>"Master Volume ("+Math.round(_.audio.masterVolume*100)+"%)",options:[{type:"selection",id:"volumeUp"},{type:"selection",id:"volumeDown"}]},{type:"dropdown",title:()=>"Song Volume ("+Math.round(_.audio.songVolume*100)+"%)",options:[{type:"selection",id:"songVolumeUp"},{type:"selection",id:"songVolumeDown"}]},{type:"dropdown",title:()=>"Effect Volume ("+Math.round(_.audio.soundEffectVolume*100)+"%)",options:[{type:"selection",id:"effectvolumeUp"},{type:"selection",id:"effectvolumeDown"}]},{type:"dropdown",title:()=>"Playback rate ("+Math.round(_.audio.rate*100)+"%)",options:[{type:"selection",id:"rateUp"},{type:"selection",id:"rateDown"},{type:"separator"},{type:"selection",id:"rateDefault"}]},{type:"separator"},{type:"selection",id:"showEq"}]},preferences:{type:"menu",title:"Preferences",options:[{type:"selection",id:"options"},{type:"selection",id:"keybinds"},{type:"selection",id:"gameplayKeybinds"}]}},Fp=["cut","copy","paste"],Np={edit:[{ids:["delete"],after:"redo"},{ids:["previousNoteType","nextNoteType","noteTypeTap","noteTypeMine","noteTypeFake","noteTypeLift","quant4","quant8","quant12","quant16","quant24","quant32","quant48","quant96","quant192"],after:"mousePlacement"}],view:[{ids:["playback","selectRegion"]}],debug:[{ids:["showFPSCounter","showDebugTimers"]}]};class Di extends Pt{static GROUPS;app;observer;searchDropdown;conflictMap=this.calculateConflicts();constructor(e){super({title:"Keybind Options",width:600,height:400,disableClose:!1,win_id:"keybind_options",blocking:!1}),this.app=e,Di.GROUPS||(Di.GROUPS=Di.createGroups()),this.initView()}initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("pref-container");const i=document.createElement("div");i.classList.add("pref-search");const s=document.createElement("input");s.classList.add("pref-search-bar"),s.type="text",s.placeholder="Search for a keybind...",s.oninput=()=>{o.replaceChildren(...this.createSections(s.value)),l.replaceChildren(...this.createOptions(s.value))};const n=pi.create(["Name","Key"],"Name");n.onChange(()=>{o.replaceChildren(...this.createSections(s.value)),l.replaceChildren(...this.createOptions(s.value))}),this.searchDropdown=n,i.replaceChildren(s,n.view);const a=document.createElement("div");a.classList.add("pref-scrollers");const o=document.createElement("div");o.classList.add("pref-section-scroller");const l=document.createElement("div");l.classList.add("pref-option-scroller"),a.replaceChildren(o,l),this.observer=new IntersectionObserver(c=>{c.forEach(u=>{const h=u.target.dataset.id,d=o.querySelector(`.pref-section[data-id=${h}]`);d&&(u.intersectionRatio>0?d.classList.add("selected"):d.classList.remove("selected"))})},{}),t.replaceChildren(i,a),o.replaceChildren(...this.createSections()),l.replaceChildren(...this.createOptions()),e.appendChild(t),this.viewElement.appendChild(e)}createSections(e=""){return Object.keys(Di.GROUPS).filter(t=>Di.GROUPS[t].some(i=>this.filterID(e,i))).map(t=>this.createEmptySection(Vn[t]?.title??Ec(t),t))}createOptions(e=""){return Object.keys(Di.GROUPS).filter(t=>Di.GROUPS[t].some(i=>this.filterID(e,i))).map(t=>{const i=Di.GROUPS[t].filter(a=>this.filterID(e,a)).map(a=>this.createKeybindItem(a)),s=document.createElement("div");s.classList.add("pref-group"),s.dataset.id=t;const n=document.createElement("div");return n.classList.add("pref-group-label"),n.innerText=Vn[t]?.title??Ec(t),s.replaceChildren(n,...i),this.observer.observe(s),s})}static createGroups(){const e=Object.keys(dt),t={};return Object.keys(Vn).forEach(i=>{t[i]=this.expandMenubarOptions(Vn[i]).map(s=>{const n=e.indexOf(s);return n!=-1&&e.splice(n,1),s}).filter(s=>!Fp.includes(s))}),Object.keys(Np).forEach(i=>{t[i]===void 0&&(t[i]=[]),Np[i].forEach(s=>{const n=s.after?t[i].findIndex(a=>s.after==a)+1:0;t[i].splice(n,0,...s.ids),s.ids.forEach(a=>{const o=e.indexOf(a);o!=-1&&e.splice(o,1)})})}),Fp.forEach(i=>{const s=e.indexOf(i);s!=-1&&e.splice(s,1)}),e.length>0&&(console.warn("Missing keybinds not shown:"),console.warn(e)),t}filterID(e,t){if((this.searchDropdown?.value??"Name")=="Name")return(dt[t].bindLabel??dt[t].label).toLowerCase().includes(e.toLowerCase());{const i=$e.getCombosForKeybind(t);if(i.some(n=>n.key.toLowerCase().includes(e.toLowerCase())))return!0;let s=e.split(" ").map(n=>n.toLowerCase());return i.some(n=>(s.includes("shift")||s.includes("⇧"))&&!n.mods.includes(zn.SHIFT)||(s.includes("ctrl")||s.includes("control")||s.includes("⌃"))&&!n.mods.includes(zn.CTRL)||(s.includes("meta")||s.includes("cmd")||s.includes("command")||s.includes("⌘"))&&!n.mods.includes(zn.META)||(s.includes("alt")||s.includes("⌥"))&&!n.mods.includes(zn.ALT)?!1:(s=s.filter(a=>!["shift","ctrl","control","meta","cmd","command","alt","⇧","⌃","⌘","⌥",""].includes(a)),s.length==0||s.length==1&&n.key.toLowerCase().includes(s[0])))}}static expandMenubarOptions(e){switch(e.type){case"menu":case"dropdown":return e.options.map(t=>this.expandMenubarOptions(t)).flat();case"selection":case"checkbox":return[e.id];case"separator":return[]}}createEmptySection(e,t){const i=document.createElement("div");return i.classList.add("pref-section"),i.dataset.id=t,i.innerText=e,i.onclick=()=>{i.parentElement.parentElement.querySelector(`.pref-group[data-id=${t}]`).scrollIntoView()},i}createKeybindItem(e){const t=document.createElement("div");t.classList.add("pref-keybind"),t.dataset.id=e,t.onclick=a=>{a.target.classList.contains("pref-keybind-combo")||a.target.tagName=="IMG"||this.app.windowManager.openWindow(new Tg(this.app,!0,o=>{$e.setKeybind(e,o),this.conflictMap=this.calculateConflicts(),t.replaceWith(this.createKeybindItem(e))},o=>{const l=this.conflictMap.get($e.getComboString(o))?.map(c=>c[0]).map(c=>dt[c].bindLabel??dt[c].label)??[];return l.includes(e)?"self":l}))};const i=document.createElement("div");i.classList.add("pref-keybind-label"),i.innerText=dt[e].bindLabel??dt[e].label;const s=document.createElement("img");s.src=He.REVERT,s.style.width="12px",s.addEventListener("click",()=>{$e.revertKeybind(e),this.conflictMap=this.calculateConflicts(),t.replaceWith(this.createKeybindItem(e))}),s.style.display=$e.checkIsDefault(e)?"none":"block";const n=document.createElement("div");return n.classList.add("pref-keybind-combos"),n.replaceChildren(...$e.getCombosForKeybind(e).map(a=>{const o=document.createElement("button");return o.classList.add("pref-keybind-combo"),o.innerText=$e.getComboString(a),this.conflictMap.get($e.getComboString(a)).length>1&&o.classList.add("conflict"),o.onclick=()=>{$e.removeKeybind(e,a),this.conflictMap=this.calculateConflicts(),t.replaceWith(this.createKeybindItem(e))},o})),t.replaceChildren(i,s,n),t}calculateConflicts(){const e=new Map;Object.keys(dt).forEach(t=>{$e.getCombosForKeybind(t).forEach((i,s)=>{const n=$e.getComboString(i);e.has(n)||e.set(n,[]),e.get(n).push([t,s])})}),[...this.viewElement.querySelectorAll(".pref-keybind-combo.conflict")].forEach(t=>t.classList.remove("conflict"));for(const t of e.values())t.length!=1&&t.forEach(i=>{const s=this.viewElement.querySelector(`.pref-keybind[data-id=${i[0]}] .pref-keybind-combos`);s?.children[i[1]]&&s.children[i[1]].classList.add("conflict")});return e}onClose(){this.observer?.disconnect()}}function $t(r){return!!r.simfileTimingData}class Sg{_cache={warpedBeats:new Map,beatsToSeconds:new Map};columns={};offset;buildBeatTimingDataCache(){const e=[];let t=this.getTimingData("BPMS","STOPS","WARPS","DELAYS");t=t.concat(this.getTimingData("WARPS").map(n=>({type:"WARP_DEST",beat:n.beat+n.value,value:n.value})));const i=["WARP_DEST","BPMS","STOPS","WARPS","DELAYS"];t.sort((n,a)=>n.beat==a.beat?i.indexOf(n.type)-i.indexOf(a.type):n.beat-a.beat);const s=this.getOffset();e.push({beat:0,secondBefore:-s,secondOf:-s,secondAfter:-s,secondClamp:-s,bpm:this.getTimingData("BPMS")[0]?.value??120,warped:!1});for(const n of t){if(e.at(-1)?.beat!=n.beat){e.at(-1).secondClamp=Math.max(Math.max(e.at(-2)?.secondClamp??-s,e.at(-2)?.secondAfter??-s),e.at(-1).secondBefore);let a=(n.beat-e.at(-1).beat)*60/e.at(-1).bpm;e.at(-1).warped&&(a=0),e.push({beat:n.beat,secondBefore:e.at(-1).secondAfter+a,secondOf:e.at(-1).secondAfter+a,secondAfter:e.at(-1).secondAfter+a,secondClamp:0,bpm:e.at(-1).bpm,warped:e.at(-1).warped})}n.type=="WARPS"&&(e.at(-1).warped=!0),n.type=="WARP_DEST"&&(e.at(-1).warped=!1),n.type=="BPMS"&&(e.at(-1).bpm=n.value),n.type=="STOPS"&&(e.at(-1).secondAfter+=n.value),n.type=="DELAYS"&&(e.at(-1).secondOf+=n.value,e.at(-1).secondAfter+=n.value)}e.at(-1).secondClamp=Math.max(e.at(-2)?.secondClamp??-s,e.at(-1).secondBefore),this._cache.beatTiming=e,this._cache.warpedBeats.clear(),this._cache.beatsToSeconds.clear()}buildEffectiveBeatTimingDataCache(){const e=[...this.getTimingData("SCROLLS")];let t=0;if(e.length==0){this._cache.effectiveBeatTiming=[];return}e[0].beat!=0&&e.unshift({type:"SCROLLS",beat:0,value:1}),t=e[0].beat;for(let i=0;is[t])}mergeColumns(e){if(e.length==0)return[];for(e=e.filter(t=>t.length>0);e.length>1;){const t=[];for(let i=0;i=e.length)return n.concat(t.slice(s))}else if(n.push(t[s]),s++,s>=t.length)return n.concat(e.slice(i))}splitEvents(e){const t=new Map;return e.forEach(i=>{t.has(i.type)||t.set(i.type,[]),t.get(i.type).push(i)}),t}splitEventPairs(e){const t=new Map;return e.forEach(i=>{t.has(i[0].type)||t.set(i[0].type,[]),t.get(i[0].type).push(i)}),t}parse(e,t){if(e=="OFFSET"){this.offset=parseFloat(t);return}e in this.columns||this.createColumn(e),this.parseEvents(e,t)}setOffset(e){const t=this.offset;ht.instance.run({action:()=>{this.offset=e,this.reloadCache(["OFFSET"]),$.emit("timingModified"),$.emit("chartModified")},undo:()=>{this.offset=t,this.reloadCache(["OFFSET"]),$.emit("timingModified"),$.emit("chartModified")}})}serialize(e){this.reloadCache();let t="";this.offset&&(t+="#OFFSET:"+this.offset+`; +}`;this.exportOptions.options.minify&&(e=e.replaceAll(/\s/g,"")),this.outputDiv.innerText=e}padNum(e){return this.exportOptions.options.padNumbers?(Math.round(e*1e3)/1e3).toFixed(3):Math.round(e*1e3)/1e3}}const Sr={"dance-single":[{label:"Left",keys:["Left","A"]},{label:"Down",keys:["Down","S"]},{label:"Up",keys:["Up","W"]},{label:"Right",keys:["Right","D"]}],"dance-double":[{label:"P1 Left",keys:["Left"]},{label:"P1 Down",keys:["Down"]},{label:"P1 Up",keys:["Up"]},{label:"P1 Right",keys:["Right"]},{label:"P2 Left",keys:["A"]},{label:"P2 Down",keys:["S"]},{label:"P2 Up",keys:["W"]},{label:"P2 Right",keys:["D"]}],"dance-couple":[{label:"P1 Left",keys:["Left"]},{label:"P1 Down",keys:["Down"]},{label:"P1 Up",keys:["Up"]},{label:"P1 Right",keys:["Right"]},{label:"P2 Left",keys:["A"]},{label:"P2 Down",keys:["S"]},{label:"P2 Up",keys:["W"]},{label:"P2 Right",keys:["D"]}],"dance-solo":[{label:"Left",keys:["Left","A"]},{label:"UpLeft",keys:["Q"]},{label:"Down",keys:["Down","S"]},{label:"Up",keys:["Up","W"]},{label:"UpRight",keys:["E"]},{label:"Right",keys:["Right","D"]}],"dance-solodouble":[{label:"P1 Left",keys:["A"]},{label:"P1 UpLeft",keys:["Q"]},{label:"P1 Down",keys:["S"]},{label:"P1 Up",keys:["W"]},{label:"P1 UpRight",keys:["E"]},{label:"P1 Right",keys:["D"]},{label:"P2 Left",keys:["J"]},{label:"P2 UpLeft",keys:["U"]},{label:"P2 Down",keys:["K"]},{label:"P2 Up",keys:["I"]},{label:"P2 UpRight",keys:["O"]},{label:"P2 Right",keys:["L"]}],"dance-threepanel":[{label:"UpLeft",keys:["Left","Q"]},{label:"Down",keys:["Down","S"]},{label:"UpRight",keys:["Right","E"]}],"dance-threedouble":[{label:"P1 UpLeft",keys:["Left"]},{label:"P1 Down",keys:["Down"]},{label:"P1 UpRight",keys:["Right"]},{label:"P2 UpLeft",keys:["Q"]},{label:"P2 Down",keys:["S"]},{label:"P2 UpRight",keys:["E"]}]};class $e{static app;static userKeybinds=new Map;static userGameplayKeybinds=new Map;static load(e){this.app=e;try{this.loadKeybinds()}catch(t){console.error("Failed to load user keybinds!"),console.error(t.stack),this.userKeybinds.clear(),this.userGameplayKeybinds.clear()}window.addEventListener("keydown",t=>this.checkKey(t,"keydown")),window.addEventListener("keyup",t=>this.checkKey(t,"keyup"))}static checkKey(e,t){if(e.target.classList.contains("inlineEdit")||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLInputElement||["Meta","Control","Shift","Alt"].includes(e.key))return;const i=[];for(let a=0;a(o[u]??c.keys).some(h=>s==h));if(l!=-1){if(e.preventDefault(),this.app.windowManager.getFocusedWindow()?.options?.win_id=="keybind_options"||this.app.windowManager.isBlocked())return;this.app.chartManager[t=="keydown"?"judgeCol":"judgeColUp"](l);return}}const n=Object.keys(dt).filter(a=>{for(const o of this.getCombosForKeybind(a))if(this.compareModifiers(o.mods,i)&&o.key==s)return!0;return!1}).map(a=>dt[a]);if(n.length>0){if(n.every(a=>a.preventDefault!=!1)&&e.preventDefault(),this.app.windowManager.getFocusedWindow()?.options?.win_id=="keybind_options"||this.app.windowManager.isBlocked())return;for(const a of n){let o=a.disabled;if(o instanceof Function&&(o=o(this.app)),!o&&!(a.disableRepeat&&e.repeat)){t=="keydown"?a.callback(this.app):a.callbackKeyUp?.(this.app);return}}}}static getKeyNameFromCode(e){let t=e;return t.startsWith("Digit")&&(t=t.slice(5)),t.startsWith("Key")&&(t=t.slice(3)),t in zp&&(t=zp[t]),t}static getKeybindString(e){return e in dt?dt[e].combos.map(i=>this.getComboString(i)).join(" / "):(console.warn("Couldn't find keybind with id "+e),"")}static getComboString(e){const t=vo.filter(i=>e.mods.includes(i)).map(i=>_T[i]).join("");return t+(t!=""?" ":"")+e.key}static getCombosForKeybind(e){return e in dt?this.userKeybinds.get(e)??dt[e].combos:(console.log("Couldn't find keybind with id "+e),[])}static getKeysForGameType(e){const t=Ke.getGameType(e);return t?new Array(t.numCols).fill(null).map((i,s)=>this.userGameplayKeybinds.get(e)?.[s]??Sr[e]?.[s].keys??[]):(console.log("Couldn't find game type with id "+e),[])}static compareModifiers(e,t){if(e.length!=t.length)return!1;for(const i of vo)if((e.includes(i)?1:0)+(t.includes(i)?1:0)==1)return!1;return!0}static compareCombos(e,t){return e.key==t.key&&this.compareModifiers(e.mods,t.mods)}static loadKeybinds(){const e=localStorage.getItem("keybinds");if(e){const i=JSON.parse(e);if(typeof i!="object")return console.error("Couldn't load keybinds from storage");for(const[s,n]of Object.entries(i)){if(!(s in dt)){console.warn("Couldn't load keybind "+s+": key doesn't exist");continue}Array.isArray(n)||console.warn("Couldn't load keybind "+s+": value is not an array"),this.userKeybinds.set(s,n.filter(a=>typeof a.key!="string"||!Array.isArray(a.mods)?(console.warn("Couldn't load keycombo for keybind "+s+": "+JSON.stringify(a)),!1):!0))}}const t=localStorage.getItem("keybindsGP");if(t){const i=JSON.parse(t);if(typeof i!="object")return console.error("Couldn't load gameplay keybinds from storage");for(const[s,n]of Object.entries(i)){if(!Ke.getGameType(s)){console.warn("Couldn't load gameplay keybinds for gameType "+s+": gameType doesn't exist");continue}Array.isArray(n)||console.warn("Couldn't load gameplay keybind "+s+": value is not an array"),this.userGameplayKeybinds.set(s,n.map((a,o)=>!Array.isArray(a)&&a!==null?(console.warn("Couldn't load gameplay keys for type "+s+" col "+o+": "+JSON.stringify(a)),null):a))}}}static clearSave(){localStorage.removeItem("keybinds"),localStorage.removeItem("keybindsGP")}static setKeybind(e,t){this.userKeybinds.has(e)||this.userKeybinds.set(e,[...dt[e].combos]),this.userKeybinds.get(e)?.push(t),this.checkIsDefault(e),this.saveKeybinds()}static removeKeybind(e,t){this.userKeybinds.has(e)||this.userKeybinds.set(e,[...dt[e].combos]),this.userKeybinds.set(e,this.userKeybinds.get(e).filter(i=>!this.compareCombos(i,t))),this.checkIsDefault(e),this.saveKeybinds()}static revertKeybind(e){this.userKeybinds.delete(e),this.saveKeybinds()}static revertGameplayKeybind(e,t){this.userGameplayKeybinds.has(e)&&(this.userGameplayKeybinds.get(e)[t]=null,this.userGameplayKeybinds.get(e).every(i=>i===null)&&this.userGameplayKeybinds.delete(e)),this.saveKeybinds()}static setGameplayKeybind(e,t,i){this.userGameplayKeybinds.has(e)||this.userGameplayKeybinds.set(e,new Array(Ke.getGameType(e).numCols).fill(null)),this.userGameplayKeybinds.get(e)[t]==null&&(this.userGameplayKeybinds.get(e)[t]=[...Sr[e]?.[t].keys??[]]),this.userGameplayKeybinds.get(e)[t].push(i),this.checkIsDefaultGameplay(e,t),this.saveKeybinds()}static removeGameplayKeybind(e,t,i){this.userGameplayKeybinds.has(e)||this.userGameplayKeybinds.set(e,new Array(Ke.getGameType(e).numCols).fill(null)),this.userGameplayKeybinds.get(e)[t]==null&&(this.userGameplayKeybinds.get(e)[t]=[...Sr[e]?.[t].keys??[]]),this.userGameplayKeybinds.get(e)[t]=this.userGameplayKeybinds.get(e)[t].filter(s=>s!=i),this.checkIsDefaultGameplay(e,t),this.saveKeybinds()}static checkIsDefault(e){if(!this.userKeybinds.has(e))return!0;const t=this.userKeybinds.get(e),i=[...dt[e].combos];return t.length!=i.length?!1:t.map(s=>this.getComboString(s)).sort().join("∆")==i.map(s=>this.getComboString(s)).sort().join("∆")?(this.userKeybinds.delete(e),!0):!1}static checkIsDefaultGameplay(e,t){if(!this.userGameplayKeybinds.has(e)||this.userGameplayKeybinds.get(e)[t]===null)return!0;const i=this.userGameplayKeybinds.get(e)[t],s=[...Sr[e]?.[t].keys??[]];return i.length!=s.length?!1:i.sort().join("∆")==s.sort().join("∆")?(this.userGameplayKeybinds.get(e)[t]=null,this.userGameplayKeybinds.get(e).every(n=>n===null)&&this.userGameplayKeybinds.delete(e),!0):!1}static saveKeybinds(){const e={};for(const[i,s]of this.userKeybinds.entries())e[i]=s;localStorage.setItem("keybinds",JSON.stringify(e));const t={};for(const[i,s]of this.userGameplayKeybinds.entries())t[i]=s;localStorage.setItem("keybindsGP",JSON.stringify(t))}}class Tg extends Pt{app;allowMods;callback;combo={mods:[],key:""};conflictCheck;listener;constructor(e,t,i,s){super({title:"",width:300,height:168,disableClose:!0,win_id:"keyComboSelector",blocking:!0}),this.app=e,this.allowMods=t,this.callback=i,this.conflictCheck=s??(()=>[]),this.initView()}initView(){this.viewElement.replaceChildren(),this.viewElement.classList.add("confirmation");const e=document.createElement("div");e.classList.add("padding"),e.style.gap="8px";const t=document.createElement("div");t.classList.add("label"),t.innerText="Input a key combo and select Ok when finished.",e.appendChild(t);const i=document.createElement("input");i.type="text",i.disabled=!0,i.style.fontSize="18px",i.style.height="24px",i.style.flex="0",i.style.textAlign="center",e.appendChild(i);const s=document.createElement("div");s.classList.add("detail"),s.innerText="No conflicts",s.style.flex="1",e.appendChild(s);const n=document.createElement("div");n.classList.add("menu-options");const a=document.createElement("button");a.innerText="Ok",a.onclick=()=>{this.callback(this.combo),this.closeWindow()},a.classList.add("confirm"),a.disabled=!0;const o=document.createElement("button");o.innerText="Cancel",o.onclick=()=>{this.closeWindow()},n.append(a),n.append(o),e.appendChild(n),this.viewElement.appendChild(e),this.listener=l=>{if(["Meta","Control","Shift","Alt","Escape"].includes(l.key))return;if(this.combo.key=$e.getKeyNameFromCode(l.code),this.allowMods){const u=[];for(let h=0;h=3?s.innerText=`Conflicts with ${c.length} keybinds`:c.length>=1?s.innerText=`Conflicts with ${c.join(",")}`:s.innerText="No conflicts"),l.preventDefault()},window.addEventListener("keydown",this.listener)}onClose(){window.removeEventListener("keydown",this.listener)}}class aT extends Pt{app;observer;conflictMap=this.calculateConflicts();constructor(e){super({title:"Gameplay Keybind Options",width:600,height:400,disableClose:!1,win_id:"gameplay_keybind_options",blocking:!1}),this.app=e,this.initView()}initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("pref-container");const i=document.createElement("div");i.classList.add("pref-scrollers");const s=document.createElement("div");s.classList.add("pref-section-scroller");const n=document.createElement("div");n.classList.add("pref-option-scroller"),i.replaceChildren(s,n),this.observer=new IntersectionObserver(a=>{a.forEach(o=>{const l=o.target.dataset.id,c=s.querySelector(`.pref-section[data-id=${l}]`);c&&(o.intersectionRatio>0?c.classList.add("selected"):c.classList.remove("selected"))})},{}),t.replaceChildren(i),s.replaceChildren(...this.createSections()),n.replaceChildren(...this.createOptions()),e.appendChild(t),this.viewElement.appendChild(e)}createSections(){return Object.keys(Ke.getTypes()).map(e=>this.createEmptySection(e))}createOptions(){return Object.keys(Ke.getTypes()).map(e=>{const t=new Array(Ke.getTypes()[e].numCols).fill(null).map((n,a)=>this.createKeybindItem(e,a)),i=document.createElement("div");i.classList.add("pref-group"),i.dataset.id=e;const s=document.createElement("div");return s.classList.add("pref-group-label"),s.innerText=e,i.replaceChildren(s,...t),this.observer.observe(i),i})}createEmptySection(e){const t=document.createElement("div");return t.classList.add("pref-section"),t.dataset.id=e,t.innerText=e,t.onclick=()=>{t.parentElement.parentElement.querySelector(`.pref-group[data-id=${e}]`).scrollIntoView()},t}createKeybindItem(e,t){const i=document.createElement("div");i.classList.add("pref-keybind"),i.dataset.id=e+"-"+t,i.onclick=o=>{o.target.classList.contains("pref-keybind-combo")||o.target.tagName=="IMG"||this.app.windowManager.openWindow(new Tg(this.app,!1,l=>{$e.setGameplayKeybind(e,t,l.key),this.conflictMap=this.calculateConflicts(),i.replaceWith(this.createKeybindItem(e,t))},l=>{const c=this.conflictMap.get(e)?.get(l.key)?.map(u=>Sr[u[0]]?.[u[1]].label??"Column "+u[1])??[];return c.includes(Sr[e]?.[t].label??"Column "+t)?"self":c}))};const s=document.createElement("div");s.classList.add("pref-keybind-label"),s.innerText=Sr[e]?.[t].label??"Column "+t;const n=document.createElement("img");n.src=He.REVERT,n.style.width="12px",n.addEventListener("click",()=>{$e.revertGameplayKeybind(e,t),this.conflictMap=this.calculateConflicts(),i.replaceWith(this.createKeybindItem(e,t))}),n.style.display=$e.checkIsDefaultGameplay(e,t)?"none":"block";const a=document.createElement("div");return a.classList.add("pref-keybind-combos"),a.replaceChildren(...$e.getKeysForGameType(e)[t].map(o=>{const l=document.createElement("button");return l.classList.add("pref-keybind-combo"),l.innerText=o,this.conflictMap.get(e).get(o).length>1&&l.classList.add("conflict"),l.onclick=()=>{$e.removeGameplayKeybind(e,t,o),this.conflictMap=this.calculateConflicts(),i.replaceWith(this.createKeybindItem(e,t))},l})),i.replaceChildren(s,n,a),i}calculateConflicts(){const e=new Map;Object.keys(Ke.getTypes()).forEach(t=>{const i=new Map;$e.getKeysForGameType(t).forEach((s,n)=>{s.forEach((a,o)=>{i.has(a)||i.set(a,[]),i.get(a).push([t,n,o])})}),e.set(t,i)}),[...this.viewElement.querySelectorAll(".pref-keybind-combo.conflict")].forEach(t=>t.classList.remove("conflict"));for(const t of e.values())for(const i of t.values())i.length!=1&&i.forEach(s=>{const n=this.viewElement.querySelector(`.pref-keybind[data-id=${s[0]}-${s[1]}] .pref-keybind-combos`);n?.children[s[2]]&&n.children[s[2]].classList.add("conflict")});return e}onClose(){this.observer?.disconnect()}}const Vn={file:{type:"menu",title:"File",options:[{type:"selection",id:"newSong"},{type:"selection",id:"openSong"},{type:"separator"},{type:"selection",id:"save"},{type:"selection",id:"export"}]},edit:{type:"menu",title:"Edit",options:[{type:"selection",id:"cut"},{type:"selection",id:"copy"},{type:"selection",id:"paste"},{type:"separator"},{type:"selection",id:"undo"},{type:"selection",id:"redo"},{type:"separator"},{type:"checkbox",id:"mousePlacement",checked:()=>_.chart.mousePlacement}]},view:{type:"menu",title:"View",options:[{type:"dropdown",title:"Cursor",options:[{type:"selection",id:"cursorUp"},{type:"selection",id:"cursorDown"},{type:"separator"},{type:"selection",id:"previousNote"},{type:"selection",id:"nextNote"},{type:"separator"},{type:"selection",id:"previousMeasure"},{type:"selection",id:"nextMeasure"},{type:"separator"},{type:"selection",id:"jumpChartStart"},{type:"selection",id:"jumpChartEnd"},{type:"separator"},{type:"selection",id:"jumpSongStart"},{type:"selection",id:"jumpSongEnd"}]},{type:"dropdown",title:"Snap",options:[{type:"selection",id:"decreaseSnap"},{type:"selection",id:"increaseSnap"}]},{type:"dropdown",title:"Scroll",options:[{type:"checkbox",id:"XMod",checked:()=>!_.chart.CMod},{type:"checkbox",id:"CMod",checked:()=>_.chart.CMod},{type:"separator"},{type:"selection",id:"increaseScrollSpeed"},{type:"selection",id:"decreaseScrollSpeed"}]},{type:"dropdown",title:"Zoom",options:[{type:"selection",id:"zoomIn"},{type:"selection",id:"zoomOut"},{type:"separator"},{type:"selection",id:"zoomDefault"}]},{type:"dropdown",title:"Waveform",options:[{type:"checkbox",id:"renderWaveform",checked:()=>_.chart.waveform.enabled},{type:"selection",id:"waveformOptions"}]},{type:"separator"},{type:"selection",id:"playMode"},{type:"selection",id:"playModeStart"},{type:"separator"},{type:"selection",id:"recordMode"},{type:"selection",id:"recordModeStart"},{type:"separator"},{type:"checkbox",id:"hideWarpedArrows",checked:()=>_.chart.hideWarpedArrows},{type:"checkbox",id:"hideFakedArrows",checked:()=>_.chart.hideFakedArrows},{type:"checkbox",id:"doSpeedChanges",checked:()=>_.chart.doSpeedChanges}]},chart:{type:"menu",title:"Chart",options:[{type:"selection",id:"openChart"},{type:"separator"},{type:"selection",id:"songProperties"},{type:"separator"},{type:"selection",id:"timingDataRow"}]},selection:{type:"menu",title:"Selection",options:[{type:"dropdown",title:"Convert",options:[{type:"selection",id:"convertHoldsRolls"},{type:"selection",id:"convertRollsHolds"},{type:"selection",id:"swapHoldsRolls"},{type:"separator"},{type:"selection",id:"convertHoldsTaps"},{type:"selection",id:"convertTapsMines"},{type:"selection",id:"convertTapsLifts"},{type:"selection",id:"convertTapsFakes"}]},{type:"dropdown",title:"Mirror",options:[{type:"selection",id:"mirrorHorizontally"},{type:"selection",id:"mirrorVertically"},{type:"selection",id:"mirrorBoth"}]},{type:"dropdown",title:"Stretch",options:[{type:"selection",id:"expand2to1"},{type:"selection",id:"expand3to2"},{type:"selection",id:"expand4to3"},{type:"separator"},{type:"selection",id:"compress1to2"},{type:"selection",id:"compress2to3"},{type:"selection",id:"compress3to4"}]},{type:"dropdown",title:"Quantize",options:[{type:"selection",id:"quantize4th"},{type:"selection",id:"quantize8th"},{type:"selection",id:"quantize12th"},{type:"selection",id:"quantize16th"},{type:"selection",id:"quantize24th"},{type:"selection",id:"quantize32nd"},{type:"selection",id:"quantize48th"},{type:"selection",id:"quantize96th"}]},{type:"separator"},{type:"selection",id:"setSongPreview"},{type:"separator"},{type:"selection",id:"exportNotedata"},{type:"separator"},{type:"selection",id:"selectAll"}]},audio:{type:"menu",title:"Audio",options:[{type:"selection",id:"adjustOffset"},{type:"checkbox",id:"assistTick",checked:()=>_.audio.assistTick&&Ie.assist},{type:"checkbox",id:"metronome",checked:()=>_.audio.metronome&&Ie.assist},{type:"separator"},{type:"dropdown",title:()=>"Master Volume ("+Math.round(_.audio.masterVolume*100)+"%)",options:[{type:"selection",id:"volumeUp"},{type:"selection",id:"volumeDown"}]},{type:"dropdown",title:()=>"Song Volume ("+Math.round(_.audio.songVolume*100)+"%)",options:[{type:"selection",id:"songVolumeUp"},{type:"selection",id:"songVolumeDown"}]},{type:"dropdown",title:()=>"Effect Volume ("+Math.round(_.audio.soundEffectVolume*100)+"%)",options:[{type:"selection",id:"effectvolumeUp"},{type:"selection",id:"effectvolumeDown"}]},{type:"dropdown",title:()=>"Playback rate ("+Math.round(_.audio.rate*100)+"%)",options:[{type:"selection",id:"rateUp"},{type:"selection",id:"rateDown"},{type:"separator"},{type:"selection",id:"rateDefault"}]},{type:"separator"},{type:"selection",id:"showEq"}]},preferences:{type:"menu",title:"Preferences",options:[{type:"selection",id:"options"},{type:"selection",id:"keybinds"},{type:"selection",id:"gameplayKeybinds"}]}},Fp=["cut","copy","paste"],Np={edit:[{ids:["delete"],after:"redo"},{ids:["previousNoteType","nextNoteType","noteTypeTap","noteTypeMine","noteTypeFake","noteTypeLift","quant4","quant8","quant12","quant16","quant24","quant32","quant48","quant96","quant192"],after:"mousePlacement"}],view:[{ids:["playback","selectRegion"]}],debug:[{ids:["showFPSCounter","showDebugTimers"]}]};class Di extends Pt{static GROUPS;app;observer;searchDropdown;conflictMap=this.calculateConflicts();constructor(e){super({title:"Keybind Options",width:600,height:400,disableClose:!1,win_id:"keybind_options",blocking:!1}),this.app=e,Di.GROUPS||(Di.GROUPS=Di.createGroups()),this.initView()}initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("pref-container");const i=document.createElement("div");i.classList.add("pref-search");const s=document.createElement("input");s.classList.add("pref-search-bar"),s.type="text",s.placeholder="Search for a keybind...",s.oninput=()=>{o.replaceChildren(...this.createSections(s.value)),l.replaceChildren(...this.createOptions(s.value))};const n=pi.create(["Name","Key"],"Name");n.onChange(()=>{o.replaceChildren(...this.createSections(s.value)),l.replaceChildren(...this.createOptions(s.value))}),this.searchDropdown=n,i.replaceChildren(s,n.view);const a=document.createElement("div");a.classList.add("pref-scrollers");const o=document.createElement("div");o.classList.add("pref-section-scroller");const l=document.createElement("div");l.classList.add("pref-option-scroller"),a.replaceChildren(o,l),this.observer=new IntersectionObserver(c=>{c.forEach(u=>{const h=u.target.dataset.id,d=o.querySelector(`.pref-section[data-id=${h}]`);d&&(u.intersectionRatio>0?d.classList.add("selected"):d.classList.remove("selected"))})},{}),t.replaceChildren(i,a),o.replaceChildren(...this.createSections()),l.replaceChildren(...this.createOptions()),e.appendChild(t),this.viewElement.appendChild(e)}createSections(e=""){return Object.keys(Di.GROUPS).filter(t=>Di.GROUPS[t].some(i=>this.filterID(e,i))).map(t=>this.createEmptySection(Vn[t]?.title??Ec(t),t))}createOptions(e=""){return Object.keys(Di.GROUPS).filter(t=>Di.GROUPS[t].some(i=>this.filterID(e,i))).map(t=>{const i=Di.GROUPS[t].filter(a=>this.filterID(e,a)).map(a=>this.createKeybindItem(a)),s=document.createElement("div");s.classList.add("pref-group"),s.dataset.id=t;const n=document.createElement("div");return n.classList.add("pref-group-label"),n.innerText=Vn[t]?.title??Ec(t),s.replaceChildren(n,...i),this.observer.observe(s),s})}static createGroups(){const e=Object.keys(dt),t={};return Object.keys(Vn).forEach(i=>{t[i]=this.expandMenubarOptions(Vn[i]).map(s=>{const n=e.indexOf(s);return n!=-1&&e.splice(n,1),s}).filter(s=>!Fp.includes(s))}),Object.keys(Np).forEach(i=>{t[i]===void 0&&(t[i]=[]),Np[i].forEach(s=>{const n=s.after?t[i].findIndex(a=>s.after==a)+1:0;t[i].splice(n,0,...s.ids),s.ids.forEach(a=>{const o=e.indexOf(a);o!=-1&&e.splice(o,1)})})}),Fp.forEach(i=>{const s=e.indexOf(i);s!=-1&&e.splice(s,1)}),e.length>0&&(console.warn("Missing keybinds not shown:"),console.warn(e)),t}filterID(e,t){if((this.searchDropdown?.value??"Name")=="Name")return(dt[t].bindLabel??dt[t].label).toLowerCase().includes(e.toLowerCase());{const i=$e.getCombosForKeybind(t);if(i.some(n=>n.key.toLowerCase().includes(e.toLowerCase())))return!0;let s=e.split(" ").map(n=>n.toLowerCase());return i.some(n=>(s.includes("shift")||s.includes("⇧"))&&!n.mods.includes(zn.SHIFT)||(s.includes("ctrl")||s.includes("control")||s.includes("⌃"))&&!n.mods.includes(zn.CTRL)||(s.includes("meta")||s.includes("cmd")||s.includes("command")||s.includes("⌘"))&&!n.mods.includes(zn.META)||(s.includes("alt")||s.includes("⌥"))&&!n.mods.includes(zn.ALT)?!1:(s=s.filter(a=>!["shift","ctrl","control","meta","cmd","command","alt","⇧","⌃","⌘","⌥",""].includes(a)),s.length==0||s.length==1&&n.key.toLowerCase().includes(s[0])))}}static expandMenubarOptions(e){switch(e.type){case"menu":case"dropdown":return e.options.map(t=>this.expandMenubarOptions(t)).flat();case"selection":case"checkbox":return[e.id];case"separator":return[]}}createEmptySection(e,t){const i=document.createElement("div");return i.classList.add("pref-section"),i.dataset.id=t,i.innerText=e,i.onclick=()=>{i.parentElement.parentElement.querySelector(`.pref-group[data-id=${t}]`).scrollIntoView()},i}createKeybindItem(e){const t=document.createElement("div");t.classList.add("pref-keybind"),t.dataset.id=e,t.onclick=a=>{a.target.classList.contains("pref-keybind-combo")||a.target.tagName=="IMG"||this.app.windowManager.openWindow(new Tg(this.app,!0,o=>{$e.setKeybind(e,o),this.conflictMap=this.calculateConflicts(),t.replaceWith(this.createKeybindItem(e))},o=>{const l=this.conflictMap.get($e.getComboString(o))?.map(c=>c[0]).map(c=>dt[c].bindLabel??dt[c].label)??[];return l.includes(e)?"self":l}))};const i=document.createElement("div");i.classList.add("pref-keybind-label"),i.innerText=dt[e].bindLabel??dt[e].label;const s=document.createElement("img");s.src=He.REVERT,s.style.width="12px",s.addEventListener("click",()=>{$e.revertKeybind(e),this.conflictMap=this.calculateConflicts(),t.replaceWith(this.createKeybindItem(e))}),s.style.display=$e.checkIsDefault(e)?"none":"block";const n=document.createElement("div");return n.classList.add("pref-keybind-combos"),n.replaceChildren(...$e.getCombosForKeybind(e).map(a=>{const o=document.createElement("button");return o.classList.add("pref-keybind-combo"),o.innerText=$e.getComboString(a),this.conflictMap.get($e.getComboString(a)).length>1&&o.classList.add("conflict"),o.onclick=()=>{$e.removeKeybind(e,a),this.conflictMap=this.calculateConflicts(),t.replaceWith(this.createKeybindItem(e))},o})),t.replaceChildren(i,s,n),t}calculateConflicts(){const e=new Map;Object.keys(dt).forEach(t=>{$e.getCombosForKeybind(t).forEach((i,s)=>{const n=$e.getComboString(i);e.has(n)||e.set(n,[]),e.get(n).push([t,s])})}),[...this.viewElement.querySelectorAll(".pref-keybind-combo.conflict")].forEach(t=>t.classList.remove("conflict"));for(const t of e.values())t.length!=1&&t.forEach(i=>{const s=this.viewElement.querySelector(`.pref-keybind[data-id=${i[0]}] .pref-keybind-combos`);s?.children[i[1]]&&s.children[i[1]].classList.add("conflict")});return e}onClose(){this.observer?.disconnect()}}function $t(r){return!!r.simfileTimingData}class Sg{_cache={warpedBeats:new Map,beatsToSeconds:new Map};columns={};offset;buildBeatTimingDataCache(){const e=[];let t=this.getTimingData("BPMS","STOPS","WARPS","DELAYS");t=t.concat(this.getTimingData("WARPS").map(n=>({type:"WARP_DEST",beat:n.beat+n.value,value:n.value})));const i=["WARP_DEST","BPMS","STOPS","WARPS","DELAYS"];t.sort((n,a)=>n.beat==a.beat?i.indexOf(n.type)-i.indexOf(a.type):n.beat-a.beat);const s=this.getOffset();e.push({beat:0,secondBefore:-s,secondOf:-s,secondAfter:-s,secondClamp:-s,bpm:this.getTimingData("BPMS")[0]?.value??120,warped:!1});for(const n of t){if(e.at(-1)?.beat!=n.beat){e.at(-1).secondClamp=Math.max(Math.max(e.at(-2)?.secondClamp??-s,e.at(-2)?.secondAfter??-s),e.at(-1).secondBefore);let a=(n.beat-e.at(-1).beat)*60/e.at(-1).bpm;e.at(-1).warped&&(a=0),e.push({beat:n.beat,secondBefore:e.at(-1).secondAfter+a,secondOf:e.at(-1).secondAfter+a,secondAfter:e.at(-1).secondAfter+a,secondClamp:0,bpm:e.at(-1).bpm,warped:e.at(-1).warped})}n.type=="WARPS"&&(e.at(-1).warped=!0),n.type=="WARP_DEST"&&(e.at(-1).warped=!1),n.type=="BPMS"&&(e.at(-1).bpm=n.value),n.type=="STOPS"&&(e.at(-1).secondAfter+=n.value),n.type=="DELAYS"&&(e.at(-1).secondOf+=n.value,e.at(-1).secondAfter+=n.value)}e.at(-1).secondClamp=Math.max(e.at(-2)?.secondClamp??-s,e.at(-1).secondBefore),this._cache.beatTiming=e,this._cache.warpedBeats.clear(),this._cache.beatsToSeconds.clear()}buildEffectiveBeatTimingDataCache(){const e=[...this.getTimingData("SCROLLS")];let t=0;if(e.length==0){this._cache.effectiveBeatTiming=[];return}e[0].beat!=0&&e.unshift({type:"SCROLLS",beat:0,value:1}),t=e[0].beat;for(let i=0;is[t])}mergeColumns(e){if(e.length==0)return[];for(e=e.filter(t=>t.length>0);e.length>1;){const t=[];for(let i=0;i=e.length)return n.concat(t.slice(s))}else if(n.push(t[s]),s++,s>=t.length)return n.concat(e.slice(i))}splitEvents(e){const t=new Map;return e.forEach(i=>{t.has(i.type)||t.set(i.type,[]),t.get(i.type).push(i)}),t}splitEventPairs(e){const t=new Map;return e.forEach(i=>{t.has(i[0].type)||t.set(i[0].type,[]),t.get(i[0].type).push(i)}),t}parse(e,t){if(e=="OFFSET"){this.offset=parseFloat(t);return}e in this.columns||this.createColumn(e),this.parseEvents(e,t)}setOffset(e){const t=this.offset;ht.instance.run({action:()=>{this.offset=e,this.reloadCache(["OFFSET"]),$.emit("timingModified"),$.emit("chartModified")},undo:()=>{this.offset=t,this.reloadCache(["OFFSET"]),$.emit("timingModified"),$.emit("chartModified")}})}serialize(e){this.reloadCache();let t="";this.offset&&(t+="#OFFSET:"+this.offset+`; `);let i=["BPMS","STOPS","WARPS","DELAYS","SPEEDS","SCROLLS","TICKCOUNTS","TIMESIGNATURES","LABELS","COMBOS","FAKES","BGCHANGES","FGCHANGES","ATTACKS"];e=="sm"&&(i=["BPMS","STOPS","TIMESIGNATURES","BGCHANGES","FGCHANGES","ATTACKS"]);for(const s of i)s in this.columns&&(t+=this.formatProperty(e,s));return t}formatProperty(e,t){let s="";const n=a=>ne(a,3).toFixed(3);switch(t){case"ATTACKS":{s=this.columns[t].events.map(o=>`TIME=${o.second}:${o.endType}=${o.value}:MODS=${o.mods}`).join(`: `);break}case"BGCHANGES":case"FGCHANGES":{s=this.columns[t].events.map(o=>[o.beat,o.file,n(o.updateRate),Number(o.crossFade),Number(o.stretchRewind),Number(o.stretchNoLoop),o.effect,o.file2,o.transition,o.color1,o.color2].join("=")).join(`, `);break}case"BPMS":case"DELAYS":case"FAKES":case"SCROLLS":case"WARPS":{s=this.columns[t].events.map(o=>[n(o.beat),n(o.value)].join("=")).join(`, @@ -1208,7 +1208,7 @@ https://github.com/nodeca/pako/blob/main/LICENSE `);break}case"TIMESIGNATURES":{s=this.getTimingData(t).map(o=>[n(o.beat),o.upper,o.lower].join("=")).join(`, `);break}}return s.includes(",")&&(s+=` `),"#"+t+":"+s+`; -`}createColumn(e){this.columns[e]={type:e,events:[]}}getTime(e){switch(e.type){case"BPMS":case"STOPS":case"WARPS":case"DELAYS":case"LABELS":case"SPEEDS":case"SCROLLS":case"TICKCOUNTS":case"TIMESIGNATURES":case"COMBOS":case"FAKES":case"BGCHANGES":case"FGCHANGES":return e.beat;case"ATTACKS":return e.second}}isNullEvent(e){switch(e.type){case"BPMS":case"SPEEDS":case"TICKCOUNTS":case"TIMESIGNATURES":case"COMBOS":return!1;case"STOPS":case"WARPS":case"DELAYS":case"SCROLLS":case"FAKES":return e.value==0;case"LABELS":return e.value=="";case"BGCHANGES":case"FGCHANGES":return e.file=="";case"ATTACKS":return e.mods==""}}isSimilar(e,t){switch(e.type){case"BPMS":case"LABELS":case"SPEEDS":case"SCROLLS":case"TICKCOUNTS":return e.type==t.type&&e.value==t.value;case"TIMESIGNATURES":return e.type==t.type&&e.upper==t.upper&&e.lower==t.lower;case"COMBOS":return e.type==t.type&&e.hitMult==t.hitMult&&e.missMult==t.missMult;case"STOPS":case"WARPS":case"DELAYS":case"FAKES":case"BGCHANGES":case"FGCHANGES":case"ATTACKS":return!1}}removeOverlapping(e){const t=[];let i=null;for(;e.length>0;)this.getTime(e[0])!=i&&(i=this.getTime(e[0]),t.push(e[0])),e.shift();return t}compareEvents(e,t){const i=s=>!s.some(n=>e[n]!==void 0&&e[n]!==t[n]);switch(e.type){case"BPMS":case"STOPS":case"WARPS":case"DELAYS":case"SCROLLS":case"TICKCOUNTS":case"FAKES":case"LABELS":return i(["type","beat","value"]);case"SPEEDS":return i(["type","beat","value","unit","delay"]);case"TIMESIGNATURES":return i(["type","beat","upper","lower"]);case"COMBOS":return i(["type","beat","hitMult","missMult"]);case"ATTACKS":return i(["type","second","mods","endType","value"]);case"FGCHANGES":case"BGCHANGES":return i(["type","beat","color1","color2","crossFade","effect","file1","file2","stretchNoLoop","stretchRewind","transition","updateRate"])}}insertEvents(e,t){this.columns[e]||this.createColumn(e);const i=this.columns[e],s=[];t=this.removeOverlapping(t);let n=0;for(;t[0]&&i.events[n];){const a=i.events[n],o=[];for(;t[0]&&this.getTime(a)>=this.getTime(t[0]);)o.push(t.shift());if(o.length==0){n++;continue}i.events.splice(n,0,...o),n+=o.length,this.getTime(o.at(-1))==this.getTime(a)?s.push(...i.events.splice(n,1)):n++}return i.events.push(...t),s}deleteEvents(e,t){this.columns[e]||this.createColumn(e);const i=this.columns[e];t=this.removeOverlapping(t);const s=[];let n=0,a=0;for(;t[n]&&i.events[a];)this.compareEvents(t[n],i.events[a])?(s.push(...i.events.splice(a,1)),n++):a++;return s}getColumnType(e){switch(e){case"BPMS":case"LABELS":case"SPEEDS":case"SCROLLS":case"TICKCOUNTS":case"TIMESIGNATURES":case"COMBOS":return"continuing";case"STOPS":case"WARPS":case"DELAYS":case"FAKES":case"BGCHANGES":case"FGCHANGES":case"ATTACKS":return"instant"}}findConflictingEvents(e){const t=this.columns[e];if(!t)return[];switch(this.getColumnType(t.type)){case"continuing":{const i=[];let s=0;for(;t.events[s]&&this.isNullEvent(t.events[s]);)i.push(t.events[s]),s++;let n=t.events[s];for(s++;sthis.isNullEvent(i))}}parseEvents(e,t){switch(e){case"BPMS":case"STOPS":case"WARPS":case"DELAYS":case"SCROLLS":case"FAKES":this.insertEvents(e,Array.from(t.matchAll(/(-?[\d.]+)=(-?[\d.]+)/g)).map(i=>({type:e,beat:parseFloat(i[1]),value:parseFloat(i[2])})));return;case"TICKCOUNTS":this.insertEvents(e,Array.from(t.matchAll(/(-?[\d.]+)=(-?\d+)/g)).map(i=>({type:"TICKCOUNTS",beat:parseFloat(i[1]),value:parseInt(i[2])})));return;case"LABELS":this.insertEvents(e,Array.from(t.matchAll(/((-?[\d.]+)=([^\n]+)=\d)|((-?[\d.]+)=([^\n,]+))/g)).map(i=>i[1]===void 0?{type:"LABELS",beat:parseFloat(i[5]),value:i[6].trim()}:{type:"LABELS",beat:parseFloat(i[2]),value:i[3].trim()}));return;case"SPEEDS":this.insertEvents(e,Array.from(t.matchAll(/(-?[\d.]+)=(-?[\d.]+)=([\d.]+)=([01])/g)).map(i=>({type:"SPEEDS",beat:parseFloat(i[1]),value:parseFloat(i[2]),delay:parseFloat(i[3]),unit:i[4].trim()=="0"?"B":"T"})));return;case"TIMESIGNATURES":this.insertEvents(e,Array.from(t.matchAll(/(-?[\d.]+)=(\d+)=(\d+)/g)).map(i=>({type:"TIMESIGNATURES",beat:parseFloat(i[1]),upper:parseInt(i[2]),lower:parseInt(i[3])})));return;case"COMBOS":this.insertEvents(e,Array.from(t.matchAll(/(-?[\d.]+)=(\d+)=*(\d+)*/g)).map(i=>({type:"COMBOS",beat:parseFloat(i[1]),hitMult:parseInt(i[2]),missMult:parseInt(i[3]??i[2])})));return;case"ATTACKS":this.insertEvents(e,Array.from(t.matchAll(/TIME=(-?[\d.]+):(END|LEN)=(-?[\d.]+):MODS=([^:]+)/g)).map(i=>({type:"ATTACKS",second:parseFloat(i[1]),endType:i[2].trim(),value:parseFloat(i[3]),mods:i[4].trim()})));return;case"BGCHANGES":case"FGCHANGES":this.insertEvents(e,Array.from(t.matchAll(/(-?[\d.]+)=([^\n]+?)=(-?[\d.]+)=([01])=([01])=([01])=?([^\n=,]*)=?([^\n=,]*)=?([^\n=,]*)=?([^\n=,]*)=?([^\n=,]*)/g)).map(i=>({type:e,beat:parseFloat(i[1]),file:i[2].trim(),updateRate:parseFloat(i[3]),crossFade:i[4].trim()=="1",stretchRewind:i[5].trim()=="1",stretchNoLoop:i[6].trim()=="1",effect:i[7].trim()??"",file2:i[8].trim()??"",transition:i[9].trim()??"",color1:i[10].trim()??"",color2:i[11].trim()??""})))}}typeRequiresSSC(e){switch(e){case"BPMS":case"STOPS":case"ATTACKS":case"BGCHANGES":case"FGCHANGES":return!1;case"WARPS":case"DELAYS":case"LABELS":case"SPEEDS":case"SCROLLS":case"TICKCOUNTS":case"TIMESIGNATURES":case"COMBOS":case"FAKES":return!!this.columns[e]&&this.columns[e].events.length>0}}getDefaultEvent(e,t){switch(e){case"BPMS":return{type:e,beat:t,value:120,second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"STOPS":case"WARPS":case"FAKES":return{type:e,beat:t,value:0,second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"DELAYS":return{type:e,beat:t,value:0,second:this.getSecondsFromBeat(t,"before"),isChartTiming:$t(this)};case"LABELS":return{type:e,beat:t,value:"",second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"SPEEDS":return{type:e,beat:t,value:1,delay:0,unit:"B",second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"SCROLLS":return{type:e,beat:t,value:1,second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"TICKCOUNTS":return{type:e,beat:t,value:4,second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"TIMESIGNATURES":return{type:e,beat:t,upper:4,lower:4,second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"COMBOS":return{type:e,beat:t,hitMult:1,missMult:1,second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"ATTACKS":return{type:e,beat:t,second:this.getSecondsFromBeat(t),endType:"LEN",value:1,mods:"",isChartTiming:$t(this)};case"BGCHANGES":case"FGCHANGES":return{type:e,beat:t,file:"",updateRate:1,crossFade:!1,stretchRewind:!1,stretchNoLoop:!1,effect:"",file2:"",transition:"",color1:"",color2:"",second:this.getSecondsFromBeat(t),isChartTiming:$t(this)}}}getEventAtBeat(e,t,i=!0){const s=this.getColumn(e),n=s.events[hi(s.events,t,a=>a.beat)];if(!n)switch(this.getColumnType(s.type)){case"continuing":return i?this.getDefaultEvent(s.type,0):void 0;case"instant":return}return n}updateEvents(e){const t=this.columns[e];if(t){switch(e){case"DELAYS":t.events.forEach(i=>i.second=this.getSecondsFromBeat(i.beat,"before"));break;case"ATTACKS":t.events.forEach(i=>i.beat=this.getBeatFromSeconds(i.second));break;case"BPMS":case"STOPS":case"WARPS":case"LABELS":case"SPEEDS":case"SCROLLS":case"TICKCOUNTS":case"TIMESIGNATURES":case"COMBOS":case"FAKES":case"BGCHANGES":case"FGCHANGES":t.events.forEach(i=>i.second=this.getSecondsFromBeat(i.beat))}t.events.forEach(i=>i.isChartTiming=$t(this))}}_insert(e){e=e.sort((n,a)=>n.type=="ATTACKS"&&a.type=="ATTACKS"?n.second-a.second:n.type!="ATTACKS"&&a.type!="ATTACKS"?n.beat-a.beat:0);const t=this.splitEvents(e),i=[],s=[];for(const[n,a]of t.entries())i.push(...this.insertEvents(n,a)),s.push(...this.findConflictingEvents(n));return{events:e,insertConflicts:i,errors:s}}_modify(e){const t=this.splitEventPairs(e),i=[],s=[];for(const[n,a]of t.entries())this.deleteEvents(n,a.map(o=>o[0]).sort((o,l)=>o.type=="ATTACKS"&&l.type=="ATTACKS"?o.second-l.second:o.type!="ATTACKS"&&l.type!="ATTACKS"?o.beat-l.beat:0)),i.push(...this.insertEvents(n,a.map(o=>o[1]).sort((o,l)=>o.type=="ATTACKS"&&l.type=="ATTACKS"?o.second-l.second:o.type!="ATTACKS"&&l.type!="ATTACKS"?o.beat-l.beat:0))),s.push(...this.findConflictingEvents(n));return{newEvents:e.map(n=>n[1]).sort((n,a)=>n.type=="ATTACKS"&&a.type=="ATTACKS"?n.second-a.second:n.type!="ATTACKS"&&a.type!="ATTACKS"?n.beat-a.beat:0),oldEvents:e.map(n=>n[0]).sort((n,a)=>n.type=="ATTACKS"&&a.type=="ATTACKS"?n.second-a.second:n.type!="ATTACKS"&&a.type!="ATTACKS"?n.beat-a.beat:0),insertConflicts:i,errors:s}}_delete(e){e=e.sort((n,a)=>n.type=="ATTACKS"&&a.type=="ATTACKS"?n.second-a.second:n.type!="ATTACKS"&&a.type!="ATTACKS"?n.beat-a.beat:0);const t=this.splitEvents(e),i=[],s=[];for(const[n,a]of t.entries())s.push(...this.deleteEvents(n,a)),i.push(...this.findConflictingEvents(n));return{removedEvents:s,errors:i}}findEvents(e){const t=this.splitEvents(e),i=[];for(const[s,n]of t.entries()){const a=this.columns[s];if(!a)continue;let o=0,l=0;for(;n[o]&&a.events[l];)this.compareEvents(n[o],a.events[l])?(i.push(a.events[l]),o++):l++}return i}getBeatFromSeconds(e){if(!isFinite(e))return 0;if(this._cache.beatTiming==null&&this.buildBeatTimingDataCache(),e+this.getOffset()<0)return(e+this.getOffset())*this._cache.beatTiming[0].bpm/60;const t=this._cache.beatTiming,i=this.binarySearch(t,"secondClamp",e),s=Math.max(0,e-i.secondAfter);return i.beat+s*i.bpm/60}getSecondsFromBeat(e,t){if(t||="",!isFinite(e))return 0;this._cache.beatTiming==null&&this.buildBeatTimingDataCache();const i=Math.floor(e*1e3)/1e3;if(e<=0){const c=this._cache.beatTiming[0].bpm;return-this.getOffset()+e*60/c}const s=`${e}-${t}`;if(this._cache.beatsToSeconds.has(s))return this._cache.beatsToSeconds.get(s);const n=this._cache.beatTiming,a=this.binarySearch(n,"beat",i);if(a.beat==i){if(t=="noclamp"||t=="")return this._cache.beatsToSeconds.set(s,a.secondOf),a.secondOf;if(t=="before")return this._cache.beatsToSeconds.set(s,a.secondBefore),a.secondBefore;if(t=="after")return this._cache.beatsToSeconds.set(s,a.secondAfter),a.secondAfter}let l=(e-a.beat)*60/a.bpm;return a.warped&&(l=0),t=="noclamp"?(this._cache.beatsToSeconds.set(s,a.secondAfter+l),a.secondAfter+l):(this._cache.beatsToSeconds.set(s,Math.max(a.secondClamp,a.secondAfter+l)),Math.max(a.secondClamp,a.secondAfter+l))}isBeatWarped(e){if(!isFinite(e))return!1;const t=Math.floor(e*1e3)/1e3;if(this._cache.warpedBeats.has(t))return this._cache.warpedBeats.get(t);this._cache.beatTiming==null&&this.buildBeatTimingDataCache();const i=this._cache.beatTiming,s=this.binarySearch(i,"beat",t),n=s.beat==t?s.secondClamp:Math.max(s.secondAfter,s.secondClamp);return s.secondOf=s.beat&&te&&i.beat>0)return e;let s=i.effectiveBeat;const n=e-i.beat;return s+=n*i.value,s}getBeatFromEffectiveBeat(e){if(!isFinite(e))return 0;this._cache.effectiveBeatTiming==null&&this.buildEffectiveBeatTimingDataCache();const t=this._cache.effectiveBeatTiming;if(t.length==0)return e;let i=0;for(;t[i+1]&&(t[i].value<=0||t[i+1].effectiveBeat<=e);)i++;let n=(e-t[i].effectiveBeat)/t[i].value;return isFinite(n)||(n=0),t[i].beat+n}getSpeedMult(e,t){if(!isFinite(e)||!isFinite(t))return 0;const i=this.getColumn("SPEEDS").events;if(i.length==0)return 1;const s=this.binarySearchIndex(i,"beat",e),n=i[s];if(n==null)return 1;let a=e-n.beat;n.unit=="T"&&(a=t-n.second);let o=Ve(a/n.delay,0,1);n.delay==0&&(o=1);const l=i[s-1]?.value??1;return o*(n.value-l)+l}reloadCache(e=[]){let t=e;(e.length==0||e.filter(i=>["WARPS","STOPS","DELAYS","BPMS","OFFSET"].includes(i)).length>0)&&(this.buildBeatTimingDataCache(),t=[...Dr]),(e.length==0||e.includes("SCROLLS"))&&this.buildEffectiveBeatTimingDataCache(),(e.length==0||e.includes("TIMESIGNATURES"))&&this.buildMeasureTimingCache(),t.filter(i=>i!="OFFSET").forEach(i=>this.updateEvents(i)),this._cache.sortedEvents=this.mergeColumns(Dr.map(i=>this.getColumn(i).events))}getBeatTiming(){return[...this._cache.beatTiming]}getTimingData(...e){return e.length==0?this._cache.sortedEvents:this.mergeColumns(e.map(t=>this.getColumn(t).events))}requiresSSC(){return Dr.some(e=>this.typeRequiresSSC(e))}}class oT extends Sg{simfileTimingData;chart;constructor(e,t){super(),this.simfileTimingData=e,this.chart=t}getColumn(e){return this.columns[e]??this.simfileTimingData.getColumn(e)}splitSM(e){const t=[],i=[];for(const s of e)s.isChartTiming?i.push(s):t.push(s);return[t,i]}splitSMPairs(e){const t=[],i=[];for(const s of e)s[0].isChartTiming?i.push(s):t.push(s);return[t,i]}insert(e){let t,i;const s=e.find(o=>o.type=="TIMESIGNATURES"),[n,a]=this.splitSM(e);ht.instance.run({action:o=>{t=this.simfileTimingData._insert(n),this.simfileTimingData._delete(t.errors),i=this._insert(a),this._delete(i.errors),this.simfileTimingData.reloadCache(),o.chartManager.clearSelections(),o.chartManager.setEventSelection(this.findEvents(i.events).concat(this.simfileTimingData.findEvents(t.events))),$.emit("timingModified"),$.emit("chartModified"),s&&$.emit("timeSigChanged")},undo:o=>{this.simfileTimingData._insert(t.errors),this.simfileTimingData._delete(t.events),this.simfileTimingData._insert(t.insertConflicts),this._insert(i.errors),this._delete(i.events),this._insert(i.insertConflicts),this.simfileTimingData.reloadCache(),o.chartManager.clearSelections(),$.emit("timingModified"),$.emit("chartModified"),s&&$.emit("timeSigChanged")}})}modify(e){let t,i;const s=e.find(o=>o[0].type=="TIMESIGNATURES"),[n,a]=this.splitSMPairs(e);ht.instance.run({action:o=>{t=this.simfileTimingData._modify(n),this.simfileTimingData._delete(t.errors),i=this._modify(a),this._delete(i.errors),this.simfileTimingData.reloadCache(),o.chartManager.clearSelections(),o.chartManager.setEventSelection(this.findEvents(i.newEvents).concat(this.simfileTimingData.findEvents(t.newEvents))),$.emit("timingModified"),$.emit("chartModified"),s&&$.emit("timeSigChanged")},undo:o=>{this.simfileTimingData._insert(t.errors),this.simfileTimingData._delete(t.newEvents),this.simfileTimingData._insert(t.insertConflicts),this.simfileTimingData._insert(t.oldEvents),this._insert(i.errors),this._delete(i.newEvents),this._insert(i.insertConflicts),this._insert(i.oldEvents),this.simfileTimingData.reloadCache(),o.chartManager.clearSelections(),o.chartManager.setEventSelection(this.findEvents(i.oldEvents).concat(this.simfileTimingData.findEvents(t.oldEvents))),$.emit("timingModified"),$.emit("chartModified"),s&&$.emit("timeSigChanged")}})}delete(e){let t,i;const s=e.find(o=>o.type=="TIMESIGNATURES"),[n,a]=this.splitSM(e);ht.instance.run({action:o=>{t=this.simfileTimingData._delete(n),this.simfileTimingData._delete(t.errors),i=this._delete(a),this._delete(i.errors),this.simfileTimingData.reloadCache(),o.chartManager.clearSelections(),$.emit("timingModified"),$.emit("chartModified"),s&&$.emit("timeSigChanged")},undo:o=>{this.simfileTimingData._insert(t.errors),this.simfileTimingData._insert(t.removedEvents),this._insert(i.errors),this._insert(i.removedEvents),this.simfileTimingData.reloadCache(),o.chartManager.clearSelections(),o.chartManager.setEventSelection(this.findEvents(i.removedEvents).concat(this.simfileTimingData.findEvents(t.removedEvents))),$.emit("timingModified"),$.emit("chartModified"),s&&$.emit("timeSigChanged")}})}getOffset(){return this.offset??this.simfileTimingData.getOffset()}usesChartTiming(){return this.offset!==void 0||Object.values(this.columns).length>0}hasChartOffset(){return this.offset!==void 0}isPropertyChartSpecific(e){return e in this.columns}reloadCache(e=[]){super.reloadCache(e),this.chart.recalculateNotes()}}class lT extends Sg{offset=0;chartTimingDatas=[];constructor(){super(),Dr.forEach(e=>this.createColumn(e))}createChartTimingData(e){const t=new oT(this,e);return this.chartTimingDatas.push(t),t}getColumn(e){return this.columns[e]}getOffset(){return this.offset}reloadCache(e=[]){super.reloadCache(e),this.chartTimingDatas.forEach(t=>t.reloadCache(e))}insert(e){let t;const i=e.find(s=>s.type=="TIMESIGNATURES");ht.instance.run({action:s=>{t=this._insert(e),this._delete(t.errors),this.reloadCache(),s.chartManager.clearSelections(),s.chartManager.setEventSelection(this.findEvents(t.events)),$.emit("timingModified"),$.emit("chartModified"),i&&$.emit("timeSigChanged")},undo:s=>{this._insert(t.errors),this._delete(t.events),this._insert(t.insertConflicts),this.reloadCache(),s.chartManager.clearSelections(),$.emit("timingModified"),$.emit("chartModified"),i&&$.emit("timeSigChanged")}})}modify(e){let t;const i=e.find(s=>s[0].type=="TIMESIGNATURES");ht.instance.run({action:s=>{t=this._modify(e),this._delete(t.errors),this.reloadCache(),s.chartManager.clearSelections(),s.chartManager.setEventSelection(this.findEvents(t.newEvents)),$.emit("timingModified"),$.emit("chartModified"),i&&$.emit("timeSigChanged")},undo:s=>{this._insert(t.errors),this._delete(t.newEvents),this._insert(t.insertConflicts),this._insert(t.oldEvents),this.reloadCache(),s.chartManager.clearSelections(),s.chartManager.setEventSelection(this.findEvents(t.oldEvents)),$.emit("timingModified"),$.emit("chartModified"),i&&$.emit("timeSigChanged")}})}delete(e){let t;const i=e.find(s=>s.type=="TIMESIGNATURES");ht.instance.run({action:s=>{t=this._delete(e),this._delete(t.errors),this.reloadCache(),s.chartManager.clearSelections(),$.emit("timingModified"),$.emit("chartModified"),i&&$.emit("timeSigChanged")},undo:s=>{this._insert(t.errors),this._insert(t.removedEvents),this.reloadCache(),s.chartManager.clearSelections(),s.chartManager.setEventSelection(this.findEvents(t.removedEvents)),$.emit("timingModified"),$.emit("chartModified"),i&&$.emit("timeSigChanged")}})}}const hT=["TITLE","SUBTITLE","ARTIST","TITLETRANSLIT","SUBTITLETRANSLIT","ARTISTTRANSLIT","GENRE","CREDIT","ORIGIN","BACKGROUND","BANNER","MUSIC","CDTITLE","JACKET","DISCIMAGE","CDIMAGE","PREVIEW","LYRICSPATH","SAMPLESTART","SAMPLELENGTH","SELECTABLE"];class Cg{charts={};_type;other_properties={};properties={};timingData=new lT;unloadedCharts=[];loaded;constructor(e){this.loaded=new Promise(t=>{const i=e.name.split(".").pop();i=="sm"||i=="ssc"?this._type=i:t(),e.text().then(s=>{s=s.replaceAll(/\/\/.+/g,"");const n=[...s.matchAll(/#([A-Z]+):([^;]*);/g)];let a=!1,o={};const l=[];for(const c of n)c[1]=="NOTEDATA"&&i=="ssc"||a?(a=!0,o[c[1]]=c[2],c[1]=="NOTES"&&(l.push(o),o={},a=!1)):c[1]=="NOTES"?l.push(c[2]):hT.includes(c[1])?this.properties[c[1]]=c[2]:c[1]=="OFFSET"||Dr.includes(c[1])?this.timingData.parse(c[1],c[2]):this.other_properties[c[1]]=c[2];this.charts={};for(const c of l){let u;try{u=new mg(this,c)}catch(h){this.unloadedCharts.push(c),Ce.createFormatted(h instanceof Error?h.message:String(h),"warn");continue}this.addChart(u)}this.timingData.reloadCache(),t()})})}addChart(e){this.charts[e.gameType.id]||=[],this.charts[e.gameType.id].push(e),this.charts[e.gameType.id].sort((t,i)=>xi.indexOf(t.difficulty)==xi.indexOf(i.difficulty)?t.meter-i.meter:xi.indexOf(t.difficulty)-xi.indexOf(i.difficulty))}removeChart(e){if(!this.charts[e.gameType.id])return!1;const t=this.charts[e.gameType.id].indexOf(e);return t==-1?!1:(this.charts[e.gameType.id].splice(t,1),!0)}serialize(e){let t="";e=="sm"?(this.other_properties.NITGVERSION&&(t+=this.formatProperty("NITGVERSION",this.other_properties.NITGVERSION)),t+=this.formatProperty("TITLE",this.properties.TITLE),t+=this.formatProperty("SUBTITLE",this.properties.SUBTITLE),t+=this.formatProperty("ARTIST",this.properties.ARTIST),t+=this.formatProperty("MUSIC",this.properties.MUSIC??""),t+=this.formatProperty("BANNER",this.properties.GENRE),t+=this.formatProperty("BACKGROUND",this.properties.BACKGROUND),t+=this.formatProperty("LYRICSPATH",this.properties.LYRICSPATH),t+=this.formatProperty("CDTITLE",this.properties.CDTITLE),t+=this.formatProperty("SAMPLESTART",this.properties.SAMPLESTART),t+=this.formatProperty("SAMPLELENGTH",this.properties.SAMPLELENGTH)):(t+=this.formatProperty("VERSION",this.other_properties.VERSION??.83),t+=this.formatProperty("TITLE",this.properties.TITLE),t+=this.formatProperty("SUBTITLE",this.properties.SUBTITLE),t+=this.formatProperty("ARTIST",this.properties.ARTIST),t+=this.formatProperty("TITLETRANSLIT",this.properties.TITLETRANSLIT),t+=this.formatProperty("SUBTITLETRANSLIT",this.properties.SUBTITLETRANSLIT),t+=this.formatProperty("ARTISTTRANSLIT",this.properties.ARTISTTRANSLIT),t+=this.formatProperty("GENRE",this.properties.GENRE),t+=this.formatProperty("CREDIT",this.properties.CREDIT),t+=this.formatProperty("MUSIC",this.properties.MUSIC??""),t+=this.formatProperty("BANNER",this.properties.BANNER),t+=this.formatProperty("BACKGROUND",this.properties.BACKGROUND),t+=this.formatProperty("JACKET",this.properties.JACKET),t+=this.formatProperty("DISCIMAGE",this.properties.DISCIMAGE),t+=this.formatProperty("CDIMAGE",this.properties.CDIMAGE),t+=this.formatProperty("SELECTABLE",this.properties.SELECTABLE??"YES"),t+=this.formatProperty("LYRICSPATH",this.properties.LYRICSPATH),t+=this.formatProperty("CDTITLE",this.properties.CDTITLE),t+=this.formatProperty("SAMPLESTART",this.properties.SAMPLESTART),t+=this.formatProperty("SAMPLELENGTH",this.properties.SAMPLELENGTH)),t+=this.timingData.serialize(e);for(const i in this.other_properties)i=="VERSION"||i=="NITGVERSION"||(t+=this.formatProperty(i,this.other_properties[i]));t+=` +`}createColumn(e){this.columns[e]={type:e,events:[]}}getTime(e){switch(e.type){case"BPMS":case"STOPS":case"WARPS":case"DELAYS":case"LABELS":case"SPEEDS":case"SCROLLS":case"TICKCOUNTS":case"TIMESIGNATURES":case"COMBOS":case"FAKES":case"BGCHANGES":case"FGCHANGES":return e.beat;case"ATTACKS":return e.second}}isNullEvent(e){switch(e.type){case"BPMS":case"SPEEDS":case"TICKCOUNTS":case"TIMESIGNATURES":case"COMBOS":return!1;case"STOPS":case"WARPS":case"DELAYS":case"SCROLLS":case"FAKES":return e.value==0;case"LABELS":return e.value=="";case"BGCHANGES":case"FGCHANGES":return e.file=="";case"ATTACKS":return e.mods==""}}isSimilar(e,t){switch(e.type){case"BPMS":case"LABELS":case"SPEEDS":case"SCROLLS":case"TICKCOUNTS":return e.type==t.type&&e.value==t.value;case"TIMESIGNATURES":return e.type==t.type&&e.upper==t.upper&&e.lower==t.lower;case"COMBOS":return e.type==t.type&&e.hitMult==t.hitMult&&e.missMult==t.missMult;case"STOPS":case"WARPS":case"DELAYS":case"FAKES":case"BGCHANGES":case"FGCHANGES":case"ATTACKS":return!1}}removeOverlapping(e){const t=[];let i=null;for(;e.length>0;)this.getTime(e[0])!=i&&(i=this.getTime(e[0]),t.push(e[0])),e.shift();return t}compareEvents(e,t){const i=s=>!s.some(n=>e[n]!==void 0&&e[n]!==t[n]);switch(e.type){case"BPMS":case"STOPS":case"WARPS":case"DELAYS":case"SCROLLS":case"TICKCOUNTS":case"FAKES":case"LABELS":return i(["type","beat","value"]);case"SPEEDS":return i(["type","beat","value","unit","delay"]);case"TIMESIGNATURES":return i(["type","beat","upper","lower"]);case"COMBOS":return i(["type","beat","hitMult","missMult"]);case"ATTACKS":return i(["type","second","mods","endType","value"]);case"FGCHANGES":case"BGCHANGES":return i(["type","beat","color1","color2","crossFade","effect","file1","file2","stretchNoLoop","stretchRewind","transition","updateRate"])}}insertEvents(e,t){this.columns[e]||this.createColumn(e);const i=this.columns[e],s=[];t=this.removeOverlapping(t);let n=0;for(;t[0]&&i.events[n];){const a=i.events[n],o=[];for(;t[0]&&this.getTime(a)>=this.getTime(t[0]);)o.push(t.shift());if(o.length==0){n++;continue}i.events.splice(n,0,...o),n+=o.length,this.getTime(o.at(-1))==this.getTime(a)?s.push(...i.events.splice(n,1)):n++}return i.events.push(...t),s}deleteEvents(e,t){this.columns[e]||this.createColumn(e);const i=this.columns[e];t=this.removeOverlapping(t);const s=[];let n=0,a=0;for(;t[n]&&i.events[a];)this.compareEvents(t[n],i.events[a])?(s.push(...i.events.splice(a,1)),n++):a++;return s}getColumnType(e){switch(e){case"BPMS":case"LABELS":case"SPEEDS":case"SCROLLS":case"TICKCOUNTS":case"TIMESIGNATURES":case"COMBOS":return"continuing";case"STOPS":case"WARPS":case"DELAYS":case"FAKES":case"BGCHANGES":case"FGCHANGES":case"ATTACKS":return"instant"}}findConflictingEvents(e){const t=this.columns[e];if(!t)return[];switch(this.getColumnType(t.type)){case"continuing":{const i=[];let s=0;for(;t.events[s]&&this.isNullEvent(t.events[s]);)i.push(t.events[s]),s++;let n=t.events[s];for(s++;sthis.isNullEvent(i))}}parseEvents(e,t){switch(e){case"BPMS":case"STOPS":case"WARPS":case"DELAYS":case"SCROLLS":case"FAKES":this.insertEvents(e,Array.from(t.matchAll(/(-?[\d.]+)=(-?[\d.]+)/g)).map(i=>({type:e,beat:parseFloat(i[1]),value:parseFloat(i[2])})));return;case"TICKCOUNTS":this.insertEvents(e,Array.from(t.matchAll(/(-?[\d.]+)=(-?\d+)/g)).map(i=>({type:"TICKCOUNTS",beat:parseFloat(i[1]),value:parseInt(i[2])})));return;case"LABELS":this.insertEvents(e,Array.from(t.matchAll(/((-?[\d.]+)=([^\n]+)=\d)|((-?[\d.]+)=([^\n,]+))/g)).map(i=>i[1]===void 0?{type:"LABELS",beat:parseFloat(i[5]),value:i[6].trim()}:{type:"LABELS",beat:parseFloat(i[2]),value:i[3].trim()}));return;case"SPEEDS":this.insertEvents(e,Array.from(t.matchAll(/(-?[\d.]+)=(-?[\d.]+)=([\d.]+)=([01])/g)).map(i=>({type:"SPEEDS",beat:parseFloat(i[1]),value:parseFloat(i[2]),delay:parseFloat(i[3]),unit:i[4].trim()=="0"?"B":"T"})));return;case"TIMESIGNATURES":this.insertEvents(e,Array.from(t.matchAll(/(-?[\d.]+)=(\d+)=(\d+)/g)).map(i=>({type:"TIMESIGNATURES",beat:parseFloat(i[1]),upper:parseInt(i[2]),lower:parseInt(i[3])})));return;case"COMBOS":this.insertEvents(e,Array.from(t.matchAll(/(-?[\d.]+)=(\d+)=*(\d+)*/g)).map(i=>({type:"COMBOS",beat:parseFloat(i[1]),hitMult:parseInt(i[2]),missMult:parseInt(i[3]??i[2])})));return;case"ATTACKS":this.insertEvents(e,Array.from(t.matchAll(/TIME=(-?[\d.]+):(END|LEN)=(-?[\d.]+):MODS=([^:]+)/g)).map(i=>({type:"ATTACKS",second:parseFloat(i[1]),endType:i[2].trim(),value:parseFloat(i[3]),mods:i[4].trim()})));return;case"BGCHANGES":case"FGCHANGES":this.insertEvents(e,Array.from(t.matchAll(/(-?[\d.]+)=([^\n]+?)=(-?[\d.]+)=([01])=([01])=([01])=?([^\n=,]*)=?([^\n=,]*)=?([^\n=,]*)=?([^\n=,]*)=?([^\n=,]*)/g)).map(i=>({type:e,beat:parseFloat(i[1]),file:i[2].trim(),updateRate:parseFloat(i[3]),crossFade:i[4].trim()=="1",stretchRewind:i[5].trim()=="1",stretchNoLoop:i[6].trim()=="1",effect:i[7].trim()??"",file2:i[8].trim()??"",transition:i[9].trim()??"",color1:i[10].trim()??"",color2:i[11].trim()??""})))}}typeRequiresSSC(e){switch(e){case"BPMS":case"STOPS":case"ATTACKS":case"BGCHANGES":case"FGCHANGES":return!1;case"WARPS":case"DELAYS":case"LABELS":case"SPEEDS":case"SCROLLS":case"TICKCOUNTS":case"TIMESIGNATURES":case"COMBOS":case"FAKES":return!!this.columns[e]&&this.columns[e].events.length>0}}getDefaultEvent(e,t){switch(e){case"BPMS":return{type:e,beat:t,value:120,second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"STOPS":case"WARPS":case"FAKES":return{type:e,beat:t,value:0,second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"DELAYS":return{type:e,beat:t,value:0,second:this.getSecondsFromBeat(t,"before"),isChartTiming:$t(this)};case"LABELS":return{type:e,beat:t,value:"",second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"SPEEDS":return{type:e,beat:t,value:1,delay:0,unit:"B",second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"SCROLLS":return{type:e,beat:t,value:1,second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"TICKCOUNTS":return{type:e,beat:t,value:4,second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"TIMESIGNATURES":return{type:e,beat:t,upper:4,lower:4,second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"COMBOS":return{type:e,beat:t,hitMult:1,missMult:1,second:this.getSecondsFromBeat(t),isChartTiming:$t(this)};case"ATTACKS":return{type:e,beat:t,second:this.getSecondsFromBeat(t),endType:"LEN",value:1,mods:"",isChartTiming:$t(this)};case"BGCHANGES":case"FGCHANGES":return{type:e,beat:t,file:"",updateRate:1,crossFade:!1,stretchRewind:!1,stretchNoLoop:!1,effect:"",file2:"",transition:"",color1:"",color2:"",second:this.getSecondsFromBeat(t),isChartTiming:$t(this)}}}getEventAtBeat(e,t,i=!0){const s=this.getColumn(e),n=s.events[hi(s.events,t,a=>a.beat)];if(!n)switch(this.getColumnType(s.type)){case"continuing":return i?this.getDefaultEvent(s.type,0):void 0;case"instant":return}return n}updateEvents(e){const t=this.columns[e];if(t){switch(e){case"DELAYS":t.events.forEach(i=>i.second=this.getSecondsFromBeat(i.beat,"before"));break;case"ATTACKS":t.events.forEach(i=>i.beat=this.getBeatFromSeconds(i.second));break;case"BPMS":case"STOPS":case"WARPS":case"LABELS":case"SPEEDS":case"SCROLLS":case"TICKCOUNTS":case"TIMESIGNATURES":case"COMBOS":case"FAKES":case"BGCHANGES":case"FGCHANGES":t.events.forEach(i=>i.second=this.getSecondsFromBeat(i.beat))}t.events.forEach(i=>i.isChartTiming=$t(this))}}_insert(e){e=e.sort((n,a)=>n.type=="ATTACKS"&&a.type=="ATTACKS"?n.second-a.second:n.type!="ATTACKS"&&a.type!="ATTACKS"?n.beat-a.beat:0);const t=this.splitEvents(e),i=[],s=[];for(const[n,a]of t.entries())i.push(...this.insertEvents(n,a)),s.push(...this.findConflictingEvents(n));return{events:e,insertConflicts:i,errors:s}}_modify(e){const t=this.splitEventPairs(e),i=[],s=[];for(const[n,a]of t.entries())this.deleteEvents(n,a.map(o=>o[0]).sort((o,l)=>o.type=="ATTACKS"&&l.type=="ATTACKS"?o.second-l.second:o.type!="ATTACKS"&&l.type!="ATTACKS"?o.beat-l.beat:0)),i.push(...this.insertEvents(n,a.map(o=>o[1]).sort((o,l)=>o.type=="ATTACKS"&&l.type=="ATTACKS"?o.second-l.second:o.type!="ATTACKS"&&l.type!="ATTACKS"?o.beat-l.beat:0))),s.push(...this.findConflictingEvents(n));return{newEvents:e.map(n=>n[1]).sort((n,a)=>n.type=="ATTACKS"&&a.type=="ATTACKS"?n.second-a.second:n.type!="ATTACKS"&&a.type!="ATTACKS"?n.beat-a.beat:0),oldEvents:e.map(n=>n[0]).sort((n,a)=>n.type=="ATTACKS"&&a.type=="ATTACKS"?n.second-a.second:n.type!="ATTACKS"&&a.type!="ATTACKS"?n.beat-a.beat:0),insertConflicts:i,errors:s}}_delete(e){e=e.sort((n,a)=>n.type=="ATTACKS"&&a.type=="ATTACKS"?n.second-a.second:n.type!="ATTACKS"&&a.type!="ATTACKS"?n.beat-a.beat:0);const t=this.splitEvents(e),i=[],s=[];for(const[n,a]of t.entries())s.push(...this.deleteEvents(n,a)),i.push(...this.findConflictingEvents(n));return{removedEvents:s,errors:i}}findEvents(e){const t=this.splitEvents(e),i=[];for(const[s,n]of t.entries()){const a=this.columns[s];if(!a)continue;let o=0,l=0;for(;n[o]&&a.events[l];)this.compareEvents(n[o],a.events[l])?(i.push(a.events[l]),o++):l++}return i}getBeatFromSeconds(e){if(!isFinite(e))return 0;if(this._cache.beatTiming==null&&this.buildBeatTimingDataCache(),e+this.getOffset()<0)return(e+this.getOffset())*this._cache.beatTiming[0].bpm/60;const t=this._cache.beatTiming,i=this.binarySearch(t,"secondClamp",e),s=Math.max(0,e-i.secondAfter);return i.beat+s*i.bpm/60}getSecondsFromBeat(e,t){if(t||="",!isFinite(e))return 0;this._cache.beatTiming==null&&this.buildBeatTimingDataCache();const i=Math.floor(e*1e3)/1e3;if(e<=0){const c=this._cache.beatTiming[0].bpm;return-this.getOffset()+e*60/c}const s=`${e}-${t}`;if(this._cache.beatsToSeconds.has(s))return this._cache.beatsToSeconds.get(s);const n=this._cache.beatTiming,a=this.binarySearch(n,"beat",i);if(a.beat==i){if(t=="noclamp"||t=="")return this._cache.beatsToSeconds.set(s,a.secondOf),a.secondOf;if(t=="before")return this._cache.beatsToSeconds.set(s,a.secondBefore),a.secondBefore;if(t=="after")return this._cache.beatsToSeconds.set(s,a.secondAfter),a.secondAfter}let l=(e-a.beat)*60/a.bpm;return a.warped&&(l=0),t=="noclamp"?(this._cache.beatsToSeconds.set(s,a.secondAfter+l),a.secondAfter+l):(this._cache.beatsToSeconds.set(s,Math.max(a.secondClamp,a.secondAfter+l)),Math.max(a.secondClamp,a.secondAfter+l))}isBeatWarped(e){if(!isFinite(e))return!1;const t=Math.floor(e*1e3)/1e3;if(this._cache.warpedBeats.has(t))return this._cache.warpedBeats.get(t);this._cache.beatTiming==null&&this.buildBeatTimingDataCache();const i=this._cache.beatTiming,s=this.binarySearch(i,"beat",t),n=s.beat==t?s.secondClamp:Math.max(s.secondAfter,s.secondClamp);return s.secondOf=s.beat&&te&&i.beat>0)return e;let s=i.effectiveBeat;const n=e-i.beat;return s+=n*i.value,s}getBeatFromEffectiveBeat(e){if(!isFinite(e))return 0;this._cache.effectiveBeatTiming==null&&this.buildEffectiveBeatTimingDataCache();const t=this._cache.effectiveBeatTiming;if(t.length==0)return e;let i=0;for(;t[i+1]&&(t[i].value<=0||t[i+1].effectiveBeat<=e);)i++;let n=(e-t[i].effectiveBeat)/t[i].value;return isFinite(n)||(n=0),t[i].beat+n}getSpeedMult(e,t){if(!isFinite(e)||!isFinite(t))return 0;const i=this.getColumn("SPEEDS").events;if(i.length==0)return 1;const s=this.binarySearchIndex(i,"beat",e),n=i[s];if(n==null)return 1;let a=e-n.beat;n.unit=="T"&&(a=t-n.second);let o=Ve(a/n.delay,0,1);n.delay==0&&(o=1);const l=i[s-1]?.value??1;return o*(n.value-l)+l}reloadCache(e=[]){let t=e;(e.length==0||e.filter(i=>["WARPS","STOPS","DELAYS","BPMS","OFFSET"].includes(i)).length>0)&&(this.buildBeatTimingDataCache(),t=[...ar]),(e.length==0||e.includes("SCROLLS"))&&this.buildEffectiveBeatTimingDataCache(),(e.length==0||e.includes("TIMESIGNATURES"))&&this.buildMeasureTimingCache(),t.filter(i=>i!="OFFSET").forEach(i=>this.updateEvents(i)),this._cache.sortedEvents=this.mergeColumns(ar.map(i=>this.getColumn(i).events))}getBeatTiming(){return[...this._cache.beatTiming]}getTimingData(...e){return e.length==0?this._cache.sortedEvents:this.mergeColumns(e.map(t=>this.getColumn(t).events))}requiresSSC(){return ar.some(e=>this.typeRequiresSSC(e))}}class oT extends Sg{simfileTimingData;chart;constructor(e,t){super(),this.simfileTimingData=e,this.chart=t}getColumn(e){return this.columns[e]??this.simfileTimingData.getColumn(e)}splitSM(e){const t=[],i=[];for(const s of e)s.isChartTiming?i.push(s):t.push(s);return[t,i]}splitSMPairs(e){const t=[],i=[];for(const s of e)s[0].isChartTiming?i.push(s):t.push(s);return[t,i]}insert(e){let t,i;const s=e.find(o=>o.type=="TIMESIGNATURES"),[n,a]=this.splitSM(e);ht.instance.run({action:o=>{t=this.simfileTimingData._insert(n),this.simfileTimingData._delete(t.errors),i=this._insert(a),this._delete(i.errors),this.simfileTimingData.reloadCache(),o.chartManager.clearSelections(),o.chartManager.setEventSelection(this.findEvents(i.events).concat(this.simfileTimingData.findEvents(t.events))),$.emit("timingModified"),$.emit("chartModified"),s&&$.emit("timeSigChanged")},undo:o=>{this.simfileTimingData._insert(t.errors),this.simfileTimingData._delete(t.events),this.simfileTimingData._insert(t.insertConflicts),this._insert(i.errors),this._delete(i.events),this._insert(i.insertConflicts),this.simfileTimingData.reloadCache(),o.chartManager.clearSelections(),$.emit("timingModified"),$.emit("chartModified"),s&&$.emit("timeSigChanged")}})}modify(e){let t,i;const s=e.find(o=>o[0].type=="TIMESIGNATURES"),[n,a]=this.splitSMPairs(e);ht.instance.run({action:o=>{t=this.simfileTimingData._modify(n),this.simfileTimingData._delete(t.errors),i=this._modify(a),this._delete(i.errors),this.simfileTimingData.reloadCache(),o.chartManager.clearSelections(),o.chartManager.setEventSelection(this.findEvents(i.newEvents).concat(this.simfileTimingData.findEvents(t.newEvents))),$.emit("timingModified"),$.emit("chartModified"),s&&$.emit("timeSigChanged")},undo:o=>{this.simfileTimingData._insert(t.errors),this.simfileTimingData._delete(t.newEvents),this.simfileTimingData._insert(t.insertConflicts),this.simfileTimingData._insert(t.oldEvents),this._insert(i.errors),this._delete(i.newEvents),this._insert(i.insertConflicts),this._insert(i.oldEvents),this.simfileTimingData.reloadCache(),o.chartManager.clearSelections(),o.chartManager.setEventSelection(this.findEvents(i.oldEvents).concat(this.simfileTimingData.findEvents(t.oldEvents))),$.emit("timingModified"),$.emit("chartModified"),s&&$.emit("timeSigChanged")}})}delete(e){let t,i;const s=e.find(o=>o.type=="TIMESIGNATURES"),[n,a]=this.splitSM(e);ht.instance.run({action:o=>{t=this.simfileTimingData._delete(n),this.simfileTimingData._delete(t.errors),i=this._delete(a),this._delete(i.errors),this.simfileTimingData.reloadCache(),o.chartManager.clearSelections(),$.emit("timingModified"),$.emit("chartModified"),s&&$.emit("timeSigChanged")},undo:o=>{this.simfileTimingData._insert(t.errors),this.simfileTimingData._insert(t.removedEvents),this._insert(i.errors),this._insert(i.removedEvents),this.simfileTimingData.reloadCache(),o.chartManager.clearSelections(),o.chartManager.setEventSelection(this.findEvents(i.removedEvents).concat(this.simfileTimingData.findEvents(t.removedEvents))),$.emit("timingModified"),$.emit("chartModified"),s&&$.emit("timeSigChanged")}})}getOffset(){return this.offset??this.simfileTimingData.getOffset()}usesChartTiming(){return this.offset!==void 0||Object.values(this.columns).length>0}hasChartOffset(){return this.offset!==void 0}isPropertyChartSpecific(e){return e in this.columns}reloadCache(e=[]){super.reloadCache(e),this.chart.recalculateNotes()}}class lT extends Sg{offset=0;chartTimingDatas=[];constructor(){super(),ar.forEach(e=>this.createColumn(e))}createChartTimingData(e){const t=new oT(this,e);return this.chartTimingDatas.push(t),t}getColumn(e){return this.columns[e]}getOffset(){return this.offset}reloadCache(e=[]){super.reloadCache(e),this.chartTimingDatas.forEach(t=>t.reloadCache(e))}insert(e){let t;const i=e.find(s=>s.type=="TIMESIGNATURES");ht.instance.run({action:s=>{t=this._insert(e),this._delete(t.errors),this.reloadCache(),s.chartManager.clearSelections(),s.chartManager.setEventSelection(this.findEvents(t.events)),$.emit("timingModified"),$.emit("chartModified"),i&&$.emit("timeSigChanged")},undo:s=>{this._insert(t.errors),this._delete(t.events),this._insert(t.insertConflicts),this.reloadCache(),s.chartManager.clearSelections(),$.emit("timingModified"),$.emit("chartModified"),i&&$.emit("timeSigChanged")}})}modify(e){let t;const i=e.find(s=>s[0].type=="TIMESIGNATURES");ht.instance.run({action:s=>{t=this._modify(e),this._delete(t.errors),this.reloadCache(),s.chartManager.clearSelections(),s.chartManager.setEventSelection(this.findEvents(t.newEvents)),$.emit("timingModified"),$.emit("chartModified"),i&&$.emit("timeSigChanged")},undo:s=>{this._insert(t.errors),this._delete(t.newEvents),this._insert(t.insertConflicts),this._insert(t.oldEvents),this.reloadCache(),s.chartManager.clearSelections(),s.chartManager.setEventSelection(this.findEvents(t.oldEvents)),$.emit("timingModified"),$.emit("chartModified"),i&&$.emit("timeSigChanged")}})}delete(e){let t;const i=e.find(s=>s.type=="TIMESIGNATURES");ht.instance.run({action:s=>{t=this._delete(e),this._delete(t.errors),this.reloadCache(),s.chartManager.clearSelections(),$.emit("timingModified"),$.emit("chartModified"),i&&$.emit("timeSigChanged")},undo:s=>{this._insert(t.errors),this._insert(t.removedEvents),this.reloadCache(),s.chartManager.clearSelections(),s.chartManager.setEventSelection(this.findEvents(t.removedEvents)),$.emit("timingModified"),$.emit("chartModified"),i&&$.emit("timeSigChanged")}})}}const hT=["TITLE","SUBTITLE","ARTIST","TITLETRANSLIT","SUBTITLETRANSLIT","ARTISTTRANSLIT","GENRE","CREDIT","ORIGIN","BACKGROUND","BANNER","MUSIC","CDTITLE","JACKET","DISCIMAGE","CDIMAGE","PREVIEW","LYRICSPATH","SAMPLESTART","SAMPLELENGTH","SELECTABLE"];class Cg{charts={};_type;other_properties={};properties={};timingData=new lT;unloadedCharts=[];loaded;constructor(e){this.loaded=new Promise(t=>{const i=e.name.split(".").pop();i=="sm"||i=="ssc"?this._type=i:t(),e.text().then(s=>{s=s.replaceAll(/\/\/.+/g,"");const n=[...s.matchAll(/#([A-Z]+):([^;]*);/g)];let a=!1,o={};const l=[];for(const c of n)c[1]=="NOTEDATA"&&i=="ssc"||a?(a=!0,o[c[1]]=c[2],c[1]=="NOTES"&&(l.push(o),o={},a=!1)):c[1]=="NOTES"?l.push(c[2]):hT.includes(c[1])?this.properties[c[1]]=c[2]:c[1]=="OFFSET"||ar.includes(c[1])?this.timingData.parse(c[1],c[2]):this.other_properties[c[1]]=c[2];this.charts={};for(const c of l){let u;try{u=new mg(this,c)}catch(h){this.unloadedCharts.push(c),Ce.createFormatted(h instanceof Error?h.message:String(h),"warn");continue}this.addChart(u)}this.timingData.reloadCache(),t()})})}addChart(e){this.charts[e.gameType.id]||=[],this.charts[e.gameType.id].push(e),this.charts[e.gameType.id].sort((t,i)=>xi.indexOf(t.difficulty)==xi.indexOf(i.difficulty)?t.meter-i.meter:xi.indexOf(t.difficulty)-xi.indexOf(i.difficulty))}removeChart(e){if(!this.charts[e.gameType.id])return!1;const t=this.charts[e.gameType.id].indexOf(e);return t==-1?!1:(this.charts[e.gameType.id].splice(t,1),!0)}serialize(e){let t="";e=="sm"?(this.other_properties.NITGVERSION&&(t+=this.formatProperty("NITGVERSION",this.other_properties.NITGVERSION)),t+=this.formatProperty("TITLE",this.properties.TITLE),t+=this.formatProperty("SUBTITLE",this.properties.SUBTITLE),t+=this.formatProperty("ARTIST",this.properties.ARTIST),t+=this.formatProperty("MUSIC",this.properties.MUSIC??""),t+=this.formatProperty("BANNER",this.properties.GENRE),t+=this.formatProperty("BACKGROUND",this.properties.BACKGROUND),t+=this.formatProperty("LYRICSPATH",this.properties.LYRICSPATH),t+=this.formatProperty("CDTITLE",this.properties.CDTITLE),t+=this.formatProperty("SAMPLESTART",this.properties.SAMPLESTART),t+=this.formatProperty("SAMPLELENGTH",this.properties.SAMPLELENGTH)):(t+=this.formatProperty("VERSION",this.other_properties.VERSION??.83),t+=this.formatProperty("TITLE",this.properties.TITLE),t+=this.formatProperty("SUBTITLE",this.properties.SUBTITLE),t+=this.formatProperty("ARTIST",this.properties.ARTIST),t+=this.formatProperty("TITLETRANSLIT",this.properties.TITLETRANSLIT),t+=this.formatProperty("SUBTITLETRANSLIT",this.properties.SUBTITLETRANSLIT),t+=this.formatProperty("ARTISTTRANSLIT",this.properties.ARTISTTRANSLIT),t+=this.formatProperty("GENRE",this.properties.GENRE),t+=this.formatProperty("CREDIT",this.properties.CREDIT),t+=this.formatProperty("MUSIC",this.properties.MUSIC??""),t+=this.formatProperty("BANNER",this.properties.BANNER),t+=this.formatProperty("BACKGROUND",this.properties.BACKGROUND),t+=this.formatProperty("JACKET",this.properties.JACKET),t+=this.formatProperty("DISCIMAGE",this.properties.DISCIMAGE),t+=this.formatProperty("CDIMAGE",this.properties.CDIMAGE),t+=this.formatProperty("SELECTABLE",this.properties.SELECTABLE??"YES"),t+=this.formatProperty("LYRICSPATH",this.properties.LYRICSPATH),t+=this.formatProperty("CDTITLE",this.properties.CDTITLE),t+=this.formatProperty("SAMPLESTART",this.properties.SAMPLESTART),t+=this.formatProperty("SAMPLELENGTH",this.properties.SAMPLELENGTH)),t+=this.timingData.serialize(e);for(const i in this.other_properties)i=="VERSION"||i=="NITGVERSION"||(t+=this.formatProperty(i,this.other_properties[i]));t+=` `;for(const i in this.charts)for(const s of this.charts[i])t+=s.serialize(e)+` `;for(const i of this.unloadedCharts)if(typeof i=="string")t+="#NOTES:"+i+` `;else{t+="//---------------"+i.STEPSTYPE+" - "+i.DESCRIPTION+`--------------- @@ -1249,11 +1249,11 @@ https://github.com/nodeca/pako/blob/main/LICENSE #FGCHANGES:; #KEYSOUNDS:; #ATTACKS:; -`;class Ze{view;input;onChange;min=-Number.MAX_VALUE;max=Number.MAX_VALUE;precision;step=1;lastVal="";constructor(e,t,i,s,n,a){this.view=e,this.view.classList.add("spinner"),this.view.onfocus=()=>{o.focus()};const o=document.createElement("input");o.classList.add("spinner-input"),o.type="text",o.autocomplete="off",o.spellcheck=!1,o.onblur=()=>{if(o.value===this.lastVal)return;if(o.value===""){this.onChange?.(void 0);return}const h=gn(o.value);if(h===null){o.value=this.lastVal;return}let d=ne(h,this.precision??3);d=Ve(d,this.min,this.max),o.value=this.formatValue(d),this.onChange?.(d)},o.onkeydown=h=>{h.key=="Enter"&&o.blur(),h.key=="Escape"&&(o.value=this.lastVal,o.blur())},o.onfocus=()=>{this.lastVal=o.value},this.input=o,this.min=n??this.min,this.max=a??this.max,this.step=i,this.precision=s,this.setValue(t),e.appendChild(o);const l=document.createElement("div");l.classList.add("spinner-btns"),e.appendChild(l);const c=document.createElement("button");c.classList.add("spinner-up"),c.onclick=()=>{a!==void 0&&parseFloat(o.value)+(i??_.general.spinnerStep)>a||(o.value=this.formatValue(parseFloat(o.value)+(i??_.general.spinnerStep)),this.onChange?.(parseFloat(o.value)))},l.appendChild(c);const u=document.createElement("button");u.classList.add("spinner-down"),u.onclick=()=>{n!==void 0&&parseFloat(o.value)-(i??_.general.spinnerStep)r.chartManager.loadAudio()}},{title:"Background Image",propName:"BACKGROUND",input:{type:"file",typeName:"image",accept:ts}},{title:"Banner Image",propName:"BANNER",input:{type:"file",typeName:"image",accept:ts}},{title:"CD Title",propName:"CDTITLE",input:{type:"file",typeName:"image",accept:ts}},{title:"CD Image",propName:"CDIMAGE",input:{type:"file",typeName:"image",accept:ts}},{title:"Jacket",propName:"JACKET",input:{type:"file",typeName:"image",accept:ts}},{title:"Disc Image",propName:"DISCIMAGE",input:{type:"file",typeName:"image",accept:ts}}]},{title:"Song",items:[{title:"Song Preview",propName:"SAMPLESTART",input:{type:"custom",create:(r,e,t)=>{const i=t??ht.instance,s=()=>{a.value{(e??p.chartManager.loadedSM).properties.SAMPLESTART=h,(e??p.chartManager.loadedSM).properties.SAMPLELENGTH=d,n.setValue(parseFloat(h)),a.setValue(parseFloat(h)+parseFloat(d))},undo:()=>{(e??r.chartManager.loadedSM).properties.SAMPLESTART=c,(e??r.chartManager.loadedSM).properties.SAMPLELENGTH=u,n.setValue(parseFloat(c)),a.setValue(parseFloat(c)+parseFloat(u))}})},n=Ze.create(parseFloat((e??r.chartManager.loadedSM).properties.SAMPLESTART??"0"),void 0,3,0);n.onChange=c=>{if(c===void 0){n.setValue(parseFloat((e??r.chartManager.loadedSM).properties.SAMPLESTART??"0"));return}s()};const a=Ze.create(parseFloat((e??r.chartManager.loadedSM).properties.SAMPLESTART??"0")+parseFloat((e??r.chartManager.loadedSM).properties.SAMPLELENGTH??"10"),void 0,3,0);a.onChange=c=>{if(c===void 0){a.setValue(parseFloat((e??r.chartManager.loadedSM).properties.SAMPLESTART??"0")+parseFloat((e??r.chartManager.loadedSM).properties.SAMPLELENGTH??"10"));return}s()};const o=document.createElement("div"),l=document.createElement("div");return l.innerText="to",o.classList.add("flex-row","flex-column-gap"),o.replaceChildren(n.view,l,a.view),o}}}]}];function Ig(r,e,t,i){const s=i??ht.instance;switch(e.input.type){case"custom":return e.input.create(r,t,i);case"string":{const n=document.createElement("input");return n.type="text",n.autocomplete="off",n.spellcheck=!1,n.onkeydown=a=>{a.key=="Enter"&&n.blur()},n.onblur=()=>{const a=(t??r.chartManager.loadedSM).properties[e.propName],o=n.value;s.run({action:l=>{(t??l.chartManager.loadedSM).properties[e.propName]=o,n.value=o},undo:()=>{(t??r.chartManager.loadedSM).properties[e.propName]=a,n.value=a??""}})},n.value=(t??r.chartManager.loadedSM).properties[e.propName]??"",n}case"number":{const n=e.input,a=Ze.create(parseFloat((t??r.chartManager.loadedSM).properties[e.propName])??15,n.step,n.precision,n.min,n.max);return a.onChange=o=>{if(o===void 0){a.setValue(parseFloat((t??r.chartManager.loadedSM).properties[e.propName]??"0"));return}const l=(t??r.chartManager.loadedSM).properties[e.propName],c=o.toString();s.run({action:u=>{(t??u.chartManager.loadedSM).properties[e.propName]=c,a.setValue(parseFloat(c))},undo:()=>{(t??r.chartManager.loadedSM).properties[e.propName]=l,a.setValue(parseFloat(l??"0"))}})},a.view}case"file":{const n=e.input,a=e.input.onChange,o=document.createElement("div");o.classList.add("flex-row","flex-column-gap");const l=document.createElement("input");l.type="text",l.autocomplete="off",l.spellcheck=!1,l.placeholder="click to select a file",l.onclick=h=>{h.preventDefault(),l.blur();const d=r.chartManager.smPath.split("/").slice(0,-1).join("/");if(window.nw){const p=document.createElement("input");p.type="file",p.accept=n.accept.join(","),p.onchange=()=>{const f=Re.getRelativePath(d,p.value),m=(t??r.chartManager.loadedSM).properties[e.propName]??"";s.run({action:g=>{(t??g.chartManager.loadedSM).properties[e.propName]=f,l.value=f},undo:()=>{(t??r.chartManager.loadedSM).properties[e.propName]=m,l.value=m}}),a?.(r)},p.click()}else r.windowManager.openWindow(new ml(r,{title:`Select a${n.typeName.match(/^[aieouAIEOU].*/)?"n":""} ${n.typeName} file...`,accepted_file_types:n.accept,disableClose:!0,callback:p=>{const f=Re.getRelativePath(d,p),m=(t??r.chartManager.loadedSM).properties[e.propName]??"";s.run({action:g=>{(t??g.chartManager.loadedSM).properties[e.propName]=f,l.value=f},undo:()=>{(t??r.chartManager.loadedSM).properties[e.propName]=m,l.value=m}}),a?.(r)}},(t??r.chartManager.loadedSM).properties[e.propName]?d+"/"+(t??r.chartManager.loadedSM).properties[e.propName]:r.chartManager.smPath))},l.value=(t??r.chartManager.loadedSM).properties[e.propName]??"",o.appendChild(l);const c=document.createElement("button");c.style.height="100%",c.classList.add("delete"),c.disabled=!(t??r.chartManager.loadedSM).properties[e.propName],c.onclick=()=>{l.value="",c.disabled=!0};const u=document.createElement("img");return u.classList.add("icon"),u.style.height="12px",u.src=He.TRASH,c.appendChild(u),o.appendChild(c),o}}}class kg extends Pt{app;sm;actionHistory;fileTable={};constructor(e){super({title:"New Song",width:450,height:492,disableClose:!0,win_id:"sm_properties",blocking:!0});const t=new Blob([cT],{type:"text/plain"}),i=new File([t],"song.sm",{type:"text/plain"});this.sm=new Cg(i),this.app=e,this.actionHistory=new ht(this.app),this.initView()}initView(){this.viewElement.replaceChildren(),this.viewElement.classList.add("sm-properties");const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("label"),t.innerText="Apply to",Mg.forEach(l=>{const c=document.createElement("div");c.classList.add("sm-container");const u=document.createElement("div");u.classList.add("sm-title"),u.innerText=l.title;const h=document.createElement("div");h.classList.add("property-grid"),l.items.forEach(d=>{const p=document.createElement("div");p.classList.add("label"),p.innerText=d.title,h.appendChild(p),d.input.type=="file"?h.appendChild(this.createFileElement(d.propName,d.input.typeName)):h.appendChild(Ig(this.app,d,this.sm,this.actionHistory))}),c.appendChild(u),c.appendChild(h),e.appendChild(c)});const i=document.createElement("div");i.classList.add("menu-options");const s=document.createElement("div");s.classList.add("menu-left");const n=document.createElement("div");n.classList.add("menu-right"),i.appendChild(s),i.appendChild(n);const a=document.createElement("button");a.innerText="Cancel",a.onclick=()=>{this.closeWindow()};const o=document.createElement("button");o.innerText="Create",o.classList.add("confirm"),o.onclick=()=>{this.sm.properties.MUSIC===void 0||this.sm.properties.MUSIC===""?this.app.windowManager.openWindow(new fd(this.app,"No audio file uploaded","Are you sure you want to create a file with no audio?",[{type:"confirm",label:"Yes",callback:()=>{this.createSong(),this.closeWindow()}},{type:"default",label:"No"}])):(this.createSong(),this.closeWindow())},s.appendChild(a),n.appendChild(o),e.appendChild(i),this.viewElement.appendChild(e)}async createSong(){let e=this.sm.properties.TITLE;if(window.nw){const t=nw.require("path"),i=document.createElement("input");i.type="file",i.nwsaveas=e+".sm",i.onchange=async()=>{const s=t.basename(i.value,t.extname(i.value));e=t.dirname(i.value);const n=t.join(e,s+".sm");await Re.writeFile(n,this.sm.serialize("sm")),await Promise.all(Object.entries(this.fileTable).map(a=>Re.writeFile(e+`/${a[0]}`,a[1]))),await this.app.chartManager.loadSM(n),this.app.windowManager?.getWindowById("select_sm_initial")?.closeWindow()},i.click()}else{if(await Re.getDirectoryHandle(e)){let t=2;for(;await Re.getDirectoryHandle(e);)e=`${this.sm.properties.TITLE} ${t++}`}await Re.writeFile(e+"/song.sm",this.sm.serialize("sm")),await Promise.all(Object.entries(this.fileTable).map(t=>Re.writeFile(e+`/${t[0]}`,t[1]))),await this.app.chartManager.loadSM(e+"/song.sm"),this.app.windowManager?.getWindowById("select_sm_initial")?.closeWindow()}}createFileElement(e,t){const i=document.createElement("div");i.classList.add("flex-row","flex-column-gap");const s=document.createElement("input");s.type="text",s.autocomplete="off",s.spellcheck=!1,s.placeholder="click to upload a file",s.onclick=o=>{o.preventDefault(),s.blur();const l=document.createElement("input");l.type="file",l.accept=t=="audio"?"audio/*":"image/*",l.onchange=()=>{const c=l.files?.[0];if(!c)return;this.sm.properties[e]&&this.fileTable[this.sm.properties[e]]&&delete this.fileTable[this.sm.properties[e]];let u=c.name;for(;this.fileTable[c.name]&&(this.fileTable[c.name].size!=c.size||this.fileTable[c.name].type!=c.type);)u="_"+u;this.fileTable[u]=c,s.value=u,this.sm.properties[e]=s.value,n.disabled=!1},l.click()},s.value=this.sm.properties[e]??"",i.appendChild(s);const n=document.createElement("button");n.style.height="100%",n.classList.add("delete"),n.disabled=!0,n.onclick=()=>{this.sm.properties[e]&&this.fileTable[this.sm.properties[e]]&&delete this.fileTable[this.sm.properties[e]],this.sm.properties[e]=void 0,s.value="",n.disabled=!0};const a=document.createElement("img");return a.classList.add("icon"),a.style.height="12px",a.src=He.TRASH,n.appendChild(a),i.appendChild(n),i}}class dT extends Pt{app;metronomeInterval;startTime;me_high=new hs.Howl({src:rg,volume:_.audio.soundEffectVolume});me_low=new hs.Howl({src:sg,volume:_.audio.soundEffectVolume});tickLines=[];resultLines=[];previousOffsets=[];keyHandler;constructor(e){super({title:"Offset Adjuster",width:300,height:200,win_id:"offset",blocking:!0}),this.app=e,this.initView(),this.startTime=performance.now();let t=this.startTime+500;this.tickLines.push({time:t+500,beat:0}),this.tickLines.push({time:t+500*2,beat:1}),this.tickLines.push({time:t+500*3,beat:2}),this.tickLines.push({time:t+500*4,beat:3});let i=0;this.metronomeInterval=setInterval(()=>{const s=performance.now();if(s-t>500){for(t=s,(i%4==0?this.me_high:this.me_low).play();this.tickLines[0]?.time+1e3s-n.startTime<8e3)},5),this.keyHandler=s=>{if(s.code.startsWith("Digit")||s.code.startsWith("Key")||s.code=="Space"){let n=this.tickLines[0];const a=performance.now();for(const l of this.tickLines)if(a-l.time+_.play.offset*1e3<300){n=l;break}s.preventDefault();const o=a-n.time+_.play.offset*1e3;o>-300&&(this.tickLines.splice(this.tickLines.indexOf(n),1),this.resultLines.push({startTime:performance.now(),offset:o}),this.previousOffsets.push(o),this.previousOffsets.length==16&&(ug(this.previousOffsets)<70&&(_.play.offset-=fl(this.previousOffsets)/1e3),this.previousOffsets=[]))}},window.addEventListener("keydown",this.keyHandler)}initView(){this.viewElement.replaceChildren();const e=document.createElement("canvas");this.viewElement.appendChild(e);const t=this.drawEQ(e);requestAnimationFrame(t)}drawEQ(e){const t=e.getContext("2d");t.canvas.width=250,t.canvas.height=100;const i=()=>{t.fillStyle="rgba(0, 0, 0, 1)",t.fillRect(0,0,e.width,e.height),t.fillStyle="rgb(255, 255, 255)",t.fillRect(e.width/2-1,8,2,e.height-16);const s=performance.now();for(const n of this.resultLines){t.fillStyle="rgba(255, 255, 255, 1)";const a=Math.min(1,4-(s-n.startTime)/2e3);if(n.offset<0&&(t.fillStyle=`rgba(160, ${sr(160,0,-n.offset/250)}, ${sr(160,0,-n.offset/250)}, ${a})`),n.offset>0&&(t.fillStyle=`rgba(${sr(160,0,n.offset/250)}, ${sr(160,0,n.offset/250)}, 160, ${a})`),t.fillRect(e.width/2-.5+n.offset/4,12,1,e.height-24),s-n.startTime<250){const o=(s-n.startTime)/250;t.globalAlpha=1-o,t.fillRect(e.width/2-.5-o*3+n.offset/4,12-o*10,1+o*6,e.height-24+o*20)}t.globalAlpha=1}for(const n of this.tickLines){const a=n.time-s-_.play.offset*1e3;t.fillStyle="rgba(255, 255, 255, 0.8)",n.beat%4!=0?t.fillRect(e.width/2-1-a/4,12,2,e.height-24):t.fillRect(e.width/2-2-a/4,12,4,e.height-24)}e.closest("#windows")&&requestAnimationFrame(i)};return i}onClose(){clearInterval(this.metronomeInterval),window.removeEventListener("keydown",this.keyHandler)}}class uT extends Pt{app;changeHandler=()=>this.initView();constructor(e){super({title:"Song Properties",width:450,height:486,disableClose:!1,win_id:"sm_properties",blocking:!1}),this.app=e,this.initView(),$.on("smLoaded",this.changeHandler),$.on("undo",this.changeHandler),$.on("redo",this.changeHandler)}onClose(){$.off("smLoaded",this.changeHandler),$.off("undo",this.changeHandler),$.off("redo",this.changeHandler)}initView(){this.viewElement.replaceChildren(),this.viewElement.classList.add("sm-properties");const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("label"),t.innerText="Apply to",Mg.forEach(i=>{const s=document.createElement("div");s.classList.add("sm-container");const n=document.createElement("div");n.classList.add("sm-title"),n.innerText=i.title;const a=document.createElement("div");a.classList.add("property-grid"),i.items.forEach(o=>{const l=document.createElement("div");l.classList.add("label"),l.innerText=o.title,a.appendChild(l),a.appendChild(Ig(this.app,o))}),s.appendChild(n),s.appendChild(a),e.appendChild(s)}),this.viewElement.appendChild(e)}}var pT=yT,Yo=8192,gd=65536,yd=new ArrayBuffer(gd*4),fT=new Float64Array(yd,gd,Yo),mT=new Float64Array(yd,gd*2,Yo/2),gT=vT({Math,Float64Array},null,yd);function yT(r){if(!r)throw Error("Input data is not provided, pass an array.");var e=r.length;if(e>Yo)throw Error("Input length is too big, must be under "+Yo);var t=Math.floor(Math.log(e)/Math.LN2);if(Math.pow(2,t)!==e)throw Error("Invalid array size, must be a power of 2.");return fT.set(r),gT(e,t),mT.subarray(0,e/2)}function vT(r,e,t){var i=6.283185307179586,s=r.Math.sqrt,n=r.Math.sin,a=r.Math.cos,o=r.Math.abs,l=r.Math.SQRT1_2,c=r.Math.imul,u=new r.Float64Array(t),h=new r.Float64Array(t),d=8192,p=16384;function f(g,y){g=g|0,y=y|0;var b=0,A=0,v=0,E=0,C=0,M=0,P=0,k=0,N=0,H=0,T=0,S=0,w=0,F=0,z=0,L=0,te=0,R=0,G=0,D=0,O=0,ee=0,Q=0,K=0,ge=0,Te=0,he=0,pe=0,be=0,oe=0,ue=0,ve=0;for(b=g>>>1,v=2/+(g|0),m(g),oe=0,ve=4;(oe|0)<(g|0);ve=c(ve,4)){for(ue=oe;(ue|0)<(g|0);ue=ue+ve|0)D=h[ue<<3>>3]-h[ue+1<<3>>3],h[ue<<3>>3]=h[ue<<3>>3]+h[ue+1<<3>>3],h[ue+1<<3>>3]=D;oe=c(2,ve-1)}for(E=2,P=g>>>1;P=P>>>1;){oe=0,E=E<<1,ve=E<<1,C=E>>>2,M=E>>>3;do{if((C|0)!=1)for(ue=oe;(ue|0)<(g|0);ue=ue+ve|0)S=ue,w=S+C|0,F=w+C|0,z=F+C|0,k=h[F<<3>>3]+h[z<<3>>3],h[z<<3>>3]=h[z<<3>>3]-h[F<<3>>3],h[F<<3>>3]=h[S<<3>>3]-k,h[S<<3>>3]=h[S<<3>>3]+k,S=S+M|0,w=w+M|0,F=F+M|0,z=z+M|0,k=h[F<<3>>3]+h[z<<3>>3],N=h[F<<3>>3]-h[z<<3>>3],k=-k*l,N=N*l,D=+h[w<<3>>3],h[z<<3>>3]=k+D,h[F<<3>>3]=k-D,h[w<<3>>3]=h[S<<3>>3]-N,h[S<<3>>3]=h[S<<3>>3]+N;else for(ue=oe;(ue|0)<(g|0);ue=ue+ve|0)S=ue,w=S+C|0,F=w+C|0,z=F+C|0,k=h[F<<3>>3]+h[z<<3>>3],h[z<<3>>3]=h[z<<3>>3]-h[F<<3>>3],h[F<<3>>3]=h[S<<3>>3]-k,h[S<<3>>3]=h[S<<3>>3]+k;oe=(ve<<1)-E|0,ve=ve<<2}while((oe|0)<(g|0));for(ge=i/+(E|0),A=1;(A|0)<(M|0);A=A+1|0){Te=+(A|0)*ge,ee=n(Te),O=a(Te),Q=4*O*(O*O-.75),K=4*ee*(.75-ee*ee),oe=0,ve=E<<1;do{for(ue=oe;(ue|0)<(g|0);ue=ue+ve|0)S=ue+A|0,w=S+C|0,F=w+C|0,z=F+C|0,L=ue+C-A|0,te=L+C|0,R=te+C|0,G=R+C|0,N=h[R<<3>>3]*O-h[F<<3>>3]*ee,k=h[R<<3>>3]*ee+h[F<<3>>3]*O,T=h[G<<3>>3]*Q-h[z<<3>>3]*K,H=h[G<<3>>3]*K+h[z<<3>>3]*Q,D=N-T,N=N+T,T=D,h[G<<3>>3]=N+h[te<<3>>3],h[F<<3>>3]=N-h[te<<3>>3],D=H-k,k=k+H,H=D,h[z<<3>>3]=H+h[w<<3>>3],h[R<<3>>3]=H-h[w<<3>>3],h[te<<3>>3]=h[S<<3>>3]-k,h[S<<3>>3]=h[S<<3>>3]+k,h[w<<3>>3]=T+h[L<<3>>3],h[L<<3>>3]=h[L<<3>>3]-T;oe=(ve<<1)-E|0,ve=ve<<2}while((oe|0)<(g|0))}}for(;b=b-1|0;)he=+h[b<<3>>3],pe=+h[g-b-1<<3>>3],be=v*s(he*he+pe*pe),u[p+b<<3>>3]=be;u[p+0<<3>>3]=o(v*h[0])}function m(g){g=g|0;var y=0,b=0,A=1,v=0,E=0;y=g>>>1,b=g-1|0,h[0]=u[d+0<<3>>3];do{for(v=v+y|0,h[A<<3>>3]=u[d+v<<3>>3],h[v<<3>>3]=u[d+A<<3>>3],A=A+1|0,E=y<<1;E=E>>1,((v=v^E)&E)==0;);(v|0)>=(A|0)&&(h[A<<3>>3]=u[d+v<<3>>3],h[v<<3>>3]=u[d+A<<3>>3],h[b-A<<3>>3]=u[d+b-v<<3>>3],h[b-v<<3>>3]=u[d+b-A<<3>>3]),A=A+1|0}while((A|0)<(y|0));h[b<<3>>3]=u[d+b<<3>>3]}return f}const Up=da(pT),pr=1e3,Xe=300,gi=1024,gt=512,Ls=4096,fr=2,gh=3,Pn=125,Rn=250,ro=3,Gp=.01,bT=.02,Os=6,yh=800,Hp=15,Wt=32768,vh=[{frequency:20,weight:.4006009013520281},{frequency:25,weight:.4258037044922291},{frequency:31.5,weight:.4536690484291709},{frequency:40,weight:.4840856831659204},{frequency:50,weight:.5142710208279764},{frequency:63,weight:.5473453749315819},{frequency:80,weight:.5841121495327103},{frequency:100,weight:.6214074879602299},{frequency:125,weight:.6601749463607856},{frequency:160,weight:.7054673721340388},{frequency:200,weight:.7489234225800412},{frequency:250,weight:.7936507936507937},{frequency:315,weight:.8406893652795292},{frequency:400,weight:.889284126278346},{frequency:500,weight:.9291521486643438},{frequency:630,weight:.9675858732462506},{frequency:800,weight:.9985022466300548},{frequency:1e3,weight:.9997500624843789},{frequency:1250,weight:.9564801530368244},{frequency:1600,weight:.9409550693954364},{frequency:2e3,weight:1.0196278358399185},{frequency:2500,weight:1.0955902492467817},{frequency:3150,weight:1.1232799775344005},{frequency:4e3,weight:1.0914051841746248},{frequency:5e3,weight:.9997500624843789},{frequency:6300,weight:.8727907484180668},{frequency:8e3,weight:.7722007722007722},{frequency:1e4,weight:.7369196757553427},{frequency:12500,weight:.7768498737618955},{frequency:16e3,weight:.7698229407236336},{frequency:2e4,weight:.4311738708634257},{frequency:22550,weight:.2},{frequency:25e3,weight:0}];class AT extends Pt{app;onAudioLoad=this.reset.bind(this);monoAudioData;audioLength=0;sampleRate=44100;tempogram=[];tempogramGroups=[];spectrogram=[];spectrogramDifference=[];noveltyCurve=[];noveltyCurveIsolated=[];spectrogramCanvases=[];lowestFinishedBlock=0;numRenderedBlocks=0;peaks=[];_threshold=.3;spectroHeights=[];spectroWeights=[];lastBeat=-1;updateInterval;bpm;offset;placeNotesButton;toggleButton;changeHandler=this.updateSpinners.bind(this);doAnalysis=!1;constructor(e){super({title:"Sync Audio",width:500,height:400,win_id:"sync-audio"}),this.app=e,this.initView(),this.reset(),this.updateInterval=setInterval(()=>{Math.round(this.app.chartManager.getBeat()*1e3)/1e3!=this.lastBeat&&(this.lastBeat=Math.round(this.app.chartManager.getBeat()*1e3)/1e3,this.updateSpinners())},17),$.on("timingModified",this.changeHandler),$.on("chartLoaded",this.changeHandler),$.on("audioLoaded",this.onAudioLoad)}onClose(){$.off("timingModified",this.changeHandler),$.off("chartLoaded",this.changeHandler),$.off("audioLoaded",this.onAudioLoad),this.app.chartManager.chartAudio.offLoad(this.onAudioLoad),clearInterval(this.updateInterval)}updateSpinners(){document.activeElement!=this.offset.input&&this.offset.setValue(this.app.chartManager.loadedChart?.timingData.getOffset()??0),document.activeElement!=this.bpm.input&&this.bpm.setValue(this.app.chartManager.loadedChart?.timingData.getEventAtBeat("BPMS",this.app.chartManager.getBeat())?.value??120)}initView(){this.viewElement.replaceChildren(),this.lastBeat=Math.round(this.app.chartManager.getBeat()*1e3)/1e3;const e=document.createElement("div");e.classList.add("sync-spinner-container");const t=document.createElement("div");t.innerText="Offset",this.offset=Ze.create(this.app.chartManager.loadedChart?.timingData.getOffset()??0,.001,3),this.offset.onChange=m=>{m!=null&&(!this.app.chartManager.loadedChart||!this.app.chartManager.loadedSM||((this.app.chartManager.loadedChart.timingData.hasChartOffset()?this.app.chartManager.loadedChart.timingData:this.app.chartManager.loadedSM.timingData).setOffset(m),this.app.chartManager.setBeat(this.app.chartManager.getBeat())))},e.replaceChildren(t,this.offset.view);const i=document.createElement("div");i.classList.add("sync-spinner-container");const s=document.createElement("div");s.innerText="BPM",this.bpm=Ze.create(this.app.chartManager.loadedChart?.timingData.getEventAtBeat("BPMS",this.app.chartManager.getBeat())?.value??120,.001,3),this.bpm.onChange=m=>{m!=null&&(!this.app.chartManager.loadedChart||!this.app.chartManager.loadedSM||((this.app.chartManager.loadedChart.timingData.isPropertyChartSpecific("BPMS")?this.app.chartManager.loadedChart.timingData:this.app.chartManager.loadedSM.timingData).insert([{type:"BPMS",beat:this.app.chartManager.getBeat(),value:m}]),this.app.chartManager.setBeat(this.app.chartManager.getBeat())))},i.replaceChildren(s,this.bpm.view);const n=document.createElement("div");n.classList.add("sync-container"),n.style.display="flex",n.style.flexDirection="column",n.style.alignItems="center";const a=document.createElement("div");a.classList.add("sync-top-container"),a.replaceChildren(e,i);const o=document.createElement("div");o.classList.add("sync-bottom-container"),this.toggleButton=document.createElement("button"),this.toggleButton.innerText="Start analyzing",this.toggleButton.style.width="120px",this.toggleButton.onclick=()=>{this.doAnalysis=!this.doAnalysis,this.toggleButton.innerText=this.doAnalysis?"Stop analyzing":"Start analyzing"},this.placeNotesButton=document.createElement("button"),this.placeNotesButton.innerText=this.app.chartManager.startRegion!==void 0&&this.app.chartManager.endRegion!==void 0?"Place onsets as notes in region":"Place onsets as notes",this.placeNotesButton.style.width="185px",this.placeNotesButton.onclick=()=>this.placeOnsets();const l=document.createElement("div");l.style.display="flex",l.style.alignItems="center",l.style.flexDirection="column";const c=document.createElement("div");c.style.display="flex",c.style.alignItems="center";const u=document.createElement("div");u.innerText="Onset Threshold";const h=document.createElement("input");h.type="range",h.min="0",h.max="1",h.step="0.01",h.value=`${this._threshold}`,h.style.width="75px";const d=document.createElement("input");d.type="text",d.value=`${this._threshold}`,d.onblur=()=>{let m=gn(d.value);if(m===null){d.value=`${this._threshold}`;return}m=Ve(m,0,1),d.value=ne(m,2).toString(),d.blur(),this.threshold=m,h.value=m.toString()},h.oninput=()=>{const m=parseFloat(h.value);d.value=ne(m,3).toString(),this.threshold=m},d.style.width="50px",d.onkeydown=m=>{m.key=="Enter"&&d.blur()},c.replaceChildren(h,d),l.replaceChildren(u,c),o.replaceChildren(l,this.placeNotesButton,this.toggleButton);const p=document.createElement("canvas");p.style.width=`${pr/2}px`,p.style.height=`${Xe}px`,n.replaceChildren(a,p,o),this.viewElement.appendChild(n);const f=this.windowLoop(p);requestAnimationFrame(f)}async reset(){this._threshold=.3,this.doAnalysis=!1,this.toggleButton.disabled=!1,this.toggleButton.style.background="",this.toggleButton.innerText="Start analyzing",this.app.chartManager.chartAudio.onLoad(this.onAudioLoad),await this.getMonoAudioData(),this.sampleRate=this.app.chartManager.chartAudio.getSampleRate(),this.spectroHeights=new Array(gi).fill(0).map((t,i)=>{const s=i/(gi/2)*this.sampleRate/2,n=(i+1)/(gi/2)*this.sampleRate/2,a=Xe-Ve(Math.log(s/20)/Math.log(this.sampleRate/40)*Xe,0,Xe),o=Xe-Ve(Math.log(n/20)/Math.log(this.sampleRate/40)*Xe,0,Xe);return{y:o,height:a-o}}),this.spectroWeights=new Array(gi).fill(0).map((t,i)=>{const s=i/(gi/2)*this.sampleRate/2,n=vh.findIndex(l=>l.frequency>s);if(n<1)return 0;const a=vh[n-1],o=vh[n];return sr(a.weight,o.weight,Ai(Math.log(1+a.frequency),Math.log(1+o.frequency),Math.log(1+s)))});const e=Math.max(1,Math.ceil(this.audioLength/gt));this.spectrogramCanvases=[];for(let t=0;t{if(this.placeNotesButton.innerText=this.app.chartManager.startRegion!==void 0&&this.app.chartManager.endRegion!==void 0?"Place onsets as notes in region":"Place onsets as notes",!this.app.chartManager.chartAudio)return;const s=Math.ceil(this.audioLength/gt);if(this.monoAudioData&&this.doAnalysis){const h=performance.now();for(;performance.now()-h=Math.ceil(this.monoAudioData.length/gt)){this.tempogram.length==0&&(this.toggleButton.disabled=!0,this.toggleButton.innerText="Finding tempo",this.calcTempogram());break}this.spectrogram[this.lowestFinishedBlock]===void 0&&(this.renderBlock(this.lowestFinishedBlock),this.calcDifference(this.lowestFinishedBlock),this.calcIsolatedNovelty(this.lowestFinishedBlock),this.numRenderedBlocks++),this.lowestFinishedBlock++}this.lowestFinishedBlocky.centerh.center-Os);g!==void 0&&(d+=g.groups[0].value,p+=g.avg,f++)}d/=f,p/=f,t.font=`${18+d*300}px Assistant`,t.globalAlpha=Math.min(1,(h.groups[0].value-Gp)*100),t.fillText(ne(p,0)+"",200,sr(Xe*2,Xe*1.5,Ai(Pn,Rn,p)))}t.globalAlpha=1,t.font="22px Assistant",t.textAlign="left",t.textBaseline="top",t.fillText("Spectogram",10,10),t.fillText("Onsets",10,Xe+10),t.fillText("Tempogram",10,Xe*1.5+10),e.closest("#windows")&&requestAnimationFrame(i)};return i}renderBlock(e){if(!this.monoAudioData)return;const t=new Float32Array(gi);t.set(this.monoAudioData.subarray(Math.max(0,e*gt-gi/2),e*gt+gi/2),-Math.min(0,e*gt-gi/2));for(let s=0;s{const a=this.spectroHeights[n],o=Ve(s*2e3,0,255);i.globalAlpha=o/255,i.fillRect(e%Wt,a.y,1,a.height)}),i.globalAlpha=1}storeDifferenceResponse(e,t){this.spectrogramDifference[e]=t;const i=t.reduce((s,n)=>s+n,0);this.noveltyCurve[e]=i}calcIsolatedNovelty(e){for(let t=e-gh;t<=e;t++){if(t<0)continue;let i=0,s=0;for(let n=t-gh;n<=t+gh;n++)this.noveltyCurve[n]!==void 0&&(i+=this.noveltyCurve[n],s++);i/=s,this.storeIsolatedNovelty(t,Math.max(0,this.noveltyCurve[t]-i))}}storeIsolatedNovelty(e,t){this.noveltyCurveIsolated[e]=Math.log(1+t),Math.log(1+t)>this._threshold&&Math.log(1+t)>(this.noveltyCurveIsolated[e-1]??0)?(this.peaks[e-1]&&(this.peaks[e-1]=!1),this.peaks[e]=!0):this.peaks[e]=!1;const i=this.spectrogramCanvases[Math.floor(e/Wt)].getContext("2d"),s=Math.min(1,Math.log(1+t))*Xe*.5;i.fillStyle="rgb(11, 14, 26)",i.fillRect(e%Wt,Xe,1,Xe*.5),i.fillStyle="rgba(0, 100, 150, 0.5)",i.fillRect(e%Wt,Xe*1.5-s,1,s)}async getMonoAudioData(){const e=this.app.chartManager.chartAudio;if(!e)return;const t=e.getBuffer(),i=new OfflineAudioContext(t.numberOfChannels,t.length,t.sampleRate),s=i.createBufferSource();s.buffer=t;const n=i.createChannelMerger(t.numberOfChannels);s.connect(n),n.connect(i.destination),s.start(),await i.startRendering().then(a=>{this.monoAudioData=a.getChannelData(0),this.audioLength=this.monoAudioData.length}).catch(()=>{Ce.createFormatted("Failed to load audio: audio rendering failed","error")})}get threshold(){return this._threshold}set threshold(e){this._threshold=e,this.peaks=this.noveltyCurveIsolated.map((t,i)=>t>this._threshold&&(this.noveltyCurveIsolated[i-1]??0)f.groups[0].value>=bT);if(p.length!=0&&(i=h,p.forEach(f=>{let m=0,g=0;for(let b=h-ro;b<=h+ro;b++){if(this.tempogramGroups[b]===void 0)continue;const A=this.tempogramGroups[b].find(v=>v.centerf.center-Os);A!==void 0&&(g+=A.avg,m++)}const y=Math.round(g/m);e.has(y)||e.set(y,0),e.set(y,e.get(y)+1),e.get(y)>t&&(t=e.get(y),s=y)}),t>50))break}if(s==0)return;const n=60/s*(this.sampleRate/gt),a=new Array(yh).fill(0).map((h,d)=>{const p=d%n/n;let f=0,m=0;for(let g=1;g<=4;g++)m+=Math.max(1-Math.abs(Math.round(p*g)/g-p)*12,0)*1/g,f+=1/g;return m/f});let o=0,l=0;const c=[];for(let h=i;ha[f]*p).reduce((p,f)=>p+f,0);d>o&&(o=d,l=h),c.push({block:h,offset:-(h*gt/this.sampleRate)%(60/s),response:d,curve:this.noveltyCurveIsolated.slice(h,h+yh).map((p,f)=>a[f]*p)})}c.sort((h,d)=>d.response-h.response);const u=-(l*gt/this.sampleRate%(60/s));console.log(s,e,i,u,c)}placeOnsets(){const e=this.peaks.map((t,i)=>{if(!t)return null;let s=this.app.chartManager.loadedChart.getBeatFromSeconds(i*gt/this.sampleRate);return s=Math.round(s*48)/48,s<0?null:{type:"Tap",beat:s,col:0}}).filter(t=>t!==null).filter(t=>this.app.chartManager.startRegion===void 0||this.app.chartManager.endRegion===void 0?!0:t.beat>this.app.chartManager.startRegion&&t.beatd.beat==n.beat):-1,o=i.getDivisionLength(e);const l=i.getDivisionOfMeasure(e)%1*o;let c=Math.max(0,e-l);c=s[a+1]?.beat&&(a++,n=s[a],c=n.beat,o=i.getDivisionLength(c),u=0,h=n.upper)}calcTempogram(){let e=0;for(let a=0;ae&&(e=this.noveltyCurveIsolated[a]);const t=new Float32Array(this.noveltyCurveIsolated.length);for(let a=0;a{const o=new Float32Array(Ls);o.set(t.subarray(Math.max(0,a*fr-Ls/2),a*fr+Ls/2),-Math.min(0,a*fr-Ls/2));for(let c=0;cn(++a),1)):(this.calculateOffset(),this.spectrogram=[],this.noveltyCurve=[],this.tempogram=[],this.monoAudioData=void 0,this.toggleButton.innerText="Finished analyzing",this.toggleButton.style.background="#265296")};n(0)}storeTempogram(e,t){const i=new Map,s=[];t.forEach((a,o)=>{let l=this.sampleRate*60/(gt*Ls)*o;if(!(l>Rn*4||lRn&&l!=1/0;)l/=2;for(;l({bpm:a,value:o})).sort((a,o)=>o.value-a.value).filter(a=>a.value!=0);for(let a=0;ac.centero.bpm-Os);if(l===void 0){s.push({center:o.bpm,groups:[o]});continue}l.groups.push(o)}this.tempogramGroups[e]=s.map(a=>({...a,avg:a.groups.reduce((o,l)=>o+l.bpm*l.value,0)/a.groups.reduce((o,l)=>o+l.value,0)}));const n=this.spectrogramCanvases[Math.floor(e*fr/Wt)].getContext("2d");n.fillStyle="rgba(0, 166, 255, 1)",this.tempogram[e].forEach(a=>{const o=Ve(a.value*8e3,0,255);n.globalAlpha=o/255,n.fillRect(e*fr%Wt,sr(Xe*2,Xe*1.5,Ai(Pn,Rn,a.bpm)),1*fr,Xe*.5/(Rn-Pn))})}}const Jt=r=>r,Wp={offset:{title:"Offset",element:Jt({create:(r,e)=>{const t=Ze.create(0,.001,3);return t.onChange=i=>{i!=null&&(e().setOffset(i),r.chartManager.setBeat(r.chartManager.getBeat()))},t.view},update:(r,e)=>{const t=r.querySelector(".spinner-input");if(document.activeElement==t)return;const i=e.getOffset();t.value!=ne(i,3).toFixed(3)&&(t.value=ne(i,3).toFixed(3))}})},bpm:{title:"BPM",element:Jt({create:(r,e)=>{const t=Ze.create(120,void 0,3);return t.onChange=i=>{if(i==null){const s=r.chartManager.getBeat();e().delete([{type:"BPMS",beat:s}]);return}e().insert([{type:"BPMS",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("BPMS",t)?.value??120;i.value!=ne(s,3).toFixed(3)&&(i.value=ne(s,3).toFixed(3))}})},stop:{title:"Stop",element:Jt({create:(r,e)=>{const t=Ze.create(0,void 0,3);return t.onChange=i=>{if(i==null||i==0){const s=r.chartManager.getBeat();e().delete([{type:"STOPS",beat:s}]);return}e().insert([{type:"STOPS",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("STOPS",t);let n=s?.value??0;t!=s?.beat&&(n=0),i.value!=ne(n,3).toFixed(3)&&(i.value=ne(n,3).toFixed(3))}})},delay:{title:"Delay",element:Jt({create:(r,e)=>{const t=Ze.create(0,void 0,3);return t.onChange=i=>{if(i==null||i==0){const s=r.chartManager.getBeat();e().delete([{type:"DELAYS",beat:s}]);return}e().insert([{type:"DELAYS",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("DELAYS",t);let n=s?.value??0;t!=s?.beat&&(n=0),i.value!=ne(n,3).toFixed(3)&&(i.value=ne(n,3).toFixed(3))}})},warp:{title:"Warp",element:Jt({create:(r,e)=>{const t=Ze.create(0,void 0,3,0);return t.onChange=i=>{if(i==null||i==0){const s=r.chartManager.getBeat();e().delete([{type:"WARPS",beat:s}]);return}i<0||e().insert([{type:"WARPS",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("WARPS",t);let n=s?.value??0;t!=s?.beat&&(n=0),i.value!=ne(n,3).toFixed(3)&&(i.value=ne(n,3).toFixed(3))}})},timeSig:{title:"Time Sig.",element:Jt({create:(r,e)=>{const t=document.createElement("div");t.classList.add("flex-column-gap");const i=Ze.create(4,1,0,1);i.onChange=n=>{if(n==null){const a=r.chartManager.getBeat();e().delete([{type:"TIMESIGNATURES",beat:a}]);return}n<1||e().insert([{type:"TIMESIGNATURES",beat:r.chartManager.getBeat(),upper:n,lower:s.value}])};const s=Ze.create(4,1,0,1);return s.onChange=n=>{if(n==null){const a=r.chartManager.getBeat();e().delete([{type:"TIMESIGNATURES",beat:a}]);return}n<1||e().insert([{type:"TIMESIGNATURES",beat:r.chartManager.getBeat(),upper:i.value,lower:n}])},t.appendChild(i.view),t.appendChild(s.view),t},update:(r,e,t)=>{const i=r.firstElementChild.querySelector(".spinner-input"),s=r.lastElementChild.querySelector(".spinner-input"),n=e.getEventAtBeat("TIMESIGNATURES",t),a=n?.upper??4,o=n?.lower??4;document.activeElement!=i&&i.value!=Math.round(a).toString()&&(i.value=Math.round(a).toString()),document.activeElement!=s&&s.value!=Math.round(o).toString()&&(s.value=Math.round(o).toString())}})},tick:{title:"Tickcount",element:Jt({create:(r,e)=>{const t=Ze.create(4,1,0,0);return t.onChange=i=>{if(i==null){const s=r.chartManager.getBeat();e().delete([{type:"TICKCOUNTS",beat:s}]);return}i<0||e().insert([{type:"TICKCOUNTS",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("TICKCOUNTS",t)?.value??4;i.value!=Math.round(s).toString()&&(i.value=Math.round(s).toString())}})},combo:{title:"Combo",element:Jt({create:(r,e)=>{const t=document.createElement("div");t.classList.add("flex-column-gap");const i=Ze.create(1,1,0,0);i.onChange=n=>{if(n==null){const a=r.chartManager.getBeat();e().delete([{type:"COMBOS",beat:a}]);return}n<0||e().insert([{type:"COMBOS",beat:r.chartManager.getBeat(),hitMult:n,missMult:s.value}])};const s=Ze.create(1,1,0,0);return s.onChange=n=>{if(n==null){const a=r.chartManager.getBeat();s.setValue(r.chartManager.loadedChart?.timingData.getEventAtBeat("COMBOS",a)?.missMult??1);return}n<0||e().insert([{type:"COMBOS",beat:r.chartManager.getBeat(),hitMult:i.value,missMult:n}])},t.appendChild(i.view),t.appendChild(s.view),t},update:(r,e,t)=>{const i=r.firstElementChild.querySelector(".spinner-input"),s=r.lastElementChild.querySelector(".spinner-input"),n=e.getEventAtBeat("COMBOS",t),a=n?.hitMult??1,o=n?.missMult??1;document.activeElement!=i&&i.value!=Math.round(a).toString()&&(i.value=Math.round(a).toString()),document.activeElement!=s&&s.value!=Math.round(o).toString()&&(s.value=Math.round(o).toString())}})},speed:{title:"Speed",element:Jt({create:(r,e)=>{const t=document.createElement("div");t.classList.add("flex-column-gap");const i=()=>{e().insert([{type:"SPEEDS",beat:r.chartManager.getBeat(),value:s.value,delay:n.value,unit:a.value=="Beats"?"B":"T"}])},s=Ze.create(1,.1,0);s.onChange=o=>{if(o==null){const l=r.chartManager.getBeat();e().delete([{type:"SPEEDS",beat:l}]);return}i()};const n=Ze.create(1,.1,0);n.onChange=o=>{o==null||o<0||i()};const a=pi.create(["Beat","Time"],"Beats");return a.onChange=i,t.appendChild(s.view),t.appendChild(n.view),t.appendChild(a.view),t},update:(r,e,t)=>{const i=r.firstElementChild.querySelector(".spinner-input"),s=r.children[1].querySelector(".spinner-input"),n=e.getEventAtBeat("SPEEDS",t),a=n?.value??1,o=n?.delay??0,l=n?.unit=="B"?"Beat":"Time";document.activeElement!=i&&i.value!=ne(a,3).toFixed(3)&&(i.value=ne(a,3).toFixed(3)),document.activeElement!=s&&s.value!=ne(o,3).toFixed(3)&&(s.value=ne(o,3).toFixed(3)),s.disabled=n?.beat!=t;const c=r.lastElementChild.querySelector(".dropdown-selected");c.innerText!=l&&(c.innerText=l),n?.beat!=t?c.classList.add("disabled"):c.classList.remove("disabled")}})},scroll:{title:"Scroll",element:Jt({create:(r,e)=>{const t=Ze.create(1,void 0,3);return t.onChange=i=>{if(i==null){const s=r.chartManager.getBeat();e().delete([{type:"SCROLLS",beat:s}]);return}e().insert([{type:"SCROLLS",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("SCROLLS",t)?.value??1;i.value!=ne(s,3).toFixed(3)&&(i.value=ne(s,3).toFixed(3))}})},fake:{title:"Fake",element:Jt({create:(r,e)=>{const t=Ze.create(1,void 0,3,0);return t.onChange=i=>{if(i==null){const s=r.chartManager.getBeat();e().delete([{type:"FAKES",beat:s}]);return}i<0||e().insert([{type:"FAKES",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("FAKES",t);let n=s?.value??1;t!=s?.beat&&(n=0),i.value!=ne(n,3).toFixed(3)&&(i.value=ne(n,3).toFixed(3))}})},label:{title:"Label",element:Jt({create:(r,e)=>{const t=document.createElement("input");return t.type="text",t.autocomplete="off",t.spellcheck=!1,t.onkeydown=i=>{i.key=="Enter"&&t.blur()},t.onblur=()=>{if(t.value==""){const i=r.chartManager.getBeat();e().delete([{type:"LABELS",beat:i}]);return}e().insert([{type:"LABELS",beat:r.chartManager.getBeat(),value:t.value}])},t},update:(r,e,t)=>{const i=r;if(document.activeElement==i)return;const n=e.getEventAtBeat("LABELS",t)?.value??"";i.value!=n&&(i.value=n)}})}};class wT extends Pt{app;lastBeat;chartTiming=!1;interval;changeHandler=()=>this.setData();constructor(e){super({title:"Edit Timing Data",width:300,height:340,disableClose:!1,win_id:"timing_data",blocking:!1}),this.app=e,this.lastBeat=Math.round(this.app.chartManager.getBeat()*1e3)/1e3,this.chartTiming=this.app.chartManager.loadedChart.timingData.usesChartTiming(),this.initView(),this.interval=setInterval(()=>{Math.round(this.app.chartManager.getBeat()*1e3)/1e3!=this.lastBeat&&(this.lastBeat=Math.round(this.app.chartManager.getBeat()*1e3)/1e3,this.setData())},17),$.on("timingModified",this.changeHandler),$.on("chartLoaded",this.changeHandler)}onClose(){$.off("timingModified",this.changeHandler),clearInterval(this.interval)}initView(){this.viewElement.replaceChildren(),this.viewElement.classList.add("timing-data");const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("label"),t.innerText="Apply to";const i=pi.create(["All charts","This chart"],this.chartTiming?"This chart":"All charts");i.onChange(s=>{this.chartTiming=s=="This chart"}),e.appendChild(t),e.appendChild(i.view),Object.values(Wp).forEach(s=>{const n=document.createElement("div");n.classList.add("label"),n.innerText=s.title;const a=s.element.create(this.app,()=>this.chartTiming?this.app.chartManager.loadedChart.timingData:this.app.chartManager.loadedSM.timingData);e.appendChild(n),e.appendChild(a)}),this.viewElement.appendChild(e),this.setData()}setData(){this.app.chartManager.loadedChart&&Object.values(Wp).forEach((e,t)=>{const i=this.viewElement.children[0].children[t*2+3];e.element.update(i,this.app.chartManager.loadedChart.timingData,this.lastBeat)})}}const Vp=[{type:"group",id:"general",label:"General",children:[{type:"subgroup",children:[{type:"item",label:"Smooth Animations",id:"general.smoothAnimations",input:{type:"checkbox",onChange:(r,e)=>{e?document.body.classList.add("animated"):document.body.classList.remove("animated")}}},{type:"item",label:"Warn before exit",id:"general.warnBeforeExit",input:{type:"checkbox"},tooltip:"Warn before exiting the editor if you have unsaved changes."},{type:"item",label:"Spinner step",id:"general.spinnerStep",input:{type:"slider",min:0,step:.1,max:5,hardMin:0,hardMax:2**31-1},tooltip:"The default increment for all number spinners."}]}]},{type:"group",id:"chart",label:"Chart",children:[{type:"subgroup",label:"Playfield",children:[{type:"subgroup",children:[{type:"item",label:"Enable mouse placement",id:"chart.mousePlacement",input:{type:"checkbox"}}]},{type:"subgroup",children:[{type:"item",label:"Zoom",id:"chart.zoom",input:{type:"slider",min:50,step:1,max:200,hardMax:2**31-1,transformers:{serialize:r=>r*100,deserialize:r=>r/100}}},{type:"item",label:"Reverse playfield",id:"chart.reverse",input:{type:"checkbox"}}]},{type:"subgroup",children:[{type:"item",label:"Y position",id:"chart.receptorYPos",input:{type:"slider",min:-400,max:0,hardMin:-(2**31-1),hardMax:2**31-1}},{type:"item",label:"Draw length",id:"chart.maxDrawBeats",input:{type:"slider",min:0,max:30,hardMax:2**31-1},tooltip:"Maximum number of beats to draw notes. Increasing this works well for songs with high bpm but can affect performance. Only applies to XMod."},{type:"item",label:"Draw length past receptors",id:"chart.maxDrawBeatsBack",input:{type:"slider",min:0,max:30,hardMax:2**31-1},tooltip:"Maximum number of beats to draw notes past the receptors. Increasing this can affect performance. Only applies to XMod."}]},{type:"subgroup",children:[{type:"item",label:"Draw noteflashes",id:"chart.drawNoteFlash",input:{type:"checkbox"}}]}]},{type:"subgroup",label:"Scrolling",children:[{type:"item",label:"Scroll sensitivity",id:"chart.scroll.scrollSensitivity",input:{type:"slider",min:0,step:1,max:200,hardMax:2**31-1,transformers:{serialize:r=>r*100,deserialize:r=>r/100}},tooltip:"Adjust the scroll sensitivity when scrolling through the chart."},{type:"item",label:"Snap every scroll",id:"chart.scroll.scrollSnapEveryScroll",input:{type:"checkbox"},tooltip:"Whether each scroll movement corresponds to moving one snap unit when scrolling. Turning this on will have the same behavior as ArrowVortex. Recommended on for those using a mouse, off for those using trackpad."},{type:"item",label:"Invert zoom in/out",id:"chart.scroll.invertZoomScroll",input:{type:"checkbox"},tooltip:"Inverts the zoom in/out control when scrolling."},{type:"item",label:"Invert scroll direction when in reverse",id:"chart.scroll.invertReverseScroll",input:{type:"checkbox"}}]},{type:"subgroup",label:"Waveform",children:[{type:"item",label:"Draw waveform",id:"chart.waveform.enabled",input:{type:"checkbox"}},{type:"subgroup",children:[{type:"item",label:"Color",id:"chart.waveform.color",input:{type:"color"}},{type:"item",label:"Opacity",id:"chart.waveform.opacity",input:{type:"slider",min:0,max:1,step:.01}}]},{type:"subgroup",children:[{type:"item",label:"Draw filtered waveform",id:"chart.waveform.allowFilter",input:{type:"checkbox"}},{type:"item",label:"Filtered color",id:"chart.waveform.filteredColor",input:{type:"color"}},{type:"item",label:"Filtered opacity",id:"chart.waveform.filteredOpacity",input:{type:"slider",min:0,max:1,step:.01}}]},{type:"item",label:"Line height",id:"chart.waveform.lineHeight",input:{type:"slider",min:1,max:3,step:.1,hardMax:100},tooltip:"The height of each line of the waveform. Increasing this can help performance."},{type:"item",label:"Antialiasing",id:"chart.waveform.antialiasing",input:{type:"checkbox"}},{type:"item",label:"Allow speed changes",id:"chart.waveform.speedChanges",input:{type:"checkbox"},tooltip:"Allows the waveform to be affected by SPEEDS and SCROLLS."}]}]},{type:"group",id:"audio",label:"Audio",children:[{type:"subgroup",children:[{type:"item",label:"Master volume",id:"audio.masterVolume",input:{type:"slider",min:0,step:1,max:100,hardMax:2**31-1,transformers:{serialize:r=>r*100,deserialize:r=>r/100}}},{type:"item",label:"Song volume",id:"audio.songVolume",input:{type:"slider",min:0,step:1,max:100,hardMax:2**31-1,transformers:{serialize:r=>r*100,deserialize:r=>r/100}}},{type:"item",label:"Sound effect volume",id:"audio.soundEffectVolume",input:{type:"slider",min:0,step:1,max:100,hardMax:2**31-1,transformers:{serialize:r=>r*100,deserialize:r=>r/100}}}]},{type:"subgroup",children:[{type:"item",label:"Enable assist tick",id:"audio.assistTick",input:{type:"checkbox"},tooltip:"Plays a sound when a note passes the receptors"},{type:"item",label:"Enable metronome",id:"audio.metronome",input:{type:"checkbox"}}]},{type:"subgroup",children:[{type:"item",label:"Allow filters to affect audio",id:"audio.allowFilter",input:{type:"checkbox",onChange:r=>{r.chartManager.chartAudio.reload()}}},{type:"item",label:"Enable metronome",id:"audio.metronome",input:{type:"checkbox"}}]}]},{type:"group",id:"play",label:"Play mode",children:[{type:"subgroup",label:"Calibration",children:[{type:"item",label:"Global offset",id:"play.offset",input:{type:"slider",min:-1,step:.001,max:1,hardMin:-(2**31-1),hardMax:2**31-1},tooltip:"Offset in seconds when playing a chart. Set to positive if you are hitting early and negative if you are hitting late."},{type:"item",label:"Sound effect offset",id:"play.effectOffset",input:{type:"slider",min:-1,step:.001,max:1,hardMin:-(2**31-1),hardMax:2**31-1},tooltip:"Offset in seconds when playing sound effects like assist tick and metronome."},{type:"item",label:"Visual offset",id:"play.visualOffset",input:{type:"slider",min:-1,step:.001,max:1,hardMin:-(2**31-1),hardMax:2**31-1},tooltip:"Offset in seconds when displaying notes."}]},{type:"subgroup",children:[{type:"item",label:"Judgment tilt",id:"play.judgmentTilt",input:{type:"checkbox"},tooltip:"Tilts the judgement text left if you are hitting early and right if you are hitting late."},{type:"item",label:"Hide barlines during play",id:"play.hideBarlines",input:{type:"checkbox"}}]},{type:"subgroup",label:"Timing windows",children:[{type:"item",id:"play.timingCollection",label:"Timing window collection",input:{type:"dropdown",advanced:!1,get items(){return Object.keys(qe.getCollections())}}},{type:"item",id:"play.timingWindowScale",label:"Timing window scale",input:{type:"slider",min:0,step:.001,max:2,hardMax:2**31-1},tooltip:"Scales all timing windows by the given amount."},{type:"item",id:"play.timingWindowAdd",label:"Timing window add",input:{type:"slider",min:0,step:.001,max:1,hardMax:2**31-1},tooltip:"Adds this value (in seconds) to all timing windows."}]}]},{type:"group",id:"performance",label:"Performance",children:[{type:"item",label:"Antialiasing",id:"performance.antialiasing",input:{type:"checkbox"}},{type:"item",label:"Resolution",id:"performance.resolution",input:{type:"slider",min:1,step:1,max:4,hardMin:0,hardMax:2**31-1},tooltip:"Requires a reload."}]},{type:"group",id:"debug",label:"Debug",children:[{type:"item",label:"Show FPS",id:"debug.showFPS",input:{type:"checkbox"}},{type:"item",label:"Show rendering timers",id:"debug.showTimers",input:{type:"checkbox"}}]}];class xT extends Pt{app;observer;sectionContainer;constructor(e){super({title:"Options",width:600,height:400,disableClose:!1,win_id:"user_options",blocking:!1}),this.app=e,this.initView()}initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("pref-container");const i=document.createElement("div");i.classList.add("pref-search");const s=document.createElement("input");s.classList.add("pref-search-bar"),s.type="text",s.placeholder="Search for an option...",s.oninput=()=>{a.replaceChildren(),o.replaceChildren(...this.createOptions(this.filterOptions(s.value)))},i.appendChild(s);const n=document.createElement("div");n.classList.add("pref-scrollers");const a=document.createElement("div");a.classList.add("pref-section-scroller"),this.sectionContainer=a;const o=document.createElement("div");o.classList.add("pref-option-scroller"),n.replaceChildren(a,o),this.observer=new IntersectionObserver(l=>{l.forEach(c=>{const u=c.target.dataset.id,h=a.querySelector(`.pref-section[data-id=${u}]`);h&&(c.intersectionRatio>0?h.classList.add("selected"):h.classList.remove("selected"))})},{}),t.replaceChildren(i,n),a.replaceChildren(),o.replaceChildren(...this.createOptions(Vp)),e.appendChild(t),this.viewElement.appendChild(e)}createOptions(e){return e.map(t=>{const i=this.makeOption(t);return t.type=="group"&&(this.observer.observe(i),this.sectionContainer?.appendChild(this.createEmptyGroup(t))),i})}makeOption(e){const t=document.createElement("div");t.classList.add("pref-"+e.type),(e.type=="group"||e.type=="item")&&(t.dataset.id=e.id);const i=document.createElement("div");i.classList.add(`pref-${e.type}-label`),e.label!==void 0&&(i.innerText=e.label,t.appendChild(i));const s=document.createElement("img");if(e.type=="item"&&(s.src=He.REVERT,s.style.width="12px",s.addEventListener("click",()=>{_.applyOption([e.id,_.getDefaultOption(e.id)]),t.replaceWith(this.makeOption(e))}),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",t.appendChild(s)),e.type=="item"){const n=_.getOption(e.id);let a;if(!e.input)return t;switch(i.innerText=e.label,e.input.type){case"checkbox":{const o=document.createElement("input"),l=e.input.onChange;o.type="checkbox",o.checked=n,o.onblur=null,o.onchange=()=>{_.applyOption([e.id,o.checked]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",l?.(this.app,o.checked)},o.classList.add("pref-input","right"),o.onkeydown=c=>{c.key=="Enter"&&o.blur()},a=o;break}case"dropdown":{if(e.input.advanced){const o=e.input.transformers.deserialize,l=e.input.transformers.serialize,c=e.input.onChange,u=pi.create(e.input.items,l(n));u.onChange(h=>{_.applyOption([e.id,o(h)]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",c?.(o(h))}),u.view.classList.add("pref-input","dropdown-right"),a=u.view}else{const o=e.input.onChange,l=pi.create(e.input.items,n);l.onChange(c=>{_.applyOption([e.id,c]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",o?.(c)}),l.view.classList.add("pref-input","dropdown-right"),a=l.view}break}case"number":{const o=e.input.transformers?.deserialize??(h=>h),l=e.input.transformers?.serialize??(h=>h),c=e.input.onChange,u=Ze.create(l(n),e.input.step,e.input.precision,e.input.min,e.input.max);u.onChange=h=>{if(!h){u.setValue(l(h));return}_.applyOption([e.id,o(h)]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",c?.(o(h))},a=u.view;break}case"slider":{const o=e.input.transformers?.deserialize??(m=>m),l=e.input.transformers?.serialize??(m=>m),c=e.input.onChange,u=document.createElement("div");u.style.display="flex",u.style.alignItems="center";const h=document.createElement("input");h.type="range",h.min=e.input.min?.toString()??"",h.max=e.input.max?.toString()??"",h.step=e.input.step?.toString()??"1",h.value=l(n).toString();const d=document.createElement("input");d.type="text",d.value=(Math.round(l(n)*1e3)/1e3).toString();const p=e.input.min??e.input.hardMin??-Number.MAX_VALUE,f=e.input.max??e.input.hardMax??Number.MAX_VALUE;d.onblur=()=>{let m=gn(d.value);if(m===null){d.value=(Math.round(l(n)*1e3)/1e3).toString();return}m=Ve(m,p,f),d.value=ne(m,3).toString(),d.blur(),d.value==""?d.value=l(m).toString():_.applyOption([e.id,o(m)]),h.value=m.toString(),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",c?.(o(m))},h.oninput=()=>{const m=parseFloat(h.value);d.value=ne(m,3).toString(),_.applyOption([e.id,o(m)]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block"},d.style.width="50px",d.onkeydown=m=>{m.key=="Enter"&&d.blur()},u.appendChild(h),u.appendChild(d),a=u;break}case"text":{const o=e.input.onChange,l=document.createElement("input");l.type="text",l.value=n.toString(),l.onblur=()=>{_.applyOption([e.id,l.value]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",o?.(l.value)},l.onkeydown=c=>{c.key=="Enter"&&l.blur()},a=l;break}case"color":{const o=document.createElement("input");o.type="color",o.value="#"+n.toString(16),o.onblur=()=>{_.applyOption([e.id,parseInt(o.value.slice(1),16)]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block"},a=o}}a.classList.add("pref-item-input"),t.appendChild(a)}else{const n=document.createElement("div");n.classList.add("pref-children"),t.appendChild(n),n.replaceChildren(...this.createOptions(e.children))}return e.type=="item"&&e.tooltip!==void 0&&Mt(t,{content:e.tooltip}),t}filterOptions(e,t=Vp){const i=[];return t.forEach(s=>{if(s.label&&s.label.toLowerCase().includes(e.toLowerCase())){i.push(s);return}if(s.type=="group"||s.type=="subgroup"){const n=this.filterOptions(e,s.children);n.length!=0&&i.push({...s,children:n})}}),i}createEmptyGroup(e){const t=document.createElement("div");return t.classList.add("pref-section"),t.dataset.id=e.id,t.innerText=e.label,t.onclick=()=>{t.parentElement.parentElement.querySelector(`.pref-group[data-id=${e.id}]`).scrollIntoView()},t}onClose(){this.observer?.disconnect()}}var zn=(r=>(r.SHIFT="Shift",r.CTRL="Ctrl",r.ALT="Alt",r.META="Command",r))(zn||{});const ys=navigator.userAgent.indexOf("Mac OS X")>-1,yt=ys?"Command":"Ctrl",_T={Shift:ys?"⇧":"Shift",Ctrl:ys?"⌃":"Ctrl",Alt:ys?"⌥":"Alt",Command:"⌘"},zp={ArrowLeft:"Left",ArrowUp:"Up",ArrowRight:"Right",ArrowDown:"Down",BracketLeft:"[",BracketRight:"]",Semicolon:";",Quote:"'",Backslash:"\\",Slash:"/",Period:".",Comma:",",Backquote:"`",Minus:"-",Equal:"+"},Xo=["ctrlKey","altKey","shiftKey","metaKey"],vo=["Ctrl","Alt","Shift","Command"],dt={playback:{label:"Play/Pause",combos:[{key:"Space",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.playPause()},decreaseSnap:{label:"Decrease snap",combos:[{key:"Left",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.previousSnap()},increaseSnap:{label:"Increase snap",combos:[{key:"Right",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.nextSnap()},cursorUp:{label:"Move cursor up",combos:[{key:"Up",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>{r.chartManager.snapToPreviousTick()}},cursorDown:{label:"Move cursor down",combos:[{key:"Down",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>{r.chartManager.snapToNextTick()}},increaseScrollSpeed:{label:"Increase scroll speed",combos:[{key:"Up",mods:[yt]}],disabled:r=>!r.chartManager.chartView,callback:()=>_.chart.speed=Math.max(10,_.chart.speed*Math.pow(1.01,30))},decreaseScrollSpeed:{label:"Decrease scroll speed",combos:[{key:"Down",mods:[yt]}],disabled:r=>!r.chartManager.chartView,callback:()=>_.chart.speed=Math.max(10,_.chart.speed*Math.pow(1.01,-30))},zoomIn:{label:"Zoom in",combos:[{key:"+",mods:[yt]}],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.zoom+=.1,Ce.create("Zoom: "+Math.round(_.chart.zoom*100)+"%")}},zoomOut:{label:"Zoom out",combos:[{key:"-",mods:[yt]}],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.zoom=Math.max(.1,_.chart.zoom-.1),Ce.create("Zoom: "+Math.round(_.chart.zoom*100)+"%")}},zoomDefault:{label:"Reset zoom",combos:[{key:"0",mods:[yt]}],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.zoom=1,Ce.create("Zoom: "+Math.round(_.chart.zoom*100)+"%")}},newSong:{label:"New song...",bindLabel:"New song",combos:[{key:"N",mods:[yt]}],disabled:r=>!r.chartManager.loadedSM||!Ie.openWindows,callback:r=>{r.windowManager.openWindow(new kg(r))}},openSong:{label:"Open song...",bindLabel:"Open song",combos:[{key:"O",mods:[yt]}],disabled:r=>!r.chartManager.loadedSM||!Ie.openWindows,callback:r=>{if(window.nw){const e=document.createElement("input");e.type="file",e.accept=".sm,.ssc",e.onchange=()=>r.chartManager.loadSM(e.value),e.click()}else r.windowManager.openWindow(new ml(r,{title:"Select an sm/ssc file...",accepted_file_types:[".sm",".ssc"],disableClose:!0,callback:e=>r.chartManager.loadSM(e)}))}},songProperties:{label:"Song properties...",bindLabel:"Open song properties",combos:[{key:"O",mods:["Shift"]}],disabled:r=>!r.chartManager.loadedSM||!Ie.openWindows,callback:r=>r.windowManager.openWindow(new uT(r))},save:{label:"Save...",bindLabel:"Save",combos:[{key:"S",mods:[yt]}],disabled:r=>!r.chartManager.loadedSM||r.chartManager.smPath.startsWith("https://")||r.chartManager.smPath.startsWith("http://"),callback:r=>r.chartManager.save()},export:{label:"Save and export current song",combos:[{key:"E",mods:[yt]}],disabled:r=>!!window.nw||!r.chartManager.loadedSM||r.chartManager.smPath.startsWith("https://")||r.chartManager.smPath.startsWith("http://"),callback:r=>{r.chartManager.save(),Re.getStandardHandler().saveDirectory(r.chartManager.smPath)}},exportNotedata:{label:"Export to notedata...",bindLabel:"Export to notedata",combos:[{key:"E",mods:[yt,"Shift"]}],disabled:r=>!r.chartManager.loadedSM||!Ie.openWindows,callback:r=>r.windowManager.openWindow(new nT(r,r.chartManager.selection.notes))},openChart:{label:"Chart list",bindLabel:"Open chart list",combos:[{key:"O",mods:[yt,"Shift"]}],disabled:r=>!r.chartManager.loadedSM||!Ie.openWindows,callback:r=>r.windowManager.openWindow(new Ag(r))},timingDataRow:{label:"Edit timing data at row",combos:[{key:"T",mods:["Shift"]}],disabled:r=>!r.chartManager.chartView||!Ie.openWindows,callback:r=>r.windowManager.openWindow(new wT(r))},selectRegion:{label:"Select region",combos:[{key:"Tab",mods:[]}],disabled:r=>!r.chartManager.loadedChart&&r.chartManager.getMode()!=Y.Edit,callback:r=>r.chartManager.selectRegion()},volumeUp:{label:"Increase master volume",combos:[{key:"Up",mods:["Alt"]}],disabled:!1,callback:()=>{_.audio.masterVolume=Math.min(_.audio.masterVolume+.05,1),Ce.create("Master volume: "+Math.round(_.audio.masterVolume*100)+"%")}},volumeDown:{label:"Decrease master volume",combos:[{key:"Down",mods:["Alt"]}],disabled:!1,callback:()=>{_.audio.masterVolume=Math.max(_.audio.masterVolume-.05,0),Ce.create("Master volume: "+Math.round(_.audio.masterVolume*100)+"%")}},songVolumeUp:{label:"Increase song volume",combos:[{key:"Up",mods:["Shift","Alt"]}],disabled:!1,callback:()=>{_.audio.songVolume=Math.min(_.audio.songVolume+.05,1),Ce.create("Song volume: "+Math.round(_.audio.songVolume*100)+"%")}},songVolumeDown:{label:"Decrease song volume",combos:[{key:"Down",mods:["Shift","Alt"]}],disabled:!1,callback:()=>{_.audio.songVolume=Math.max(_.audio.songVolume-.05,0),Ce.create("Song volume: "+Math.round(_.audio.songVolume*100)+"%")}},effectvolumeUp:{label:"Increase tick/metronome volume",combos:[{key:"Up",mods:["Shift",yt,"Alt"]}],disabled:!1,callback:()=>{_.audio.soundEffectVolume=Math.min(_.audio.soundEffectVolume+.05,1),Ce.create("Effect volume: "+Math.round(_.audio.soundEffectVolume*100)+"%")}},effectvolumeDown:{label:"Decrease tick/metronome volume",combos:[{key:"Down",mods:["Shift",yt,"Alt"]}],disabled:!1,callback:()=>{_.audio.soundEffectVolume=Math.max(_.audio.soundEffectVolume-.05,0),Ce.create("Effect Volume: "+Math.round(_.audio.soundEffectVolume*100)+"%")}},rateUp:{label:"Increase playback rate",combos:[{key:"Right",mods:["Shift"]}],disabled:r=>r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:()=>{_.audio.rate+=.05,Ce.create("Playback Rate: "+Math.round(_.audio.rate*100)+"%")}},rateDown:{label:"Decrease playback rate",combos:[{key:"Left",mods:["Shift"]}],disabled:r=>r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:()=>{_.audio.rate=Math.max(_.audio.rate-.05,.1),Ce.create("Playback Rate: "+Math.round(_.audio.rate*100)+"%")}},rateDefault:{label:"Reset playback rate",combos:[],disabled:!1,callback:()=>{_.audio.rate=1,Ce.create("Playback Rate: "+Math.round(_.audio.rate)+"%")}},previousMeasure:{label:"Previous measure",combos:[{key:"PageUp",mods:[]},{key:";",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>{const e=r.chartManager.getBeat(),t=r.chartManager.loadedChart.timingData.getMeasureLength(e-.001);r.chartManager.snapToNearestTick(Math.max(0,e-t))}},nextMeasure:{label:"Next measure",combos:[{key:"PageDown",mods:[]},{key:"'",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>{const e=r.chartManager.getBeat(),t=r.chartManager.loadedChart.timingData.getMeasureLength(e);r.chartManager.snapToNearestTick(Math.max(0,e+t))}},previousNote:{label:"Previous note",combos:[{key:",",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.previousNote()},nextNote:{label:"Next note",combos:[{key:".",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.nextNote()},jumpChartStart:{label:"Jump to first note",combos:[{key:"Home",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.firstNote()},jumpChartEnd:{label:"Jump to last note",combos:[{key:"End",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.lastNote()},jumpSongStart:{label:"Jump to song start",combos:[{key:"Home",mods:["Shift"]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.setBeat(Math.max(0,r.chartManager.loadedChart.getBeatFromSeconds(0)))},jumpSongEnd:{label:"Jump to song end",combos:[{key:"End",mods:["Shift"]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.setBeat(r.chartManager.loadedChart.getBeatFromSeconds(r.chartManager.chartAudio.getSongLength()))},assistTick:{label:"Assist tick",combos:[{key:"F7",mods:[]}],disabled:()=>!Ie.assist,callback:()=>{_.audio.assistTick=!_.audio.assistTick,Ce.create("Assist Tick: "+(_.audio.assistTick?"on":"off"))}},metronome:{label:"Metronome",combos:[{key:"F7",mods:["Alt"]}],disabled:()=>!Ie.assist,callback:()=>{_.audio.metronome=!_.audio.metronome,Ce.create("Metronome: "+(_.audio.metronome?"on":"off"))}},renderWaveform:{label:"Render waveform",combos:[],disabled:!1,callback:()=>{_.chart.waveform.enabled=!_.chart.waveform.enabled,Ce.create("Waveform: "+(_.chart.waveform.enabled?"on":"off"))}},waveformOptions:{label:"Waveform options...",bindLabel:"Waveform options",combos:[],disabled:!0,callback:()=>0},XMod:{label:"XMod (Beat-based)",combos:[{key:"X",mods:["Shift"]}],disabled:!1,callback:()=>{_.chart.CMod=!1,Ce.create("Switched to XMod")}},CMod:{label:"CMod (Time-based)",combos:[{key:"C",mods:["Shift"]}],disabled:!1,callback:()=>{_.chart.CMod=!0,Ce.create("Switched to CMod")}},hideWarpedArrows:{label:"Hide warped arrows (CMod only)",combos:[{key:"W",mods:["Shift"]}],disabled:!1,callback:()=>{_.chart.hideWarpedArrows=!_.chart.hideWarpedArrows,Ce.create("Hide Warped Arrows: "+(_.chart.hideWarpedArrows?"on":"off"))}},hideFakedArrows:{label:"Hide faked arrows (CMod only)",combos:[{key:"F",mods:["Shift"]}],disabled:!1,callback:()=>{_.chart.hideFakedArrows=!_.chart.hideFakedArrows,Ce.create("Hide Faked Arrows: "+(_.chart.hideFakedArrows?"on":"off"))}},doSpeedChanges:{label:"Do speed changes (XMod only)",combos:[{key:"S",mods:["Shift"]}],disabled:!1,callback:()=>{_.chart.doSpeedChanges=!_.chart.doSpeedChanges,Ce.create("Speed Changes: "+(_.chart.doSpeedChanges?"on":"off"))}},showEq:{label:"Equalizer",combos:[{key:"E",mods:["Shift"]}],disabled:r=>!r.chartManager.chartAudio||!Ie.openWindows,callback:r=>r.windowManager.openWindow(new iT(r))},syncAudio:{label:"Sync Audio",combos:[{key:"L",mods:["Shift"]}],disabled:r=>!r.chartManager.chartAudio||!Ie.openWindows,callback:r=>r.windowManager.openWindow(new AT(r))},previousNoteType:{label:"Previous note type",combos:[{key:"N",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.previousNoteType()},nextNoteType:{label:"Next note type",combos:[{key:"M",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.nextNoteType()},undo:{label:"Undo",combos:[{key:"Z",mods:[yt]}],disabled:r=>!r.actionHistory.canUndo()||r.chartManager.getMode()!=Y.Edit,callback:r=>r.actionHistory.undo()},redo:{label:"Redo",combos:[{key:"Y",mods:[yt]},{key:"Z",mods:[yt,"Shift"]}],disabled:r=>!r.actionHistory.canRedo()||r.chartManager.getMode()!=Y.Edit,callback:r=>r.actionHistory.redo()},mousePlacement:{label:"Enable Mouse Note Placement",combos:[{key:"M",mods:["Shift"]}],disabled:!1,callback:()=>{_.chart.mousePlacement=!_.chart.mousePlacement,Ce.create("Mouse Note Placement: "+(_.chart.mousePlacement?"on":"off"))}},playMode:{label:"Enter/Exit Play Mode",combos:[{key:"P",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Record||!Ie.playMode,callback:r=>r.chartManager.setMode(Y.Play)},recordMode:{label:"Enter/Exit Record Mode",combos:[{key:"R",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.View||!Ie.recordMode,callback:r=>r.chartManager.setMode(Y.Record)},playModeStart:{label:"Play from start",combos:[{key:"P",mods:["Shift"]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Record||!Ie.playMode,callback:r=>{r.chartManager.setBeat(0),r.chartManager.setMode(Y.Play)}},recordModeStart:{label:"Record from start",combos:[{key:"R",mods:["Shift"]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.View||!Ie.recordMode,callback:r=>r.chartManager.setMode(Y.Record)},options:{label:"Options...",bindLabel:"Edit options",combos:[{key:",",mods:[yt]}],disabled:()=>!Ie.openWindows||!Ie.openWindows,callback:r=>{r.windowManager.openWindow(new xT(r))}},keybinds:{label:"Keybinds...",bindLabel:"Edit keybinds",combos:[],disabled:()=>!Ie.openWindows||!Ie.openWindows,callback:r=>{r.windowManager.openWindow(new Di(r))}},gameplayKeybinds:{label:"Gameplay keybinds...",bindLabel:"Edit gameplay keybinds",combos:[],disabled:()=>!Ie.openWindows||!Ie.openWindows,callback:r=>{r.windowManager.openWindow(new aT(r))}},convertHoldsRolls:{label:"Holds to rolls",bindLabel:"Convert holds to rolls",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.type=="Hold"&&(e.type="Roll"),e))}},convertRollsHolds:{label:"Rolls to holds",bindLabel:"Convert rolls to holds",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.type=="Roll"&&(e.type="Hold"),e))}},swapHoldsRolls:{label:"Swap holds and rolls",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.type=="Hold"?e.type="Roll":e.type=="Roll"&&(e.type="Hold"),e))}},convertHoldsTaps:{label:"Holds/rolls to taps",bindLabel:"Convert holds/rolls to taps",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>((e.type=="Hold"||e.type=="Roll")&&(e.type="Tap"),e))}},convertTapsMines:{label:"Taps to mines",bindLabel:"Convert ntapsotes to mines",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.type=="Tap"&&(e.type="Mine"),e))}},convertTapsLifts:{label:"Taps to lifts",bindLabel:"Convert taps to lifts",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.type=="Tap"&&(e.type="Lift"),e))}},convertTapsFakes:{label:"Taps to fakes",bindLabel:"Convert taps to fakes",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.type=="Tap"&&(e.type="Fake"),e))}},mirrorHorizontally:{label:"Horizontally",bindLabel:"Mirror horizontally",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.col=r.chartManager.loadedChart.gameType.flipColumns.horizontal[e.col],e))}},mirrorVertically:{label:"Vertically",bindLabel:"Mirror vertically",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.col=r.chartManager.loadedChart.gameType.flipColumns.vertical[e.col],e))}},mirrorBoth:{label:"Both",bindLabel:"Mirror both",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.col=r.chartManager.loadedChart.gameType.flipColumns.horizontal[e.col],e.col=r.chartManager.loadedChart.gameType.flipColumns.vertical[e.col],e))}},selectAll:{label:"Select all",combos:[{key:"A",mods:[yt]}],disabled:r=>!r.chartManager.loadedChart,callback:r=>{r.chartManager.editTimingMode==De.Off?r.chartManager.setNoteSelection(r.chartManager.loadedChart.getNotedata()):r.chartManager.setEventSelection(r.chartManager.loadedChart.timingData.getTimingData())}},expand2to1:{label:"Expand 2:1 (8th to 4th)",combos:[],disabled:r=>r.chartManager.selection.notes.length<2||r.chartManager.getMode()!=Y.Edit,callback:r=>{const e=Math.min(...r.chartManager.selection.notes.map(t=>t.beat));r.chartManager.modifySelection(t=>(t.beat=(t.beat-e)*2+e,t.beat=Math.round(t.beat*48)/48,Be(t)&&(t.hold*=2,t.hold=Math.round(t.hold*48)/48),t))}},expand3to2:{label:"Expand 3:2 (12th to 8th)",combos:[],disabled:r=>r.chartManager.selection.notes.length<2||r.chartManager.getMode()!=Y.Edit,callback:r=>{const e=Math.min(...r.chartManager.selection.notes.map(t=>t.beat));r.chartManager.modifySelection(t=>(t.beat=(t.beat-e)*1.5+e,t.beat=Math.round(t.beat*48)/48,Be(t)&&(t.hold*=1.5,t.hold=Math.round(t.hold*48)/48),t))}},expand4to3:{label:"Expand 4:3 (16th to 2th)",combos:[],disabled:r=>r.chartManager.selection.notes.length<2||r.chartManager.getMode()!=Y.Edit,callback:r=>{const e=Math.min(...r.chartManager.selection.notes.map(t=>t.beat));r.chartManager.modifySelection(t=>(t.beat=(t.beat-e)*4/3+e,t.beat=Math.round(t.beat*48)/48,Be(t)&&(t.hold*=4/3,t.hold=Math.round(t.hold*48)/48),t))}},compress1to2:{label:"Compress 1:2 (4th to 8th)",combos:[],disabled:r=>r.chartManager.selection.notes.length<2||r.chartManager.getMode()!=Y.Edit,callback:r=>{const e=Math.min(...r.chartManager.selection.notes.map(t=>t.beat));r.chartManager.modifySelection(t=>(t.beat=(t.beat-e)/2+e,t.beat=Math.round(t.beat*48)/48,Be(t)&&(t.hold/=2,t.hold=Math.round(t.hold*48)/48),t))}},compress2to3:{label:"Compress 2:3 (8th to 12th)",combos:[],disabled:r=>r.chartManager.selection.notes.length<2||r.chartManager.getMode()!=Y.Edit,callback:r=>{const e=Math.min(...r.chartManager.selection.notes.map(t=>t.beat));r.chartManager.modifySelection(t=>(t.beat=(t.beat-e)/1.5+e,t.beat=Math.round(t.beat*48)/48,Be(t)&&(t.hold/=1.5,t.hold=Math.round(t.hold*48)/48),t))}},compress3to4:{label:"Compress 3:4 (12th to 16th)",combos:[],disabled:r=>r.chartManager.selection.notes.length<2||r.chartManager.getMode()!=Y.Edit,callback:r=>{const e=Math.min(...r.chartManager.selection.notes.map(t=>t.beat));r.chartManager.modifySelection(t=>(t.beat=(t.beat-e)*.75+e,t.beat=Math.round(t.beat*48)/48,Be(t)&&(t.hold*=.75,t.hold=Math.round(t.hold*48)/48),t))}},quantize4th:{label:"4ths",bindLabel:"Quantize to 4ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,4),e.beat=Math.round(e.beat*48)/48,e))}},quantize8th:{label:"8ths",bindLabel:"Quantize to 8ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,8),e.beat=Math.round(e.beat*48)/48,e))}},quantize12th:{label:"12ths",bindLabel:"Quantize to 12ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,12),e.beat=Math.round(e.beat*48)/48,e))}},quantize16th:{label:"16ths",bindLabel:"Quantize to 16ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,16),e.beat=Math.round(e.beat*48)/48,e))}},quantize24th:{label:"24ths",bindLabel:"Quantize to 24ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,24),e.beat=Math.round(e.beat*48)/48,e))}},quantize32nd:{label:"32nds",bindLabel:"Quantize to 32nds",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,32),e.beat=Math.round(e.beat*48)/48,e))}},quantize48th:{label:"48ths",bindLabel:"Quantize to 48ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,48),e.beat=Math.round(e.beat*48)/48,e))}},quantize96th:{label:"96ths",bindLabel:"Quantize to 96ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,96),e.beat=Math.round(e.beat*48)/48,e))}},delete:{label:"Delete",combos:[{key:"Backspace",mods:[]},{key:"Delete",mods:[]}],disabled:r=>r.chartManager.getMode()!=Y.Edit||r.chartManager.selection.notes.length==0&&r.chartManager.eventSelection.timingEvents.length==0,callback:r=>{r.chartManager.deleteSelection(),r.chartManager.deleteEventSelection()}},paste:{label:"Paste",combos:[],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()!=Y.Edit,callback:async r=>{const e=await navigator.clipboard.readText();r.chartManager.paste(e)}},copy:{label:"Copy",combos:[],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()!=Y.Edit||!r.chartManager.hasSelection(),callback:async r=>{const e=r.chartManager.copy();e&&await navigator.clipboard.writeText(e)}},cut:{label:"Cut",combos:[],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()!=Y.Edit||!r.chartManager.hasSelection(),callback:async r=>{const e=r.chartManager.copy();e&&await navigator.clipboard.writeText(e),r.chartManager.deleteSelection()}},adjustOffset:{label:"Adjust offset",combos:[],disabled:()=>!Ie.openWindows,callback:r=>r.windowManager.openWindow(new dT(r))},setSongPreview:{label:"Set as song preview",combos:[],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()!=Y.Edit||!r.chartManager.hasRange(),callback:r=>{const e=r.chartManager.loadedChart,t=r.chartManager.loadedSM.properties.SAMPLESTART??"0",i=r.chartManager.loadedSM.properties.SAMPLELENGTH??"10";let s="",n="";if(r.chartManager.startRegion!==void 0&&r.chartManager.endRegion!==void 0){const a=e.getSecondsFromBeat(r.chartManager.startRegion),o=e.getSecondsFromBeat(r.chartManager.endRegion);s=ne(a,3).toString(),n=ne(o-a,3).toString()}else{const o=(r.chartManager.selection.notes.length>0?r.chartManager.selection.notes:r.chartManager.eventSelection.timingEvents).map(u=>u.beat),l=e.getSecondsFromBeat(Math.min(...o)),c=e.getSecondsFromBeat(Math.max(...o));s=ne(l,3).toString(),n=ne(c-l,3).toString()}ht.instance.run({action:a=>{a.chartManager.loadedSM.properties.SAMPLESTART=s,a.chartManager.loadedSM.properties.SAMPLELENGTH=n},undo:()=>{r.chartManager.loadedSM.properties.SAMPLESTART=t,r.chartManager.loadedSM.properties.SAMPLELENGTH=i}})}},showDebugTimers:{label:"Toggle Debug Timers",combos:[{key:"F3",mods:["Shift"]}],disabled:!1,callback:()=>{_.debug.showTimers=!_.debug.showTimers}},showFPSCounter:{label:"Toggle FPS Counter",combos:[{key:"F3",mods:[]}],disabled:!1,callback:()=>{_.debug.showFPS=!_.debug.showFPS}},noteTypeTap:{label:"Switch to Taps",combos:[],disabled:r=>!r.chartManager.chartView,callback:r=>{r.chartManager.setEditingNoteType("Tap")}},noteTypeLift:{label:"Switch to Lifts",combos:[],disabled:r=>!r.chartManager.chartView,callback:r=>{r.chartManager.setEditingNoteType("Lift")}},noteTypeMine:{label:"Switch to Mines",combos:[],disabled:r=>!r.chartManager.chartView,callback:r=>{r.chartManager.setEditingNoteType("Mine")}},noteTypeFake:{label:"Switch to Fakes",combos:[],disabled:r=>!r.chartManager.chartView,callback:r=>{r.chartManager.setEditingNoteType("Fake")}},quant4:{label:"Switch to 4ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1}},quant8:{label:"Switch to 8ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/2}},quant12:{label:"Switch to 12ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/3}},quant16:{label:"Switch to 16ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/4}},quant24:{label:"Switch to 24ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/6}},quant32:{label:"Switch to 32ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/8}},quant48:{label:"Switch to 48ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/12}},quant96:{label:"Switch to 96ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/24}},quant192:{label:"Switch to 192nds",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/48}}};class ET{static popup;static open(e,t){this.popup=this.build(e,t),document.getElementById("popups")?.appendChild(this.popup)}static build(e,t){const i=document.createElement("div");i.classList.add("update-popup");const s=document.createElement("div");s.classList.add("title"),s.innerText=`A new version of the desktop app is available! (${e})`;const n=document.createElement("div");return n.classList.add("desc"),n.innerText="Click here to download the new version.",i.replaceChildren(s,n),i.onclick=()=>{localStorage.setItem("downloadedVersion",e),nw.require("nw.gui").Shell.openExternal(t),this.close()},i}static close(){this.popup&&(this.popup.style.opacity="0",this.popup.onclick=null,setTimeout(()=>this.popup.remove(),300))}}class Nt extends o1{static graphics=new ma;static textures={default:mt.create({width:50,height:50}),noBorder:mt.create({width:50,height:50}),onlyBorder:mt.create({width:50,height:50})};static init(e){this.textures.default=mt.create({width:50,height:50,resolution:e.resolution}),this.textures.noBorder=mt.create({width:50,height:50,resolution:e.resolution}),this.textures.onlyBorder=mt.create({width:50,height:50,resolution:e.resolution}),this.graphics.beginFill(16777215,1),this.graphics.lineStyle(1,0),this.graphics.drawRoundedRect(0,0,50,50,5),this.graphics.endFill(),e.render(this.graphics,{renderTexture:this.textures.default}),this.graphics.clear(),this.graphics.beginFill(16777215,1),this.graphics.lineStyle(1,16777215),this.graphics.drawRoundedRect(0,0,50,50,5),this.graphics.endFill(),e.render(this.graphics,{renderTexture:this.textures.noBorder}),this.graphics.clear(),this.graphics.beginFill(16777215,0),this.graphics.lineStyle(2,16777215),this.graphics.drawRoundedRect(0,0,50,50,5),this.graphics.endFill(),e.render(this.graphics,{renderTexture:this.textures.onlyBorder})}constructor(e){super(Nt.textures[e??"default"],5,5,5,5)}}const jn=[];function jp(){return jn.length}function cC(){for(jn.push(Date.now());jn.length>0&&jn[0]0&&Yn[0]jp()+" FPS"});drawUpdateTimeGraph=new Dn({width:300,height:yi,color:6034982,min:0,unit:"ms",label:"DrawUpdate",precision:1});updateTimeGraph=new Dn({width:300,height:yi,color:1516101,min:0,unit:"ms",label:"Update",precision:1,sublabel:()=>Yp()+" TPS"});memoryTimeGraph=new Dn({width:300,height:yi,color:6626406,min:0,formatter:e=>Math.round(e/1048576)+" MB",label:"Memory"});cpuGraph=new Dn({width:300,height:yi,color:5190685,min:0,label:"CPU"});graphs=new xe;fpsCounter=new xe;fpsBg=new Nt;fpsText=new Fe("",{fontName:"Main",fontSize:12});lastFrameTime=0;constructor(e){super(e),this.drawUpdateTimeGraph.y+=yi+5,this.updateTimeGraph.y+=(yi+5)*2,this.memoryTimeGraph.y+=(yi+5)*3,this.cpuGraph.y+=(yi+5)*4,la.instance=this,this.fpsBg.tint=0,this.fpsBg.alpha=.5,this.fpsText.x=5,this.fpsBg.y=-5,this.graphs.addChild(this.frameTimeGraph,this.drawUpdateTimeGraph,this.updateTimeGraph),performance.memory&&this.graphs.addChild(this.memoryTimeGraph),this.fpsCounter.addChild(this.fpsBg,this.fpsText),this.graphs.visible=_.debug.showTimers,this.fpsCounter.visible=_.debug.showFPS,this.addChild(this.graphs,this.fpsCounter)}update(){this.x=-this.manager.app.renderer.screen.width/2+20,this.y=-this.manager.app.renderer.screen.height/2+20,this.graphs.children.forEach(e=>e.update()),this.graphs.visible=_.debug.showTimers,this.fpsCounter.visible=_.debug.showFPS,this.fpsText.text=`${jp()} FPS +`;class Ze{view;input;onChange;min=-Number.MAX_VALUE;max=Number.MAX_VALUE;precision;step=1;lastVal="";constructor(e,t,i,s,n,a){this.view=e,this.view.classList.add("spinner"),this.view.onfocus=()=>{o.focus()};const o=document.createElement("input");o.classList.add("spinner-input"),o.type="text",o.autocomplete="off",o.spellcheck=!1,o.onblur=()=>{if(o.value===this.lastVal)return;if(o.value===""){this.onChange?.(void 0);return}const h=gn(o.value);if(h===null){o.value=this.lastVal;return}let d=ne(h,this.precision??3);d=Ve(d,this.min,this.max),o.value=this.formatValue(d),this.onChange?.(d)},o.onkeydown=h=>{h.key=="Enter"&&o.blur(),h.key=="Escape"&&(o.value=this.lastVal,o.blur())},o.onfocus=()=>{this.lastVal=o.value},this.input=o,this.min=n??this.min,this.max=a??this.max,this.step=i,this.precision=s,this.setValue(t),e.appendChild(o);const l=document.createElement("div");l.classList.add("spinner-btns"),e.appendChild(l);const c=document.createElement("button");c.classList.add("spinner-up"),c.onclick=()=>{a!==void 0&&parseFloat(o.value)+(i??_.general.spinnerStep)>a||(o.value=this.formatValue(parseFloat(o.value)+(i??_.general.spinnerStep)),this.onChange?.(parseFloat(o.value)))},l.appendChild(c);const u=document.createElement("button");u.classList.add("spinner-down"),u.onclick=()=>{n!==void 0&&parseFloat(o.value)-(i??_.general.spinnerStep)r.chartManager.loadAudio()}},{title:"Background Image",propName:"BACKGROUND",input:{type:"file",typeName:"image",accept:ts}},{title:"Banner Image",propName:"BANNER",input:{type:"file",typeName:"image",accept:ts}},{title:"CD Title",propName:"CDTITLE",input:{type:"file",typeName:"image",accept:ts}},{title:"CD Image",propName:"CDIMAGE",input:{type:"file",typeName:"image",accept:ts}},{title:"Jacket",propName:"JACKET",input:{type:"file",typeName:"image",accept:ts}},{title:"Disc Image",propName:"DISCIMAGE",input:{type:"file",typeName:"image",accept:ts}}]},{title:"Song",items:[{title:"Song Preview",propName:"SAMPLESTART",input:{type:"custom",create:(r,e,t)=>{const i=t??ht.instance,s=()=>{a.value{(e??p.chartManager.loadedSM).properties.SAMPLESTART=h,(e??p.chartManager.loadedSM).properties.SAMPLELENGTH=d,n.setValue(parseFloat(h)),a.setValue(parseFloat(h)+parseFloat(d))},undo:()=>{(e??r.chartManager.loadedSM).properties.SAMPLESTART=c,(e??r.chartManager.loadedSM).properties.SAMPLELENGTH=u,n.setValue(parseFloat(c)),a.setValue(parseFloat(c)+parseFloat(u))}})},n=Ze.create(parseFloat((e??r.chartManager.loadedSM).properties.SAMPLESTART??"0"),void 0,3,0);n.onChange=c=>{if(c===void 0){n.setValue(parseFloat((e??r.chartManager.loadedSM).properties.SAMPLESTART??"0"));return}s()};const a=Ze.create(parseFloat((e??r.chartManager.loadedSM).properties.SAMPLESTART??"0")+parseFloat((e??r.chartManager.loadedSM).properties.SAMPLELENGTH??"10"),void 0,3,0);a.onChange=c=>{if(c===void 0){a.setValue(parseFloat((e??r.chartManager.loadedSM).properties.SAMPLESTART??"0")+parseFloat((e??r.chartManager.loadedSM).properties.SAMPLELENGTH??"10"));return}s()};const o=document.createElement("div"),l=document.createElement("div");return l.innerText="to",o.classList.add("flex-row","flex-column-gap"),o.replaceChildren(n.view,l,a.view),o}}}]}];function Ig(r,e,t,i){const s=i??ht.instance;switch(e.input.type){case"custom":return e.input.create(r,t,i);case"string":{const n=document.createElement("input");return n.type="text",n.autocomplete="off",n.spellcheck=!1,n.onkeydown=a=>{a.key=="Enter"&&n.blur()},n.onblur=()=>{const a=(t??r.chartManager.loadedSM).properties[e.propName],o=n.value;s.run({action:l=>{(t??l.chartManager.loadedSM).properties[e.propName]=o,n.value=o},undo:()=>{(t??r.chartManager.loadedSM).properties[e.propName]=a,n.value=a??""}})},n.value=(t??r.chartManager.loadedSM).properties[e.propName]??"",n}case"number":{const n=e.input,a=Ze.create(parseFloat((t??r.chartManager.loadedSM).properties[e.propName])??15,n.step,n.precision,n.min,n.max);return a.onChange=o=>{if(o===void 0){a.setValue(parseFloat((t??r.chartManager.loadedSM).properties[e.propName]??"0"));return}const l=(t??r.chartManager.loadedSM).properties[e.propName],c=o.toString();s.run({action:u=>{(t??u.chartManager.loadedSM).properties[e.propName]=c,a.setValue(parseFloat(c))},undo:()=>{(t??r.chartManager.loadedSM).properties[e.propName]=l,a.setValue(parseFloat(l??"0"))}})},a.view}case"file":{const n=e.input,a=e.input.onChange,o=document.createElement("div");o.classList.add("flex-row","flex-column-gap");const l=document.createElement("input");l.type="text",l.autocomplete="off",l.spellcheck=!1,l.placeholder="click to select a file",l.onclick=h=>{h.preventDefault(),l.blur();const d=r.chartManager.smPath.split("/").slice(0,-1).join("/");if(window.nw){const p=document.createElement("input");p.type="file",p.accept=n.accept.join(","),p.onchange=()=>{const f=Re.getRelativePath(d,p.value),m=(t??r.chartManager.loadedSM).properties[e.propName]??"";s.run({action:g=>{(t??g.chartManager.loadedSM).properties[e.propName]=f,l.value=f},undo:()=>{(t??r.chartManager.loadedSM).properties[e.propName]=m,l.value=m}}),a?.(r)},p.click()}else r.windowManager.openWindow(new ml(r,{title:`Select a${n.typeName.match(/^[aieouAIEOU].*/)?"n":""} ${n.typeName} file...`,accepted_file_types:n.accept,disableClose:!0,callback:p=>{const f=Re.getRelativePath(d,p),m=(t??r.chartManager.loadedSM).properties[e.propName]??"";s.run({action:g=>{(t??g.chartManager.loadedSM).properties[e.propName]=f,l.value=f},undo:()=>{(t??r.chartManager.loadedSM).properties[e.propName]=m,l.value=m}}),a?.(r)}},(t??r.chartManager.loadedSM).properties[e.propName]?d+"/"+(t??r.chartManager.loadedSM).properties[e.propName]:r.chartManager.smPath))},l.value=(t??r.chartManager.loadedSM).properties[e.propName]??"",o.appendChild(l);const c=document.createElement("button");c.style.height="100%",c.classList.add("delete"),c.disabled=!(t??r.chartManager.loadedSM).properties[e.propName],c.onclick=()=>{l.value="",c.disabled=!0};const u=document.createElement("img");return u.classList.add("icon"),u.style.height="12px",u.src=He.TRASH,c.appendChild(u),o.appendChild(c),o}}}class kg extends Pt{app;sm;actionHistory;fileTable={};constructor(e){super({title:"New Song",width:450,height:492,disableClose:!0,win_id:"sm_properties",blocking:!0});const t=new Blob([cT],{type:"text/plain"}),i=new File([t],"song.sm",{type:"text/plain"});this.sm=new Cg(i),this.app=e,this.actionHistory=new ht(this.app),this.initView()}initView(){this.viewElement.replaceChildren(),this.viewElement.classList.add("sm-properties");const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("label"),t.innerText="Apply to",Mg.forEach(l=>{const c=document.createElement("div");c.classList.add("sm-container");const u=document.createElement("div");u.classList.add("sm-title"),u.innerText=l.title;const h=document.createElement("div");h.classList.add("property-grid"),l.items.forEach(d=>{const p=document.createElement("div");p.classList.add("label"),p.innerText=d.title,h.appendChild(p),d.input.type=="file"?h.appendChild(this.createFileElement(d.propName,d.input.typeName)):h.appendChild(Ig(this.app,d,this.sm,this.actionHistory))}),c.appendChild(u),c.appendChild(h),e.appendChild(c)});const i=document.createElement("div");i.classList.add("menu-options");const s=document.createElement("div");s.classList.add("menu-left");const n=document.createElement("div");n.classList.add("menu-right"),i.appendChild(s),i.appendChild(n);const a=document.createElement("button");a.innerText="Cancel",a.onclick=()=>{this.closeWindow()};const o=document.createElement("button");o.innerText="Create",o.classList.add("confirm"),o.onclick=()=>{this.sm.properties.MUSIC===void 0||this.sm.properties.MUSIC===""?this.app.windowManager.openWindow(new fd(this.app,"No audio file uploaded","Are you sure you want to create a file with no audio?",[{type:"confirm",label:"Yes",callback:()=>{this.createSong(),this.closeWindow()}},{type:"default",label:"No"}])):(this.createSong(),this.closeWindow())},s.appendChild(a),n.appendChild(o),e.appendChild(i),this.viewElement.appendChild(e)}async createSong(){let e=this.sm.properties.TITLE;if(window.nw){const t=nw.require("path"),i=document.createElement("input");i.type="file",i.nwsaveas=e+".sm",i.onchange=async()=>{const s=t.basename(i.value,t.extname(i.value));e=t.dirname(i.value);const n=t.join(e,s+".sm");await Re.writeFile(n,this.sm.serialize("sm")),await Promise.all(Object.entries(this.fileTable).map(a=>Re.writeFile(e+`/${a[0]}`,a[1]))),await this.app.chartManager.loadSM(n),this.app.windowManager?.getWindowById("select_sm_initial")?.closeWindow()},i.click()}else{if(await Re.getDirectoryHandle(e)){let t=2;for(;await Re.getDirectoryHandle(e);)e=`${this.sm.properties.TITLE} ${t++}`}await Re.writeFile(e+"/song.sm",this.sm.serialize("sm")),await Promise.all(Object.entries(this.fileTable).map(t=>Re.writeFile(e+`/${t[0]}`,t[1]))),await this.app.chartManager.loadSM(e+"/song.sm"),this.app.windowManager?.getWindowById("select_sm_initial")?.closeWindow()}}createFileElement(e,t){const i=document.createElement("div");i.classList.add("flex-row","flex-column-gap");const s=document.createElement("input");s.type="text",s.autocomplete="off",s.spellcheck=!1,s.placeholder="click to upload a file",s.onclick=o=>{o.preventDefault(),s.blur();const l=document.createElement("input");l.type="file",l.accept=t=="audio"?"audio/*":"image/*",l.onchange=()=>{const c=l.files?.[0];if(!c)return;this.sm.properties[e]&&this.fileTable[this.sm.properties[e]]&&delete this.fileTable[this.sm.properties[e]];let u=c.name;for(;this.fileTable[c.name]&&(this.fileTable[c.name].size!=c.size||this.fileTable[c.name].type!=c.type);)u="_"+u;this.fileTable[u]=c,s.value=u,this.sm.properties[e]=s.value,n.disabled=!1},l.click()},s.value=this.sm.properties[e]??"",i.appendChild(s);const n=document.createElement("button");n.style.height="100%",n.classList.add("delete"),n.disabled=!0,n.onclick=()=>{this.sm.properties[e]&&this.fileTable[this.sm.properties[e]]&&delete this.fileTable[this.sm.properties[e]],this.sm.properties[e]=void 0,s.value="",n.disabled=!0};const a=document.createElement("img");return a.classList.add("icon"),a.style.height="12px",a.src=He.TRASH,n.appendChild(a),i.appendChild(n),i}}class dT extends Pt{app;metronomeInterval;startTime;me_high=new hs.Howl({src:rg,volume:_.audio.soundEffectVolume});me_low=new hs.Howl({src:sg,volume:_.audio.soundEffectVolume});tickLines=[];resultLines=[];previousOffsets=[];keyHandler;constructor(e){super({title:"Offset Adjuster",width:300,height:200,win_id:"offset",blocking:!0}),this.app=e,this.initView(),this.startTime=performance.now();let t=this.startTime+500;this.tickLines.push({time:t+500,beat:0}),this.tickLines.push({time:t+500*2,beat:1}),this.tickLines.push({time:t+500*3,beat:2}),this.tickLines.push({time:t+500*4,beat:3});let i=0;this.metronomeInterval=setInterval(()=>{const s=performance.now();if(s-t>500){for(t=s,(i%4==0?this.me_high:this.me_low).play();this.tickLines[0]?.time+1e3s-n.startTime<8e3)},5),this.keyHandler=s=>{if(s.code.startsWith("Digit")||s.code.startsWith("Key")||s.code=="Space"){let n=this.tickLines[0];const a=performance.now();for(const l of this.tickLines)if(a-l.time+_.play.offset*1e3<300){n=l;break}s.preventDefault();const o=a-n.time+_.play.offset*1e3;o>-300&&(this.tickLines.splice(this.tickLines.indexOf(n),1),this.resultLines.push({startTime:performance.now(),offset:o}),this.previousOffsets.push(o),this.previousOffsets.length==16&&(ug(this.previousOffsets)<70&&(_.play.offset-=fl(this.previousOffsets)/1e3),this.previousOffsets=[]))}},window.addEventListener("keydown",this.keyHandler)}initView(){this.viewElement.replaceChildren();const e=document.createElement("canvas");this.viewElement.appendChild(e);const t=this.drawEQ(e);requestAnimationFrame(t)}drawEQ(e){const t=e.getContext("2d");t.canvas.width=250,t.canvas.height=100;const i=()=>{t.fillStyle="rgba(0, 0, 0, 1)",t.fillRect(0,0,e.width,e.height),t.fillStyle="rgb(255, 255, 255)",t.fillRect(e.width/2-1,8,2,e.height-16);const s=performance.now();for(const n of this.resultLines){t.fillStyle="rgba(255, 255, 255, 1)";const a=Math.min(1,4-(s-n.startTime)/2e3);if(n.offset<0&&(t.fillStyle=`rgba(160, ${sr(160,0,-n.offset/250)}, ${sr(160,0,-n.offset/250)}, ${a})`),n.offset>0&&(t.fillStyle=`rgba(${sr(160,0,n.offset/250)}, ${sr(160,0,n.offset/250)}, 160, ${a})`),t.fillRect(e.width/2-.5+n.offset/4,12,1,e.height-24),s-n.startTime<250){const o=(s-n.startTime)/250;t.globalAlpha=1-o,t.fillRect(e.width/2-.5-o*3+n.offset/4,12-o*10,1+o*6,e.height-24+o*20)}t.globalAlpha=1}for(const n of this.tickLines){const a=n.time-s-_.play.offset*1e3;t.fillStyle="rgba(255, 255, 255, 0.8)",n.beat%4!=0?t.fillRect(e.width/2-1-a/4,12,2,e.height-24):t.fillRect(e.width/2-2-a/4,12,4,e.height-24)}e.closest("#windows")&&requestAnimationFrame(i)};return i}onClose(){clearInterval(this.metronomeInterval),window.removeEventListener("keydown",this.keyHandler)}}class uT extends Pt{app;changeHandler=()=>this.initView();constructor(e){super({title:"Song Properties",width:450,height:486,disableClose:!1,win_id:"sm_properties",blocking:!1}),this.app=e,this.initView(),$.on("smLoaded",this.changeHandler),$.on("undo",this.changeHandler),$.on("redo",this.changeHandler)}onClose(){$.off("smLoaded",this.changeHandler),$.off("undo",this.changeHandler),$.off("redo",this.changeHandler)}initView(){this.viewElement.replaceChildren(),this.viewElement.classList.add("sm-properties");const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("label"),t.innerText="Apply to",Mg.forEach(i=>{const s=document.createElement("div");s.classList.add("sm-container");const n=document.createElement("div");n.classList.add("sm-title"),n.innerText=i.title;const a=document.createElement("div");a.classList.add("property-grid"),i.items.forEach(o=>{const l=document.createElement("div");l.classList.add("label"),l.innerText=o.title,a.appendChild(l),a.appendChild(Ig(this.app,o))}),s.appendChild(n),s.appendChild(a),e.appendChild(s)}),this.viewElement.appendChild(e)}}var pT=yT,Yo=8192,gd=65536,yd=new ArrayBuffer(gd*4),fT=new Float64Array(yd,gd,Yo),mT=new Float64Array(yd,gd*2,Yo/2),gT=vT({Math,Float64Array},null,yd);function yT(r){if(!r)throw Error("Input data is not provided, pass an array.");var e=r.length;if(e>Yo)throw Error("Input length is too big, must be under "+Yo);var t=Math.floor(Math.log(e)/Math.LN2);if(Math.pow(2,t)!==e)throw Error("Invalid array size, must be a power of 2.");return fT.set(r),gT(e,t),mT.subarray(0,e/2)}function vT(r,e,t){var i=6.283185307179586,s=r.Math.sqrt,n=r.Math.sin,a=r.Math.cos,o=r.Math.abs,l=r.Math.SQRT1_2,c=r.Math.imul,u=new r.Float64Array(t),h=new r.Float64Array(t),d=8192,p=16384;function f(g,y){g=g|0,y=y|0;var b=0,A=0,v=0,E=0,C=0,M=0,P=0,k=0,N=0,H=0,T=0,S=0,w=0,F=0,z=0,L=0,te=0,R=0,G=0,D=0,O=0,ee=0,Q=0,K=0,ge=0,Te=0,he=0,pe=0,be=0,oe=0,ue=0,ve=0;for(b=g>>>1,v=2/+(g|0),m(g),oe=0,ve=4;(oe|0)<(g|0);ve=c(ve,4)){for(ue=oe;(ue|0)<(g|0);ue=ue+ve|0)D=h[ue<<3>>3]-h[ue+1<<3>>3],h[ue<<3>>3]=h[ue<<3>>3]+h[ue+1<<3>>3],h[ue+1<<3>>3]=D;oe=c(2,ve-1)}for(E=2,P=g>>>1;P=P>>>1;){oe=0,E=E<<1,ve=E<<1,C=E>>>2,M=E>>>3;do{if((C|0)!=1)for(ue=oe;(ue|0)<(g|0);ue=ue+ve|0)S=ue,w=S+C|0,F=w+C|0,z=F+C|0,k=h[F<<3>>3]+h[z<<3>>3],h[z<<3>>3]=h[z<<3>>3]-h[F<<3>>3],h[F<<3>>3]=h[S<<3>>3]-k,h[S<<3>>3]=h[S<<3>>3]+k,S=S+M|0,w=w+M|0,F=F+M|0,z=z+M|0,k=h[F<<3>>3]+h[z<<3>>3],N=h[F<<3>>3]-h[z<<3>>3],k=-k*l,N=N*l,D=+h[w<<3>>3],h[z<<3>>3]=k+D,h[F<<3>>3]=k-D,h[w<<3>>3]=h[S<<3>>3]-N,h[S<<3>>3]=h[S<<3>>3]+N;else for(ue=oe;(ue|0)<(g|0);ue=ue+ve|0)S=ue,w=S+C|0,F=w+C|0,z=F+C|0,k=h[F<<3>>3]+h[z<<3>>3],h[z<<3>>3]=h[z<<3>>3]-h[F<<3>>3],h[F<<3>>3]=h[S<<3>>3]-k,h[S<<3>>3]=h[S<<3>>3]+k;oe=(ve<<1)-E|0,ve=ve<<2}while((oe|0)<(g|0));for(ge=i/+(E|0),A=1;(A|0)<(M|0);A=A+1|0){Te=+(A|0)*ge,ee=n(Te),O=a(Te),Q=4*O*(O*O-.75),K=4*ee*(.75-ee*ee),oe=0,ve=E<<1;do{for(ue=oe;(ue|0)<(g|0);ue=ue+ve|0)S=ue+A|0,w=S+C|0,F=w+C|0,z=F+C|0,L=ue+C-A|0,te=L+C|0,R=te+C|0,G=R+C|0,N=h[R<<3>>3]*O-h[F<<3>>3]*ee,k=h[R<<3>>3]*ee+h[F<<3>>3]*O,T=h[G<<3>>3]*Q-h[z<<3>>3]*K,H=h[G<<3>>3]*K+h[z<<3>>3]*Q,D=N-T,N=N+T,T=D,h[G<<3>>3]=N+h[te<<3>>3],h[F<<3>>3]=N-h[te<<3>>3],D=H-k,k=k+H,H=D,h[z<<3>>3]=H+h[w<<3>>3],h[R<<3>>3]=H-h[w<<3>>3],h[te<<3>>3]=h[S<<3>>3]-k,h[S<<3>>3]=h[S<<3>>3]+k,h[w<<3>>3]=T+h[L<<3>>3],h[L<<3>>3]=h[L<<3>>3]-T;oe=(ve<<1)-E|0,ve=ve<<2}while((oe|0)<(g|0))}}for(;b=b-1|0;)he=+h[b<<3>>3],pe=+h[g-b-1<<3>>3],be=v*s(he*he+pe*pe),u[p+b<<3>>3]=be;u[p+0<<3>>3]=o(v*h[0])}function m(g){g=g|0;var y=0,b=0,A=1,v=0,E=0;y=g>>>1,b=g-1|0,h[0]=u[d+0<<3>>3];do{for(v=v+y|0,h[A<<3>>3]=u[d+v<<3>>3],h[v<<3>>3]=u[d+A<<3>>3],A=A+1|0,E=y<<1;E=E>>1,((v=v^E)&E)==0;);(v|0)>=(A|0)&&(h[A<<3>>3]=u[d+v<<3>>3],h[v<<3>>3]=u[d+A<<3>>3],h[b-A<<3>>3]=u[d+b-v<<3>>3],h[b-v<<3>>3]=u[d+b-A<<3>>3]),A=A+1|0}while((A|0)<(y|0));h[b<<3>>3]=u[d+b<<3>>3]}return f}const Up=da(pT),fr=1e3,Xe=300,gi=1024,gt=512,Ls=4096,mr=2,gh=3,Pn=125,Rn=250,ro=3,Gp=.01,bT=.02,Os=6,yh=800,Hp=15,Wt=32768,vh=[{frequency:20,weight:.4006009013520281},{frequency:25,weight:.4258037044922291},{frequency:31.5,weight:.4536690484291709},{frequency:40,weight:.4840856831659204},{frequency:50,weight:.5142710208279764},{frequency:63,weight:.5473453749315819},{frequency:80,weight:.5841121495327103},{frequency:100,weight:.6214074879602299},{frequency:125,weight:.6601749463607856},{frequency:160,weight:.7054673721340388},{frequency:200,weight:.7489234225800412},{frequency:250,weight:.7936507936507937},{frequency:315,weight:.8406893652795292},{frequency:400,weight:.889284126278346},{frequency:500,weight:.9291521486643438},{frequency:630,weight:.9675858732462506},{frequency:800,weight:.9985022466300548},{frequency:1e3,weight:.9997500624843789},{frequency:1250,weight:.9564801530368244},{frequency:1600,weight:.9409550693954364},{frequency:2e3,weight:1.0196278358399185},{frequency:2500,weight:1.0955902492467817},{frequency:3150,weight:1.1232799775344005},{frequency:4e3,weight:1.0914051841746248},{frequency:5e3,weight:.9997500624843789},{frequency:6300,weight:.8727907484180668},{frequency:8e3,weight:.7722007722007722},{frequency:1e4,weight:.7369196757553427},{frequency:12500,weight:.7768498737618955},{frequency:16e3,weight:.7698229407236336},{frequency:2e4,weight:.4311738708634257},{frequency:22550,weight:.2},{frequency:25e3,weight:0}];class AT extends Pt{app;onAudioLoad=this.reset.bind(this);monoAudioData;audioLength=0;sampleRate=44100;tempogram=[];tempogramGroups=[];spectrogram=[];spectrogramDifference=[];noveltyCurve=[];noveltyCurveIsolated=[];spectrogramCanvases=[];lowestFinishedBlock=0;numRenderedBlocks=0;peaks=[];_threshold=.3;spectroHeights=[];spectroWeights=[];lastBeat=-1;updateInterval;bpm;offset;placeNotesButton;toggleButton;changeHandler=this.updateSpinners.bind(this);doAnalysis=!1;constructor(e){super({title:"Sync Audio",width:500,height:400,win_id:"sync-audio"}),this.app=e,this.initView(),this.reset(),this.updateInterval=setInterval(()=>{Math.round(this.app.chartManager.getBeat()*1e3)/1e3!=this.lastBeat&&(this.lastBeat=Math.round(this.app.chartManager.getBeat()*1e3)/1e3,this.updateSpinners())},17),$.on("timingModified",this.changeHandler),$.on("chartLoaded",this.changeHandler),$.on("audioLoaded",this.onAudioLoad)}onClose(){$.off("timingModified",this.changeHandler),$.off("chartLoaded",this.changeHandler),$.off("audioLoaded",this.onAudioLoad),this.app.chartManager.chartAudio.offLoad(this.onAudioLoad),clearInterval(this.updateInterval)}updateSpinners(){document.activeElement!=this.offset.input&&this.offset.setValue(this.app.chartManager.loadedChart?.timingData.getOffset()??0),document.activeElement!=this.bpm.input&&this.bpm.setValue(this.app.chartManager.loadedChart?.timingData.getEventAtBeat("BPMS",this.app.chartManager.getBeat())?.value??120)}initView(){this.viewElement.replaceChildren(),this.lastBeat=Math.round(this.app.chartManager.getBeat()*1e3)/1e3;const e=document.createElement("div");e.classList.add("sync-spinner-container");const t=document.createElement("div");t.innerText="Offset",this.offset=Ze.create(this.app.chartManager.loadedChart?.timingData.getOffset()??0,.001,3),this.offset.onChange=m=>{m!=null&&(!this.app.chartManager.loadedChart||!this.app.chartManager.loadedSM||((this.app.chartManager.loadedChart.timingData.hasChartOffset()?this.app.chartManager.loadedChart.timingData:this.app.chartManager.loadedSM.timingData).setOffset(m),this.app.chartManager.setBeat(this.app.chartManager.getBeat())))},e.replaceChildren(t,this.offset.view);const i=document.createElement("div");i.classList.add("sync-spinner-container");const s=document.createElement("div");s.innerText="BPM",this.bpm=Ze.create(this.app.chartManager.loadedChart?.timingData.getEventAtBeat("BPMS",this.app.chartManager.getBeat())?.value??120,.001,3),this.bpm.onChange=m=>{m!=null&&(!this.app.chartManager.loadedChart||!this.app.chartManager.loadedSM||((this.app.chartManager.loadedChart.timingData.isPropertyChartSpecific("BPMS")?this.app.chartManager.loadedChart.timingData:this.app.chartManager.loadedSM.timingData).insert([{type:"BPMS",beat:this.app.chartManager.getBeat(),value:m}]),this.app.chartManager.setBeat(this.app.chartManager.getBeat())))},i.replaceChildren(s,this.bpm.view);const n=document.createElement("div");n.classList.add("sync-container"),n.style.display="flex",n.style.flexDirection="column",n.style.alignItems="center";const a=document.createElement("div");a.classList.add("sync-top-container"),a.replaceChildren(e,i);const o=document.createElement("div");o.classList.add("sync-bottom-container"),this.toggleButton=document.createElement("button"),this.toggleButton.innerText="Start analyzing",this.toggleButton.style.width="120px",this.toggleButton.onclick=()=>{this.doAnalysis=!this.doAnalysis,this.toggleButton.innerText=this.doAnalysis?"Stop analyzing":"Start analyzing"},this.placeNotesButton=document.createElement("button"),this.placeNotesButton.innerText=this.app.chartManager.startRegion!==void 0&&this.app.chartManager.endRegion!==void 0?"Place onsets as notes in region":"Place onsets as notes",this.placeNotesButton.style.width="185px",this.placeNotesButton.onclick=()=>this.placeOnsets();const l=document.createElement("div");l.style.display="flex",l.style.alignItems="center",l.style.flexDirection="column";const c=document.createElement("div");c.style.display="flex",c.style.alignItems="center";const u=document.createElement("div");u.innerText="Onset Threshold";const h=document.createElement("input");h.type="range",h.min="0",h.max="1",h.step="0.01",h.value=`${this._threshold}`,h.style.width="75px";const d=document.createElement("input");d.type="text",d.value=`${this._threshold}`,d.onblur=()=>{let m=gn(d.value);if(m===null){d.value=`${this._threshold}`;return}m=Ve(m,0,1),d.value=ne(m,2).toString(),d.blur(),this.threshold=m,h.value=m.toString()},h.oninput=()=>{const m=parseFloat(h.value);d.value=ne(m,3).toString(),this.threshold=m},d.style.width="50px",d.onkeydown=m=>{m.key=="Enter"&&d.blur()},c.replaceChildren(h,d),l.replaceChildren(u,c),o.replaceChildren(l,this.placeNotesButton,this.toggleButton);const p=document.createElement("canvas");p.style.width=`${fr/2}px`,p.style.height=`${Xe}px`,n.replaceChildren(a,p,o),this.viewElement.appendChild(n);const f=this.windowLoop(p);requestAnimationFrame(f)}async reset(){this._threshold=.3,this.doAnalysis=!1,this.toggleButton.disabled=!1,this.toggleButton.style.background="",this.toggleButton.innerText="Start analyzing",this.app.chartManager.chartAudio.onLoad(this.onAudioLoad),await this.getMonoAudioData(),this.sampleRate=this.app.chartManager.chartAudio.getSampleRate(),this.spectroHeights=new Array(gi).fill(0).map((t,i)=>{const s=i/(gi/2)*this.sampleRate/2,n=(i+1)/(gi/2)*this.sampleRate/2,a=Xe-Ve(Math.log(s/20)/Math.log(this.sampleRate/40)*Xe,0,Xe),o=Xe-Ve(Math.log(n/20)/Math.log(this.sampleRate/40)*Xe,0,Xe);return{y:o,height:a-o}}),this.spectroWeights=new Array(gi).fill(0).map((t,i)=>{const s=i/(gi/2)*this.sampleRate/2,n=vh.findIndex(l=>l.frequency>s);if(n<1)return 0;const a=vh[n-1],o=vh[n];return sr(a.weight,o.weight,Ai(Math.log(1+a.frequency),Math.log(1+o.frequency),Math.log(1+s)))});const e=Math.max(1,Math.ceil(this.audioLength/gt));this.spectrogramCanvases=[];for(let t=0;t{if(this.placeNotesButton.innerText=this.app.chartManager.startRegion!==void 0&&this.app.chartManager.endRegion!==void 0?"Place onsets as notes in region":"Place onsets as notes",!this.app.chartManager.chartAudio)return;const s=Math.ceil(this.audioLength/gt);if(this.monoAudioData&&this.doAnalysis){const h=performance.now();for(;performance.now()-h=Math.ceil(this.monoAudioData.length/gt)){this.tempogram.length==0&&(this.toggleButton.disabled=!0,this.toggleButton.innerText="Finding tempo",this.calcTempogram());break}this.spectrogram[this.lowestFinishedBlock]===void 0&&(this.renderBlock(this.lowestFinishedBlock),this.calcDifference(this.lowestFinishedBlock),this.calcIsolatedNovelty(this.lowestFinishedBlock),this.numRenderedBlocks++),this.lowestFinishedBlock++}this.lowestFinishedBlocky.centerh.center-Os);g!==void 0&&(d+=g.groups[0].value,p+=g.avg,f++)}d/=f,p/=f,t.font=`${18+d*300}px Assistant`,t.globalAlpha=Math.min(1,(h.groups[0].value-Gp)*100),t.fillText(ne(p,0)+"",200,sr(Xe*2,Xe*1.5,Ai(Pn,Rn,p)))}t.globalAlpha=1,t.font="22px Assistant",t.textAlign="left",t.textBaseline="top",t.fillText("Spectogram",10,10),t.fillText("Onsets",10,Xe+10),t.fillText("Tempogram",10,Xe*1.5+10),e.closest("#windows")&&requestAnimationFrame(i)};return i}renderBlock(e){if(!this.monoAudioData)return;const t=new Float32Array(gi);t.set(this.monoAudioData.subarray(Math.max(0,e*gt-gi/2),e*gt+gi/2),-Math.min(0,e*gt-gi/2));for(let s=0;s{const a=this.spectroHeights[n],o=Ve(s*2e3,0,255);i.globalAlpha=o/255,i.fillRect(e%Wt,a.y,1,a.height)}),i.globalAlpha=1}storeDifferenceResponse(e,t){this.spectrogramDifference[e]=t;const i=t.reduce((s,n)=>s+n,0);this.noveltyCurve[e]=i}calcIsolatedNovelty(e){for(let t=e-gh;t<=e;t++){if(t<0)continue;let i=0,s=0;for(let n=t-gh;n<=t+gh;n++)this.noveltyCurve[n]!==void 0&&(i+=this.noveltyCurve[n],s++);i/=s,this.storeIsolatedNovelty(t,Math.max(0,this.noveltyCurve[t]-i))}}storeIsolatedNovelty(e,t){this.noveltyCurveIsolated[e]=Math.log(1+t),Math.log(1+t)>this._threshold&&Math.log(1+t)>(this.noveltyCurveIsolated[e-1]??0)?(this.peaks[e-1]&&(this.peaks[e-1]=!1),this.peaks[e]=!0):this.peaks[e]=!1;const i=this.spectrogramCanvases[Math.floor(e/Wt)].getContext("2d"),s=Math.min(1,Math.log(1+t))*Xe*.5;i.fillStyle="rgb(11, 14, 26)",i.fillRect(e%Wt,Xe,1,Xe*.5),i.fillStyle="rgba(0, 100, 150, 0.5)",i.fillRect(e%Wt,Xe*1.5-s,1,s)}async getMonoAudioData(){const e=this.app.chartManager.chartAudio;if(!e)return;const t=e.getBuffer(),i=new OfflineAudioContext(t.numberOfChannels,t.length,t.sampleRate),s=i.createBufferSource();s.buffer=t;const n=i.createChannelMerger(t.numberOfChannels);s.connect(n),n.connect(i.destination),s.start(),await i.startRendering().then(a=>{this.monoAudioData=a.getChannelData(0),this.audioLength=this.monoAudioData.length}).catch(()=>{Ce.createFormatted("Failed to load audio: audio rendering failed","error")})}get threshold(){return this._threshold}set threshold(e){this._threshold=e,this.peaks=this.noveltyCurveIsolated.map((t,i)=>t>this._threshold&&(this.noveltyCurveIsolated[i-1]??0)f.groups[0].value>=bT);if(p.length!=0&&(i=h,p.forEach(f=>{let m=0,g=0;for(let b=h-ro;b<=h+ro;b++){if(this.tempogramGroups[b]===void 0)continue;const A=this.tempogramGroups[b].find(v=>v.centerf.center-Os);A!==void 0&&(g+=A.avg,m++)}const y=Math.round(g/m);e.has(y)||e.set(y,0),e.set(y,e.get(y)+1),e.get(y)>t&&(t=e.get(y),s=y)}),t>50))break}if(s==0)return;const n=60/s*(this.sampleRate/gt),a=new Array(yh).fill(0).map((h,d)=>{const p=d%n/n;let f=0,m=0;for(let g=1;g<=4;g++)m+=Math.max(1-Math.abs(Math.round(p*g)/g-p)*12,0)*1/g,f+=1/g;return m/f});let o=0,l=0;const c=[];for(let h=i;ha[f]*p).reduce((p,f)=>p+f,0);d>o&&(o=d,l=h),c.push({block:h,offset:-(h*gt/this.sampleRate)%(60/s),response:d,curve:this.noveltyCurveIsolated.slice(h,h+yh).map((p,f)=>a[f]*p)})}c.sort((h,d)=>d.response-h.response);const u=-(l*gt/this.sampleRate%(60/s));console.log(s,e,i,u,c)}placeOnsets(){const e=this.peaks.map((t,i)=>{if(!t)return null;let s=this.app.chartManager.loadedChart.getBeatFromSeconds(i*gt/this.sampleRate);return s=Math.round(s*48)/48,s<0?null:{type:"Tap",beat:s,col:0}}).filter(t=>t!==null).filter(t=>this.app.chartManager.startRegion===void 0||this.app.chartManager.endRegion===void 0?!0:t.beat>this.app.chartManager.startRegion&&t.beatd.beat==n.beat):-1,o=i.getDivisionLength(e);const l=i.getDivisionOfMeasure(e)%1*o;let c=Math.max(0,e-l);c=s[a+1]?.beat&&(a++,n=s[a],c=n.beat,o=i.getDivisionLength(c),u=0,h=n.upper)}calcTempogram(){let e=0;for(let a=0;ae&&(e=this.noveltyCurveIsolated[a]);const t=new Float32Array(this.noveltyCurveIsolated.length);for(let a=0;a{const o=new Float32Array(Ls);o.set(t.subarray(Math.max(0,a*mr-Ls/2),a*mr+Ls/2),-Math.min(0,a*mr-Ls/2));for(let c=0;cn(++a),1)):(this.calculateOffset(),this.spectrogram=[],this.noveltyCurve=[],this.tempogram=[],this.monoAudioData=void 0,this.toggleButton.innerText="Finished analyzing",this.toggleButton.style.background="#265296")};n(0)}storeTempogram(e,t){const i=new Map,s=[];t.forEach((a,o)=>{let l=this.sampleRate*60/(gt*Ls)*o;if(!(l>Rn*4||lRn&&l!=1/0;)l/=2;for(;l({bpm:a,value:o})).sort((a,o)=>o.value-a.value).filter(a=>a.value!=0);for(let a=0;ac.centero.bpm-Os);if(l===void 0){s.push({center:o.bpm,groups:[o]});continue}l.groups.push(o)}this.tempogramGroups[e]=s.map(a=>({...a,avg:a.groups.reduce((o,l)=>o+l.bpm*l.value,0)/a.groups.reduce((o,l)=>o+l.value,0)}));const n=this.spectrogramCanvases[Math.floor(e*mr/Wt)].getContext("2d");n.fillStyle="rgba(0, 166, 255, 1)",this.tempogram[e].forEach(a=>{const o=Ve(a.value*8e3,0,255);n.globalAlpha=o/255,n.fillRect(e*mr%Wt,sr(Xe*2,Xe*1.5,Ai(Pn,Rn,a.bpm)),1*mr,Xe*.5/(Rn-Pn))})}}const Jt=r=>r,Wp={offset:{title:"Offset",element:Jt({create:(r,e)=>{const t=Ze.create(0,.001,3);return t.onChange=i=>{i!=null&&(e().setOffset(i),r.chartManager.setBeat(r.chartManager.getBeat()))},t.view},update:(r,e)=>{const t=r.querySelector(".spinner-input");if(document.activeElement==t)return;const i=e.getOffset();t.value!=ne(i,3).toFixed(3)&&(t.value=ne(i,3).toFixed(3))}})},bpm:{title:"BPM",element:Jt({create:(r,e)=>{const t=Ze.create(120,void 0,3);return t.onChange=i=>{if(i==null){const s=r.chartManager.getBeat();e().delete([{type:"BPMS",beat:s}]);return}e().insert([{type:"BPMS",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("BPMS",t)?.value??120;i.value!=ne(s,3).toFixed(3)&&(i.value=ne(s,3).toFixed(3))}})},stop:{title:"Stop",element:Jt({create:(r,e)=>{const t=Ze.create(0,void 0,3);return t.onChange=i=>{if(i==null||i==0){const s=r.chartManager.getBeat();e().delete([{type:"STOPS",beat:s}]);return}e().insert([{type:"STOPS",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("STOPS",t);let n=s?.value??0;t!=s?.beat&&(n=0),i.value!=ne(n,3).toFixed(3)&&(i.value=ne(n,3).toFixed(3))}})},delay:{title:"Delay",element:Jt({create:(r,e)=>{const t=Ze.create(0,void 0,3);return t.onChange=i=>{if(i==null||i==0){const s=r.chartManager.getBeat();e().delete([{type:"DELAYS",beat:s}]);return}e().insert([{type:"DELAYS",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("DELAYS",t);let n=s?.value??0;t!=s?.beat&&(n=0),i.value!=ne(n,3).toFixed(3)&&(i.value=ne(n,3).toFixed(3))}})},warp:{title:"Warp",element:Jt({create:(r,e)=>{const t=Ze.create(0,void 0,3,0);return t.onChange=i=>{if(i==null||i==0){const s=r.chartManager.getBeat();e().delete([{type:"WARPS",beat:s}]);return}i<0||e().insert([{type:"WARPS",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("WARPS",t);let n=s?.value??0;t!=s?.beat&&(n=0),i.value!=ne(n,3).toFixed(3)&&(i.value=ne(n,3).toFixed(3))}})},timeSig:{title:"Time Sig.",element:Jt({create:(r,e)=>{const t=document.createElement("div");t.classList.add("flex-column-gap");const i=Ze.create(4,1,0,1);i.onChange=n=>{if(n==null){const a=r.chartManager.getBeat();e().delete([{type:"TIMESIGNATURES",beat:a}]);return}n<1||e().insert([{type:"TIMESIGNATURES",beat:r.chartManager.getBeat(),upper:n,lower:s.value}])};const s=Ze.create(4,1,0,1);return s.onChange=n=>{if(n==null){const a=r.chartManager.getBeat();e().delete([{type:"TIMESIGNATURES",beat:a}]);return}n<1||e().insert([{type:"TIMESIGNATURES",beat:r.chartManager.getBeat(),upper:i.value,lower:n}])},t.appendChild(i.view),t.appendChild(s.view),t},update:(r,e,t)=>{const i=r.firstElementChild.querySelector(".spinner-input"),s=r.lastElementChild.querySelector(".spinner-input"),n=e.getEventAtBeat("TIMESIGNATURES",t),a=n?.upper??4,o=n?.lower??4;document.activeElement!=i&&i.value!=Math.round(a).toString()&&(i.value=Math.round(a).toString()),document.activeElement!=s&&s.value!=Math.round(o).toString()&&(s.value=Math.round(o).toString())}})},tick:{title:"Tickcount",element:Jt({create:(r,e)=>{const t=Ze.create(4,1,0,0);return t.onChange=i=>{if(i==null){const s=r.chartManager.getBeat();e().delete([{type:"TICKCOUNTS",beat:s}]);return}i<0||e().insert([{type:"TICKCOUNTS",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("TICKCOUNTS",t)?.value??4;i.value!=Math.round(s).toString()&&(i.value=Math.round(s).toString())}})},combo:{title:"Combo",element:Jt({create:(r,e)=>{const t=document.createElement("div");t.classList.add("flex-column-gap");const i=Ze.create(1,1,0,0);i.onChange=n=>{if(n==null){const a=r.chartManager.getBeat();e().delete([{type:"COMBOS",beat:a}]);return}n<0||e().insert([{type:"COMBOS",beat:r.chartManager.getBeat(),hitMult:n,missMult:s.value}])};const s=Ze.create(1,1,0,0);return s.onChange=n=>{if(n==null){const a=r.chartManager.getBeat();s.setValue(r.chartManager.loadedChart?.timingData.getEventAtBeat("COMBOS",a)?.missMult??1);return}n<0||e().insert([{type:"COMBOS",beat:r.chartManager.getBeat(),hitMult:i.value,missMult:n}])},t.appendChild(i.view),t.appendChild(s.view),t},update:(r,e,t)=>{const i=r.firstElementChild.querySelector(".spinner-input"),s=r.lastElementChild.querySelector(".spinner-input"),n=e.getEventAtBeat("COMBOS",t),a=n?.hitMult??1,o=n?.missMult??1;document.activeElement!=i&&i.value!=Math.round(a).toString()&&(i.value=Math.round(a).toString()),document.activeElement!=s&&s.value!=Math.round(o).toString()&&(s.value=Math.round(o).toString())}})},speed:{title:"Speed",element:Jt({create:(r,e)=>{const t=document.createElement("div");t.classList.add("flex-column-gap");const i=()=>{e().insert([{type:"SPEEDS",beat:r.chartManager.getBeat(),value:s.value,delay:n.value,unit:a.value=="Beats"?"B":"T"}])},s=Ze.create(1,.1,0);s.onChange=o=>{if(o==null){const l=r.chartManager.getBeat();e().delete([{type:"SPEEDS",beat:l}]);return}i()};const n=Ze.create(1,.1,0);n.onChange=o=>{o==null||o<0||i()};const a=pi.create(["Beat","Time"],"Beats");return a.onChange=i,t.appendChild(s.view),t.appendChild(n.view),t.appendChild(a.view),t},update:(r,e,t)=>{const i=r.firstElementChild.querySelector(".spinner-input"),s=r.children[1].querySelector(".spinner-input"),n=e.getEventAtBeat("SPEEDS",t),a=n?.value??1,o=n?.delay??0,l=n?.unit=="B"?"Beat":"Time";document.activeElement!=i&&i.value!=ne(a,3).toFixed(3)&&(i.value=ne(a,3).toFixed(3)),document.activeElement!=s&&s.value!=ne(o,3).toFixed(3)&&(s.value=ne(o,3).toFixed(3)),s.disabled=n?.beat!=t;const c=r.lastElementChild.querySelector(".dropdown-selected");c.innerText!=l&&(c.innerText=l),n?.beat!=t?c.classList.add("disabled"):c.classList.remove("disabled")}})},scroll:{title:"Scroll",element:Jt({create:(r,e)=>{const t=Ze.create(1,void 0,3);return t.onChange=i=>{if(i==null){const s=r.chartManager.getBeat();e().delete([{type:"SCROLLS",beat:s}]);return}e().insert([{type:"SCROLLS",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("SCROLLS",t)?.value??1;i.value!=ne(s,3).toFixed(3)&&(i.value=ne(s,3).toFixed(3))}})},fake:{title:"Fake",element:Jt({create:(r,e)=>{const t=Ze.create(1,void 0,3,0);return t.onChange=i=>{if(i==null){const s=r.chartManager.getBeat();e().delete([{type:"FAKES",beat:s}]);return}i<0||e().insert([{type:"FAKES",beat:r.chartManager.getBeat(),value:i}])},t.view},update:(r,e,t)=>{const i=r.querySelector(".spinner-input");if(document.activeElement==i)return;const s=e.getEventAtBeat("FAKES",t);let n=s?.value??1;t!=s?.beat&&(n=0),i.value!=ne(n,3).toFixed(3)&&(i.value=ne(n,3).toFixed(3))}})},label:{title:"Label",element:Jt({create:(r,e)=>{const t=document.createElement("input");return t.type="text",t.autocomplete="off",t.spellcheck=!1,t.onkeydown=i=>{i.key=="Enter"&&t.blur()},t.onblur=()=>{if(t.value==""){const i=r.chartManager.getBeat();e().delete([{type:"LABELS",beat:i}]);return}e().insert([{type:"LABELS",beat:r.chartManager.getBeat(),value:t.value}])},t},update:(r,e,t)=>{const i=r;if(document.activeElement==i)return;const n=e.getEventAtBeat("LABELS",t)?.value??"";i.value!=n&&(i.value=n)}})}};class wT extends Pt{app;lastBeat;chartTiming=!1;interval;changeHandler=()=>this.setData();constructor(e){super({title:"Edit Timing Data",width:300,height:340,disableClose:!1,win_id:"timing_data",blocking:!1}),this.app=e,this.lastBeat=Math.round(this.app.chartManager.getBeat()*1e3)/1e3,this.chartTiming=this.app.chartManager.loadedChart.timingData.usesChartTiming(),this.initView(),this.interval=setInterval(()=>{Math.round(this.app.chartManager.getBeat()*1e3)/1e3!=this.lastBeat&&(this.lastBeat=Math.round(this.app.chartManager.getBeat()*1e3)/1e3,this.setData())},17),$.on("timingModified",this.changeHandler),$.on("chartLoaded",this.changeHandler)}onClose(){$.off("timingModified",this.changeHandler),clearInterval(this.interval)}initView(){this.viewElement.replaceChildren(),this.viewElement.classList.add("timing-data");const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("label"),t.innerText="Apply to";const i=pi.create(["All charts","This chart"],this.chartTiming?"This chart":"All charts");i.onChange(s=>{this.chartTiming=s=="This chart"}),e.appendChild(t),e.appendChild(i.view),Object.values(Wp).forEach(s=>{const n=document.createElement("div");n.classList.add("label"),n.innerText=s.title;const a=s.element.create(this.app,()=>this.chartTiming?this.app.chartManager.loadedChart.timingData:this.app.chartManager.loadedSM.timingData);e.appendChild(n),e.appendChild(a)}),this.viewElement.appendChild(e),this.setData()}setData(){this.app.chartManager.loadedChart&&Object.values(Wp).forEach((e,t)=>{const i=this.viewElement.children[0].children[t*2+3];e.element.update(i,this.app.chartManager.loadedChart.timingData,this.lastBeat)})}}const Vp=[{type:"group",id:"general",label:"General",children:[{type:"subgroup",children:[{type:"item",label:"Smooth Animations",id:"general.smoothAnimations",input:{type:"checkbox",onChange:(r,e)=>{e?document.body.classList.add("animated"):document.body.classList.remove("animated")}}},{type:"item",label:"Warn before exit",id:"general.warnBeforeExit",input:{type:"checkbox"},tooltip:"Warn before exiting the editor if you have unsaved changes."},{type:"item",label:"Spinner step",id:"general.spinnerStep",input:{type:"slider",min:0,step:.1,max:5,hardMin:0,hardMax:2**31-1},tooltip:"The default increment for all number spinners."}]}]},{type:"group",id:"chart",label:"Chart",children:[{type:"subgroup",label:"Playfield",children:[{type:"subgroup",children:[{type:"item",label:"Enable mouse placement",id:"chart.mousePlacement",input:{type:"checkbox"}}]},{type:"subgroup",children:[{type:"item",label:"Zoom",id:"chart.zoom",input:{type:"slider",min:50,step:1,max:200,hardMax:2**31-1,transformers:{serialize:r=>r*100,deserialize:r=>r/100}}},{type:"item",label:"Reverse playfield",id:"chart.reverse",input:{type:"checkbox"}}]},{type:"subgroup",children:[{type:"item",label:"Y position",id:"chart.receptorYPos",input:{type:"slider",min:-400,max:0,hardMin:-(2**31-1),hardMax:2**31-1}},{type:"item",label:"Draw length",id:"chart.maxDrawBeats",input:{type:"slider",min:0,max:30,hardMax:2**31-1},tooltip:"Maximum number of beats to draw notes. Increasing this works well for songs with high bpm but can affect performance. Only applies to XMod."},{type:"item",label:"Draw length past receptors",id:"chart.maxDrawBeatsBack",input:{type:"slider",min:0,max:30,hardMax:2**31-1},tooltip:"Maximum number of beats to draw notes past the receptors. Increasing this can affect performance. Only applies to XMod."}]},{type:"subgroup",children:[{type:"item",label:"Draw noteflashes",id:"chart.drawNoteFlash",input:{type:"checkbox"}}]}]},{type:"subgroup",label:"Scrolling",children:[{type:"item",label:"Scroll sensitivity",id:"chart.scroll.scrollSensitivity",input:{type:"slider",min:0,step:1,max:200,hardMax:2**31-1,transformers:{serialize:r=>r*100,deserialize:r=>r/100}},tooltip:"Adjust the scroll sensitivity when scrolling through the chart."},{type:"item",label:"Snap every scroll",id:"chart.scroll.scrollSnapEveryScroll",input:{type:"checkbox"},tooltip:"Whether each scroll movement corresponds to moving one snap unit when scrolling. Turning this on will have the same behavior as ArrowVortex. Recommended on for those using a mouse, off for those using trackpad."},{type:"item",label:"Invert zoom in/out",id:"chart.scroll.invertZoomScroll",input:{type:"checkbox"},tooltip:"Inverts the zoom in/out control when scrolling."},{type:"item",label:"Invert scroll direction when in reverse",id:"chart.scroll.invertReverseScroll",input:{type:"checkbox"}}]},{type:"subgroup",label:"Waveform",children:[{type:"item",label:"Draw waveform",id:"chart.waveform.enabled",input:{type:"checkbox"}},{type:"subgroup",children:[{type:"item",label:"Color",id:"chart.waveform.color",input:{type:"color"}},{type:"item",label:"Opacity",id:"chart.waveform.opacity",input:{type:"slider",min:0,max:1,step:.01}}]},{type:"subgroup",children:[{type:"item",label:"Draw filtered waveform",id:"chart.waveform.allowFilter",input:{type:"checkbox"}},{type:"item",label:"Filtered color",id:"chart.waveform.filteredColor",input:{type:"color"}},{type:"item",label:"Filtered opacity",id:"chart.waveform.filteredOpacity",input:{type:"slider",min:0,max:1,step:.01}}]},{type:"item",label:"Line height",id:"chart.waveform.lineHeight",input:{type:"slider",min:1,max:3,step:.1,hardMax:100},tooltip:"The height of each line of the waveform. Increasing this can help performance."},{type:"item",label:"Antialiasing",id:"chart.waveform.antialiasing",input:{type:"checkbox"}},{type:"item",label:"Allow speed changes",id:"chart.waveform.speedChanges",input:{type:"checkbox"},tooltip:"Allows the waveform to be affected by SPEEDS and SCROLLS."}]}]},{type:"group",id:"audio",label:"Audio",children:[{type:"subgroup",children:[{type:"item",label:"Master volume",id:"audio.masterVolume",input:{type:"slider",min:0,step:1,max:100,hardMax:2**31-1,transformers:{serialize:r=>r*100,deserialize:r=>r/100}}},{type:"item",label:"Song volume",id:"audio.songVolume",input:{type:"slider",min:0,step:1,max:100,hardMax:2**31-1,transformers:{serialize:r=>r*100,deserialize:r=>r/100}}},{type:"item",label:"Sound effect volume",id:"audio.soundEffectVolume",input:{type:"slider",min:0,step:1,max:100,hardMax:2**31-1,transformers:{serialize:r=>r*100,deserialize:r=>r/100}}}]},{type:"subgroup",children:[{type:"item",label:"Enable assist tick",id:"audio.assistTick",input:{type:"checkbox"},tooltip:"Plays a sound when a note passes the receptors"},{type:"item",label:"Enable metronome",id:"audio.metronome",input:{type:"checkbox"}}]},{type:"subgroup",children:[{type:"item",label:"Allow filters to affect audio",id:"audio.allowFilter",input:{type:"checkbox",onChange:r=>{r.chartManager.chartAudio.reload()}}},{type:"item",label:"Enable metronome",id:"audio.metronome",input:{type:"checkbox"}}]}]},{type:"group",id:"play",label:"Play mode",children:[{type:"subgroup",label:"Calibration",children:[{type:"item",label:"Global offset",id:"play.offset",input:{type:"slider",min:-1,step:.001,max:1,hardMin:-(2**31-1),hardMax:2**31-1},tooltip:"Offset in seconds when playing a chart. Set to positive if you are hitting early and negative if you are hitting late."},{type:"item",label:"Sound effect offset",id:"play.effectOffset",input:{type:"slider",min:-1,step:.001,max:1,hardMin:-(2**31-1),hardMax:2**31-1},tooltip:"Offset in seconds when playing sound effects like assist tick and metronome."},{type:"item",label:"Visual offset",id:"play.visualOffset",input:{type:"slider",min:-1,step:.001,max:1,hardMin:-(2**31-1),hardMax:2**31-1},tooltip:"Offset in seconds when displaying notes."}]},{type:"subgroup",children:[{type:"item",label:"Judgment tilt",id:"play.judgmentTilt",input:{type:"checkbox"},tooltip:"Tilts the judgement text left if you are hitting early and right if you are hitting late."},{type:"item",label:"Hide barlines during play",id:"play.hideBarlines",input:{type:"checkbox"}}]},{type:"subgroup",label:"Timing windows",children:[{type:"item",id:"play.timingCollection",label:"Timing window collection",input:{type:"dropdown",advanced:!1,get items(){return Object.keys(qe.getCollections())}}},{type:"item",id:"play.timingWindowScale",label:"Timing window scale",input:{type:"slider",min:0,step:.001,max:2,hardMax:2**31-1},tooltip:"Scales all timing windows by the given amount."},{type:"item",id:"play.timingWindowAdd",label:"Timing window add",input:{type:"slider",min:0,step:.001,max:1,hardMax:2**31-1},tooltip:"Adds this value (in seconds) to all timing windows."}]}]},{type:"group",id:"performance",label:"Performance",children:[{type:"item",label:"Antialiasing",id:"performance.antialiasing",input:{type:"checkbox"}},{type:"item",label:"Resolution",id:"performance.resolution",input:{type:"slider",min:1,step:1,max:4,hardMin:0,hardMax:2**31-1},tooltip:"Requires a reload."}]},{type:"group",id:"debug",label:"Debug",children:[{type:"item",label:"Show FPS",id:"debug.showFPS",input:{type:"checkbox"}},{type:"item",label:"Show rendering timers",id:"debug.showTimers",input:{type:"checkbox"}}]}];class xT extends Pt{app;observer;sectionContainer;constructor(e){super({title:"Options",width:600,height:400,disableClose:!1,win_id:"user_options",blocking:!1}),this.app=e,this.initView()}initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("pref-container");const i=document.createElement("div");i.classList.add("pref-search");const s=document.createElement("input");s.classList.add("pref-search-bar"),s.type="text",s.placeholder="Search for an option...",s.oninput=()=>{a.replaceChildren(),o.replaceChildren(...this.createOptions(this.filterOptions(s.value)))},i.appendChild(s);const n=document.createElement("div");n.classList.add("pref-scrollers");const a=document.createElement("div");a.classList.add("pref-section-scroller"),this.sectionContainer=a;const o=document.createElement("div");o.classList.add("pref-option-scroller"),n.replaceChildren(a,o),this.observer=new IntersectionObserver(l=>{l.forEach(c=>{const u=c.target.dataset.id,h=a.querySelector(`.pref-section[data-id=${u}]`);h&&(c.intersectionRatio>0?h.classList.add("selected"):h.classList.remove("selected"))})},{}),t.replaceChildren(i,n),a.replaceChildren(),o.replaceChildren(...this.createOptions(Vp)),e.appendChild(t),this.viewElement.appendChild(e)}createOptions(e){return e.map(t=>{const i=this.makeOption(t);return t.type=="group"&&(this.observer.observe(i),this.sectionContainer?.appendChild(this.createEmptyGroup(t))),i})}makeOption(e){const t=document.createElement("div");t.classList.add("pref-"+e.type),(e.type=="group"||e.type=="item")&&(t.dataset.id=e.id);const i=document.createElement("div");i.classList.add(`pref-${e.type}-label`),e.label!==void 0&&(i.innerText=e.label,t.appendChild(i));const s=document.createElement("img");if(e.type=="item"&&(s.src=He.REVERT,s.style.width="12px",s.addEventListener("click",()=>{_.applyOption([e.id,_.getDefaultOption(e.id)]),t.replaceWith(this.makeOption(e))}),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",t.appendChild(s)),e.type=="item"){const n=_.getOption(e.id);let a;if(!e.input)return t;switch(i.innerText=e.label,e.input.type){case"checkbox":{const o=document.createElement("input"),l=e.input.onChange;o.type="checkbox",o.checked=n,o.onblur=null,o.onchange=()=>{_.applyOption([e.id,o.checked]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",l?.(this.app,o.checked)},o.classList.add("pref-input","right"),o.onkeydown=c=>{c.key=="Enter"&&o.blur()},a=o;break}case"dropdown":{if(e.input.advanced){const o=e.input.transformers.deserialize,l=e.input.transformers.serialize,c=e.input.onChange,u=pi.create(e.input.items,l(n));u.onChange(h=>{_.applyOption([e.id,o(h)]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",c?.(o(h))}),u.view.classList.add("pref-input","dropdown-right"),a=u.view}else{const o=e.input.onChange,l=pi.create(e.input.items,n);l.onChange(c=>{_.applyOption([e.id,c]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",o?.(c)}),l.view.classList.add("pref-input","dropdown-right"),a=l.view}break}case"number":{const o=e.input.transformers?.deserialize??(h=>h),l=e.input.transformers?.serialize??(h=>h),c=e.input.onChange,u=Ze.create(l(n),e.input.step,e.input.precision,e.input.min,e.input.max);u.onChange=h=>{if(!h){u.setValue(l(h));return}_.applyOption([e.id,o(h)]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",c?.(o(h))},a=u.view;break}case"slider":{const o=e.input.transformers?.deserialize??(m=>m),l=e.input.transformers?.serialize??(m=>m),c=e.input.onChange,u=document.createElement("div");u.style.display="flex",u.style.alignItems="center";const h=document.createElement("input");h.type="range",h.min=e.input.min?.toString()??"",h.max=e.input.max?.toString()??"",h.step=e.input.step?.toString()??"1",h.value=l(n).toString();const d=document.createElement("input");d.type="text",d.value=(Math.round(l(n)*1e3)/1e3).toString();const p=e.input.min??e.input.hardMin??-Number.MAX_VALUE,f=e.input.max??e.input.hardMax??Number.MAX_VALUE;d.onblur=()=>{let m=gn(d.value);if(m===null){d.value=(Math.round(l(n)*1e3)/1e3).toString();return}m=Ve(m,p,f),d.value=ne(m,3).toString(),d.blur(),d.value==""?d.value=l(m).toString():_.applyOption([e.id,o(m)]),h.value=m.toString(),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",c?.(o(m))},h.oninput=()=>{const m=parseFloat(h.value);d.value=ne(m,3).toString(),_.applyOption([e.id,o(m)]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block"},d.style.width="50px",d.onkeydown=m=>{m.key=="Enter"&&d.blur()},u.appendChild(h),u.appendChild(d),a=u;break}case"text":{const o=e.input.onChange,l=document.createElement("input");l.type="text",l.value=n.toString(),l.onblur=()=>{_.applyOption([e.id,l.value]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block",o?.(l.value)},l.onkeydown=c=>{c.key=="Enter"&&l.blur()},a=l;break}case"color":{const o=document.createElement("input");o.type="color",o.value="#"+n.toString(16),o.onblur=()=>{_.applyOption([e.id,parseInt(o.value.slice(1),16)]),s.style.display=_.getDefaultOption(e.id)===_.getOption(e.id)?"none":"block"},a=o}}a.classList.add("pref-item-input"),t.appendChild(a)}else{const n=document.createElement("div");n.classList.add("pref-children"),t.appendChild(n),n.replaceChildren(...this.createOptions(e.children))}return e.type=="item"&&e.tooltip!==void 0&&Mt(t,{content:e.tooltip}),t}filterOptions(e,t=Vp){const i=[];return t.forEach(s=>{if(s.label&&s.label.toLowerCase().includes(e.toLowerCase())){i.push(s);return}if(s.type=="group"||s.type=="subgroup"){const n=this.filterOptions(e,s.children);n.length!=0&&i.push({...s,children:n})}}),i}createEmptyGroup(e){const t=document.createElement("div");return t.classList.add("pref-section"),t.dataset.id=e.id,t.innerText=e.label,t.onclick=()=>{t.parentElement.parentElement.querySelector(`.pref-group[data-id=${e.id}]`).scrollIntoView()},t}onClose(){this.observer?.disconnect()}}var zn=(r=>(r.SHIFT="Shift",r.CTRL="Ctrl",r.ALT="Alt",r.META="Command",r))(zn||{});const ys=navigator.userAgent.indexOf("Mac OS X")>-1,yt=ys?"Command":"Ctrl",_T={Shift:ys?"⇧":"Shift",Ctrl:ys?"⌃":"Ctrl",Alt:ys?"⌥":"Alt",Command:"⌘"},zp={ArrowLeft:"Left",ArrowUp:"Up",ArrowRight:"Right",ArrowDown:"Down",BracketLeft:"[",BracketRight:"]",Semicolon:";",Quote:"'",Backslash:"\\",Slash:"/",Period:".",Comma:",",Backquote:"`",Minus:"-",Equal:"+"},Xo=["ctrlKey","altKey","shiftKey","metaKey"],vo=["Ctrl","Alt","Shift","Command"],dt={playback:{label:"Play/Pause",combos:[{key:"Space",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.playPause()},decreaseSnap:{label:"Decrease snap",combos:[{key:"Left",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.previousSnap()},increaseSnap:{label:"Increase snap",combos:[{key:"Right",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.nextSnap()},cursorUp:{label:"Move cursor up",combos:[{key:"Up",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>{r.chartManager.snapToPreviousTick()}},cursorDown:{label:"Move cursor down",combos:[{key:"Down",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>{r.chartManager.snapToNextTick()}},increaseScrollSpeed:{label:"Increase scroll speed",combos:[{key:"Up",mods:[yt]}],disabled:r=>!r.chartManager.chartView,callback:()=>_.chart.speed=Math.max(10,_.chart.speed*Math.pow(1.01,30))},decreaseScrollSpeed:{label:"Decrease scroll speed",combos:[{key:"Down",mods:[yt]}],disabled:r=>!r.chartManager.chartView,callback:()=>_.chart.speed=Math.max(10,_.chart.speed*Math.pow(1.01,-30))},zoomIn:{label:"Zoom in",combos:[{key:"+",mods:[yt]}],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.zoom+=.1,Ce.create("Zoom: "+Math.round(_.chart.zoom*100)+"%")}},zoomOut:{label:"Zoom out",combos:[{key:"-",mods:[yt]}],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.zoom=Math.max(.1,_.chart.zoom-.1),Ce.create("Zoom: "+Math.round(_.chart.zoom*100)+"%")}},zoomDefault:{label:"Reset zoom",combos:[{key:"0",mods:[yt]}],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.zoom=1,Ce.create("Zoom: "+Math.round(_.chart.zoom*100)+"%")}},newSong:{label:"New song...",bindLabel:"New song",combos:[{key:"N",mods:[yt]}],disabled:r=>!r.chartManager.loadedSM||!Ie.openWindows,callback:r=>{r.windowManager.openWindow(new kg(r))}},openSong:{label:"Open song...",bindLabel:"Open song",combos:[{key:"O",mods:[yt]}],disabled:r=>!r.chartManager.loadedSM||!Ie.openWindows,callback:r=>{if(window.nw){const e=document.createElement("input");e.type="file",e.accept=".sm,.ssc",e.onchange=()=>r.chartManager.loadSM(e.value),e.click()}else r.windowManager.openWindow(new ml(r,{title:"Select an sm/ssc file...",accepted_file_types:[".sm",".ssc"],disableClose:!0,callback:e=>r.chartManager.loadSM(e)}))}},songProperties:{label:"Song properties...",bindLabel:"Open song properties",combos:[{key:"O",mods:["Shift"]}],disabled:r=>!r.chartManager.loadedSM||!Ie.openWindows,callback:r=>r.windowManager.openWindow(new uT(r))},save:{label:"Save...",bindLabel:"Save",combos:[{key:"S",mods:[yt]}],disabled:r=>!r.chartManager.loadedSM||r.chartManager.smPath.startsWith("https://")||r.chartManager.smPath.startsWith("http://"),callback:r=>r.chartManager.save()},export:{label:"Save and export current song",combos:[{key:"E",mods:[yt]}],disabled:r=>!!window.nw||!r.chartManager.loadedSM||r.chartManager.smPath.startsWith("https://")||r.chartManager.smPath.startsWith("http://"),callback:r=>{r.chartManager.save(),Re.getStandardHandler().saveDirectory(r.chartManager.smPath)}},exportNotedata:{label:"Export to notedata...",bindLabel:"Export to notedata",combos:[{key:"E",mods:[yt,"Shift"]}],disabled:r=>!r.chartManager.loadedSM||!Ie.openWindows,callback:r=>r.windowManager.openWindow(new nT(r,r.chartManager.selection.notes))},openChart:{label:"Chart list",bindLabel:"Open chart list",combos:[{key:"O",mods:[yt,"Shift"]}],disabled:r=>!r.chartManager.loadedSM||!Ie.openWindows,callback:r=>r.windowManager.openWindow(new Ag(r))},timingDataRow:{label:"Edit timing data at row",combos:[{key:"T",mods:["Shift"]}],disabled:r=>!r.chartManager.chartView||!Ie.openWindows,callback:r=>r.windowManager.openWindow(new wT(r))},selectRegion:{label:"Select region",combos:[{key:"Tab",mods:[]}],disabled:r=>!r.chartManager.loadedChart&&r.chartManager.getMode()!=Y.Edit,callback:r=>r.chartManager.selectRegion()},volumeUp:{label:"Increase master volume",combos:[{key:"Up",mods:["Alt"]}],disabled:!1,callback:()=>{_.audio.masterVolume=Math.min(_.audio.masterVolume+.05,1),Ce.create("Master volume: "+Math.round(_.audio.masterVolume*100)+"%")}},volumeDown:{label:"Decrease master volume",combos:[{key:"Down",mods:["Alt"]}],disabled:!1,callback:()=>{_.audio.masterVolume=Math.max(_.audio.masterVolume-.05,0),Ce.create("Master volume: "+Math.round(_.audio.masterVolume*100)+"%")}},songVolumeUp:{label:"Increase song volume",combos:[{key:"Up",mods:["Shift","Alt"]}],disabled:!1,callback:()=>{_.audio.songVolume=Math.min(_.audio.songVolume+.05,1),Ce.create("Song volume: "+Math.round(_.audio.songVolume*100)+"%")}},songVolumeDown:{label:"Decrease song volume",combos:[{key:"Down",mods:["Shift","Alt"]}],disabled:!1,callback:()=>{_.audio.songVolume=Math.max(_.audio.songVolume-.05,0),Ce.create("Song volume: "+Math.round(_.audio.songVolume*100)+"%")}},effectvolumeUp:{label:"Increase tick/metronome volume",combos:[{key:"Up",mods:["Shift",yt,"Alt"]}],disabled:!1,callback:()=>{_.audio.soundEffectVolume=Math.min(_.audio.soundEffectVolume+.05,1),Ce.create("Effect volume: "+Math.round(_.audio.soundEffectVolume*100)+"%")}},effectvolumeDown:{label:"Decrease tick/metronome volume",combos:[{key:"Down",mods:["Shift",yt,"Alt"]}],disabled:!1,callback:()=>{_.audio.soundEffectVolume=Math.max(_.audio.soundEffectVolume-.05,0),Ce.create("Effect Volume: "+Math.round(_.audio.soundEffectVolume*100)+"%")}},rateUp:{label:"Increase playback rate",combos:[{key:"Right",mods:["Shift"]}],disabled:r=>r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:()=>{_.audio.rate+=.05,Ce.create("Playback Rate: "+Math.round(_.audio.rate*100)+"%")}},rateDown:{label:"Decrease playback rate",combos:[{key:"Left",mods:["Shift"]}],disabled:r=>r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:()=>{_.audio.rate=Math.max(_.audio.rate-.05,.1),Ce.create("Playback Rate: "+Math.round(_.audio.rate*100)+"%")}},rateDefault:{label:"Reset playback rate",combos:[],disabled:!1,callback:()=>{_.audio.rate=1,Ce.create("Playback Rate: "+Math.round(_.audio.rate)+"%")}},previousMeasure:{label:"Previous measure",combos:[{key:"PageUp",mods:[]},{key:";",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>{const e=r.chartManager.getBeat(),t=r.chartManager.loadedChart.timingData.getMeasureLength(e-.001);r.chartManager.snapToNearestTick(Math.max(0,e-t))}},nextMeasure:{label:"Next measure",combos:[{key:"PageDown",mods:[]},{key:"'",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>{const e=r.chartManager.getBeat(),t=r.chartManager.loadedChart.timingData.getMeasureLength(e);r.chartManager.snapToNearestTick(Math.max(0,e+t))}},previousNote:{label:"Previous note",combos:[{key:",",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.previousNote()},nextNote:{label:"Next note",combos:[{key:".",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.nextNote()},jumpChartStart:{label:"Jump to first note",combos:[{key:"Home",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.firstNote()},jumpChartEnd:{label:"Jump to last note",combos:[{key:"End",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.lastNote()},jumpSongStart:{label:"Jump to song start",combos:[{key:"Home",mods:["Shift"]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.setBeat(Math.max(0,r.chartManager.loadedChart.getBeatFromSeconds(0)))},jumpSongEnd:{label:"Jump to song end",combos:[{key:"End",mods:["Shift"]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.setBeat(r.chartManager.loadedChart.getBeatFromSeconds(r.chartManager.chartAudio.getSongLength()))},assistTick:{label:"Assist tick",combos:[{key:"F7",mods:[]}],disabled:()=>!Ie.assist,callback:()=>{_.audio.assistTick=!_.audio.assistTick,Ce.create("Assist Tick: "+(_.audio.assistTick?"on":"off"))}},metronome:{label:"Metronome",combos:[{key:"F7",mods:["Alt"]}],disabled:()=>!Ie.assist,callback:()=>{_.audio.metronome=!_.audio.metronome,Ce.create("Metronome: "+(_.audio.metronome?"on":"off"))}},renderWaveform:{label:"Render waveform",combos:[],disabled:!1,callback:()=>{_.chart.waveform.enabled=!_.chart.waveform.enabled,Ce.create("Waveform: "+(_.chart.waveform.enabled?"on":"off"))}},waveformOptions:{label:"Waveform options...",bindLabel:"Waveform options",combos:[],disabled:!0,callback:()=>0},XMod:{label:"XMod (Beat-based)",combos:[{key:"X",mods:["Shift"]}],disabled:!1,callback:()=>{_.chart.CMod=!1,Ce.create("Switched to XMod")}},CMod:{label:"CMod (Time-based)",combos:[{key:"C",mods:["Shift"]}],disabled:!1,callback:()=>{_.chart.CMod=!0,Ce.create("Switched to CMod")}},hideWarpedArrows:{label:"Hide warped arrows (CMod only)",combos:[{key:"W",mods:["Shift"]}],disabled:!1,callback:()=>{_.chart.hideWarpedArrows=!_.chart.hideWarpedArrows,Ce.create("Hide Warped Arrows: "+(_.chart.hideWarpedArrows?"on":"off"))}},hideFakedArrows:{label:"Hide faked arrows (CMod only)",combos:[{key:"F",mods:["Shift"]}],disabled:!1,callback:()=>{_.chart.hideFakedArrows=!_.chart.hideFakedArrows,Ce.create("Hide Faked Arrows: "+(_.chart.hideFakedArrows?"on":"off"))}},doSpeedChanges:{label:"Do speed changes (XMod only)",combos:[{key:"S",mods:["Shift"]}],disabled:!1,callback:()=>{_.chart.doSpeedChanges=!_.chart.doSpeedChanges,Ce.create("Speed Changes: "+(_.chart.doSpeedChanges?"on":"off"))}},showEq:{label:"Equalizer",combos:[{key:"E",mods:["Shift"]}],disabled:r=>!r.chartManager.chartAudio||!Ie.openWindows,callback:r=>r.windowManager.openWindow(new iT(r))},syncAudio:{label:"Sync Audio",combos:[{key:"L",mods:["Shift"]}],disabled:r=>!r.chartManager.chartAudio||!Ie.openWindows,callback:r=>r.windowManager.openWindow(new AT(r))},previousNoteType:{label:"Previous note type",combos:[{key:"N",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.previousNoteType()},nextNoteType:{label:"Next note type",combos:[{key:"M",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.Record,callback:r=>r.chartManager.nextNoteType()},undo:{label:"Undo",combos:[{key:"Z",mods:[yt]}],disabled:r=>!r.actionHistory.canUndo()||r.chartManager.getMode()!=Y.Edit,callback:r=>r.actionHistory.undo()},redo:{label:"Redo",combos:[{key:"Y",mods:[yt]},{key:"Z",mods:[yt,"Shift"]}],disabled:r=>!r.actionHistory.canRedo()||r.chartManager.getMode()!=Y.Edit,callback:r=>r.actionHistory.redo()},mousePlacement:{label:"Enable Mouse Note Placement",combos:[{key:"M",mods:["Shift"]}],disabled:!1,callback:()=>{_.chart.mousePlacement=!_.chart.mousePlacement,Ce.create("Mouse Note Placement: "+(_.chart.mousePlacement?"on":"off"))}},playMode:{label:"Enter/Exit Play Mode",combos:[{key:"P",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Record||!Ie.playMode,callback:r=>r.chartManager.setMode(Y.Play)},recordMode:{label:"Enter/Exit Record Mode",combos:[{key:"R",mods:[]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.View||!Ie.recordMode,callback:r=>r.chartManager.setMode(Y.Record)},playModeStart:{label:"Play from start",combos:[{key:"P",mods:["Shift"]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Record||!Ie.playMode,callback:r=>{r.chartManager.setBeat(0),r.chartManager.setMode(Y.Play)}},recordModeStart:{label:"Record from start",combos:[{key:"R",mods:["Shift"]}],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()==Y.Play||r.chartManager.getMode()==Y.View||!Ie.recordMode,callback:r=>r.chartManager.setMode(Y.Record)},options:{label:"Options...",bindLabel:"Edit options",combos:[{key:",",mods:[yt]}],disabled:()=>!Ie.openWindows||!Ie.openWindows,callback:r=>{r.windowManager.openWindow(new xT(r))}},keybinds:{label:"Keybinds...",bindLabel:"Edit keybinds",combos:[],disabled:()=>!Ie.openWindows||!Ie.openWindows,callback:r=>{r.windowManager.openWindow(new Di(r))}},gameplayKeybinds:{label:"Gameplay keybinds...",bindLabel:"Edit gameplay keybinds",combos:[],disabled:()=>!Ie.openWindows||!Ie.openWindows,callback:r=>{r.windowManager.openWindow(new aT(r))}},convertHoldsRolls:{label:"Holds to rolls",bindLabel:"Convert holds to rolls",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.type=="Hold"&&(e.type="Roll"),e))}},convertRollsHolds:{label:"Rolls to holds",bindLabel:"Convert rolls to holds",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.type=="Roll"&&(e.type="Hold"),e))}},swapHoldsRolls:{label:"Swap holds and rolls",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.type=="Hold"?e.type="Roll":e.type=="Roll"&&(e.type="Hold"),e))}},convertHoldsTaps:{label:"Holds/rolls to taps",bindLabel:"Convert holds/rolls to taps",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>((e.type=="Hold"||e.type=="Roll")&&(e.type="Tap"),e))}},convertTapsMines:{label:"Taps to mines",bindLabel:"Convert ntapsotes to mines",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.type=="Tap"&&(e.type="Mine"),e))}},convertTapsLifts:{label:"Taps to lifts",bindLabel:"Convert taps to lifts",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.type=="Tap"&&(e.type="Lift"),e))}},convertTapsFakes:{label:"Taps to fakes",bindLabel:"Convert taps to fakes",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.type=="Tap"&&(e.type="Fake"),e))}},mirrorHorizontally:{label:"Horizontally",bindLabel:"Mirror horizontally",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.col=r.chartManager.loadedChart.gameType.flipColumns.horizontal[e.col],e))}},mirrorVertically:{label:"Vertically",bindLabel:"Mirror vertically",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.col=r.chartManager.loadedChart.gameType.flipColumns.vertical[e.col],e))}},mirrorBoth:{label:"Both",bindLabel:"Mirror both",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.col=r.chartManager.loadedChart.gameType.flipColumns.horizontal[e.col],e.col=r.chartManager.loadedChart.gameType.flipColumns.vertical[e.col],e))}},selectAll:{label:"Select all",combos:[{key:"A",mods:[yt]}],disabled:r=>!r.chartManager.loadedChart,callback:r=>{r.chartManager.editTimingMode==De.Off?r.chartManager.setNoteSelection(r.chartManager.loadedChart.getNotedata()):r.chartManager.setEventSelection(r.chartManager.loadedChart.timingData.getTimingData())}},expand2to1:{label:"Expand 2:1 (8th to 4th)",combos:[],disabled:r=>r.chartManager.selection.notes.length<2||r.chartManager.getMode()!=Y.Edit,callback:r=>{const e=Math.min(...r.chartManager.selection.notes.map(t=>t.beat));r.chartManager.modifySelection(t=>(t.beat=(t.beat-e)*2+e,t.beat=Math.round(t.beat*48)/48,Be(t)&&(t.hold*=2,t.hold=Math.round(t.hold*48)/48),t))}},expand3to2:{label:"Expand 3:2 (12th to 8th)",combos:[],disabled:r=>r.chartManager.selection.notes.length<2||r.chartManager.getMode()!=Y.Edit,callback:r=>{const e=Math.min(...r.chartManager.selection.notes.map(t=>t.beat));r.chartManager.modifySelection(t=>(t.beat=(t.beat-e)*1.5+e,t.beat=Math.round(t.beat*48)/48,Be(t)&&(t.hold*=1.5,t.hold=Math.round(t.hold*48)/48),t))}},expand4to3:{label:"Expand 4:3 (16th to 2th)",combos:[],disabled:r=>r.chartManager.selection.notes.length<2||r.chartManager.getMode()!=Y.Edit,callback:r=>{const e=Math.min(...r.chartManager.selection.notes.map(t=>t.beat));r.chartManager.modifySelection(t=>(t.beat=(t.beat-e)*4/3+e,t.beat=Math.round(t.beat*48)/48,Be(t)&&(t.hold*=4/3,t.hold=Math.round(t.hold*48)/48),t))}},compress1to2:{label:"Compress 1:2 (4th to 8th)",combos:[],disabled:r=>r.chartManager.selection.notes.length<2||r.chartManager.getMode()!=Y.Edit,callback:r=>{const e=Math.min(...r.chartManager.selection.notes.map(t=>t.beat));r.chartManager.modifySelection(t=>(t.beat=(t.beat-e)/2+e,t.beat=Math.round(t.beat*48)/48,Be(t)&&(t.hold/=2,t.hold=Math.round(t.hold*48)/48),t))}},compress2to3:{label:"Compress 2:3 (8th to 12th)",combos:[],disabled:r=>r.chartManager.selection.notes.length<2||r.chartManager.getMode()!=Y.Edit,callback:r=>{const e=Math.min(...r.chartManager.selection.notes.map(t=>t.beat));r.chartManager.modifySelection(t=>(t.beat=(t.beat-e)/1.5+e,t.beat=Math.round(t.beat*48)/48,Be(t)&&(t.hold/=1.5,t.hold=Math.round(t.hold*48)/48),t))}},compress3to4:{label:"Compress 3:4 (12th to 16th)",combos:[],disabled:r=>r.chartManager.selection.notes.length<2||r.chartManager.getMode()!=Y.Edit,callback:r=>{const e=Math.min(...r.chartManager.selection.notes.map(t=>t.beat));r.chartManager.modifySelection(t=>(t.beat=(t.beat-e)*.75+e,t.beat=Math.round(t.beat*48)/48,Be(t)&&(t.hold*=.75,t.hold=Math.round(t.hold*48)/48),t))}},quantize4th:{label:"4ths",bindLabel:"Quantize to 4ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,4),e.beat=Math.round(e.beat*48)/48,e))}},quantize8th:{label:"8ths",bindLabel:"Quantize to 8ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,8),e.beat=Math.round(e.beat*48)/48,e))}},quantize12th:{label:"12ths",bindLabel:"Quantize to 12ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,12),e.beat=Math.round(e.beat*48)/48,e))}},quantize16th:{label:"16ths",bindLabel:"Quantize to 16ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,16),e.beat=Math.round(e.beat*48)/48,e))}},quantize24th:{label:"24ths",bindLabel:"Quantize to 24ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,24),e.beat=Math.round(e.beat*48)/48,e))}},quantize32nd:{label:"32nds",bindLabel:"Quantize to 32nds",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,32),e.beat=Math.round(e.beat*48)/48,e))}},quantize48th:{label:"48ths",bindLabel:"Quantize to 48ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,48),e.beat=Math.round(e.beat*48)/48,e))}},quantize96th:{label:"96ths",bindLabel:"Quantize to 96ths",combos:[],disabled:r=>r.chartManager.selection.notes.length==0||r.chartManager.getMode()!=Y.Edit,callback:r=>{r.chartManager.modifySelection(e=>(e.beat=r.chartManager.getClosestTick(e.beat,96),e.beat=Math.round(e.beat*48)/48,e))}},delete:{label:"Delete",combos:[{key:"Backspace",mods:[]},{key:"Delete",mods:[]}],disabled:r=>r.chartManager.getMode()!=Y.Edit||r.chartManager.selection.notes.length==0&&r.chartManager.eventSelection.timingEvents.length==0,callback:r=>{r.chartManager.deleteSelection(),r.chartManager.deleteEventSelection()}},paste:{label:"Paste",combos:[],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()!=Y.Edit,callback:async r=>{const e=await navigator.clipboard.readText();r.chartManager.paste(e)}},copy:{label:"Copy",combos:[],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()!=Y.Edit||!r.chartManager.hasSelection(),callback:async r=>{const e=r.chartManager.copy();e&&await navigator.clipboard.writeText(e)}},cut:{label:"Cut",combos:[],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()!=Y.Edit||!r.chartManager.hasSelection(),callback:async r=>{const e=r.chartManager.copy();e&&await navigator.clipboard.writeText(e),r.chartManager.deleteSelection()}},adjustOffset:{label:"Adjust offset",combos:[],disabled:()=>!Ie.openWindows,callback:r=>r.windowManager.openWindow(new dT(r))},setSongPreview:{label:"Set as song preview",combos:[],disabled:r=>!r.chartManager.chartView||r.chartManager.getMode()!=Y.Edit||!r.chartManager.hasRange(),callback:r=>{const e=r.chartManager.loadedChart,t=r.chartManager.loadedSM.properties.SAMPLESTART??"0",i=r.chartManager.loadedSM.properties.SAMPLELENGTH??"10";let s="",n="";if(r.chartManager.startRegion!==void 0&&r.chartManager.endRegion!==void 0){const a=e.getSecondsFromBeat(r.chartManager.startRegion),o=e.getSecondsFromBeat(r.chartManager.endRegion);s=ne(a,3).toString(),n=ne(o-a,3).toString()}else{const o=(r.chartManager.selection.notes.length>0?r.chartManager.selection.notes:r.chartManager.eventSelection.timingEvents).map(u=>u.beat),l=e.getSecondsFromBeat(Math.min(...o)),c=e.getSecondsFromBeat(Math.max(...o));s=ne(l,3).toString(),n=ne(c-l,3).toString()}ht.instance.run({action:a=>{a.chartManager.loadedSM.properties.SAMPLESTART=s,a.chartManager.loadedSM.properties.SAMPLELENGTH=n},undo:()=>{r.chartManager.loadedSM.properties.SAMPLESTART=t,r.chartManager.loadedSM.properties.SAMPLELENGTH=i}})}},showDebugTimers:{label:"Toggle Debug Timers",combos:[{key:"F3",mods:["Shift"]}],disabled:!1,callback:()=>{_.debug.showTimers=!_.debug.showTimers}},showFPSCounter:{label:"Toggle FPS Counter",combos:[{key:"F3",mods:[]}],disabled:!1,callback:()=>{_.debug.showFPS=!_.debug.showFPS}},noteTypeTap:{label:"Switch to Taps",combos:[],disabled:r=>!r.chartManager.chartView,callback:r=>{r.chartManager.setEditingNoteType("Tap")}},noteTypeLift:{label:"Switch to Lifts",combos:[],disabled:r=>!r.chartManager.chartView,callback:r=>{r.chartManager.setEditingNoteType("Lift")}},noteTypeMine:{label:"Switch to Mines",combos:[],disabled:r=>!r.chartManager.chartView,callback:r=>{r.chartManager.setEditingNoteType("Mine")}},noteTypeFake:{label:"Switch to Fakes",combos:[],disabled:r=>!r.chartManager.chartView,callback:r=>{r.chartManager.setEditingNoteType("Fake")}},quant4:{label:"Switch to 4ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1}},quant8:{label:"Switch to 8ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/2}},quant12:{label:"Switch to 12ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/3}},quant16:{label:"Switch to 16ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/4}},quant24:{label:"Switch to 24ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/6}},quant32:{label:"Switch to 32ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/8}},quant48:{label:"Switch to 48ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/12}},quant96:{label:"Switch to 96ths",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/24}},quant192:{label:"Switch to 192nds",combos:[],disabled:r=>!r.chartManager.chartView,callback:()=>{_.chart.snap=1/48}}};class ET{static popup;static open(e,t){this.popup=this.build(e,t),document.getElementById("popups")?.appendChild(this.popup)}static build(e,t){const i=document.createElement("div");i.classList.add("update-popup");const s=document.createElement("div");s.classList.add("title"),s.innerText=`A new version of the desktop app is available! (${e})`;const n=document.createElement("div");return n.classList.add("desc"),n.innerText="Click here to download the new version.",i.replaceChildren(s,n),i.onclick=()=>{localStorage.setItem("downloadedVersion",e),nw.require("nw.gui").Shell.openExternal(t),this.close()},i}static close(){this.popup&&(this.popup.style.opacity="0",this.popup.onclick=null,setTimeout(()=>this.popup.remove(),300))}}class Nt extends o1{static graphics=new ma;static textures={default:mt.create({width:50,height:50}),noBorder:mt.create({width:50,height:50}),onlyBorder:mt.create({width:50,height:50})};static init(e){this.textures.default=mt.create({width:50,height:50,resolution:e.resolution}),this.textures.noBorder=mt.create({width:50,height:50,resolution:e.resolution}),this.textures.onlyBorder=mt.create({width:50,height:50,resolution:e.resolution}),this.graphics.beginFill(16777215,1),this.graphics.lineStyle(1,0),this.graphics.drawRoundedRect(0,0,50,50,5),this.graphics.endFill(),e.render(this.graphics,{renderTexture:this.textures.default}),this.graphics.clear(),this.graphics.beginFill(16777215,1),this.graphics.lineStyle(1,16777215),this.graphics.drawRoundedRect(0,0,50,50,5),this.graphics.endFill(),e.render(this.graphics,{renderTexture:this.textures.noBorder}),this.graphics.clear(),this.graphics.beginFill(16777215,0),this.graphics.lineStyle(2,16777215),this.graphics.drawRoundedRect(0,0,50,50,5),this.graphics.endFill(),e.render(this.graphics,{renderTexture:this.textures.onlyBorder})}constructor(e){super(Nt.textures[e??"default"],5,5,5,5)}}const jn=[];function jp(){return jn.length}function cC(){for(jn.push(Date.now());jn.length>0&&jn[0]0&&Yn[0]jp()+" FPS"});drawUpdateTimeGraph=new Dn({width:300,height:yi,color:6034982,min:0,unit:"ms",label:"DrawUpdate",precision:1});updateTimeGraph=new Dn({width:300,height:yi,color:1516101,min:0,unit:"ms",label:"Update",precision:1,sublabel:()=>Yp()+" TPS"});memoryTimeGraph=new Dn({width:300,height:yi,color:6626406,min:0,formatter:e=>Math.round(e/1048576)+" MB",label:"Memory"});cpuGraph=new Dn({width:300,height:yi,color:5190685,min:0,label:"CPU"});graphs=new xe;fpsCounter=new xe;fpsBg=new Nt;fpsText=new Fe("",{fontName:"Main",fontSize:12});lastFrameTime=0;constructor(e){super(e),this.drawUpdateTimeGraph.y+=yi+5,this.updateTimeGraph.y+=(yi+5)*2,this.memoryTimeGraph.y+=(yi+5)*3,this.cpuGraph.y+=(yi+5)*4,la.instance=this,this.fpsBg.tint=0,this.fpsBg.alpha=.5,this.fpsText.x=5,this.fpsBg.y=-5,this.graphs.addChild(this.frameTimeGraph,this.drawUpdateTimeGraph,this.updateTimeGraph),performance.memory&&this.graphs.addChild(this.memoryTimeGraph),this.fpsCounter.addChild(this.fpsBg,this.fpsText),this.graphs.visible=_.debug.showTimers,this.fpsCounter.visible=_.debug.showFPS,this.addChild(this.graphs,this.fpsCounter)}update(){this.x=-this.manager.app.renderer.screen.width/2+20,this.y=-this.manager.app.renderer.screen.height/2+20,this.graphs.children.forEach(e=>e.update()),this.graphs.visible=_.debug.showTimers,this.fpsCounter.visible=_.debug.showFPS,this.fpsText.text=`${jp()} FPS ${Yp()} TPS ${this.lastFrameTime.toFixed(2)} ms -`,this.fpsBg.width=this.fpsText.width+10,this.fpsBg.height=this.fpsText.height+10,_.debug.showTimers?(this.fpsBg.y=(yi+5)*this.graphs.children.length-5,this.fpsText.y=(yi+5)*this.graphs.children.length):(this.fpsBg.y=-5,this.fpsText.y=0)}addMemoryTimeValue(e){this.memoryTimeGraph.addValue(e)}addFrameTimeValue(e){this.lastFrameTime=e,this.frameTimeGraph.addValue(e)}addUpdateTimeValue(e){this.updateTimeGraph.addValue(e)}addDrawUpdateTimeValue(e){this.drawUpdateTimeGraph.addValue(e)}}class Dn extends xe{graphWidth;graphHeight;color;unit;precision;formatter;sublabel;maxEase=1;targetMax=1;minEase=1;targetMin=1;constrainedMin=null;constrainedMax=null;dataPoints=[];linePool=[];lineContainer;labelText;sublabelText;topText;bottomText;constructor(e){super();const{width:t,height:i,color:s=16777215,unit:n="",label:a="",min:o=null,max:l=null,precision:c=0,formatter:u=null,sublabel:h=()=>""}=e;this.graphWidth=t,this.graphHeight=i,this.color=s,this.unit=n,this.constrainedMax=l,this.constrainedMin=o,this.precision=c,this.formatter=u,this.sublabel=h,this.lineContainer=new Kc(t,{position:!0},16384,!0);const d=new Nt;d.tint=0,d.alpha=.3,d.width=this.graphWidth,d.height=this.graphHeight,this.labelText=new Fe(a,{fontName:"Main",fontSize:Math.min(i/5,16)}),this.labelText.alpha=.8,this.sublabelText=new Fe("",{fontName:"Main",fontSize:Math.min(i/5,16)}),this.topText=new Fe("",{fontName:"Main",fontSize:Math.min(i/7,12)}),this.topText.anchor.x=1,this.topText.alpha=.5,this.topText.x=this.graphWidth,this.bottomText=new Fe("",{fontName:"Main",fontSize:Math.min(i/7,12)}),this.bottomText.anchor.x=1,this.bottomText.anchor.y=1,this.bottomText.alpha=.5,this.bottomText.x=this.graphWidth,this.bottomText.y=this.graphHeight,this.sublabelText.y=this.graphHeight,this.sublabelText.anchor.y=1,this.sublabelText.alpha=.5,this.addChild(d,this.lineContainer,this.labelText,this.sublabelText,this.topText,this.bottomText)}addValue(e){if(this.lineContainer.children[0]?.x+this.lineContainer.x<0){const i=this.lineContainer.children[0];this.dataPoints.shift(),this.removeChild(i),this.linePool.push(i)}this.lineContainer.x-=1,this.lineContainer.x<-1e7&&(this.lineContainer.children.forEach(i=>{i.x-=1e7}),this.lineContainer.x+=1e7);const t=this.linePool.shift()??new ke(Z.WHITE);t.width=1,t.anchor.x=.5,t.anchor.y=1,t.tint=this.color,t.alpha=.6,t.x=this.graphWidth-this.lineContainer.x,t.y=this.graphHeight,t.value=e,this.dataPoints.push(e),this.targetMax=this.constrainedMax!==null?this.constrainedMax:Math.max(...this.dataPoints),this.targetMin=this.constrainedMin!==null?this.constrainedMin:Math.min(...this.dataPoints),this.lineContainer.addChild(t)}update(){this.dataPoints.length!=0&&(this.maxEase=(this.maxEase-this.targetMax)*.1+this.targetMax,this.minEase=(this.minEase-this.targetMin)*.1+this.targetMin,this.lineContainer.children.forEach(e=>{e.height=Ve((e.value-this.minEase)/this.maxEase,0,1)*this.graphHeight}),this.topText.text=this.formatter?.(this.maxEase)??`${ne(this.maxEase,this.precision)} ${this.unit}`,this.bottomText.text=this.formatter?.(this.minEase)??`${ne(this.minEase,this.precision)} ${this.unit}`,this.sublabelText.text=this.sublabel())}}class bh{static active=!1;static persistent=!1;static popup;static clickOutside;static onSnapChange=this.updateValues.bind(this);static moveInterval;static updateInterval;static editText;static zoomer;static divInput;static divLabel;static beatInput;static open(e){this.active||(this.popup=this.build(),document.getElementById("popups")?.appendChild(this.popup),this.clickOutside=t=>{this.popup?.contains(t.target)||(this.persistent=!1,this.close())},$.on("snapChanged",this.onSnapChange),this.popup.style.display="none",setTimeout(()=>this.movePosition(e)),this.moveInterval=setInterval(()=>this.movePosition(e),150),this.active=!0)}static movePosition(e){this.popup.style.display="";const t=e.getBounds(),i=t.left+t.width/2,s=200,n=s/2+15,a=window.innerWidth-s/2-15;this.popup.style.left=`${Ve(i,n,a)}px`;const o=(t.top+t.height+35)/2;this.popup.style.top=`${t.top+t.height+35}px`,o+this.popup.clientHeight>window.innerHeight-15&&(this.popup.style.transform="translate(-50%, -100%)",this.popup.style.top=`${t.top-t.height/2}px`)}static build(){const e=document.createElement("div");e.classList.add("popup");const t=document.createElement("div");t.classList.add("popup-zoomer"),t.style.width="200px",t.style.backgroundColor="#333333",e.appendChild(t),this.zoomer=t;const i=document.createElement("div");i.innerText="Snap Options",i.classList.add("popup-title"),t.appendChild(i);const s=document.createElement("div");s.classList.add("popup-flex"),t.appendChild(s);const n=document.createElement("div");n.classList.add("popup-row");const a=document.createElement("div");a.innerText="Snap to nearest ";const o=Ze.create(_.chart.snap==0?0:Math.round(4/_.chart.snap),1,0,0,1e3);o.onChange=f=>{if(f===void 0){this.updateValues();return}f==0?_.chart.snap=0:_.chart.snap=4/f,this.updateValues()};const l=document.createElement("div");l.innerText=this.suffixSnap()+" note",n.replaceChildren(a,o.view,l);const c=document.createElement("div");c.classList.add("popup-row");const u=document.createElement("div");u.innerText="Snap every";const h=Ze.create(_.chart.snap,.001,3,0);h.onChange=f=>{if(f===void 0){this.updateValues();return}f==0?_.chart.snap=0:_.chart.snap=f,this.updateValues()};const d=document.createElement("div");d.innerText=" beats",c.replaceChildren(u,h.view,d),s.replaceChildren(n,c),this.beatInput=h,this.divInput=o,this.divLabel=l;const p=document.createElement("div");return p.innerText="click to edit",p.style.marginTop="4px",p.style.height="10px",t.appendChild(p),p.classList.add("popup-desc"),this.editText=p,e}static updateValues(){document.activeElement==this.divInput.input||document.activeElement==this.beatInput.input||(this.divInput.setValue(_.chart.snap==0?0:Math.round(4/_.chart.snap)),this.divLabel.innerText=this.suffixSnap()+" note",this.beatInput.setValue(_.chart.snap))}static suffixSnap(){const e=_.chart.snap==0?0:Math.round(4/_.chart.snap);return e%10==1&&e!=11?"st":e%10==2&&e!=12?"nd":e%10==3&&e!=13?"rd":"th"}static close(){if(!this.popup||!this.active||this.persistent)return;window.removeEventListener("click",this.clickOutside,!0),this.popup.classList.add("exiting");const e=this.popup;setTimeout(()=>e.remove(),200),this.active=!1,this.persistent=!1,clearInterval(this.moveInterval),clearInterval(this.updateInterval),$.off("timingModified",this.onSnapChange)}static select(){this.persistent=!0,this.zoomer.classList.add("selected"),this.editText.style.transform="scale(0)",this.editText.style.height="0px",setTimeout(()=>window.addEventListener("click",this.clickOutside,!0),200)}}const ST={fontName:"Main",fontSize:10,fill:["#ffffff"]},Bg={4:15157287,8:4033015,12:11152884,16:8577607,24:14167723,32:15376696,48:15699179,64:7071886,96:8553090,192:8553090};class CT extends xe{renderer;children=[];constructor(e){super(),this.renderer=e;for(let t=0;t<2;t++){const i=new xe,s=new ma,n=new Fe("4",ST);i.x=(t-.5)*(this.renderer.chart.gameType.notefieldWidth+48),s.rotation=Math.PI/4,s.lineStyle(1,0,1),s.beginFill(16777215),s.drawRect(-12,-12,24,24),s.endFill(),n.anchor.set(.5),i.addChild(s,n),this.addChild(i),i.eventMode="static",i.on("mouseenter",()=>bh.open(s)),i.on("mousedown",()=>bh.select()),i.on("mouseleave",()=>bh.close())}}update(){this.y=this.renderer.getActualReceptorYPos(),this.visible=this.renderer.chartManager.getMode()!=Y.Play;for(let e=0;e<2;e++){const t=this.children[e],i=t.children[0];i.tint=Bg[4/_.chart.snap]??7368816;const s=t.children[1];s.text=""+(_.chart.snap==0||4/_.chart.snap%1!=0?"":4/_.chart.snap)}}}class MT extends gl{barContainer=new Kc(1500,{position:!0,scale:!0,tint:!0},16384,!0);backing=new Nt;bars;barTexture;overlay=new ke(Z.WHITE);lastHeight=0;lastCMod;mouseDown=!1;queued=!1;constructor(e){super(e),this.addChild(this.backing),this.visible=!1,this.backing.tint=0,this.backing.alpha=.3,this.barTexture=mt.create({resolution:this.manager.app.renderer.resolution}),this.bars=new ke(this.barTexture),this.bars.anchor.set(.5),this.addChild(this.bars),this.overlay.anchor.x=.5,this.overlay.anchor.y=0,this.overlay.alpha=.3,this.lastCMod=_.chart.CMod,this.addChild(this.overlay),this.x=this.manager.app.renderer.screen.width/2-20,$.on("chartLoaded",()=>{this.queued=!1,this.populate()}),$.on("chartModifiedAfter",()=>{this.queued||this.populate(),this.queued=!0});const t=setInterval(()=>{this.queued&&(this.queued=!1,this.populate())},3e3);this.on("destroyed",()=>clearInterval(t)),this.populate(),this.eventMode="static",this.on("mousedown",i=>{this.mouseDown=!0,this.handleMouse(i)}),this.on("mousemove",i=>{this.mouseDown&&this.handleMouse(i)}),window.onmouseup=()=>{this.mouseDown=!1}}handleMouse(e){if(this.manager.chartManager.getMode()==Y.Play||!this.getChart())return;let t=(this.bars.toLocal(e.global).y+this.bars.height/2)/this.bars.height;t=Ve(t,0,1);const i=this.getChart().getNotedata().at(-1);if(!i)return;const s=i.beat+(Be(i)?i.hold:0),n=this.getChart().getSecondsFromBeat(s);_.chart.CMod?this.manager.chartManager.setTime(sr(-this.getChart().timingData.getOffset(),n,t)):this.manager.chartManager.setBeat(s*t)}update(){this.scale.y=_.chart.reverse?-1:1;const e=this.manager.app.renderer.screen.height-40;this.backing.height=e+10,this.backing.position.y=-this.backing.height/2,this.backing.position.x=-this.backing.width/2,this.bars.height=e,this.x=this.manager.app.renderer.screen.width/2-20;const t=this.getChart(),i=this.manager.chartManager.chartView;if(!t||!i||!Ie.layout){this.visible=!1;return}this.visible=!0;const s=t.getNotedata().at(-1);if(!s){this.overlay.height=0;return}const n=s.beat+(Be(s)?s.hold:0),a=t.getSecondsFromBeat(n),o=_.chart.CMod?i.getSecondFromYPos(-this.manager.app.renderer.screen.height/2):i.getBeatFromYPos(-this.manager.app.renderer.screen.height/2,!0),l=_.chart.CMod?i.getSecondFromYPos(this.manager.app.renderer.screen.height/2):i.getBeatFromYPos(this.manager.app.renderer.screen.height/2,!0);let c=Ai(0,n,o),u=Ai(0,n,l);_.chart.CMod&&(c=Ai(-t.timingData.getOffset(),a,o),u=Ai(-t.timingData.getOffset(),a,l)),c=Ve(c,0,1),u=Ve(u,0,1),c>u&&([c,u]=[u,c]);const h=(c-.5)*(this.backing.height-10),d=(u-.5)*(this.backing.height-10);this.overlay.y=h,this.overlay.height=d-h,this.overlay.height=Math.max(2,this.overlay.height),(this.manager.app.renderer.screen.height!=this.lastHeight||this.lastCMod!=_.chart.CMod)&&(this.lastCMod=_.chart.CMod,this.lastHeight=this.manager.app.renderer.screen.height,this.populate())}populate(){const e=this.getChart();if(!e){Wi(this.barContainer.children,()=>!0),this.manager.app.renderer.render(this.barContainer,{renderTexture:this.barTexture});return}let t=0;const i=e.gameType.numCols,s=e.getNotedata().at(-1),n=this.manager.app.renderer.screen.height-40;if(this.backing.height=n,this.backing.width=i*6+8,this.overlay.width=i*6+8,this.pivot.x=this.backing.width/2,this.barTexture.resize(i*6,n),!s){Wi(this.barContainer.children,()=>!0),this.manager.app.renderer.render(this.barContainer,{renderTexture:this.barTexture});return}const a=s.beat+(Be(s)?s.hold:0),o=e.getSecondsFromBeat(a),l=e.timingData.getOffset();e.getNotedata().forEach(c=>{let u=this.barContainer.children[t];u||(u=new ke(Z.WHITE),u.width=4,this.barContainer.addChild(u)),u.anchor.set(.5),u.height=1,u.x=(c.col+.5)*6;let h=Ai(0,a,c.beat);if(_.chart.CMod&&(h=Ai(l,o,c.second)),u.y=h*n,u.tint=Bg[Wo(c.beat)],c.type=="Mine"&&(u.tint=8421504),t++,Be(c)){let d=this.barContainer.children[t];d||(d=new ke(Z.WHITE),d.width=4,d.height=2,this.barContainer.addChild(d)),d.anchor.x=.5,d.anchor.y=0,d.x=(c.col+.5)*6;const p=(_.chart.CMod?e.getSecondsFromBeat(c.beat+c.hold)/o:(c.beat+c.hold)/a)*n+1;d.y=u.y,d.height=p-u.y,c.type=="Hold"&&(d.tint=10526880),c.type=="Roll"&&(d.tint=11379586),t++}}),Wi(this.barContainer.children,(c,u)=>u>=t),this.manager.app.renderer.render(this.barContainer,{renderTexture:this.barTexture})}getChart(){return this.manager.chartManager.loadedChart}}const Ye=300,it=150,Xp=[.045,.09,.18,.37,.18,.09,.045];class IT extends gl{max=0;barlines=new xe;backgroundRect=new Nt;background=new xe;backgroundLines=new xe;statText=new xe;meanText;medianText;modeText;stddevText;errorMS=[];texts=new xe;showEase=0;toggled=!1;drag=!1;dragStart=0;lastMode=this.manager.chartManager.getMode();constructor(e){super(e),this.visible=!1,this.backgroundRect.tint=0,this.backgroundRect.alpha=.3,this.background.addChild(this.backgroundRect),this.addChild(this.background),this.addChild(this.backgroundLines),this.eventMode="static",this.on("mousedown",()=>{this.manager.chartManager.getMode()!=Y.Play&&(this.drag=!0,this.dragStart=Date.now(),It.stop("play-widget"))}),window.addEventListener("mousemove",f=>{this.drag&&(this.showEase+=f.movementY/-400)}),window.addEventListener("mouseup",()=>{this.drag&&(Date.now()-this.dragStart>400?this.toggled=this.showEase>.5:this.toggled=!this.toggled,It.animate(this,{0:{showEase:"inherit"},1:{showEase:this.toggled?1:0}},.6,Yt(.11,.71,.33,1.39),()=>{},"play-widget")),this.drag=!1}),this.on("mouseenter",()=>{!this.toggled&&this.manager.chartManager.getMode()!=Y.Play&&It.animate(this,{0:{showEase:"inherit"},1:{showEase:.05}},.6,Yt(.11,.71,.33,1.39),()=>{},"play-widget")}),this.on("mouseleave",()=>{!this.toggled&&this.manager.chartManager.getMode()!=Y.Play&&It.animate(this,{0:{showEase:"inherit"},1:{showEase:0}},.6,Yt(.11,.71,.33,1.39),()=>{},"play-widget")});const t=new Fe("Early",{fontName:"Main",fontSize:15});t.x=-Ye/2+5,t.y=-it-40,t.alpha=.3,this.background.addChild(t);const i=new Fe("Late",{fontName:"Main",fontSize:15});i.anchor.x=1,i.x=Ye/2-5,i.y=-it-40,i.alpha=.3,this.background.addChild(i),this.meanText=new Fe("-",{fontName:"Main",fontSize:15}),this.meanText.anchor.x=.5,this.meanText.x=Ye/4*-1.5,this.meanText.y=-it-70,this.statText.addChild(this.meanText),this.medianText=new Fe("-",{fontName:"Main",fontSize:15}),this.medianText.anchor.x=.5,this.medianText.x=Ye/4*-.5,this.medianText.y=-it-70,this.statText.addChild(this.medianText),this.modeText=new Fe("-",{fontName:"Main",fontSize:15}),this.modeText.anchor.x=.5,this.modeText.x=Ye/4*.5,this.modeText.y=-it-70,this.statText.addChild(this.modeText),this.stddevText=new Fe("-",{fontName:"Main",fontSize:15}),this.stddevText.anchor.x=.5,this.stddevText.x=Ye/4*1.5,this.stddevText.y=-it-70,this.statText.addChild(this.stddevText);const s=new Fe("Mean",{fontName:"Main",fontSize:10});s.anchor.x=.5,s.x=Ye/4*-1.5,s.y=-it-80,this.statText.addChild(s);const n=new Fe("Median",{fontName:"Main",fontSize:10});n.anchor.x=.5,n.x=Ye/4*-.5,n.y=-it-80,this.statText.addChild(n);const a=new Fe("Mode",{fontName:"Main",fontSize:10});a.anchor.x=.5,a.x=Ye/4*.5,a.y=-it-80,this.statText.addChild(a);const o=new Fe("Std Dev.",{fontName:"Main",fontSize:10});o.anchor.x=.5,o.x=Ye/4*1.5,o.y=-it-80,this.statText.addChild(o);const l=new xe,c=new Nt;c.tint=3355443,c.alpha=.3,c.width=Ye/2-10,c.height=30,c.y=-25,c.x=-Ye/4,c.pivot.x=(Ye/2-10)/2,c.pivot.y=15;const u=new Fe("Adjust song offset",{fontName:"Main",fontSize:12});u.anchor.set(.5),u.x=-Ye/4,u.y=-25,l.addChild(c,u),l.eventMode="static",l.addEventListener("mouseenter",()=>{c.alpha=.6}),l.addEventListener("mousedown",f=>{f.stopImmediatePropagation(),this.adjustOffset("song")}),l.addEventListener("mouseleave",()=>{c.alpha=.3}),this.statText.addChild(l);const h=new xe,d=new Nt;d.tint=3355443,d.alpha=.3,d.width=Ye/2-10,d.height=30,d.y=-25,d.x=Ye/4,d.pivot.x=(Ye/2-10)/2,d.pivot.y=15,d.eventMode="static",h.addEventListener("mouseenter",()=>{d.alpha=.6}),h.addEventListener("mouseleave",()=>{d.alpha=.3});const p=new Fe("Adjust global offset",{fontName:"Main",fontSize:12});p.anchor.set(.5),p.x=Ye/4,p.y=-25,h.addChild(d,p),h.eventMode="static",h.addEventListener("mouseenter",()=>{d.alpha=.6}),h.addEventListener("mousedown",f=>{f.stopImmediatePropagation(),this.adjustOffset("global")}),h.addEventListener("mouseleave",()=>{d.alpha=.3}),this.statText.addChild(h),this.addChild(this.background),this.addChild(this.backgroundLines),this.eventMode="static",this.addChild(this.statText),this.addChild(this.barlines),this.addChild(this.texts)}update(){this.visible=!!this.manager.chartManager.gameStats,this.x=-this.manager.chartManager.app.renderer.screen.width/2+20+Ye/2,this.y=this.manager.chartManager.app.renderer.screen.height/2-20,this.backgroundRect.width=Ye+10,this.backgroundRect.height=it+260,this.backgroundRect.x=-Ye/2-5,this.backgroundRect.y=-it-260,this.visible=!!this.manager.chartManager.gameStats;for(const e of this.barlines.children)_.general.smoothAnimations?e.height=(e.targetHeight-e.height)*.2+e.height:e.height=e.targetHeight;this.lastMode!=this.manager.chartManager.getMode()&&(this.lastMode=this.manager.chartManager.getMode(),It.animate(this,{0:{showEase:"inherit"},1:{showEase:this.manager.chartManager.getMode()==Y.Play?1:0}},.6,Yt(.11,.71,.33,1.39),()=>{},"play-widget")),_.general.smoothAnimations?this.y+=(1-Math.abs(this.showEase))*400:this.manager.chartManager.getMode()!=Y.Play&&(this.y+=400)}newLine(){const e=new ke(Z.WHITE);return e.smoothCount=0,e.targetHeight=0,e.anchor.y=1,e.anchor.x=.5,e.height=0,e.visible=!1,e}startPlay(){const e=this.manager.chartManager.gameStats;this.max=0,this.errorMS=[],this.meanText.text="-",this.medianText.text="-",this.modeText.text="-",this.stddevText.text="-",Wi(this.barlines.children,()=>!0),Wi(this.backgroundLines.children,()=>!0),Wi(this.texts.children,()=>!0);const t=qe.getCollection(_.play.timingCollection),i=t.getStandardWindows().length+1,s=Math.round(t.maxWindowMS());for(let p=0;py.type==f&&!y.fake).length),m.tint=14540253,g.tint=14540253,g.name=f,this.texts.addChild(m),this.texts.addChild(g),m.x=-Ye/2+160,g.x=-Ye/2+290,m.y=80/o*n-it-220,g.y=80/o*n++-it-220,m.anchor.y=.5,g.anchor.y=.5,g.anchor.x=1}const l=new Fe("Max Combo",{fontName:"Main",fontSize:15}),c=new Fe("0",{fontName:"Main",fontSize:15});l.tint=14540253,c.tint=14540253,c.name="Combo",this.texts.addChild(l),this.texts.addChild(c),l.x=-Ye/2+160,c.x=-Ye/2+290,l.y=80/o*n-it-220,c.y=80/o*n++-it-220,l.anchor.y=.5,c.anchor.y=.5,c.anchor.x=1;const u=new Fe("0.00 / 0.00",{fontName:"Main",fontSize:20});u.tint=14540253,u.x=-Ye/2+225,u.y=-it-112,u.name="Score",this.texts.addChild(u),u.anchor.set(.5);const h=new Fe("Score / Current Score",{fontName:"Main",fontSize:13});h.tint=8947848,h.x=-Ye/2+225,h.y=-it-135,this.texts.addChild(h),h.anchor.set(.5);const d=new Fe("Play Statistics",{fontName:"Main",fontSize:13});d.y=-it-245,d.anchor.set(.5),this.texts.addChild(d),e.onJudge((p,f)=>{let m="";(ni(f)||Vi(f))&&(m=f.id),Rr(f)&&(m=f.noteType),ms(f)&&(m="Mine");const g=this.texts.getChildByName(m);if(Rr(f)){const b=g.text.split(" / ")[1];g.text=e.getCount(f)+" / "+b}else yn(f)||(g.text=e.getCount(f)+"");if(this.texts.getChildByName("Combo").text=e.getMaxCombo()+"",this.texts.getChildByName("Score").text=ne(e.getScore()*100,2).toFixed(2)+" / "+ne(e.getCumulativeScore()*100,2).toFixed(2),ni(f)||!Vi(f))return;const y=Math.round(p*1e3);for(let b=-3;b<=3;b++)this.barlines.children[y+s+b]&&(this.barlines.children[y+s+b].smoothCount+=Xp[b+3],this.barlines.children[y+s+b].visible=!0,this.barlines.children[y+s+b].smoothCount>this.max&&(this.modeText.text=y+"ms",this.max=this.barlines.children[y+s+b].smoothCount));this.errorMS.push(p*1e3),this.meanText.text=AE(this.errorMS).toFixed(2)+"ms",this.medianText.text=fl(this.errorMS).toFixed(2)+"ms",this.stddevText.text=ug(this.errorMS).toFixed(2)+"ms",this.redraw()})}redraw(){for(const e of this.barlines.children)e.targetHeight=e.smoothCount*(it-20)/this.max}adjustOffset(e){const t=this.manager.chartManager.gameStats;if(!t)return;const i=Math.round(t.getMedian()*1e3)/1e3;if(i==0)return;t.applyOffset(-i),this.barlines.children.forEach(o=>{o.smoothCount=0});const s=qe.getCollection(_.play.timingCollection),n=Math.round(s.maxWindowMS());t.getDataPoints().forEach(o=>{if(ni(o.judgment)||!Vi(o.judgment))return;const l=Math.round(o.error*1e3);for(let c=-3;c<=3;c++)this.barlines.children[l+n+c]&&(this.barlines.children[l+n+c].smoothCount+=Xp[c+3],this.barlines.children[l+n+c].visible=!0,this.barlines.children[l+n+c].smoothCount>this.max&&(this.modeText.text=l+"ms",this.max=this.barlines.children[l+n+c].smoothCount))}),this.redraw();const a=e=="global"?_.play.offset:this.manager.app.chartManager.loadedChart.timingData.getOffset();if(e=="global")_.play.offset=ne(_.play.offset-i,3);else if(e=="song"){const o=this.manager.app.chartManager.loadedChart.timingData.hasChartOffset()?this.manager.app.chartManager.loadedChart.timingData:this.manager.app.chartManager.loadedSM.timingData;o.setOffset(ne(o.getOffset()-i,3))}Ce.create(`Adjusted ${e} offset from ${ne(a,3).toFixed(3)} to ${ne(a-i,3).toFixed(3)}`),this.manager.app.chartManager.setBeat(this.manager.app.chartManager.getBeat())}}class ha extends xe{pool=[];options;constructor(e){super(),this.options=e}createChild(){if(this.pool.length==0&&this.options.maxPoolSize!==void 0&&this.children.length>=this.options.maxPoolSize)return;const e=this.pool.pop()??this.options.create();return this.addChild(e),e._disabledTime=Date.now(),e}destroyChild(e){this.children.includes(e)&&(e.removeFromParent(),e.removeAllListeners(),e.eventMode="auto",e._disabledTime=Date.now(),this.pool.push(e))}destroyAll(){this.children.forEach(e=>e._disabledTime=Date.now()),this.pool.push(...this.children),this.children.forEach(e=>{e.removeAllListeners(),e.eventMode="auto"}),this.removeChildren()}_render(e){super._render(e);const t=Date.now();for(;t-this.pool[0]?._disabledTime>(this.options.destroyTimer??5e3);)this.pool.shift().destroy()}}const Lr={BPMS:9182254,STOPS:4934913,DELAYS:217453,WARPS:9243998,FAKES:4868682,COMBOS:939078,SPEEDS:2968693,LABELS:7747359,SCROLLS:3557006,TIMESIGNATURES:5392684,TICKCOUNTS:1594906,BGCHANGES:8460415,FGCHANGES:8857115,ATTACKS:1856083};class kT extends xe{renderer;areaPool=new ha({create:()=>{const e=new ke(Z.WHITE);return Object.assign(e,{alpha:.2,width:this.renderer.chart.gameType.notefieldWidth+128}),e.anchor.set(.5,0),e}});timingAreaMap=new Map;timingEvents=[];timingDirty=!0;constructor(e){super(),this.renderer=e,this.addChild(this.areaPool);const t=()=>this.timingDirty=!0;$.on("timingModified",t),this.on("destroyed",()=>$.off("timingModified",t))}update(e,t){this.timingDirty&&(this.timingAreaMap.clear(),this.areaPool.destroyAll(),this.timingDirty=!1,this.timingEvents=this.renderer.chart.timingData.getTimingData("STOPS","WARPS","DELAYS","FAKES")),this.visible=this.renderer.shouldDisplayBarlines();for(const i of this.timingEvents){if(i.beat>t)break;if(this.shouldDrawEvent(i,e,t)&&!this.timingAreaMap.has(i)){const s=this.areaPool.createChild();if(!s)break;s.tint=Lr[i.type],this.timingAreaMap.set(i,s)}}for(const[i,s]of this.timingAreaMap.entries()){if(!this.shouldDrawEvent(i,e,t)){this.timingAreaMap.delete(i),this.areaPool.destroyChild(s);continue}let n=_.chart.CMod?this.renderer.getYPosFromSecond(i.second):this.renderer.getYPosFromBeat(i.beat),a=n;switch(i.type){case"STOPS":case"DELAYS":{_.chart.CMod&&i.value>0?a=this.renderer.getYPosFromSecond(i.second+i.value):i.value<0&&(a=this.renderer.getYPosFromBeat(this.renderer.chart.getBeatFromSeconds(i.second+1e-4)));break}case"FAKES":{a=this.renderer.getYPosFromBeat(i.beat+i.value);break}case"WARPS":{_.chart.CMod||(a=this.renderer.getYPosFromBeat(i.beat+i.value));break}}a0)||e.type=="WARPS"&&_.chart.CMod?!1:e.beat<=i}}function Ur(r,e,t){return(r<<16)+(e<<8)+t}function Pg(r,e){let t=r>>16,i=r>>8&255,s=r&255;return t=Ve(t*e,0,255),i=Ve(i*e,0,255),s=Ve(s*e,0,255),Ur(t,i,s)}function Cc(r,e,t){const[i,s,n]=r.match(/\w\w/g).map(d=>parseInt(d,16)),[a,o,l]=e.match(/\w\w/g).map(d=>parseInt(d,16)),c=Math.round(i+(a-i)*t).toString(16).padStart(2,"0"),u=Math.round(s+(o-s)*t).toString(16).padStart(2,"0"),h=Math.round(n+(l-n)*t).toString(16).padStart(2,"0");return"#"+c+u+h}class Ah{static active=!1;static popup;static clickOutside;static moveInterval;static exitTimeout;static draggedElement;static dragOffsetX=0;static dragOffsetY=0;static grid;static leftovers;static boundaryCache=[];static open(){this.active||(this.popup=this.build(),document.getElementById("popups")?.appendChild(this.popup),this.clickOutside=e=>{!this.popup?.contains(e.target)&&!this.draggedElement?.contains(e.target)&&!document.getElementById("arrange-tracks")?.contains(e.target)&&this.close()},setTimeout(()=>window.addEventListener("click",this.clickOutside,!0)),this.popup.style.display="none",setTimeout(()=>this.movePosition()),clearTimeout(this.exitTimeout),this.moveInterval=setInterval(()=>this.movePosition(),150),this.active=!0)}static build(){const e=document.createElement("div");e.classList.add("popup"),e.id="timing-track-order";const t=document.createElement("div");t.classList.add("popup-zoomer"),e.appendChild(t);const i=document.createElement("div");i.classList.add("container"),t.appendChild(i);const s=document.createElement("div");s.classList.add("title"),s.innerText="Arrange Timing Tracks";const n=document.createElement("div");n.classList.add("track-grid-options");const a=document.createElement("button");a.classList.add("delete"),a.innerText="Reset",a.onclick=()=>{_.chart.timingEventOrder=structuredClone(Ho.chart.timingEventOrder),this.clearBoundaries(),this.grid?.replaceChildren(),this.leftovers?.replaceChildren();const c=[...Dr];for(const h of _.chart.timingEventOrder.left){const d=this.makeDraggableTrack(h);d.classList.add("left"),this.grid?.appendChild(d),c.splice(c.indexOf(h),1)}const u=document.createElement("div");u.classList.add("draggable-track"),u.innerText="PLAYFIELD",u.style.backgroundColor="#2D2D2D",u.style.padding="20px 10px",u.style.writingMode="horizontal-tb",u.addEventListener("mousedown",h=>this.startDragging(h,u)),u.dataset.type="PLAYFIELD",this.grid?.appendChild(u);for(const h of _.chart.timingEventOrder.right){const d=this.makeDraggableTrack(h);d.classList.add("right"),this.grid?.appendChild(d),c.splice(c.indexOf(h),1)}for(const h of c)this.leftovers?.appendChild(this.makeLeftoverTrack(h))},this.grid=document.createElement("div"),this.grid.classList.add("track-grid"),i.appendChild(s),i.appendChild(this.grid),i.appendChild(n);const o=[...Dr];for(const c of _.chart.timingEventOrder.left){const u=this.makeDraggableTrack(c);u.classList.add("left"),this.grid.appendChild(u),o.splice(o.indexOf(c),1)}const l=document.createElement("div");l.classList.add("draggable-track"),l.innerText="PLAYFIELD",l.style.backgroundColor="#2D2D2D",l.style.padding="20px 10px",l.style.writingMode="horizontal-tb",l.addEventListener("mousedown",c=>this.startDragging(c,l)),l.dataset.type="PLAYFIELD",this.grid.appendChild(l);for(const c of _.chart.timingEventOrder.right){const u=this.makeDraggableTrack(c);u.classList.add("right"),this.grid.appendChild(u),o.splice(o.indexOf(c),1)}this.leftovers=document.createElement("div"),this.leftovers.classList.add("track-selector"),n.appendChild(this.leftovers),n.appendChild(a);for(const c of o)this.leftovers.appendChild(this.makeLeftoverTrack(c));return e}static makeDraggableTrack(e){const t=document.createElement("div");t.classList.add("draggable-track");const i=document.createElement("div");i.classList.add("draggable-track-text"),i.innerText=e,t.style.backgroundColor=Cc(Lr[e].toString(16).padStart(6,"0"),"#333333",.7),t.appendChild(i);let s=!0;const n=document.createElement("img");return n.src=He.TRASH,n.style.width="16px",n.addEventListener("click",()=>{if(!s)return;s=!1,this.deleteTrack(e),t.classList.add("exiting"),setTimeout(()=>t.remove(),400);const a=this.makeLeftoverTrack(e);a.classList.add("entering"),setTimeout(()=>a.classList.remove("entering"),400),this.leftovers?.appendChild(a),this.clearBoundaries()}),t.appendChild(n),t.addEventListener("mousedown",a=>{s&&a.target!=n&&this.startDragging(a,t)}),t.dataset.type=e,t}static makeLeftoverTrack(e){const t=document.createElement("div");t.classList.add("leftover-track");const i=document.createElement("img");i.src=He.PLUS,t.append(i);const s=document.createElement("div");s.classList.add("leftover-track-text"),s.innerText=e,t.style.backgroundColor=Cc(Lr[e].toString(16).padStart(6,"0"),"#333333",.7),t.appendChild(s);let n=0,a=0,o=!1,l=!1;return t.addEventListener("mousedown",()=>{o=!0}),t.addEventListener("mousemove",c=>{if(!(!o||l)&&(n+=c.movementX,a+=c.movementY,n*n+a*a>15)){l=!0;const u=this.makeDraggableTrack(e);this.grid?.appendChild(u),this.clearBoundaries();const h=t.getBoundingClientRect(),d=this.getClosestSlot(h.left),p=_.chart.timingEventOrder.left.concat(["PLAYFIELD"],_.chart.timingEventOrder.right);p.splice(d,0,e),this.saveOptions(p),p.forEach(f=>{const m=this.grid?.querySelector(`div[data-type=${f}]`);this.grid?.appendChild(m),f!="PLAYFIELD"&&(m?.classList.remove("left","right"),_.chart.timingEventOrder.left.includes(f)&&m?.classList.add("left"),_.chart.timingEventOrder.right.includes(f)&&m?.classList.add("right"))}),this.startDragging(c,u,c.clientX,c.clientY),_.general.smoothAnimations?(t.style.width=t.clientWidth+"px",t.style.transition="0.4s cubic-bezier(0, 0.91, 0.34, 1.05)",setTimeout(()=>{t.style.width="0px",t.style.opacity="0",t.style.padding="0",t.style.fontSize="0"},10),setTimeout(()=>t.remove(),400)):t.remove()}}),t.addEventListener("mouseup",()=>{if(!o||l)return;l=!0,_.chart.timingEventOrder.right.push(e),_.general.smoothAnimations?(t.style.width=t.clientWidth+"px",t.style.transition="0.4s cubic-bezier(0, 0.91, 0.34, 1.05)",setTimeout(()=>{t.style.width="0px",t.style.opacity="0",t.style.padding="0",t.style.fontSize="0"},10),setTimeout(()=>t.remove(),400)):t.remove();const c=this.makeDraggableTrack(e);c.classList.add("entering"),c.classList.add("right"),setTimeout(()=>c.classList.remove("entering"),400),this.grid?.appendChild(c),this.clearBoundaries()}),t}static startDragging(e,t,i,s){if(!this.popup)return;this.draggedElement=t.cloneNode(!0),this.draggedElement.style.position="fixed";const n=t.getBoundingClientRect(),a=this.popup.getBoundingClientRect();!i||!s?(this.dragOffsetX=e.clientX-n.left,this.dragOffsetY=e.clientY-n.top,this.draggedElement.style.left=n.left-a.left+"px",this.draggedElement.style.top=n.top-a.top+"px"):(this.dragOffsetX=n.width/2,this.dragOffsetY=n.height/4*3,this.draggedElement.style.left=i-n.width/2-a.left+"px",this.draggedElement.style.top=s-n.height/4*3-a.top+"px",this.draggedElement.classList.add("entering")),this.draggedElement.style.boxShadow="6px 6px 6px #222",this.draggedElement.style.transition="none",t.style.opacity="0.03",this.popup.appendChild(this.draggedElement);const o=_.chart.timingEventOrder.left.concat(["PLAYFIELD"],_.chart.timingEventOrder.right),l=t.dataset.type;let c=o.indexOf(l);const u=o.indexOf(l),h=p=>{this.draggedElement.style.left=p.clientX-this.dragOffsetX-a.left+"px",this.draggedElement.style.top=p.clientY-this.dragOffsetY-a.top+"px";let f=this.getClosestSlot(p.clientX-this.dragOffsetX);Math.abs(p.clientY-this.dragOffsetY-a.top-(n.top-a.top))>140&&(f=u),c!=f&&(o.splice(c,1),o.splice(f,0,l),this.saveOptions(o),o.forEach(m=>{const g=this.grid?.querySelector(`div[data-type=${m}]`);this.grid?.appendChild(g),m!="PLAYFIELD"&&(g?.classList.remove("left","right"),_.chart.timingEventOrder.left.includes(m)&&g?.classList.add("left"),_.chart.timingEventOrder.right.includes(m)&&g?.classList.add("right"))}),l!="PLAYFIELD"&&(this.draggedElement?.classList.remove("left","right"),_.chart.timingEventOrder.left.includes(l)&&this.draggedElement?.classList.add("left"),_.chart.timingEventOrder.right.includes(l)&&this.draggedElement?.classList.add("right")),c=f)};window.addEventListener("mousemove",h);const d=()=>{this.draggedElement?.remove(),this.draggedElement=void 0,window.removeEventListener("mousemove",h),t.style.opacity="",this.clearBoundaries(),window.removeEventListener("mouseup",d)};window.addEventListener("mouseup",d)}static saveOptions(e){const t=e.indexOf("PLAYFIELD");t!=-1&&(_.chart.timingEventOrder.left=e.slice(0,t),_.chart.timingEventOrder.right=e.slice(t+1))}static deleteTrack(e){const t=_.chart.timingEventOrder.left.indexOf(e);t!=-1&&_.chart.timingEventOrder.left.splice(t,1);const i=_.chart.timingEventOrder.right.indexOf(e);i!=-1&&_.chart.timingEventOrder.right.splice(i,1)}static movePosition(){if(!this.popup)return;const e=document.getElementById("arrange-tracks");if(!e)return;this.popup.style.display="";const t=e.getBoundingClientRect(),i=t.left+t.width/2,s=this.popup.clientWidth,n=s/2+15,a=window.innerWidth-s/2-15;this.popup.style.left=`${Ve(i,n,a)}px`;const o=t.top+t.height/2;this.popup.style.top=`${t.top+t.height}px`,o+this.popup.clientHeight>window.innerHeight-15&&(this.popup.style.transform="translate(-50%, -100%)",this.popup.style.top=`${t.top-t.height/2}px`)}static getClosestSlot(e){this.boundaryCache.length==0&&this.getBoundaries();let t=-1,i=999999,s=999999;for(let n=0;ns)break;s=a}return t}static getBoundaries(){if(this.grid){for(const e of this.grid.children)this.boundaryCache.push([e,e.getBoundingClientRect()]);this.boundaryCache.sort((e,t)=>e[1].left-t[1].left)}}static clearBoundaries(){this.boundaryCache=[]}static close(){!this.popup||!this.active||(window.removeEventListener("click",this.clickOutside,!0),this.popup.classList.add("exiting"),this.exitTimeout=setTimeout(()=>this.popup.remove(),200),this.active=!1,clearInterval(this.moveInterval),this.clearBoundaries())}}class BT extends gl{view;playbackBar;skipStart;skipEnd;play;playIcon;record;playtest;timeCounter;beatCounter;min;sec;millis;beat;beatDropdown;editBar;editSteps;editTiming;stepsContainer;timingContainer;editChoiceContainer;addTimingEvent;arrangeTimingTracks;noteArrows=[];noteArrowMask;lastTime=-1;lastBeat=-1;lastMode=Y.Edit;lastTimingMode=De.Off;lastHover=0;lastPlaying=!1;hovering=!1;trackingMovement=!0;idleFrames=0;lastBounds;constructor(e){super(e);const t=document.createElement("div");t.id="status-widget",document.getElementById("view-wrapper")?.appendChild(t),Ie.viewMode&&t.classList.add("collapsed"),this.playbackBar=document.createElement("div"),this.playbackBar.classList.add("playback-bar"),this.editBar=document.createElement("div"),this.editBar.classList.add("edit-bar"),this.skipStart=document.createElement("button");const i=document.createElement("img");i.src=He.SKIP_START,i.style.height="36px",this.skipStart.appendChild(i),this.skipStart.onclick=()=>{this.manager.chartManager.setBeat(0)},Mt(this.skipStart,{content:"Skip to start"+this.keybind("jumpSongStart")}),this.skipEnd=document.createElement("button");const s=document.createElement("img");s.style.height="36px",s.src=He.SKIP_END,this.skipEnd.appendChild(s),this.skipEnd.onclick=()=>{this.manager.chartManager.setBeat(this.manager.chartManager.loadedChart.getBeatFromSeconds(this.manager.chartManager.chartAudio.getSongLength()))},Mt(this.skipEnd,{content:"Skip to end"+this.keybind("jumpSongEnd")}),this.play=document.createElement("button");const n=document.createElement("img");n.src=He.PLAY,this.play.appendChild(n),this.playIcon=n,this.play.onclick=()=>{(this.manager.chartManager.getMode()==Y.Record||this.manager.chartManager.getMode()==Y.Play)&&this.manager.chartManager.setMode(Y.Edit),this.manager.chartManager.playPause()},Mt(this.play,{content:"Play/Pause"+this.keybind("playback")}),this.record=document.createElement("button");const a=document.createElement("img");a.style.height="36px",a.src=He.RECORD,this.record.appendChild(a),this.record.onclick=()=>{this.manager.chartManager.setMode(Y.Record)},Mt(this.record,{content:"Record"+this.keybind("recordMode")}),(Ie.viewMode||!Ie.recordMode)&&(this.record.style.display="none"),this.playtest=document.createElement("button");const o=document.createElement("img");o.style.height="30px",o.src=He.PLAYTEST,this.playtest.appendChild(o),this.playtest.onclick=()=>{this.manager.chartManager.setMode(Y.Play)},Mt(this.playtest,{content:"Playtest"+this.keybind("playMode")}),Ie.playMode||(this.playtest.style.display="none");const l=document.createElement("div");l.classList.add("playback-separator"),this.timeCounter=document.createElement("div"),this.timeCounter.classList.add("playback-counter");const c=document.createElement("div");c.style.display="flex",c.classList.add("playback-counter-main");const u=document.createElement("div");u.classList.add("inlineEdit"),u.innerText="-",u.spellcheck=!1,u.contentEditable="true",u.style.maxWidth="27px",u.onkeydown=M=>{M.key=="Enter"&&u.blur(),M.key=="Tab"&&h.focus(),M.key=="Escape"&&(u.innerText=Math.floor(Math.abs(this.manager.chartManager.getTime())/60).toString().padStart(2,"0"),u.blur())},u.onfocus=()=>setTimeout(()=>this.selectText(u),25),u.onblur=()=>this.updateTime(),u.ondragstart=M=>M.preventDefault();const h=document.createElement("div");h.classList.add("inlineEdit"),h.innerText="-",h.spellcheck=!1,h.contentEditable="true",h.style.maxWidth="18px",h.onkeydown=M=>{M.key=="Enter"&&h.blur(),M.key=="Tab"&&d.focus(),M.key=="Escape"&&(h.innerText=Math.floor(Math.abs(this.manager.chartManager.getTime())%60).toString().padStart(2,"0"),h.blur())},h.onfocus=()=>setTimeout(()=>this.selectText(h),25),h.onblur=()=>this.updateTime(),h.ondragstart=M=>M.preventDefault();const d=document.createElement("div");d.classList.add("inlineEdit"),d.innerText="-",d.spellcheck=!1,d.contentEditable="true",d.style.maxWidth="27px",d.onkeydown=M=>{M.key=="Enter"&&d.blur(),M.key=="Tab"&&u.focus(),M.key=="Escape"&&(d.innerText=(ne(Math.abs(this.manager.chartManager.getTime())%1,3)*1e3).toString().padStart(3,"0"),d.blur())},d.onfocus=()=>setTimeout(()=>this.selectText(d),25),d.onblur=()=>this.updateTime(),d.ondragstart=M=>M.preventDefault(),this.min=u,this.sec=h,this.millis=d;const p=document.createElement("div");p.classList.add("playback-counter-label"),p.innerText="Time",c.appendChild(u),c.appendChild(document.createTextNode(":")),c.appendChild(h),c.appendChild(document.createTextNode(".")),c.appendChild(d),this.timeCounter.appendChild(c),this.timeCounter.appendChild(p);const f=document.createElement("div");f.classList.add("playback-separator"),this.beatCounter=document.createElement("div"),this.beatCounter.classList.add("playback-counter");const m=document.createElement("div");m.classList.add("playback-counter-main","inlineEdit"),m.innerText="-",m.spellcheck=!1,m.contentEditable="true",m.onkeydown=M=>{if(M.key=="Enter"&&m.blur(),M.key=="Escape"){if(this.beatDropdown.value=="Measure"){const P=this.manager.chartManager.loadedChart?.timingData?.getMeasure(this.manager.chartManager.getBeat())??this.manager.chartManager.getBeat()/4;m.innerText=ne(P,3).toFixed(3)}else m.innerText=ne(this.manager.chartManager.getBeat(),3).toFixed(3);m.blur()}},m.onfocus=()=>{setTimeout(()=>this.selectText(m),25)},m.onblur=()=>this.updateBeat(),m.ondragstart=M=>M.preventDefault(),this.beat=m,this.beatDropdown=pi.create(["Beat","Measure"],"Beat"),this.beatDropdown.view.querySelector(".dropdown-selected").classList.add("playback-counter-label"),this.beatCounter.appendChild(m),this.beatCounter.appendChild(this.beatDropdown.view),this.beatDropdown.onChange(()=>{if(this.beatDropdown.value=="Measure"){const M=this.manager.chartManager.loadedChart?.timingData?.getMeasure(this.manager.chartManager.getBeat())??this.manager.chartManager.getBeat()/4;m.innerText=ne(M,3).toFixed(3)}else m.innerText=ne(this.manager.chartManager.getBeat(),3).toFixed(3)}),this.playbackBar.appendChild(this.skipStart),this.playbackBar.appendChild(this.skipEnd),this.playbackBar.appendChild(this.play),this.playbackBar.appendChild(this.record),this.playbackBar.appendChild(this.playtest),this.playbackBar.appendChild(l),this.playbackBar.appendChild(this.timeCounter),this.playbackBar.appendChild(f),this.playbackBar.appendChild(this.beatCounter),this.editSteps=document.createElement("button"),this.editSteps.classList.add("edit-fancy-button");const g=document.createElement("img");g.src=He.ADD,this.editSteps.appendChild(g),this.editSteps.appendChild(document.createTextNode("Edit Steps")),this.editSteps.onclick=()=>{this.manager.chartManager.editTimingMode=De.Off},this.editSteps.style.background="rgba(255,255,255,0.15)",this.editTiming=document.createElement("button"),this.editTiming.classList.add("edit-fancy-button");const y=document.createElement("img");y.src=He.SPEED,this.editTiming.appendChild(y),this.editTiming.appendChild(document.createTextNode("Edit Timing")),this.editTiming.onclick=()=>{this.manager.chartManager.editTimingMode=De.Edit};const b=document.createElement("div");b.classList.add("playback-separator");const A=document.createElement("div");A.classList.add("edit-bar-left"),A.appendChild(this.editSteps),A.appendChild(this.editTiming),A.appendChild(b),this.editBar.appendChild(A),this.editChoiceContainer=document.createElement("div"),this.editChoiceContainer.classList.add("edit-choice-container"),this.stepsContainer=document.createElement("div"),this.stepsContainer.classList.add("edit-steps-container"),this.timingContainer=document.createElement("div"),this.timingContainer.classList.add("edit-timing-container"),this.editChoiceContainer.appendChild(this.stepsContainer),this.editChoiceContainer.appendChild(this.timingContainer),this.addTimingEvent=document.createElement("button");const v=document.createElement("img");v.style.height="32px",v.src=He.ADD_EVENT,this.addTimingEvent.appendChild(v),this.addTimingEvent.onclick=()=>{this.manager.chartManager.editTimingMode==De.Add?this.manager.chartManager.editTimingMode=De.Edit:this.manager.chartManager.editTimingMode=De.Add},this.timingContainer.appendChild(this.addTimingEvent),Mt(this.addTimingEvent,{content:"Add timing events"}),this.arrangeTimingTracks=document.createElement("button");const E=document.createElement("img");E.style.height="32px",E.src=He.EYE,this.arrangeTimingTracks.appendChild(E),this.arrangeTimingTracks.onclick=()=>{Ah.active?Ah.close():Ah.open()},this.arrangeTimingTracks.id="arrange-tracks",this.timingContainer.appendChild(this.arrangeTimingTracks),Mt(this.arrangeTimingTracks,{content:"Arrange timing tracks"}),this.editBar.appendChild(this.editChoiceContainer);const C=document.createElement("div");C.classList.add("note-placeholder-right"),this.stepsContainer.appendChild(C),$.on("resize",()=>{this.trackingMovement=!0,this.idleFrames=5}),$.on("chartLoaded",()=>{this.stepsContainer.replaceChildren(),this.noteArrows.forEach(P=>{this.removeChild(P.sprite),this.removeChild(P.bg),this.removeChild(P.highlight)}),this.noteArrows=[];const M=document.createElement("div");if(M.classList.add("note-placeholder-right"),this.stepsContainer.appendChild(M),!!this.manager.chartManager.loadedChart){for(const P of this.manager.chartManager.loadedChart.gameType.editNoteTypes){const k=this.manager.chartManager.chartView.getNotefield().getNoteSprite({type:P,beat:0,col:0,quant:4,second:0,warped:!1,fake:!1});k.width=32,k.height=32;const N=new ke(Z.WHITE);N.tint=0,N.alpha=.5,N.width=48,N.height=48,N.anchor.set(.5);const H=new Nt("noBorder");H.alpha=0,H.width=48,H.height=48,H.pivot.x=24,H.pivot.y=24;const T=document.createElement("button");T.style.height="48px",T.style.width="48px",T.classList.add("note-placeholder"),T.onclick=()=>{this.manager.chartManager.setEditingNoteType(P)},Mt(T,{content:P+this.keybind("noteType"+P)});const S={element:T,sprite:k,type:P,bg:N,highlight:H,hovered:!1};T.onmouseover=()=>{S.hovered=!0},T.onmouseleave=()=>{S.hovered=!1},this.addChild(N),this.addChild(k),this.addChild(H);const w=T.getBoundingClientRect();k.position.y=w.top-this.manager.app.view.clientHeight/2-this.manager.app.view.getBoundingClientRect().top+24,k.position.x=w.left-this.manager.app.view.clientWidth/2+24,N.position=k.position,this.noteArrows.push(S)}this.stepsContainer.replaceChildren(...this.noteArrows.map(P=>P.element),M),this.trackingMovement=!0,this.idleFrames=5}}),this.noteArrowMask=new ke(Z.WHITE),this.noteArrowMask.height=48,this.noteArrowMask.width=2500,this.noteArrowMask.anchor.y=1,this.noteArrowMask.anchor.x=.5,this.addChild(this.noteArrowMask),this.mask=this.noteArrowMask,t.onmouseenter=()=>{this.lastHover=Date.now(),this.hovering=!0,this.view.style.opacity="",this.view.style.transition=""},t.onmouseleave=()=>this.hovering=!1,t.appendChild(this.playbackBar),t.appendChild(this.editBar),this.view=t,t.style.display="none"}update(){this.view.style.display=this.manager.chartManager.loadedSM&&Ie.status?"":"none";const e=this.manager.chartManager.getTime();this.lastTime!=e&&(document.activeElement!=this.min&&(this.min.innerText=(e<0?"-":"")+Math.floor(Math.abs(e)/60).toString().padStart(2,"0")),document.activeElement!=this.sec&&(this.sec.innerText=Math.floor(Math.abs(e)%60).toString().padStart(2,"0")),document.activeElement!=this.millis&&(this.millis.innerText=(ne(Math.abs(e)%1,3)*1e3).toString().padStart(3,"0")),this.lastTime=e);const t=this.manager.chartManager.getBeat();if(this.lastBeat!=t){if(document.activeElement!=this.beat)if(this.beatDropdown.value=="Measure"){const o=this.manager.chartManager.loadedChart?.timingData?.getMeasure(t)??t/4;this.beat.innerText=ne(o,3).toFixed(3)}else this.beat.innerText=ne(t,3).toFixed(3);this.lastBeat=t}const i=this.manager.chartManager.getMode(),s=this.manager.chartManager.editTimingMode;if(this.lastMode!=i){switch(i){case Y.Edit:this.skipStart.disabled=!1,this.skipEnd.disabled=!1,this.record.disabled=!1,this.playtest.disabled=!1,this.min.contentEditable="true",this.sec.contentEditable="true",this.millis.contentEditable="true",this.beat.contentEditable="true",this.record.style.background="",this.playtest.style.background="",this.view.style.opacity="",this.view.style.transition="",this.view.classList.remove("collapsed"),this.beatDropdown.disabled=!1;break;case Y.Record:this.lastHover=Date.now(),this.skipStart.disabled=!0,this.skipEnd.disabled=!0,this.record.disabled=!1,this.record.style.background="rgba(170, 0, 0, 0.35)",this.playtest.disabled=!0,this.min.contentEditable="false",this.sec.contentEditable="false",this.millis.contentEditable="false",this.beat.contentEditable="false",s!=De.Off&&(this.visible=!1),this.view.classList.add("collapsed"),this.beatDropdown.closeDropdown(),this.beatDropdown.disabled=!0;break;case Y.Play:this.lastHover=Date.now(),this.skipStart.disabled=!0,this.skipEnd.disabled=!0,this.record.disabled=!0,this.playtest.disabled=!1,this.playtest.style.background="rgba(12, 97, 31, 0.35)",this.min.contentEditable="false",this.sec.contentEditable="false",this.millis.contentEditable="false",this.beat.contentEditable="false",s!=De.Off&&(this.visible=!1),this.view.classList.add("collapsed"),this.beatDropdown.closeDropdown(),this.beatDropdown.disabled=!0;break;case Y.View:this.lastHover=Date.now(),this.skipStart.disabled=!1,this.skipEnd.disabled=!1,this.record.disabled=!0,this.playtest.disabled=!1,this.min.contentEditable="true",this.sec.contentEditable="true",this.millis.contentEditable="true",this.beat.contentEditable="true",s!=De.Off&&(this.visible=!1),this.view.classList.add("collapsed"),this.beatDropdown.closeDropdown(),this.beatDropdown.disabled=!0}this.trackingMovement=!0,this.idleFrames=5,this.lastMode=i}if(this.lastTimingMode!=s){switch(s){case De.Off:this.visible=!0,this.stepsContainer.style.transform="",this.timingContainer.style.transform="",this.editSteps.style.background="rgba(255,255,255,0.15)",this.editTiming.style.background="";break;case De.Add:this.addTimingEvent.style.background="rgba(255,255,255,0.15)";break;case De.Edit:this.addTimingEvent.style.background=""}(this.lastTimingMode==De.Off&&s!=De.Off||this.lastTimingMode!=De.Off&&s==De.Off)&&this.manager.chartManager.clearSelections(),this.trackingMovement=!0,this.idleFrames=5,this.lastTimingMode=s,this.stepsContainer.style.transform=s==De.Off?"":"translateY(-48px)",this.timingContainer.style.transform=s==De.Off?"":"translateY(-48px)",this.editSteps.style.background=s==De.Off?"rgba(255,255,255,0.15)":"",this.editTiming.style.background=s==De.Off?"":"rgba(255,255,255,0.15)"}const n=this.manager.chartManager.chartAudio.isPlaying();if(this.lastPlaying!=n&&(this.playIcon.src=n?He.STOP:He.PLAY,this.lastPlaying=n),this.playIcon.style.height=this.manager.chartManager.chartAudio.isPlaying()?"28px":"",(i==Y.Play||i==Y.Record)&&this.view.style.opacity==""&&!this.hovering&&Date.now()-this.lastHover>3e3&&(this.view.style.opacity="0.2",this.view.style.transition="2s cubic-bezier(.11,.72,.51,1.14)"),this.trackingMovement){const o=this.noteArrows[0];if(o){const c=o.element.getBoundingClientRect();this.noteArrows.forEach((u,h)=>{u.sprite.position.y=c.top-this.manager.app.view.clientHeight/2-this.manager.app.view.getBoundingClientRect().top+24,u.sprite.position.x=c.left-this.manager.app.view.clientWidth/2+24+h*48,u.bg.position=u.sprite.position,u.highlight.position=u.sprite.position}),this.lastBounds&&Math.abs(this.lastBounds.top-c.top)+Math.abs(this.lastBounds.left-c.left)==0&&(this.idleFrames--,this.idleFrames<0&&(this.trackingMovement=!1,this.lastBounds=void 0,s!=De.Off&&(this.visible=!1))),this.lastBounds=c}const l=this.view.getBoundingClientRect();this.noteArrowMask.y=l.bottom-this.manager.app.view.clientHeight/2-this.manager.app.view.getBoundingClientRect().top}const a=this.manager.chartManager.getEditingNoteType();this.noteArrows.forEach(o=>{if(_.general.smoothAnimations){const l=a==o.type?.15:o.hovered?.05:0;o.highlight.alpha=(l-o.highlight.alpha)*.3+o.highlight.alpha}else o.highlight.alpha=a==o.type?.15:o.hovered?.05:0})}selectText(e){const t=window.getSelection(),i=document.createRange();!t||!i||(i.selectNodeContents(e),t.removeAllRanges(),t.addRange(i))}updateTime(){this.millis.innerText=this.millis.innerText.padEnd(3,"0").slice(0,3);const e=this.parseString(this.min),t=this.parseString(this.sec),i=this.parseString(this.millis);if(e===null||t===null||i===null){this.lastTime=-999;return}let s=e*60+t+i/1e3;s>9999999&&(s=9999999),this.manager.chartManager.setTime(s),this.lastTime=-999}updateBeat(){let e=this.parseString(this.beat);if(e===null){this.lastBeat=-999;return}this.beatDropdown.value=="Measure"&&(e=this.manager.chartManager.loadedChart?.timingData?.getBeatFromMeasure(e)??e*4),e>9999999&&(e=9999999),this.manager.chartManager.setBeat(e),this.lastBeat=-999}parseString(e){try{const t=Vr.evaluate(e.innerText);return!isFinite(t)||t<0?0:t}catch{return null}}keybind(e){const t=$e.getKeybindString(e);return t==""?"":" ("+t+")"}}class PT extends xe{app;chartManager;children=[];constructor(e){super(),this.app=e.app,this.chartManager=e,this.addChild(new MT(this)),this.addChild(new IT(this)),this.addChild(new BT(this)),this.addChild(new la(this)),this.zIndex=2}update(){this.x=this.app.renderer.screen.width/2,this.y=this.app.renderer.screen.height/2,this.children.forEach(e=>e.update())}startPlay(){this.children.forEach(e=>e.startPlay())}endPlay(){this.children.forEach(e=>e.endPlay())}}class Rg{static _model;static async getModel(){return this._model||await this._load(),this._model}static async _load(){this._model=[];const e=localStorage.getItem("recentFiles");if(e){try{const t=JSON.parse(e);if(!Array.isArray(t))return;for(const i of t)typeof i!="object"||Array.isArray(i)||typeof i?.name!="string"||typeof i?.path!="string"||this._model.find(s=>s.path==i.path)||this._model.push({name:i.name,path:i.path})}catch{console.log("Failed to load recent file entries");return}await this.saveEntries()}}static async getRecents(){return await this.getModel()}static async addSM(e,t){const i=await this.getModel(),s=i.findIndex(n=>n.path==e);s!=-1&&i.splice(s,1),i.unshift({name:t.properties.TITLE??"Untitled Song",path:e}),this.saveEntries()}static async limitEntries(){(await this.getModel()).splice(15)}static async saveEntries(){this.limitEntries();const e=await Promise.all(this._model.map(async t=>await Re.hasFile(t.path)));this._model=this._model.filter((t,i)=>e[i]),localStorage.setItem("recentFiles",JSON.stringify(this._model))}}class RT extends Pt{app;keyHandler;constructor(e){super({title:"Open a Song",width:400,height:320,disableClose:!0,win_id:"select_sm_initial"}),this.app=e,this.keyHandler=this.handleKeyEvent.bind(this),window.addEventListener("keydown",this.keyHandler),this.initView()}onClose(){window.removeEventListener("keydown",this.keyHandler)}initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("open-container"),e.appendChild(t);const i=document.createElement("div");i.classList.add("top-container");const s=document.createElement("div");s.classList.add("separator"),s.style.margin="10px";const n=document.createElement("div");n.classList.add("bottom-container"),t.appendChild(i),t.appendChild(s),t.appendChild(n);const a=document.createElement("button");a.style.display="flex",a.style.flexDirection="column",a.style.padding="10px",a.style.backgroundColor="#414352",i.appendChild(a);const o=document.createElement("img");o.src=He.UPLOAD,o.classList.add("icon"),o.style.width="30px",o.style.height="30px",a.appendChild(o);const l=document.createElement("div");l.innerText=window.nw?"Open an existing song":"Import a song folder",a.appendChild(l),a.onclick=()=>{if(window.nw){const f=document.createElement("input");f.type="file",f.accept=".sm,.ssc",f.onchange=()=>{this.app.chartManager.loadSM(f.value),this.closeWindow()},f.click()}else this.app.windowManager.openWindow(new ml(this.app,{title:"Select an sm/ssc file...",accepted_file_types:[".sm",".ssc"],disableClose:!0,callback:f=>{this.app.chartManager.loadSM(f),this.closeWindow()}}))};const c=document.createElement("button");c.style.display="flex",c.style.flexDirection="column",c.style.padding="10px",c.style.backgroundColor="#506352",i.appendChild(c);const u=document.createElement("img");u.src=He.PLUS,u.classList.add("icon"),u.style.width="30px",u.style.height="30px",c.appendChild(u);const h=document.createElement("div");h.innerText="New Song",c.appendChild(h),c.onclick=()=>{this.app.windowManager.openWindow(new kg(this.app))};const d=document.createElement("div");d.innerText="Recently Opened",d.classList.add("title"),n.appendChild(d);const p=document.createElement("div");p.classList.add("recent-selector"),n.appendChild(p),Rg.getRecents().then(f=>f.forEach(m=>{const g=document.createElement("div");g.classList.add("recent-item");const y=document.createElement("div");y.classList.add("recent-name"),y.innerText=m.name;const b=document.createElement("div");b.classList.add("recent-path"),b.innerText=m.path,g.appendChild(y),g.appendChild(b),g.onclick=()=>{p.querySelectorAll(".selected").forEach(A=>A.classList.remove("selected")),g.classList.add("selected")},g.ondblclick=()=>{this.app.chartManager.loadSM(m.path),this.closeWindow()},p.appendChild(g)})),this.viewElement.appendChild(e)}handleKeyEvent(e){if(!this.windowElement.classList.contains("focused"))return;const t=this.viewElement.querySelector(".selected");if(t){if(e.code=="ArrowUp"){e.preventDefault(),e.stopImmediatePropagation();const i=t.previousElementSibling;i&&(t.parentElement.querySelectorAll(".selected").forEach(s=>s.classList.remove("selected")),i.classList.add("selected"),ea(i,{scrollMode:"if-needed",block:"nearest",inline:"nearest"}))}if(e.code=="ArrowDown"){e.preventDefault(),e.stopImmediatePropagation();const i=t.nextElementSibling;i&&(t.parentElement.querySelectorAll(".selected").forEach(s=>s.classList.remove("selected")),i.classList.add("selected"),ea(i,{scrollMode:"if-needed",block:"nearest",inline:"nearest"}))}}}}const Mc=Array(85).fill(void 0).map((r,e)=>33+e),Dg=[];for(const r of Mc)for(const e of Mc)Dg.push([r,e]);const Ic="<~".split("").map(r=>r.charCodeAt(0)),kc="~>".split("").map(r=>r.charCodeAt(0));function DT(r,e,t,i=!1,s=!1,n=!1){let a;typeof r=="string"?a=r.split("").map(h=>h.charCodeAt(0)):a=[...new Uint8Array(r)];const o=4-a.length%4;for(let h=0;ho.charCodeAt(0)):i=[...new Uint8Array(r)],e){if(i.at(-1)!=kc.at(-1)||i.at(-2)!=kc.at(-2))return!1;i.at(0)==Ic.at(0)&&i.at(1)==Ic.at(1)?i=i.slice(2,-2):i=i.slice(void 0,-2)}for(let o=0;o<4;o++)i.push("u".charCodeAt(0));let s=[],n=[];for(const o of i)if(o>=33&&117>=o){if(n.push(o),n.length==5){let l=0;for(const c of n)l=85*l+(c-33);if(l>2**32-1)return!1;s.push(l>>24&255),s.push(l>>16&255),s.push(l>>8&255),s.push(l&255),n=[]}}else if(o==122){if(n.length!=0)return!1;s.push(0),s.push(0),s.push(0),s.push(0)}else if(o==121){if(n.length!=0)return!1;s.push(32),s.push(32),s.push(32),s.push(32)}else if(!t.includes(String.fromCharCode(o)))return!1;const a=4-n.length;return a&&(s=s.slice(void 0,-a)),s}function ii(r){let e=0,t=0,i=129;for(;i&128;){const s=r.shift();if(!s)break;e=e|(s&127)<<7*t++,i=s}return e}function ri(r){const e=[];let t=!1;for(;!t;){let i=r&127;r=r>>7,t=r==0,t||(i=i|128),e.push(i)}return e}const LT=["Hold","Mine","Roll","Lift","Fake"];function OT(r){if(r.startsWith("ArrowVortex:notes:")){const e=bd(r.slice(18));if(e!==!1){const t=Array.from(e);if(t.shift()!=0)return;const i=ii(t),s=[];for(let n=0;n4)continue;const h=LT[u];if(l==c){if(h=="Hold"||h=="Roll")continue;s.push({type:h,beat:l/48,col:o})}else{if(h=="Mine"||h=="Fake"||h=="Lift")continue;s.push({type:h,beat:l/48,hold:(c-l)/48,col:o})}}else s.push({type:"Tap",beat:ii(t)/48,col:o})}return s}}}function FT(r){const e=[0];e.push(...ri(r.length));for(const t of r)if(t.type=="Tap"){const i=Math.round(t.beat*48);e.push(t.col),e.push(...ri(i))}else{e.push(t.col+128);const i=Math.round(t.beat*48);let s=0;Be(t)&&(s=t.hold);const n=Math.round(s*48)+i;e.push(...ri(i)),e.push(...ri(n)),e.push(["Hold","Mine","Roll","Lift","Fake"].indexOf(t.type))}return"ArrowVortex:notes:"+vd(e).map(t=>String.fromCharCode(t)).join("")}const yl=["BPMS","STOPS","DELAYS","WARPS","TIMESIGNATURES","TICKCOUNTS","COMBOS","SPEEDS","SCROLLS","FAKES","LABELS","ATTACKS","BGCHANGES","FGCHANGES"];function mr(r){const e=new ArrayBuffer(4);return new DataView(e).setUint32(0,r,!0),Array.from(new Uint8Array(e))}function gr(r){const e=new Uint8Array(r.splice(0,4));return new DataView(e.buffer).getUint32(0,!0)}function Sr(r){const e=new ArrayBuffer(8);return new DataView(e).setFloat64(0,r,!0),Array.from(new Uint8Array(e))}function Cr(r){const e=new Uint8Array(r.splice(0,8)),t=new DataView(e.buffer);return ne(t.getFloat64(0,!0),3)}function NT(r){return[r.length,...r.split("").map(e=>e.charCodeAt(0))]}function UT(r){const e=r.shift();if(!e)return"";let t="";for(let i=0;ie.charCodeAt(0)))}function vr(r){const e=ii(r);if(!e)return"";let t="";for(let i=0;i{if(e.type=="ATTACKS"||e.type=="BGCHANGES"||e.type=="FGCHANGES")return!0;const t=Math.round(e.beat*48)/48;if(Math.abs(t-e.beat)>5e-4)return!0;if(e.type=="FAKES"||e.type=="WARPS"){const i=Math.round(e.value*48)/48;if(Math.abs(i-e.value)>5e-4)return!0}return e.type=="LABELS"&&e.value.length>255||e.type=="TIMESIGNATURES"&&(e.upper>2**32-1||e.lower>2**32-1)||e.type=="COMBOS"&&(e.hitMult>2**32-1||e.missMult>2**32-1)?!0:e.type=="TICKCOUNTS"&&e.value>2**32-1})?WT(r):HT(r)}function HT(r){const e=[],t=new Map;r.forEach(i=>{t.has(i.type)||t.set(i.type,[]),t.get(i.type)?.push(i)});for(const[i,s]of t.entries())if(!(i=="ATTACKS"||i=="BGCHANGES"||i=="FGCHANGES")){e.push(s.length),e.push(yl.indexOf(i));for(const n of s)switch(e.push(...mr(Math.round(n.beat*48))),n.type){case"BPMS":case"STOPS":case"DELAYS":case"SCROLLS":e.push(...Sr(n.value));break;case"FAKES":case"WARPS":e.push(...mr(Math.round(n.value*48)));break;case"TIMESIGNATURES":e.push(...mr(Math.round(n.upper))),e.push(...mr(Math.round(n.lower)));break;case"COMBOS":e.push(...mr(Math.round(n.hitMult))),e.push(...mr(Math.round(n.missMult)));break;case"TICKCOUNTS":e.push(...mr(Math.round(n.value)));break;case"SPEEDS":e.push(...Sr(n.value)),e.push(...Sr(n.delay)),e.push(...mr(n.unit=="B"?0:1));break;case"LABELS":e.push(...NT(n.value))}}return e.push(0),"ArrowVortex:tempo:"+vd(e).map(i=>String.fromCharCode(i)).join("")}function WT(r){const e=[],t=new Map;r.forEach(i=>{t.has(i.type)||t.set(i.type,[]),t.get(i.type)?.push(i)});for(const[i,s]of t.entries()){e.push(...ri(s.length)),e.push(yl.indexOf(i));for(const n of s)switch(e.push(...ri(Math.round((n.type=="ATTACKS"?n.second:n.beat)*1e3))),n.type){case"BPMS":case"STOPS":case"DELAYS":case"SCROLLS":case"FAKES":case"WARPS":e.push(...Sr(n.value));break;case"TIMESIGNATURES":e.push(...ri(Math.round(n.upper))),e.push(...ri(Math.round(n.lower)));break;case"COMBOS":e.push(...ri(Math.round(n.hitMult))),e.push(...ri(Math.round(n.missMult)));break;case"TICKCOUNTS":e.push(...ri(Math.round(n.value)));break;case"SPEEDS":e.push(...Sr(n.value)),e.push(...Sr(n.delay)),e.push(n.unit=="B"?0:1);break;case"LABELS":e.push(...yr(n.value));break;case"ATTACKS":e.push(...Sr(n.value)),e.push(n.endType=="LEN"?0:1),e.push(...yr(n.mods));break;case"BGCHANGES":case"FGCHANGES":e.push((n.crossFade?1:0)+((n.stretchRewind?1:0)<<1)+((n.stretchNoLoop?1:0)<<2)),e.push(...yr(n.file)),e.push(...Sr(n.updateRate)),e.push(...yr(n.effect)),e.push(...yr(n.file2)),e.push(...yr(n.transition)),e.push(...yr(n.color1)),e.push(...yr(n.color2))}}return"SMEditor:tempo:"+vd(e).map(i=>String.fromCharCode(i)).join("")}function VT(r){if(r.startsWith("SMEditor:tempo:"))return jT(r);if(r.startsWith("ArrowVortex:tempo:"))return zT(r)}function zT(r){if(!r.startsWith("ArrowVortex:tempo:"))return;const e=bd(r.slice(18)),t=[];if(e===!1)return;const i=Array.from(e);try{for(;;){const s=i.shift();if(s===void 0)return;if(s==0)break;const n=i.shift();if(n===void 0)return;const a=yl[n];for(let o=0;o0,stretchRewind:(c&2)>0,stretchNoLoop:(c&4)>0,effect:vr(i),file2:vr(i),transition:vr(i),color1:vr(i),color2:vr(i)})}}}}}catch{return}return t}const YT={"dance-single":[{x:-1,y:0},{x:0,y:-1},{x:0,y:1},{x:1,y:0}]},lt={DOUBLESTEP:850,BRACKETJACK:20,JACK:30,JUMP:30,BRACKETTAP:400,HOLDSWITCH:20,MINE:1e4,FOOTSWITCH:5e3,MISSED_FOOTSWITCH:500,FACING:2,DISTANCE:6,SPIN:1e3,SIDESWITCH:130},wh=[1,2,3,4],Kp="LlRr";class XT{app;costCache=[];cacheCounter=0;exploreCounter=0;stop=!1;layout;SEARCH_DEPTH=16;SEARCH_BREADTH=30;constructor(e,t){this.app=e,this.layout=YT[t]}help(){console.log(`Currently only compatible with dance-single. +`,this.fpsBg.width=this.fpsText.width+10,this.fpsBg.height=this.fpsText.height+10,_.debug.showTimers?(this.fpsBg.y=(yi+5)*this.graphs.children.length-5,this.fpsText.y=(yi+5)*this.graphs.children.length):(this.fpsBg.y=-5,this.fpsText.y=0)}addMemoryTimeValue(e){this.memoryTimeGraph.addValue(e)}addFrameTimeValue(e){this.lastFrameTime=e,this.frameTimeGraph.addValue(e)}addUpdateTimeValue(e){this.updateTimeGraph.addValue(e)}addDrawUpdateTimeValue(e){this.drawUpdateTimeGraph.addValue(e)}}class Dn extends xe{graphWidth;graphHeight;color;unit;precision;formatter;sublabel;maxEase=1;targetMax=1;minEase=1;targetMin=1;constrainedMin=null;constrainedMax=null;dataPoints=[];linePool=[];lineContainer;labelText;sublabelText;topText;bottomText;constructor(e){super();const{width:t,height:i,color:s=16777215,unit:n="",label:a="",min:o=null,max:l=null,precision:c=0,formatter:u=null,sublabel:h=()=>""}=e;this.graphWidth=t,this.graphHeight=i,this.color=s,this.unit=n,this.constrainedMax=l,this.constrainedMin=o,this.precision=c,this.formatter=u,this.sublabel=h,this.lineContainer=new Kc(t,{position:!0},16384,!0);const d=new Nt;d.tint=0,d.alpha=.3,d.width=this.graphWidth,d.height=this.graphHeight,this.labelText=new Fe(a,{fontName:"Main",fontSize:Math.min(i/5,16)}),this.labelText.alpha=.8,this.sublabelText=new Fe("",{fontName:"Main",fontSize:Math.min(i/5,16)}),this.topText=new Fe("",{fontName:"Main",fontSize:Math.min(i/7,12)}),this.topText.anchor.x=1,this.topText.alpha=.5,this.topText.x=this.graphWidth,this.bottomText=new Fe("",{fontName:"Main",fontSize:Math.min(i/7,12)}),this.bottomText.anchor.x=1,this.bottomText.anchor.y=1,this.bottomText.alpha=.5,this.bottomText.x=this.graphWidth,this.bottomText.y=this.graphHeight,this.sublabelText.y=this.graphHeight,this.sublabelText.anchor.y=1,this.sublabelText.alpha=.5,this.addChild(d,this.lineContainer,this.labelText,this.sublabelText,this.topText,this.bottomText)}addValue(e){if(this.lineContainer.children[0]?.x+this.lineContainer.x<0){const i=this.lineContainer.children[0];this.dataPoints.shift(),this.removeChild(i),this.linePool.push(i)}this.lineContainer.x-=1,this.lineContainer.x<-1e7&&(this.lineContainer.children.forEach(i=>{i.x-=1e7}),this.lineContainer.x+=1e7);const t=this.linePool.shift()??new ke(Z.WHITE);t.width=1,t.anchor.x=.5,t.anchor.y=1,t.tint=this.color,t.alpha=.6,t.x=this.graphWidth-this.lineContainer.x,t.y=this.graphHeight,t.value=e,this.dataPoints.push(e),this.targetMax=this.constrainedMax!==null?this.constrainedMax:Math.max(...this.dataPoints),this.targetMin=this.constrainedMin!==null?this.constrainedMin:Math.min(...this.dataPoints),this.lineContainer.addChild(t)}update(){this.dataPoints.length!=0&&(this.maxEase=(this.maxEase-this.targetMax)*.1+this.targetMax,this.minEase=(this.minEase-this.targetMin)*.1+this.targetMin,this.lineContainer.children.forEach(e=>{e.height=Ve((e.value-this.minEase)/this.maxEase,0,1)*this.graphHeight}),this.topText.text=this.formatter?.(this.maxEase)??`${ne(this.maxEase,this.precision)} ${this.unit}`,this.bottomText.text=this.formatter?.(this.minEase)??`${ne(this.minEase,this.precision)} ${this.unit}`,this.sublabelText.text=this.sublabel())}}class bh{static active=!1;static persistent=!1;static popup;static clickOutside;static onSnapChange=this.updateValues.bind(this);static moveInterval;static updateInterval;static editText;static zoomer;static divInput;static divLabel;static beatInput;static open(e){this.active||(this.popup=this.build(),document.getElementById("popups")?.appendChild(this.popup),this.clickOutside=t=>{this.popup?.contains(t.target)||(this.persistent=!1,this.close())},$.on("snapChanged",this.onSnapChange),this.popup.style.display="none",setTimeout(()=>this.movePosition(e)),this.moveInterval=setInterval(()=>this.movePosition(e),150),this.active=!0)}static movePosition(e){this.popup.style.display="";const t=e.getBounds(),i=t.left+t.width/2,s=200,n=s/2+15,a=window.innerWidth-s/2-15;this.popup.style.left=`${Ve(i,n,a)}px`;const o=(t.top+t.height+35)/2;this.popup.style.top=`${t.top+t.height+35}px`,o+this.popup.clientHeight>window.innerHeight-15&&(this.popup.style.transform="translate(-50%, -100%)",this.popup.style.top=`${t.top-t.height/2}px`)}static build(){const e=document.createElement("div");e.classList.add("popup");const t=document.createElement("div");t.classList.add("popup-zoomer"),t.style.width="200px",t.style.backgroundColor="#333333",e.appendChild(t),this.zoomer=t;const i=document.createElement("div");i.innerText="Snap Options",i.classList.add("popup-title"),t.appendChild(i);const s=document.createElement("div");s.classList.add("popup-flex"),t.appendChild(s);const n=document.createElement("div");n.classList.add("popup-row");const a=document.createElement("div");a.innerText="Snap to nearest ";const o=Ze.create(_.chart.snap==0?0:Math.round(4/_.chart.snap),1,0,0,1e3);o.onChange=f=>{if(f===void 0){this.updateValues();return}f==0?_.chart.snap=0:_.chart.snap=4/f,this.updateValues()};const l=document.createElement("div");l.innerText=this.suffixSnap()+" note",n.replaceChildren(a,o.view,l);const c=document.createElement("div");c.classList.add("popup-row");const u=document.createElement("div");u.innerText="Snap every";const h=Ze.create(_.chart.snap,.001,3,0);h.onChange=f=>{if(f===void 0){this.updateValues();return}f==0?_.chart.snap=0:_.chart.snap=f,this.updateValues()};const d=document.createElement("div");d.innerText=" beats",c.replaceChildren(u,h.view,d),s.replaceChildren(n,c),this.beatInput=h,this.divInput=o,this.divLabel=l;const p=document.createElement("div");return p.innerText="click to edit",p.style.marginTop="4px",p.style.height="10px",t.appendChild(p),p.classList.add("popup-desc"),this.editText=p,e}static updateValues(){document.activeElement==this.divInput.input||document.activeElement==this.beatInput.input||(this.divInput.setValue(_.chart.snap==0?0:Math.round(4/_.chart.snap)),this.divLabel.innerText=this.suffixSnap()+" note",this.beatInput.setValue(_.chart.snap))}static suffixSnap(){const e=_.chart.snap==0?0:Math.round(4/_.chart.snap);return e%10==1&&e!=11?"st":e%10==2&&e!=12?"nd":e%10==3&&e!=13?"rd":"th"}static close(){if(!this.popup||!this.active||this.persistent)return;window.removeEventListener("click",this.clickOutside,!0),this.popup.classList.add("exiting");const e=this.popup;setTimeout(()=>e.remove(),200),this.active=!1,this.persistent=!1,clearInterval(this.moveInterval),clearInterval(this.updateInterval),$.off("timingModified",this.onSnapChange)}static select(){this.persistent=!0,this.zoomer.classList.add("selected"),this.editText.style.transform="scale(0)",this.editText.style.height="0px",setTimeout(()=>window.addEventListener("click",this.clickOutside,!0),200)}}const ST={fontName:"Main",fontSize:10,fill:["#ffffff"]},Bg={4:15157287,8:4033015,12:11152884,16:8577607,24:14167723,32:15376696,48:15699179,64:7071886,96:8553090,192:8553090};class CT extends xe{renderer;children=[];constructor(e){super(),this.renderer=e;for(let t=0;t<2;t++){const i=new xe,s=new ma,n=new Fe("4",ST);i.x=(t-.5)*(this.renderer.chart.gameType.notefieldWidth+48),s.rotation=Math.PI/4,s.lineStyle(1,0,1),s.beginFill(16777215),s.drawRect(-12,-12,24,24),s.endFill(),n.anchor.set(.5),i.addChild(s,n),this.addChild(i),i.eventMode="static",i.on("mouseenter",()=>bh.open(s)),i.on("mousedown",()=>bh.select()),i.on("mouseleave",()=>bh.close())}}update(){this.y=this.renderer.getActualReceptorYPos(),this.visible=this.renderer.chartManager.getMode()!=Y.Play;for(let e=0;e<2;e++){const t=this.children[e],i=t.children[0];i.tint=Bg[4/_.chart.snap]??7368816;const s=t.children[1];s.text=""+(_.chart.snap==0||4/_.chart.snap%1!=0?"":4/_.chart.snap)}}}class MT extends gl{barContainer=new Kc(1500,{position:!0,scale:!0,tint:!0},16384,!0);backing=new Nt;bars;barTexture;overlay=new ke(Z.WHITE);lastHeight=0;lastCMod;mouseDown=!1;queued=!1;constructor(e){super(e),this.addChild(this.backing),this.visible=!1,this.backing.tint=0,this.backing.alpha=.3,this.barTexture=mt.create({resolution:this.manager.app.renderer.resolution}),this.bars=new ke(this.barTexture),this.bars.anchor.set(.5),this.addChild(this.bars),this.overlay.anchor.x=.5,this.overlay.anchor.y=0,this.overlay.alpha=.3,this.lastCMod=_.chart.CMod,this.addChild(this.overlay),this.x=this.manager.app.renderer.screen.width/2-20,$.on("chartLoaded",()=>{this.queued=!1,this.populate()}),$.on("chartModifiedAfter",()=>{this.queued||this.populate(),this.queued=!0});const t=setInterval(()=>{this.queued&&(this.queued=!1,this.populate())},3e3);this.on("destroyed",()=>clearInterval(t)),this.populate(),this.eventMode="static",this.on("mousedown",i=>{this.mouseDown=!0,this.handleMouse(i)}),this.on("mousemove",i=>{this.mouseDown&&this.handleMouse(i)}),window.onmouseup=()=>{this.mouseDown=!1}}handleMouse(e){if(this.manager.chartManager.getMode()==Y.Play||!this.getChart())return;let t=(this.bars.toLocal(e.global).y+this.bars.height/2)/this.bars.height;t=Ve(t,0,1);const i=this.getChart().getNotedata().at(-1);if(!i)return;const s=i.beat+(Be(i)?i.hold:0),n=this.getChart().getSecondsFromBeat(s);_.chart.CMod?this.manager.chartManager.setTime(sr(-this.getChart().timingData.getOffset(),n,t)):this.manager.chartManager.setBeat(s*t)}update(){this.scale.y=_.chart.reverse?-1:1;const e=this.manager.app.renderer.screen.height-40;this.backing.height=e+10,this.backing.position.y=-this.backing.height/2,this.backing.position.x=-this.backing.width/2,this.bars.height=e,this.x=this.manager.app.renderer.screen.width/2-20;const t=this.getChart(),i=this.manager.chartManager.chartView;if(!t||!i||!Ie.layout){this.visible=!1;return}this.visible=!0;const s=t.getNotedata().at(-1);if(!s){this.overlay.height=0;return}const n=s.beat+(Be(s)?s.hold:0),a=t.getSecondsFromBeat(n),o=_.chart.CMod?i.getSecondFromYPos(-this.manager.app.renderer.screen.height/2):i.getBeatFromYPos(-this.manager.app.renderer.screen.height/2,!0),l=_.chart.CMod?i.getSecondFromYPos(this.manager.app.renderer.screen.height/2):i.getBeatFromYPos(this.manager.app.renderer.screen.height/2,!0);let c=Ai(0,n,o),u=Ai(0,n,l);_.chart.CMod&&(c=Ai(-t.timingData.getOffset(),a,o),u=Ai(-t.timingData.getOffset(),a,l)),c=Ve(c,0,1),u=Ve(u,0,1),c>u&&([c,u]=[u,c]);const h=(c-.5)*(this.backing.height-10),d=(u-.5)*(this.backing.height-10);this.overlay.y=h,this.overlay.height=d-h,this.overlay.height=Math.max(2,this.overlay.height),(this.manager.app.renderer.screen.height!=this.lastHeight||this.lastCMod!=_.chart.CMod)&&(this.lastCMod=_.chart.CMod,this.lastHeight=this.manager.app.renderer.screen.height,this.populate())}populate(){const e=this.getChart();if(!e){Wi(this.barContainer.children,()=>!0),this.manager.app.renderer.render(this.barContainer,{renderTexture:this.barTexture});return}let t=0;const i=e.gameType.numCols,s=e.getNotedata().at(-1),n=this.manager.app.renderer.screen.height-40;if(this.backing.height=n,this.backing.width=i*6+8,this.overlay.width=i*6+8,this.pivot.x=this.backing.width/2,this.barTexture.resize(i*6,n),!s){Wi(this.barContainer.children,()=>!0),this.manager.app.renderer.render(this.barContainer,{renderTexture:this.barTexture});return}const a=s.beat+(Be(s)?s.hold:0),o=e.getSecondsFromBeat(a),l=e.timingData.getOffset();e.getNotedata().forEach(c=>{let u=this.barContainer.children[t];u||(u=new ke(Z.WHITE),u.width=4,this.barContainer.addChild(u)),u.anchor.set(.5),u.height=1,u.x=(c.col+.5)*6;let h=Ai(0,a,c.beat);if(_.chart.CMod&&(h=Ai(l,o,c.second)),u.y=h*n,u.tint=Bg[Wo(c.beat)],c.type=="Mine"&&(u.tint=8421504),t++,Be(c)){let d=this.barContainer.children[t];d||(d=new ke(Z.WHITE),d.width=4,d.height=2,this.barContainer.addChild(d)),d.anchor.x=.5,d.anchor.y=0,d.x=(c.col+.5)*6;const p=(_.chart.CMod?e.getSecondsFromBeat(c.beat+c.hold)/o:(c.beat+c.hold)/a)*n+1;d.y=u.y,d.height=p-u.y,c.type=="Hold"&&(d.tint=10526880),c.type=="Roll"&&(d.tint=11379586),t++}}),Wi(this.barContainer.children,(c,u)=>u>=t),this.manager.app.renderer.render(this.barContainer,{renderTexture:this.barTexture})}getChart(){return this.manager.chartManager.loadedChart}}const Ye=300,it=150,Xp=[.045,.09,.18,.37,.18,.09,.045];class IT extends gl{max=0;barlines=new xe;backgroundRect=new Nt;background=new xe;backgroundLines=new xe;statText=new xe;meanText;medianText;modeText;stddevText;errorMS=[];texts=new xe;showEase=0;toggled=!1;drag=!1;dragStart=0;lastMode=this.manager.chartManager.getMode();constructor(e){super(e),this.visible=!1,this.backgroundRect.tint=0,this.backgroundRect.alpha=.3,this.background.addChild(this.backgroundRect),this.addChild(this.background),this.addChild(this.backgroundLines),this.eventMode="static",this.on("mousedown",()=>{this.manager.chartManager.getMode()!=Y.Play&&(this.drag=!0,this.dragStart=Date.now(),It.stop("play-widget"))}),window.addEventListener("mousemove",f=>{this.drag&&(this.showEase+=f.movementY/-400)}),window.addEventListener("mouseup",()=>{this.drag&&(Date.now()-this.dragStart>400?this.toggled=this.showEase>.5:this.toggled=!this.toggled,It.animate(this,{0:{showEase:"inherit"},1:{showEase:this.toggled?1:0}},.6,Yt(.11,.71,.33,1.39),()=>{},"play-widget")),this.drag=!1}),this.on("mouseenter",()=>{!this.toggled&&this.manager.chartManager.getMode()!=Y.Play&&It.animate(this,{0:{showEase:"inherit"},1:{showEase:.05}},.6,Yt(.11,.71,.33,1.39),()=>{},"play-widget")}),this.on("mouseleave",()=>{!this.toggled&&this.manager.chartManager.getMode()!=Y.Play&&It.animate(this,{0:{showEase:"inherit"},1:{showEase:0}},.6,Yt(.11,.71,.33,1.39),()=>{},"play-widget")});const t=new Fe("Early",{fontName:"Main",fontSize:15});t.x=-Ye/2+5,t.y=-it-40,t.alpha=.3,this.background.addChild(t);const i=new Fe("Late",{fontName:"Main",fontSize:15});i.anchor.x=1,i.x=Ye/2-5,i.y=-it-40,i.alpha=.3,this.background.addChild(i),this.meanText=new Fe("-",{fontName:"Main",fontSize:15}),this.meanText.anchor.x=.5,this.meanText.x=Ye/4*-1.5,this.meanText.y=-it-70,this.statText.addChild(this.meanText),this.medianText=new Fe("-",{fontName:"Main",fontSize:15}),this.medianText.anchor.x=.5,this.medianText.x=Ye/4*-.5,this.medianText.y=-it-70,this.statText.addChild(this.medianText),this.modeText=new Fe("-",{fontName:"Main",fontSize:15}),this.modeText.anchor.x=.5,this.modeText.x=Ye/4*.5,this.modeText.y=-it-70,this.statText.addChild(this.modeText),this.stddevText=new Fe("-",{fontName:"Main",fontSize:15}),this.stddevText.anchor.x=.5,this.stddevText.x=Ye/4*1.5,this.stddevText.y=-it-70,this.statText.addChild(this.stddevText);const s=new Fe("Mean",{fontName:"Main",fontSize:10});s.anchor.x=.5,s.x=Ye/4*-1.5,s.y=-it-80,this.statText.addChild(s);const n=new Fe("Median",{fontName:"Main",fontSize:10});n.anchor.x=.5,n.x=Ye/4*-.5,n.y=-it-80,this.statText.addChild(n);const a=new Fe("Mode",{fontName:"Main",fontSize:10});a.anchor.x=.5,a.x=Ye/4*.5,a.y=-it-80,this.statText.addChild(a);const o=new Fe("Std Dev.",{fontName:"Main",fontSize:10});o.anchor.x=.5,o.x=Ye/4*1.5,o.y=-it-80,this.statText.addChild(o);const l=new xe,c=new Nt;c.tint=3355443,c.alpha=.3,c.width=Ye/2-10,c.height=30,c.y=-25,c.x=-Ye/4,c.pivot.x=(Ye/2-10)/2,c.pivot.y=15;const u=new Fe("Adjust song offset",{fontName:"Main",fontSize:12});u.anchor.set(.5),u.x=-Ye/4,u.y=-25,l.addChild(c,u),l.eventMode="static",l.addEventListener("mouseenter",()=>{c.alpha=.6}),l.addEventListener("mousedown",f=>{f.stopImmediatePropagation(),this.adjustOffset("song")}),l.addEventListener("mouseleave",()=>{c.alpha=.3}),this.statText.addChild(l);const h=new xe,d=new Nt;d.tint=3355443,d.alpha=.3,d.width=Ye/2-10,d.height=30,d.y=-25,d.x=Ye/4,d.pivot.x=(Ye/2-10)/2,d.pivot.y=15,d.eventMode="static",h.addEventListener("mouseenter",()=>{d.alpha=.6}),h.addEventListener("mouseleave",()=>{d.alpha=.3});const p=new Fe("Adjust global offset",{fontName:"Main",fontSize:12});p.anchor.set(.5),p.x=Ye/4,p.y=-25,h.addChild(d,p),h.eventMode="static",h.addEventListener("mouseenter",()=>{d.alpha=.6}),h.addEventListener("mousedown",f=>{f.stopImmediatePropagation(),this.adjustOffset("global")}),h.addEventListener("mouseleave",()=>{d.alpha=.3}),this.statText.addChild(h),this.addChild(this.background),this.addChild(this.backgroundLines),this.eventMode="static",this.addChild(this.statText),this.addChild(this.barlines),this.addChild(this.texts)}update(){this.visible=!!this.manager.chartManager.gameStats,this.x=-this.manager.chartManager.app.renderer.screen.width/2+20+Ye/2,this.y=this.manager.chartManager.app.renderer.screen.height/2-20,this.backgroundRect.width=Ye+10,this.backgroundRect.height=it+260,this.backgroundRect.x=-Ye/2-5,this.backgroundRect.y=-it-260,this.visible=!!this.manager.chartManager.gameStats;for(const e of this.barlines.children)_.general.smoothAnimations?e.height=(e.targetHeight-e.height)*.2+e.height:e.height=e.targetHeight;this.lastMode!=this.manager.chartManager.getMode()&&(this.lastMode=this.manager.chartManager.getMode(),It.animate(this,{0:{showEase:"inherit"},1:{showEase:this.manager.chartManager.getMode()==Y.Play?1:0}},.6,Yt(.11,.71,.33,1.39),()=>{},"play-widget")),_.general.smoothAnimations?this.y+=(1-Math.abs(this.showEase))*400:this.manager.chartManager.getMode()!=Y.Play&&(this.y+=400)}newLine(){const e=new ke(Z.WHITE);return e.smoothCount=0,e.targetHeight=0,e.anchor.y=1,e.anchor.x=.5,e.height=0,e.visible=!1,e}startPlay(){const e=this.manager.chartManager.gameStats;this.max=0,this.errorMS=[],this.meanText.text="-",this.medianText.text="-",this.modeText.text="-",this.stddevText.text="-",Wi(this.barlines.children,()=>!0),Wi(this.backgroundLines.children,()=>!0),Wi(this.texts.children,()=>!0);const t=qe.getCollection(_.play.timingCollection),i=t.getStandardWindows().length+1,s=Math.round(t.maxWindowMS());for(let p=0;py.type==f&&!y.fake).length),m.tint=14540253,g.tint=14540253,g.name=f,this.texts.addChild(m),this.texts.addChild(g),m.x=-Ye/2+160,g.x=-Ye/2+290,m.y=80/o*n-it-220,g.y=80/o*n++-it-220,m.anchor.y=.5,g.anchor.y=.5,g.anchor.x=1}const l=new Fe("Max Combo",{fontName:"Main",fontSize:15}),c=new Fe("0",{fontName:"Main",fontSize:15});l.tint=14540253,c.tint=14540253,c.name="Combo",this.texts.addChild(l),this.texts.addChild(c),l.x=-Ye/2+160,c.x=-Ye/2+290,l.y=80/o*n-it-220,c.y=80/o*n++-it-220,l.anchor.y=.5,c.anchor.y=.5,c.anchor.x=1;const u=new Fe("0.00 / 0.00",{fontName:"Main",fontSize:20});u.tint=14540253,u.x=-Ye/2+225,u.y=-it-112,u.name="Score",this.texts.addChild(u),u.anchor.set(.5);const h=new Fe("Score / Current Score",{fontName:"Main",fontSize:13});h.tint=8947848,h.x=-Ye/2+225,h.y=-it-135,this.texts.addChild(h),h.anchor.set(.5);const d=new Fe("Play Statistics",{fontName:"Main",fontSize:13});d.y=-it-245,d.anchor.set(.5),this.texts.addChild(d),e.onJudge((p,f)=>{let m="";(ni(f)||Vi(f))&&(m=f.id),Dr(f)&&(m=f.noteType),ms(f)&&(m="Mine");const g=this.texts.getChildByName(m);if(Dr(f)){const b=g.text.split(" / ")[1];g.text=e.getCount(f)+" / "+b}else yn(f)||(g.text=e.getCount(f)+"");if(this.texts.getChildByName("Combo").text=e.getMaxCombo()+"",this.texts.getChildByName("Score").text=ne(e.getScore()*100,2).toFixed(2)+" / "+ne(e.getCumulativeScore()*100,2).toFixed(2),ni(f)||!Vi(f))return;const y=Math.round(p*1e3);for(let b=-3;b<=3;b++)this.barlines.children[y+s+b]&&(this.barlines.children[y+s+b].smoothCount+=Xp[b+3],this.barlines.children[y+s+b].visible=!0,this.barlines.children[y+s+b].smoothCount>this.max&&(this.modeText.text=y+"ms",this.max=this.barlines.children[y+s+b].smoothCount));this.errorMS.push(p*1e3),this.meanText.text=AE(this.errorMS).toFixed(2)+"ms",this.medianText.text=fl(this.errorMS).toFixed(2)+"ms",this.stddevText.text=ug(this.errorMS).toFixed(2)+"ms",this.redraw()})}redraw(){for(const e of this.barlines.children)e.targetHeight=e.smoothCount*(it-20)/this.max}adjustOffset(e){const t=this.manager.chartManager.gameStats;if(!t)return;const i=Math.round(t.getMedian()*1e3)/1e3;if(i==0)return;t.applyOffset(-i),this.barlines.children.forEach(o=>{o.smoothCount=0});const s=qe.getCollection(_.play.timingCollection),n=Math.round(s.maxWindowMS());t.getDataPoints().forEach(o=>{if(ni(o.judgment)||!Vi(o.judgment))return;const l=Math.round(o.error*1e3);for(let c=-3;c<=3;c++)this.barlines.children[l+n+c]&&(this.barlines.children[l+n+c].smoothCount+=Xp[c+3],this.barlines.children[l+n+c].visible=!0,this.barlines.children[l+n+c].smoothCount>this.max&&(this.modeText.text=l+"ms",this.max=this.barlines.children[l+n+c].smoothCount))}),this.redraw();const a=e=="global"?_.play.offset:this.manager.app.chartManager.loadedChart.timingData.getOffset();if(e=="global")_.play.offset=ne(_.play.offset-i,3);else if(e=="song"){const o=this.manager.app.chartManager.loadedChart.timingData.hasChartOffset()?this.manager.app.chartManager.loadedChart.timingData:this.manager.app.chartManager.loadedSM.timingData;o.setOffset(ne(o.getOffset()-i,3))}Ce.create(`Adjusted ${e} offset from ${ne(a,3).toFixed(3)} to ${ne(a-i,3).toFixed(3)}`),this.manager.app.chartManager.setBeat(this.manager.app.chartManager.getBeat())}}class ha extends xe{pool=[];options;constructor(e){super(),this.options=e}createChild(){if(this.pool.length==0&&this.options.maxPoolSize!==void 0&&this.children.length>=this.options.maxPoolSize)return;const e=this.pool.pop()??this.options.create();return this.addChild(e),e._disabledTime=Date.now(),e}destroyChild(e){this.children.includes(e)&&(e.removeFromParent(),e.removeAllListeners(),e.eventMode="auto",e._disabledTime=Date.now(),this.pool.push(e))}destroyAll(){this.children.forEach(e=>e._disabledTime=Date.now()),this.pool.push(...this.children),this.children.forEach(e=>{e.removeAllListeners(),e.eventMode="auto"}),this.removeChildren()}_render(e){super._render(e);const t=Date.now();for(;t-this.pool[0]?._disabledTime>(this.options.destroyTimer??5e3);)this.pool.shift().destroy()}}const Lr={BPMS:9182254,STOPS:4934913,DELAYS:217453,WARPS:9243998,FAKES:4868682,COMBOS:939078,SPEEDS:2968693,LABELS:7747359,SCROLLS:3557006,TIMESIGNATURES:5392684,TICKCOUNTS:1594906,BGCHANGES:8460415,FGCHANGES:8857115,ATTACKS:1856083};class kT extends xe{renderer;areaPool=new ha({create:()=>{const e=new ke(Z.WHITE);return Object.assign(e,{alpha:.2,width:this.renderer.chart.gameType.notefieldWidth+128}),e.anchor.set(.5,0),e}});timingAreaMap=new Map;timingEvents=[];timingDirty=!0;constructor(e){super(),this.renderer=e,this.addChild(this.areaPool);const t=()=>this.timingDirty=!0;$.on("timingModified",t),this.on("destroyed",()=>$.off("timingModified",t))}update(e,t){this.timingDirty&&(this.timingAreaMap.clear(),this.areaPool.destroyAll(),this.timingDirty=!1,this.timingEvents=this.renderer.chart.timingData.getTimingData("STOPS","WARPS","DELAYS","FAKES")),this.visible=this.renderer.shouldDisplayBarlines();for(const i of this.timingEvents){if(i.beat>t)break;if(this.shouldDrawEvent(i,e,t)&&!this.timingAreaMap.has(i)){const s=this.areaPool.createChild();if(!s)break;s.tint=Lr[i.type],this.timingAreaMap.set(i,s)}}for(const[i,s]of this.timingAreaMap.entries()){if(!this.shouldDrawEvent(i,e,t)){this.timingAreaMap.delete(i),this.areaPool.destroyChild(s);continue}let n=_.chart.CMod?this.renderer.getYPosFromSecond(i.second):this.renderer.getYPosFromBeat(i.beat),a=n;switch(i.type){case"STOPS":case"DELAYS":{_.chart.CMod&&i.value>0?a=this.renderer.getYPosFromSecond(i.second+i.value):i.value<0&&(a=this.renderer.getYPosFromBeat(this.renderer.chart.getBeatFromSeconds(i.second+1e-4)));break}case"FAKES":{a=this.renderer.getYPosFromBeat(i.beat+i.value);break}case"WARPS":{_.chart.CMod||(a=this.renderer.getYPosFromBeat(i.beat+i.value));break}}a0)||e.type=="WARPS"&&_.chart.CMod?!1:e.beat<=i}}function Ur(r,e,t){return(r<<16)+(e<<8)+t}function Pg(r,e){let t=r>>16,i=r>>8&255,s=r&255;return t=Ve(t*e,0,255),i=Ve(i*e,0,255),s=Ve(s*e,0,255),Ur(t,i,s)}function Cc(r,e,t){const[i,s,n]=r.match(/\w\w/g).map(d=>parseInt(d,16)),[a,o,l]=e.match(/\w\w/g).map(d=>parseInt(d,16)),c=Math.round(i+(a-i)*t).toString(16).padStart(2,"0"),u=Math.round(s+(o-s)*t).toString(16).padStart(2,"0"),h=Math.round(n+(l-n)*t).toString(16).padStart(2,"0");return"#"+c+u+h}class Ah{static active=!1;static popup;static clickOutside;static moveInterval;static exitTimeout;static draggedElement;static dragOffsetX=0;static dragOffsetY=0;static grid;static leftovers;static boundaryCache=[];static open(){this.active||(this.popup=this.build(),document.getElementById("popups")?.appendChild(this.popup),this.clickOutside=e=>{!this.popup?.contains(e.target)&&!this.draggedElement?.contains(e.target)&&!document.getElementById("arrange-tracks")?.contains(e.target)&&this.close()},setTimeout(()=>window.addEventListener("click",this.clickOutside,!0)),this.popup.style.display="none",setTimeout(()=>this.movePosition()),clearTimeout(this.exitTimeout),this.moveInterval=setInterval(()=>this.movePosition(),150),this.active=!0)}static build(){const e=document.createElement("div");e.classList.add("popup"),e.id="timing-track-order";const t=document.createElement("div");t.classList.add("popup-zoomer"),e.appendChild(t);const i=document.createElement("div");i.classList.add("container"),t.appendChild(i);const s=document.createElement("div");s.classList.add("title"),s.innerText="Arrange Timing Tracks";const n=document.createElement("div");n.classList.add("track-grid-options");const a=document.createElement("button");a.classList.add("delete"),a.innerText="Reset",a.onclick=()=>{_.chart.timingEventOrder=structuredClone(Ho.chart.timingEventOrder),this.clearBoundaries(),this.grid?.replaceChildren(),this.leftovers?.replaceChildren();const c=[...ar];for(const h of _.chart.timingEventOrder.left){const d=this.makeDraggableTrack(h);d.classList.add("left"),this.grid?.appendChild(d),c.splice(c.indexOf(h),1)}const u=document.createElement("div");u.classList.add("draggable-track"),u.innerText="PLAYFIELD",u.style.backgroundColor="#2D2D2D",u.style.padding="20px 10px",u.style.writingMode="horizontal-tb",u.addEventListener("mousedown",h=>this.startDragging(h,u)),u.dataset.type="PLAYFIELD",this.grid?.appendChild(u);for(const h of _.chart.timingEventOrder.right){const d=this.makeDraggableTrack(h);d.classList.add("right"),this.grid?.appendChild(d),c.splice(c.indexOf(h),1)}for(const h of c)this.leftovers?.appendChild(this.makeLeftoverTrack(h))},this.grid=document.createElement("div"),this.grid.classList.add("track-grid"),i.appendChild(s),i.appendChild(this.grid),i.appendChild(n);const o=[...ar];for(const c of _.chart.timingEventOrder.left){const u=this.makeDraggableTrack(c);u.classList.add("left"),this.grid.appendChild(u),o.splice(o.indexOf(c),1)}const l=document.createElement("div");l.classList.add("draggable-track"),l.innerText="PLAYFIELD",l.style.backgroundColor="#2D2D2D",l.style.padding="20px 10px",l.style.writingMode="horizontal-tb",l.addEventListener("mousedown",c=>this.startDragging(c,l)),l.dataset.type="PLAYFIELD",this.grid.appendChild(l);for(const c of _.chart.timingEventOrder.right){const u=this.makeDraggableTrack(c);u.classList.add("right"),this.grid.appendChild(u),o.splice(o.indexOf(c),1)}this.leftovers=document.createElement("div"),this.leftovers.classList.add("track-selector"),n.appendChild(this.leftovers),n.appendChild(a);for(const c of o)this.leftovers.appendChild(this.makeLeftoverTrack(c));return e}static makeDraggableTrack(e){const t=document.createElement("div");t.classList.add("draggable-track");const i=document.createElement("div");i.classList.add("draggable-track-text"),i.innerText=e,t.style.backgroundColor=Cc(Lr[e].toString(16).padStart(6,"0"),"#333333",.7),t.appendChild(i);let s=!0;const n=document.createElement("img");return n.src=He.TRASH,n.style.width="16px",n.addEventListener("click",()=>{if(!s)return;s=!1,this.deleteTrack(e),t.classList.add("exiting"),setTimeout(()=>t.remove(),400);const a=this.makeLeftoverTrack(e);a.classList.add("entering"),setTimeout(()=>a.classList.remove("entering"),400),this.leftovers?.appendChild(a),this.clearBoundaries()}),t.appendChild(n),t.addEventListener("mousedown",a=>{s&&a.target!=n&&this.startDragging(a,t)}),t.dataset.type=e,t}static makeLeftoverTrack(e){const t=document.createElement("div");t.classList.add("leftover-track");const i=document.createElement("img");i.src=He.PLUS,t.append(i);const s=document.createElement("div");s.classList.add("leftover-track-text"),s.innerText=e,t.style.backgroundColor=Cc(Lr[e].toString(16).padStart(6,"0"),"#333333",.7),t.appendChild(s);let n=0,a=0,o=!1,l=!1;return t.addEventListener("mousedown",()=>{o=!0}),t.addEventListener("mousemove",c=>{if(!(!o||l)&&(n+=c.movementX,a+=c.movementY,n*n+a*a>15)){l=!0;const u=this.makeDraggableTrack(e);this.grid?.appendChild(u),this.clearBoundaries();const h=t.getBoundingClientRect(),d=this.getClosestSlot(h.left),p=_.chart.timingEventOrder.left.concat(["PLAYFIELD"],_.chart.timingEventOrder.right);p.splice(d,0,e),this.saveOptions(p),p.forEach(f=>{const m=this.grid?.querySelector(`div[data-type=${f}]`);this.grid?.appendChild(m),f!="PLAYFIELD"&&(m?.classList.remove("left","right"),_.chart.timingEventOrder.left.includes(f)&&m?.classList.add("left"),_.chart.timingEventOrder.right.includes(f)&&m?.classList.add("right"))}),this.startDragging(c,u,c.clientX,c.clientY),_.general.smoothAnimations?(t.style.width=t.clientWidth+"px",t.style.transition="0.4s cubic-bezier(0, 0.91, 0.34, 1.05)",setTimeout(()=>{t.style.width="0px",t.style.opacity="0",t.style.padding="0",t.style.fontSize="0"},10),setTimeout(()=>t.remove(),400)):t.remove()}}),t.addEventListener("mouseup",()=>{if(!o||l)return;l=!0,_.chart.timingEventOrder.right.push(e),_.general.smoothAnimations?(t.style.width=t.clientWidth+"px",t.style.transition="0.4s cubic-bezier(0, 0.91, 0.34, 1.05)",setTimeout(()=>{t.style.width="0px",t.style.opacity="0",t.style.padding="0",t.style.fontSize="0"},10),setTimeout(()=>t.remove(),400)):t.remove();const c=this.makeDraggableTrack(e);c.classList.add("entering"),c.classList.add("right"),setTimeout(()=>c.classList.remove("entering"),400),this.grid?.appendChild(c),this.clearBoundaries()}),t}static startDragging(e,t,i,s){if(!this.popup)return;this.draggedElement=t.cloneNode(!0),this.draggedElement.style.position="fixed";const n=t.getBoundingClientRect(),a=this.popup.getBoundingClientRect();!i||!s?(this.dragOffsetX=e.clientX-n.left,this.dragOffsetY=e.clientY-n.top,this.draggedElement.style.left=n.left-a.left+"px",this.draggedElement.style.top=n.top-a.top+"px"):(this.dragOffsetX=n.width/2,this.dragOffsetY=n.height/4*3,this.draggedElement.style.left=i-n.width/2-a.left+"px",this.draggedElement.style.top=s-n.height/4*3-a.top+"px",this.draggedElement.classList.add("entering")),this.draggedElement.style.boxShadow="6px 6px 6px #222",this.draggedElement.style.transition="none",t.style.opacity="0.03",this.popup.appendChild(this.draggedElement);const o=_.chart.timingEventOrder.left.concat(["PLAYFIELD"],_.chart.timingEventOrder.right),l=t.dataset.type;let c=o.indexOf(l);const u=o.indexOf(l),h=p=>{this.draggedElement.style.left=p.clientX-this.dragOffsetX-a.left+"px",this.draggedElement.style.top=p.clientY-this.dragOffsetY-a.top+"px";let f=this.getClosestSlot(p.clientX-this.dragOffsetX);Math.abs(p.clientY-this.dragOffsetY-a.top-(n.top-a.top))>140&&(f=u),c!=f&&(o.splice(c,1),o.splice(f,0,l),this.saveOptions(o),o.forEach(m=>{const g=this.grid?.querySelector(`div[data-type=${m}]`);this.grid?.appendChild(g),m!="PLAYFIELD"&&(g?.classList.remove("left","right"),_.chart.timingEventOrder.left.includes(m)&&g?.classList.add("left"),_.chart.timingEventOrder.right.includes(m)&&g?.classList.add("right"))}),l!="PLAYFIELD"&&(this.draggedElement?.classList.remove("left","right"),_.chart.timingEventOrder.left.includes(l)&&this.draggedElement?.classList.add("left"),_.chart.timingEventOrder.right.includes(l)&&this.draggedElement?.classList.add("right")),c=f)};window.addEventListener("mousemove",h);const d=()=>{this.draggedElement?.remove(),this.draggedElement=void 0,window.removeEventListener("mousemove",h),t.style.opacity="",this.clearBoundaries(),window.removeEventListener("mouseup",d)};window.addEventListener("mouseup",d)}static saveOptions(e){const t=e.indexOf("PLAYFIELD");t!=-1&&(_.chart.timingEventOrder.left=e.slice(0,t),_.chart.timingEventOrder.right=e.slice(t+1))}static deleteTrack(e){const t=_.chart.timingEventOrder.left.indexOf(e);t!=-1&&_.chart.timingEventOrder.left.splice(t,1);const i=_.chart.timingEventOrder.right.indexOf(e);i!=-1&&_.chart.timingEventOrder.right.splice(i,1)}static movePosition(){if(!this.popup)return;const e=document.getElementById("arrange-tracks");if(!e)return;this.popup.style.display="";const t=e.getBoundingClientRect(),i=t.left+t.width/2,s=this.popup.clientWidth,n=s/2+15,a=window.innerWidth-s/2-15;this.popup.style.left=`${Ve(i,n,a)}px`;const o=t.top+t.height/2;this.popup.style.top=`${t.top+t.height}px`,o+this.popup.clientHeight>window.innerHeight-15&&(this.popup.style.transform="translate(-50%, -100%)",this.popup.style.top=`${t.top-t.height/2}px`)}static getClosestSlot(e){this.boundaryCache.length==0&&this.getBoundaries();let t=-1,i=999999,s=999999;for(let n=0;ns)break;s=a}return t}static getBoundaries(){if(this.grid){for(const e of this.grid.children)this.boundaryCache.push([e,e.getBoundingClientRect()]);this.boundaryCache.sort((e,t)=>e[1].left-t[1].left)}}static clearBoundaries(){this.boundaryCache=[]}static close(){!this.popup||!this.active||(window.removeEventListener("click",this.clickOutside,!0),this.popup.classList.add("exiting"),this.exitTimeout=setTimeout(()=>this.popup.remove(),200),this.active=!1,clearInterval(this.moveInterval),this.clearBoundaries())}}class BT extends gl{view;playbackBar;skipStart;skipEnd;play;playIcon;record;playtest;timeCounter;beatCounter;min;sec;millis;beat;beatDropdown;editBar;editSteps;editTiming;stepsContainer;timingContainer;editChoiceContainer;addTimingEvent;arrangeTimingTracks;noteArrows=[];noteArrowMask;lastTime=-1;lastBeat=-1;lastMode=Y.Edit;lastTimingMode=De.Off;lastHover=0;lastPlaying=!1;hovering=!1;trackingMovement=!0;idleFrames=0;lastBounds;constructor(e){super(e);const t=document.createElement("div");t.id="status-widget",document.getElementById("view-wrapper")?.appendChild(t),Ie.viewMode&&t.classList.add("collapsed"),this.playbackBar=document.createElement("div"),this.playbackBar.classList.add("playback-bar"),this.editBar=document.createElement("div"),this.editBar.classList.add("edit-bar"),this.skipStart=document.createElement("button");const i=document.createElement("img");i.src=He.SKIP_START,i.style.height="36px",this.skipStart.appendChild(i),this.skipStart.onclick=()=>{this.manager.chartManager.setBeat(0)},Mt(this.skipStart,{content:"Skip to start"+this.keybind("jumpSongStart")}),this.skipEnd=document.createElement("button");const s=document.createElement("img");s.style.height="36px",s.src=He.SKIP_END,this.skipEnd.appendChild(s),this.skipEnd.onclick=()=>{this.manager.chartManager.setBeat(this.manager.chartManager.loadedChart.getBeatFromSeconds(this.manager.chartManager.chartAudio.getSongLength()))},Mt(this.skipEnd,{content:"Skip to end"+this.keybind("jumpSongEnd")}),this.play=document.createElement("button");const n=document.createElement("img");n.src=He.PLAY,this.play.appendChild(n),this.playIcon=n,this.play.onclick=()=>{(this.manager.chartManager.getMode()==Y.Record||this.manager.chartManager.getMode()==Y.Play)&&this.manager.chartManager.setMode(Y.Edit),this.manager.chartManager.playPause()},Mt(this.play,{content:"Play/Pause"+this.keybind("playback")}),this.record=document.createElement("button");const a=document.createElement("img");a.style.height="36px",a.src=He.RECORD,this.record.appendChild(a),this.record.onclick=()=>{this.manager.chartManager.setMode(Y.Record)},Mt(this.record,{content:"Record"+this.keybind("recordMode")}),(Ie.viewMode||!Ie.recordMode)&&(this.record.style.display="none"),this.playtest=document.createElement("button");const o=document.createElement("img");o.style.height="30px",o.src=He.PLAYTEST,this.playtest.appendChild(o),this.playtest.onclick=()=>{this.manager.chartManager.setMode(Y.Play)},Mt(this.playtest,{content:"Playtest"+this.keybind("playMode")}),Ie.playMode||(this.playtest.style.display="none");const l=document.createElement("div");l.classList.add("playback-separator"),this.timeCounter=document.createElement("div"),this.timeCounter.classList.add("playback-counter");const c=document.createElement("div");c.style.display="flex",c.classList.add("playback-counter-main");const u=document.createElement("div");u.classList.add("inlineEdit"),u.innerText="-",u.spellcheck=!1,u.contentEditable="true",u.style.maxWidth="27px",u.onkeydown=M=>{M.key=="Enter"&&u.blur(),M.key=="Tab"&&h.focus(),M.key=="Escape"&&(u.innerText=Math.floor(Math.abs(this.manager.chartManager.getTime())/60).toString().padStart(2,"0"),u.blur())},u.onfocus=()=>setTimeout(()=>this.selectText(u),25),u.onblur=()=>this.updateTime(),u.ondragstart=M=>M.preventDefault();const h=document.createElement("div");h.classList.add("inlineEdit"),h.innerText="-",h.spellcheck=!1,h.contentEditable="true",h.style.maxWidth="18px",h.onkeydown=M=>{M.key=="Enter"&&h.blur(),M.key=="Tab"&&d.focus(),M.key=="Escape"&&(h.innerText=Math.floor(Math.abs(this.manager.chartManager.getTime())%60).toString().padStart(2,"0"),h.blur())},h.onfocus=()=>setTimeout(()=>this.selectText(h),25),h.onblur=()=>this.updateTime(),h.ondragstart=M=>M.preventDefault();const d=document.createElement("div");d.classList.add("inlineEdit"),d.innerText="-",d.spellcheck=!1,d.contentEditable="true",d.style.maxWidth="27px",d.onkeydown=M=>{M.key=="Enter"&&d.blur(),M.key=="Tab"&&u.focus(),M.key=="Escape"&&(d.innerText=(ne(Math.abs(this.manager.chartManager.getTime())%1,3)*1e3).toString().padStart(3,"0"),d.blur())},d.onfocus=()=>setTimeout(()=>this.selectText(d),25),d.onblur=()=>this.updateTime(),d.ondragstart=M=>M.preventDefault(),this.min=u,this.sec=h,this.millis=d;const p=document.createElement("div");p.classList.add("playback-counter-label"),p.innerText="Time",c.appendChild(u),c.appendChild(document.createTextNode(":")),c.appendChild(h),c.appendChild(document.createTextNode(".")),c.appendChild(d),this.timeCounter.appendChild(c),this.timeCounter.appendChild(p);const f=document.createElement("div");f.classList.add("playback-separator"),this.beatCounter=document.createElement("div"),this.beatCounter.classList.add("playback-counter");const m=document.createElement("div");m.classList.add("playback-counter-main","inlineEdit"),m.innerText="-",m.spellcheck=!1,m.contentEditable="true",m.onkeydown=M=>{if(M.key=="Enter"&&m.blur(),M.key=="Escape"){if(this.beatDropdown.value=="Measure"){const P=this.manager.chartManager.loadedChart?.timingData?.getMeasure(this.manager.chartManager.getBeat())??this.manager.chartManager.getBeat()/4;m.innerText=ne(P,3).toFixed(3)}else m.innerText=ne(this.manager.chartManager.getBeat(),3).toFixed(3);m.blur()}},m.onfocus=()=>{setTimeout(()=>this.selectText(m),25)},m.onblur=()=>this.updateBeat(),m.ondragstart=M=>M.preventDefault(),this.beat=m,this.beatDropdown=pi.create(["Beat","Measure"],"Beat"),this.beatDropdown.view.querySelector(".dropdown-selected").classList.add("playback-counter-label"),this.beatCounter.appendChild(m),this.beatCounter.appendChild(this.beatDropdown.view),this.beatDropdown.onChange(()=>{if(this.beatDropdown.value=="Measure"){const M=this.manager.chartManager.loadedChart?.timingData?.getMeasure(this.manager.chartManager.getBeat())??this.manager.chartManager.getBeat()/4;m.innerText=ne(M,3).toFixed(3)}else m.innerText=ne(this.manager.chartManager.getBeat(),3).toFixed(3)}),this.playbackBar.appendChild(this.skipStart),this.playbackBar.appendChild(this.skipEnd),this.playbackBar.appendChild(this.play),this.playbackBar.appendChild(this.record),this.playbackBar.appendChild(this.playtest),this.playbackBar.appendChild(l),this.playbackBar.appendChild(this.timeCounter),this.playbackBar.appendChild(f),this.playbackBar.appendChild(this.beatCounter),this.editSteps=document.createElement("button"),this.editSteps.classList.add("edit-fancy-button");const g=document.createElement("img");g.src=He.ADD,this.editSteps.appendChild(g),this.editSteps.appendChild(document.createTextNode("Edit Steps")),this.editSteps.onclick=()=>{this.manager.chartManager.editTimingMode=De.Off},this.editSteps.style.background="rgba(255,255,255,0.15)",this.editTiming=document.createElement("button"),this.editTiming.classList.add("edit-fancy-button");const y=document.createElement("img");y.src=He.SPEED,this.editTiming.appendChild(y),this.editTiming.appendChild(document.createTextNode("Edit Timing")),this.editTiming.onclick=()=>{this.manager.chartManager.editTimingMode=De.Edit};const b=document.createElement("div");b.classList.add("playback-separator");const A=document.createElement("div");A.classList.add("edit-bar-left"),A.appendChild(this.editSteps),A.appendChild(this.editTiming),A.appendChild(b),this.editBar.appendChild(A),this.editChoiceContainer=document.createElement("div"),this.editChoiceContainer.classList.add("edit-choice-container"),this.stepsContainer=document.createElement("div"),this.stepsContainer.classList.add("edit-steps-container"),this.timingContainer=document.createElement("div"),this.timingContainer.classList.add("edit-timing-container"),this.editChoiceContainer.appendChild(this.stepsContainer),this.editChoiceContainer.appendChild(this.timingContainer),this.addTimingEvent=document.createElement("button");const v=document.createElement("img");v.style.height="32px",v.src=He.ADD_EVENT,this.addTimingEvent.appendChild(v),this.addTimingEvent.onclick=()=>{this.manager.chartManager.editTimingMode==De.Add?this.manager.chartManager.editTimingMode=De.Edit:this.manager.chartManager.editTimingMode=De.Add},this.timingContainer.appendChild(this.addTimingEvent),Mt(this.addTimingEvent,{content:"Add timing events"}),this.arrangeTimingTracks=document.createElement("button");const E=document.createElement("img");E.style.height="32px",E.src=He.EYE,this.arrangeTimingTracks.appendChild(E),this.arrangeTimingTracks.onclick=()=>{Ah.active?Ah.close():Ah.open()},this.arrangeTimingTracks.id="arrange-tracks",this.timingContainer.appendChild(this.arrangeTimingTracks),Mt(this.arrangeTimingTracks,{content:"Arrange timing tracks"}),this.editBar.appendChild(this.editChoiceContainer);const C=document.createElement("div");C.classList.add("note-placeholder-right"),this.stepsContainer.appendChild(C),$.on("resize",()=>{this.trackingMovement=!0,this.idleFrames=5}),$.on("chartLoaded",()=>{this.stepsContainer.replaceChildren(),this.noteArrows.forEach(P=>{this.removeChild(P.sprite),this.removeChild(P.bg),this.removeChild(P.highlight)}),this.noteArrows=[];const M=document.createElement("div");if(M.classList.add("note-placeholder-right"),this.stepsContainer.appendChild(M),!!this.manager.chartManager.loadedChart){for(const P of this.manager.chartManager.loadedChart.gameType.editNoteTypes){const k=this.manager.chartManager.chartView.getNotefield().getNoteSprite({type:P,beat:0,col:0,quant:4,second:0,warped:!1,fake:!1});k.width=32,k.height=32;const N=new ke(Z.WHITE);N.tint=0,N.alpha=.5,N.width=48,N.height=48,N.anchor.set(.5);const H=new Nt("noBorder");H.alpha=0,H.width=48,H.height=48,H.pivot.x=24,H.pivot.y=24;const T=document.createElement("button");T.style.height="48px",T.style.width="48px",T.classList.add("note-placeholder"),T.onclick=()=>{this.manager.chartManager.setEditingNoteType(P)},Mt(T,{content:P+this.keybind("noteType"+P)});const S={element:T,sprite:k,type:P,bg:N,highlight:H,hovered:!1};T.onmouseover=()=>{S.hovered=!0},T.onmouseleave=()=>{S.hovered=!1},this.addChild(N),this.addChild(k),this.addChild(H);const w=T.getBoundingClientRect();k.position.y=w.top-this.manager.app.view.clientHeight/2-this.manager.app.view.getBoundingClientRect().top+24,k.position.x=w.left-this.manager.app.view.clientWidth/2+24,N.position=k.position,this.noteArrows.push(S)}this.stepsContainer.replaceChildren(...this.noteArrows.map(P=>P.element),M),this.trackingMovement=!0,this.idleFrames=5}}),this.noteArrowMask=new ke(Z.WHITE),this.noteArrowMask.height=48,this.noteArrowMask.width=2500,this.noteArrowMask.anchor.y=1,this.noteArrowMask.anchor.x=.5,this.addChild(this.noteArrowMask),this.mask=this.noteArrowMask,t.onmouseenter=()=>{this.lastHover=Date.now(),this.hovering=!0,this.view.style.opacity="",this.view.style.transition=""},t.onmouseleave=()=>this.hovering=!1,t.appendChild(this.playbackBar),t.appendChild(this.editBar),this.view=t,t.style.display="none"}update(){this.view.style.display=this.manager.chartManager.loadedSM&&Ie.status?"":"none";const e=this.manager.chartManager.getTime();this.lastTime!=e&&(document.activeElement!=this.min&&(this.min.innerText=(e<0?"-":"")+Math.floor(Math.abs(e)/60).toString().padStart(2,"0")),document.activeElement!=this.sec&&(this.sec.innerText=Math.floor(Math.abs(e)%60).toString().padStart(2,"0")),document.activeElement!=this.millis&&(this.millis.innerText=(ne(Math.abs(e)%1,3)*1e3).toString().padStart(3,"0")),this.lastTime=e);const t=this.manager.chartManager.getBeat();if(this.lastBeat!=t){if(document.activeElement!=this.beat)if(this.beatDropdown.value=="Measure"){const o=this.manager.chartManager.loadedChart?.timingData?.getMeasure(t)??t/4;this.beat.innerText=ne(o,3).toFixed(3)}else this.beat.innerText=ne(t,3).toFixed(3);this.lastBeat=t}const i=this.manager.chartManager.getMode(),s=this.manager.chartManager.editTimingMode;if(this.lastMode!=i){switch(i){case Y.Edit:this.skipStart.disabled=!1,this.skipEnd.disabled=!1,this.record.disabled=!1,this.playtest.disabled=!1,this.min.contentEditable="true",this.sec.contentEditable="true",this.millis.contentEditable="true",this.beat.contentEditable="true",this.record.style.background="",this.playtest.style.background="",this.view.style.opacity="",this.view.style.transition="",this.view.classList.remove("collapsed"),this.beatDropdown.disabled=!1;break;case Y.Record:this.lastHover=Date.now(),this.skipStart.disabled=!0,this.skipEnd.disabled=!0,this.record.disabled=!1,this.record.style.background="rgba(170, 0, 0, 0.35)",this.playtest.disabled=!0,this.min.contentEditable="false",this.sec.contentEditable="false",this.millis.contentEditable="false",this.beat.contentEditable="false",s!=De.Off&&(this.visible=!1),this.view.classList.add("collapsed"),this.beatDropdown.closeDropdown(),this.beatDropdown.disabled=!0;break;case Y.Play:this.lastHover=Date.now(),this.skipStart.disabled=!0,this.skipEnd.disabled=!0,this.record.disabled=!0,this.playtest.disabled=!1,this.playtest.style.background="rgba(12, 97, 31, 0.35)",this.min.contentEditable="false",this.sec.contentEditable="false",this.millis.contentEditable="false",this.beat.contentEditable="false",s!=De.Off&&(this.visible=!1),this.view.classList.add("collapsed"),this.beatDropdown.closeDropdown(),this.beatDropdown.disabled=!0;break;case Y.View:this.lastHover=Date.now(),this.skipStart.disabled=!1,this.skipEnd.disabled=!1,this.record.disabled=!0,this.playtest.disabled=!1,this.min.contentEditable="true",this.sec.contentEditable="true",this.millis.contentEditable="true",this.beat.contentEditable="true",s!=De.Off&&(this.visible=!1),this.view.classList.add("collapsed"),this.beatDropdown.closeDropdown(),this.beatDropdown.disabled=!0}this.trackingMovement=!0,this.idleFrames=5,this.lastMode=i}if(this.lastTimingMode!=s){switch(s){case De.Off:this.visible=!0,this.stepsContainer.style.transform="",this.timingContainer.style.transform="",this.editSteps.style.background="rgba(255,255,255,0.15)",this.editTiming.style.background="";break;case De.Add:this.addTimingEvent.style.background="rgba(255,255,255,0.15)";break;case De.Edit:this.addTimingEvent.style.background=""}(this.lastTimingMode==De.Off&&s!=De.Off||this.lastTimingMode!=De.Off&&s==De.Off)&&this.manager.chartManager.clearSelections(),this.trackingMovement=!0,this.idleFrames=5,this.lastTimingMode=s,this.stepsContainer.style.transform=s==De.Off?"":"translateY(-48px)",this.timingContainer.style.transform=s==De.Off?"":"translateY(-48px)",this.editSteps.style.background=s==De.Off?"rgba(255,255,255,0.15)":"",this.editTiming.style.background=s==De.Off?"":"rgba(255,255,255,0.15)"}const n=this.manager.chartManager.chartAudio.isPlaying();if(this.lastPlaying!=n&&(this.playIcon.src=n?He.STOP:He.PLAY,this.lastPlaying=n),this.playIcon.style.height=this.manager.chartManager.chartAudio.isPlaying()?"28px":"",(i==Y.Play||i==Y.Record)&&this.view.style.opacity==""&&!this.hovering&&Date.now()-this.lastHover>3e3&&(this.view.style.opacity="0.2",this.view.style.transition="2s cubic-bezier(.11,.72,.51,1.14)"),this.trackingMovement){const o=this.noteArrows[0];if(o){const c=o.element.getBoundingClientRect();this.noteArrows.forEach((u,h)=>{u.sprite.position.y=c.top-this.manager.app.view.clientHeight/2-this.manager.app.view.getBoundingClientRect().top+24,u.sprite.position.x=c.left-this.manager.app.view.clientWidth/2+24+h*48,u.bg.position=u.sprite.position,u.highlight.position=u.sprite.position}),this.lastBounds&&Math.abs(this.lastBounds.top-c.top)+Math.abs(this.lastBounds.left-c.left)==0&&(this.idleFrames--,this.idleFrames<0&&(this.trackingMovement=!1,this.lastBounds=void 0,s!=De.Off&&(this.visible=!1))),this.lastBounds=c}const l=this.view.getBoundingClientRect();this.noteArrowMask.y=l.bottom-this.manager.app.view.clientHeight/2-this.manager.app.view.getBoundingClientRect().top}const a=this.manager.chartManager.getEditingNoteType();this.noteArrows.forEach(o=>{if(_.general.smoothAnimations){const l=a==o.type?.15:o.hovered?.05:0;o.highlight.alpha=(l-o.highlight.alpha)*.3+o.highlight.alpha}else o.highlight.alpha=a==o.type?.15:o.hovered?.05:0})}selectText(e){const t=window.getSelection(),i=document.createRange();!t||!i||(i.selectNodeContents(e),t.removeAllRanges(),t.addRange(i))}updateTime(){this.millis.innerText=this.millis.innerText.padEnd(3,"0").slice(0,3);const e=this.parseString(this.min),t=this.parseString(this.sec),i=this.parseString(this.millis);if(e===null||t===null||i===null){this.lastTime=-999;return}let s=e*60+t+i/1e3;s>9999999&&(s=9999999),this.manager.chartManager.setTime(s),this.lastTime=-999}updateBeat(){let e=this.parseString(this.beat);if(e===null){this.lastBeat=-999;return}this.beatDropdown.value=="Measure"&&(e=this.manager.chartManager.loadedChart?.timingData?.getBeatFromMeasure(e)??e*4),e>9999999&&(e=9999999),this.manager.chartManager.setBeat(e),this.lastBeat=-999}parseString(e){try{const t=Vr.evaluate(e.innerText);return!isFinite(t)||t<0?0:t}catch{return null}}keybind(e){const t=$e.getKeybindString(e);return t==""?"":" ("+t+")"}}class PT extends xe{app;chartManager;children=[];constructor(e){super(),this.app=e.app,this.chartManager=e,this.addChild(new MT(this)),this.addChild(new IT(this)),this.addChild(new BT(this)),this.addChild(new la(this)),this.zIndex=2}update(){this.x=this.app.renderer.screen.width/2,this.y=this.app.renderer.screen.height/2,this.children.forEach(e=>e.update())}startPlay(){this.children.forEach(e=>e.startPlay())}endPlay(){this.children.forEach(e=>e.endPlay())}}class Rg{static _model;static async getModel(){return this._model||await this._load(),this._model}static async _load(){this._model=[];const e=localStorage.getItem("recentFiles");if(e){try{const t=JSON.parse(e);if(!Array.isArray(t))return;for(const i of t)typeof i!="object"||Array.isArray(i)||typeof i?.name!="string"||typeof i?.path!="string"||this._model.find(s=>s.path==i.path)||this._model.push({name:i.name,path:i.path})}catch{console.log("Failed to load recent file entries");return}await this.saveEntries()}}static async getRecents(){return await this.getModel()}static async addSM(e,t){const i=await this.getModel(),s=i.findIndex(n=>n.path==e);s!=-1&&i.splice(s,1),i.unshift({name:t.properties.TITLE??"Untitled Song",path:e}),this.saveEntries()}static async limitEntries(){(await this.getModel()).splice(15)}static async saveEntries(){this.limitEntries();const e=await Promise.all(this._model.map(async t=>await Re.hasFile(t.path)));this._model=this._model.filter((t,i)=>e[i]),localStorage.setItem("recentFiles",JSON.stringify(this._model))}}class RT extends Pt{app;keyHandler;constructor(e){super({title:"Open a Song",width:400,height:320,disableClose:!0,win_id:"select_sm_initial"}),this.app=e,this.keyHandler=this.handleKeyEvent.bind(this),window.addEventListener("keydown",this.keyHandler),this.initView()}onClose(){window.removeEventListener("keydown",this.keyHandler)}initView(){this.viewElement.replaceChildren();const e=document.createElement("div");e.classList.add("padding");const t=document.createElement("div");t.classList.add("open-container"),e.appendChild(t);const i=document.createElement("div");i.classList.add("top-container");const s=document.createElement("div");s.classList.add("separator"),s.style.margin="10px";const n=document.createElement("div");n.classList.add("bottom-container"),t.appendChild(i),t.appendChild(s),t.appendChild(n);const a=document.createElement("button");a.style.display="flex",a.style.flexDirection="column",a.style.padding="10px",a.style.backgroundColor="#414352",i.appendChild(a);const o=document.createElement("img");o.src=He.UPLOAD,o.classList.add("icon"),o.style.width="30px",o.style.height="30px",a.appendChild(o);const l=document.createElement("div");l.innerText=window.nw?"Open an existing song":"Import a song folder",a.appendChild(l),a.onclick=()=>{if(window.nw){const f=document.createElement("input");f.type="file",f.accept=".sm,.ssc",f.onchange=()=>{this.app.chartManager.loadSM(f.value),this.closeWindow()},f.click()}else this.app.windowManager.openWindow(new ml(this.app,{title:"Select an sm/ssc file...",accepted_file_types:[".sm",".ssc"],disableClose:!0,callback:f=>{this.app.chartManager.loadSM(f),this.closeWindow()}}))};const c=document.createElement("button");c.style.display="flex",c.style.flexDirection="column",c.style.padding="10px",c.style.backgroundColor="#506352",i.appendChild(c);const u=document.createElement("img");u.src=He.PLUS,u.classList.add("icon"),u.style.width="30px",u.style.height="30px",c.appendChild(u);const h=document.createElement("div");h.innerText="New Song",c.appendChild(h),c.onclick=()=>{this.app.windowManager.openWindow(new kg(this.app))};const d=document.createElement("div");d.innerText="Recently Opened",d.classList.add("title"),n.appendChild(d);const p=document.createElement("div");p.classList.add("recent-selector"),n.appendChild(p),Rg.getRecents().then(f=>f.forEach(m=>{const g=document.createElement("div");g.classList.add("recent-item");const y=document.createElement("div");y.classList.add("recent-name"),y.innerText=m.name;const b=document.createElement("div");b.classList.add("recent-path"),b.innerText=m.path,g.appendChild(y),g.appendChild(b),g.onclick=()=>{p.querySelectorAll(".selected").forEach(A=>A.classList.remove("selected")),g.classList.add("selected")},g.ondblclick=()=>{this.app.chartManager.loadSM(m.path),this.closeWindow()},p.appendChild(g)})),this.viewElement.appendChild(e)}handleKeyEvent(e){if(!this.windowElement.classList.contains("focused"))return;const t=this.viewElement.querySelector(".selected");if(t){if(e.code=="ArrowUp"){e.preventDefault(),e.stopImmediatePropagation();const i=t.previousElementSibling;i&&(t.parentElement.querySelectorAll(".selected").forEach(s=>s.classList.remove("selected")),i.classList.add("selected"),ea(i,{scrollMode:"if-needed",block:"nearest",inline:"nearest"}))}if(e.code=="ArrowDown"){e.preventDefault(),e.stopImmediatePropagation();const i=t.nextElementSibling;i&&(t.parentElement.querySelectorAll(".selected").forEach(s=>s.classList.remove("selected")),i.classList.add("selected"),ea(i,{scrollMode:"if-needed",block:"nearest",inline:"nearest"}))}}}}const Mc=Array(85).fill(void 0).map((r,e)=>33+e),Dg=[];for(const r of Mc)for(const e of Mc)Dg.push([r,e]);const Ic="<~".split("").map(r=>r.charCodeAt(0)),kc="~>".split("").map(r=>r.charCodeAt(0));function DT(r,e,t,i=!1,s=!1,n=!1){let a;typeof r=="string"?a=r.split("").map(h=>h.charCodeAt(0)):a=[...new Uint8Array(r)];const o=4-a.length%4;for(let h=0;ho.charCodeAt(0)):i=[...new Uint8Array(r)],e){if(i.at(-1)!=kc.at(-1)||i.at(-2)!=kc.at(-2))return!1;i.at(0)==Ic.at(0)&&i.at(1)==Ic.at(1)?i=i.slice(2,-2):i=i.slice(void 0,-2)}for(let o=0;o<4;o++)i.push("u".charCodeAt(0));let s=[],n=[];for(const o of i)if(o>=33&&117>=o){if(n.push(o),n.length==5){let l=0;for(const c of n)l=85*l+(c-33);if(l>2**32-1)return!1;s.push(l>>24&255),s.push(l>>16&255),s.push(l>>8&255),s.push(l&255),n=[]}}else if(o==122){if(n.length!=0)return!1;s.push(0),s.push(0),s.push(0),s.push(0)}else if(o==121){if(n.length!=0)return!1;s.push(32),s.push(32),s.push(32),s.push(32)}else if(!t.includes(String.fromCharCode(o)))return!1;const a=4-n.length;return a&&(s=s.slice(void 0,-a)),s}function ii(r){let e=0,t=0,i=129;for(;i&128;){const s=r.shift();if(!s)break;e=e|(s&127)<<7*t++,i=s}return e}function ri(r){const e=[];let t=!1;for(;!t;){let i=r&127;r=r>>7,t=r==0,t||(i=i|128),e.push(i)}return e}const LT=["Hold","Mine","Roll","Lift","Fake"];function OT(r){if(r.startsWith("ArrowVortex:notes:")){const e=bd(r.slice(18));if(e!==!1){const t=Array.from(e);if(t.shift()!=0)return;const i=ii(t),s=[];for(let n=0;n4)continue;const h=LT[u];if(l==c){if(h=="Hold"||h=="Roll")continue;s.push({type:h,beat:l/48,col:o})}else{if(h=="Mine"||h=="Fake"||h=="Lift")continue;s.push({type:h,beat:l/48,hold:(c-l)/48,col:o})}}else s.push({type:"Tap",beat:ii(t)/48,col:o})}return s}}}function FT(r){const e=[0];e.push(...ri(r.length));for(const t of r)if(t.type=="Tap"){const i=Math.round(t.beat*48);e.push(t.col),e.push(...ri(i))}else{e.push(t.col+128);const i=Math.round(t.beat*48);let s=0;Be(t)&&(s=t.hold);const n=Math.round(s*48)+i;e.push(...ri(i)),e.push(...ri(n)),e.push(["Hold","Mine","Roll","Lift","Fake"].indexOf(t.type))}return"ArrowVortex:notes:"+vd(e).map(t=>String.fromCharCode(t)).join("")}const yl=["BPMS","STOPS","DELAYS","WARPS","TIMESIGNATURES","TICKCOUNTS","COMBOS","SPEEDS","SCROLLS","FAKES","LABELS","ATTACKS","BGCHANGES","FGCHANGES"];function gr(r){const e=new ArrayBuffer(4);return new DataView(e).setUint32(0,r,!0),Array.from(new Uint8Array(e))}function yr(r){const e=new Uint8Array(r.splice(0,4));return new DataView(e.buffer).getUint32(0,!0)}function Cr(r){const e=new ArrayBuffer(8);return new DataView(e).setFloat64(0,r,!0),Array.from(new Uint8Array(e))}function Mr(r){const e=new Uint8Array(r.splice(0,8)),t=new DataView(e.buffer);return ne(t.getFloat64(0,!0),3)}function NT(r){return[r.length,...r.split("").map(e=>e.charCodeAt(0))]}function UT(r){const e=r.shift();if(!e)return"";let t="";for(let i=0;ie.charCodeAt(0)))}function br(r){const e=ii(r);if(!e)return"";let t="";for(let i=0;i{if(e.type=="ATTACKS"||e.type=="BGCHANGES"||e.type=="FGCHANGES")return!0;const t=Math.round(e.beat*48)/48;if(Math.abs(t-e.beat)>5e-4)return!0;if(e.type=="FAKES"||e.type=="WARPS"){const i=Math.round(e.value*48)/48;if(Math.abs(i-e.value)>5e-4)return!0}return e.type=="LABELS"&&e.value.length>255||e.type=="TIMESIGNATURES"&&(e.upper>2**32-1||e.lower>2**32-1)||e.type=="COMBOS"&&(e.hitMult>2**32-1||e.missMult>2**32-1)?!0:e.type=="TICKCOUNTS"&&e.value>2**32-1})?WT(r):HT(r)}function HT(r){const e=[],t=new Map;r.forEach(i=>{t.has(i.type)||t.set(i.type,[]),t.get(i.type)?.push(i)});for(const[i,s]of t.entries())if(!(i=="ATTACKS"||i=="BGCHANGES"||i=="FGCHANGES")){e.push(s.length),e.push(yl.indexOf(i));for(const n of s)switch(e.push(...gr(Math.round(n.beat*48))),n.type){case"BPMS":case"STOPS":case"DELAYS":case"SCROLLS":e.push(...Cr(n.value));break;case"FAKES":case"WARPS":e.push(...gr(Math.round(n.value*48)));break;case"TIMESIGNATURES":e.push(...gr(Math.round(n.upper))),e.push(...gr(Math.round(n.lower)));break;case"COMBOS":e.push(...gr(Math.round(n.hitMult))),e.push(...gr(Math.round(n.missMult)));break;case"TICKCOUNTS":e.push(...gr(Math.round(n.value)));break;case"SPEEDS":e.push(...Cr(n.value)),e.push(...Cr(n.delay)),e.push(...gr(n.unit=="B"?0:1));break;case"LABELS":e.push(...NT(n.value))}}return e.push(0),"ArrowVortex:tempo:"+vd(e).map(i=>String.fromCharCode(i)).join("")}function WT(r){const e=[],t=new Map;r.forEach(i=>{t.has(i.type)||t.set(i.type,[]),t.get(i.type)?.push(i)});for(const[i,s]of t.entries()){e.push(...ri(s.length)),e.push(yl.indexOf(i));for(const n of s)switch(e.push(...ri(Math.round((n.type=="ATTACKS"?n.second:n.beat)*1e3))),n.type){case"BPMS":case"STOPS":case"DELAYS":case"SCROLLS":case"FAKES":case"WARPS":e.push(...Cr(n.value));break;case"TIMESIGNATURES":e.push(...ri(Math.round(n.upper))),e.push(...ri(Math.round(n.lower)));break;case"COMBOS":e.push(...ri(Math.round(n.hitMult))),e.push(...ri(Math.round(n.missMult)));break;case"TICKCOUNTS":e.push(...ri(Math.round(n.value)));break;case"SPEEDS":e.push(...Cr(n.value)),e.push(...Cr(n.delay)),e.push(n.unit=="B"?0:1);break;case"LABELS":e.push(...vr(n.value));break;case"ATTACKS":e.push(...Cr(n.value)),e.push(n.endType=="LEN"?0:1),e.push(...vr(n.mods));break;case"BGCHANGES":case"FGCHANGES":e.push((n.crossFade?1:0)+((n.stretchRewind?1:0)<<1)+((n.stretchNoLoop?1:0)<<2)),e.push(...vr(n.file)),e.push(...Cr(n.updateRate)),e.push(...vr(n.effect)),e.push(...vr(n.file2)),e.push(...vr(n.transition)),e.push(...vr(n.color1)),e.push(...vr(n.color2))}}return"SMEditor:tempo:"+vd(e).map(i=>String.fromCharCode(i)).join("")}function VT(r){if(r.startsWith("SMEditor:tempo:"))return jT(r);if(r.startsWith("ArrowVortex:tempo:"))return zT(r)}function zT(r){if(!r.startsWith("ArrowVortex:tempo:"))return;const e=bd(r.slice(18)),t=[];if(e===!1)return;const i=Array.from(e);try{for(;;){const s=i.shift();if(s===void 0)return;if(s==0)break;const n=i.shift();if(n===void 0)return;const a=yl[n];for(let o=0;o0,stretchRewind:(c&2)>0,stretchNoLoop:(c&4)>0,effect:br(i),file2:br(i),transition:br(i),color1:br(i),color2:br(i)})}}}}}catch{return}return t}const YT={"dance-single":[{x:-1,y:0},{x:0,y:-1},{x:0,y:1},{x:1,y:0}]},lt={DOUBLESTEP:850,BRACKETJACK:20,JACK:30,JUMP:30,BRACKETTAP:400,HOLDSWITCH:20,MINE:1e4,FOOTSWITCH:5e3,MISSED_FOOTSWITCH:500,FACING:2,DISTANCE:6,SPIN:1e3,SIDESWITCH:130},wh=[1,2,3,4],Kp="LlRr";class XT{app;costCache=[];cacheCounter=0;exploreCounter=0;stop=!1;layout;SEARCH_DEPTH=16;SEARCH_BREADTH=30;constructor(e,t){this.app=e,this.layout=YT[t]}help(){console.log(`Currently only compatible with dance-single. Available commands: analyze(options): analyze the current chart options: { @@ -1264,7 +1264,7 @@ analyze(options): analyze the current chart } leave options blank for default stopAnalyzing(): stop analysis in case something goes wrong -clear(): clear parity highlights`)}getActionCost(e,t,i){const s=t[i],n=e.resultState.second-e.initialState.second;let a=0;const o=new Array(e.resultState.columns.length).fill(0);for(let R=0;RR!=0))for(const R of e.resultState.movedFeet)switch(R){case 1:case 2:e.initialState.columns.includes(3)||e.initialState.columns.includes(4)||(a+=500);break;case 3:case 4:e.initialState.columns.includes(1)||e.initialState.columns.includes(4)||(a+=500);break}const f=e.resultState.movedFeet.has(1)||e.resultState.movedFeet.has(2),m=e.resultState.movedFeet.has(3)||e.resultState.movedFeet.has(4),g=(e.initialState.movedFeet.has(1)&&!e.initialState.holdFeet.has(1)||e.initialState.movedFeet.has(2)&&!e.initialState.holdFeet.has(2))&&(e.initialState.movedFeet.has(3)&&!e.initialState.holdFeet.has(3)||e.initialState.movedFeet.has(4)&&!e.initialState.holdFeet.has(4));let y=!1,b=!1;if(g||(u!=-1&&f&&(e.initialState.columns[u]==1&&!e.resultState.holdFeet.has(1)&&(e.initialState.movedFeet.has(1)&&!e.initialState.holdFeet.has(1)||e.initialState.movedFeet.has(2)&&!e.initialState.holdFeet.has(2))&&(y=!0),e.initialState.columns[h]==2&&!e.resultState.holdFeet.has(2)&&(e.initialState.movedFeet.has(1)&&!e.initialState.holdFeet.has(1)||e.initialState.movedFeet.has(2)&&!e.initialState.holdFeet.has(2))&&(y=!0)),d!=-1&&m&&(e.initialState.columns[d]==3&&!e.resultState.holdFeet.has(3)&&(e.initialState.movedFeet.has(3)&&!e.initialState.holdFeet.has(3)||e.initialState.movedFeet.has(4)&&!e.initialState.holdFeet.has(4))&&(b=!0),e.initialState.columns[p]==4&&!e.resultState.holdFeet.has(4)&&(e.initialState.movedFeet.has(3)&&!e.initialState.holdFeet.has(3)||e.initialState.movedFeet.has(4)&&!e.initialState.holdFeet.has(4))&&(b=!0))),f!=m&&(f||m)&&e.resultState.holdFeet.size==0&&!g){let R=!1;f&&!y&&(e.initialState.movedFeet.has(1)&&!e.initialState.holdFeet.has(1)||e.initialState.movedFeet.has(2)&&!e.initialState.holdFeet.has(2))&&(R=!0),m&&!b&&(e.initialState.movedFeet.has(3)&&!e.initialState.holdFeet.has(3)||e.initialState.movedFeet.has(4)&&!e.initialState.holdFeet.has(4))&&(R=!0);const G=t[i-1];if(G!==void 0)for(const D of G.holds){if(D===void 0)continue;const O=this.app.chartManager.loadedChart.timingData.getBeatFromSeconds(s.second),ee=this.app.chartManager.loadedChart.timingData.getBeatFromSeconds(G.second);D.beat+D.hold>ee&&D.beat+D.hold=O&&(R=!1)}R&&(a+=lt.DOUBLESTEP),y&&e.resultState.movedFeet.has(1)&&e.resultState.movedFeet.has(2)&&(a+=lt.BRACKETJACK),b&&e.resultState.movedFeet.has(3)&&e.resultState.movedFeet.has(4)&&(a+=lt.BRACKETJACK)}f&&m&&s.notes.filter(R=>R!==void 0).length>=2&&(a+=lt.JUMP/n);let A=-1,v=-1,E=-1,C=-1;for(let R=0;R0&&(a+=H*lt.FACING),T>0&&(a+=T*lt.FACING),S>0&&(a+=S*lt.FACING),w>0&&(a+=w*lt.FACING);const F=this.averagePoint(e.initialState.columns.indexOf(1),e.initialState.columns.indexOf(2)),z=this.averagePoint(e.initialState.columns.indexOf(3),e.initialState.columns.indexOf(4)),L=this.averagePoint(A,v),te=this.averagePoint(E,C);if(te.xF.y&&(a+=lt.SPIN),te.xL.y&&z.y=.25&&!s.mines.some(R=>R!==void 0)&&!s.fakeMines.some(R=>R!==void 0)){const R=n-.25;for(let G=0;GR!==void 0)||s.fakeMines.some(R=>R!==void 0))&&(a+=lt.MISSED_FOOTSWITCH),n<=.15&&f!=m){const R=.15-n;(y||b)&&(a+=(1/R-1/.15)*lt.JACK)}for(const R of e.resultState.movedFeet){const G=e.initialState.columns.indexOf(R);G!=-1&&(a+=Math.sqrt(this.getDistanceSq(this.layout[G],this.layout[e.resultState.columns.indexOf(R)]))*lt.DISTANCE/n)}e.cost=a,e.resultState.columns=o,this.costCache[i]===void 0&&(this.costCache[i]=new Map),this.exploreCounter++,this.costCache[i].set(l,a)}getPossibleActions(e,t,i){const s=t[i];return this.permuteColumn(s,new Array(4).fill(0),0).map(n=>{const a={initialState:e,resultState:{columns:n,movedFeet:new Set(n.filter((o,l)=>o===0?!1:s.holds[l]?e.columns[l]!=o:!0)),holdFeet:new Set(n.filter((o,l)=>o===0?!1:s.holds[l]!==void 0)),second:s.second},cost:0};return this.getActionCost(a,t,i),a})}permuteColumn(e,t,i){if(i>=t.length){let n=-1,a=-1,o=-1,l=-1;for(let c=0;c0?u.fake?l[u.col]=u.second:o[u.col]=u.second:u.fake?a[u.col]=u.second:n[u.col]=u.second;continue}u.fake||(i!=u.second&&(i!=null&&c.push({notes:s,holds:t.map(h=>{if(!(h===void 0||h.second>=i))return h}),holdTails:new Set(t.filter(h=>!(h===void 0||Math.abs(h.beat+h.hold-this.app.chartManager.loadedChart.timingData.getBeatFromSeconds(i))>5e-4)).map(h=>h.col)),mines:o,fakeMines:l,second:i}),i=u.second,s=[],o=n,l=a,n=[],a=[],t=t.map(h=>{if(!(h===void 0||u.beat>h.beat+h.hold))return h})),s[u.col]=u,Be(u)&&(t[u.col]=u))}return c.push({notes:s,holds:t.map(u=>{if(!(u===void 0||u.second>=i))return u}),holdTails:new Set(t.filter(u=>!(u===void 0||Math.abs(u.beat+u.hold-this.app.chartManager.loadedChart.timingData.getBeatFromSeconds(i))>5e-4)).map(u=>u.col)),mines:o,fakeMines:l,second:i}),c}analyze(e={}){const{log:t=!1,delay:i=0,searchBreadth:s=30,searchDepth:n=16}=e;this.SEARCH_BREADTH=s,this.SEARCH_DEPTH=n,t&&console.time("Analyze");let a={columns:[0,0,0,0],movedFeet:new Set,holdFeet:new Set,second:-1};this.costCache=[],this.cacheCounter=0,this.exploreCounter=0;const o=this.app.chartManager.loadedChart?.getNotedata();if(!o)return;const l=this.createRows(o);let c=0;if(this.stop=!1,i==0){for(;c!=l.length&&!this.stop;){const u=this.getBestMoveLookahead(a,l,c),h=u[0].head??u[0];t&&console.log(c,u,l[c].second);for(let d=0;d{const h=this.getBestMoveLookahead(a,l,c),d=h[0].head??h[0];t&&console.log(c,h,l[c].second);for(let p=0;pn.cost-a.cost);for(let n=1;n{const o=this.getPossibleActions(a.resultState,t,i+n);return o.forEach(l=>{l.cost=l.cost*Math.pow(.95,n)+a.cost,l.head=a.head??a,l.parent=a}),o}).sort((a,o)=>a.cost-o.cost).slice(0,this.SEARCH_BREADTH);return s}bracketCheck(e,t){const i=this.layout[e],s=this.layout[t];return this.getDistanceSq(i,s)<=2}getDistanceSq(e,t){return(e.y-t.y)*(e.y-t.y)+(e.x-t.x)*(e.x-t.x)}getPosition(e){if(e.length==0)return;if(e.length==1)return this.layout[e[0]];const t=this.layout[e[0]],i=this.layout[e[1]];return{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}getPlayerAngle(e,t){const i=t.x-e.x,s=t.y-e.y,n=1,a=0,o=i*n+s*a,l=i*a-s*n;return Math.atan2(l,o)}compareCols(e,t){if(e===t)return!0;if(e==null||t==null||e.length!==t.length)return!1;for(let i=0;it.parity=void 0)}}class KT{static menuElement;static closeTimeout;static open(e,t){e.chartManager.getMode()!=Y.View&&(this.buildMenu(e),this.menuElement.style.display="none",setTimeout(()=>this.fitContextMenu(t)),this.menuElement.classList.add("entering"),clearTimeout(this.closeTimeout),setTimeout(()=>this.menuElement?.classList.remove("entering"),300),this.menuElement.style.left=t.clientX+"px",this.menuElement.style.top=t.clientY+"px")}static fitContextMenu(e){this.menuElement.style.display="";const t=this.menuElement.getBoundingClientRect(),i=window.innerHeight-t.bottom-20,s=window.innerWidth-t.right-20;i<0&&(this.menuElement.style.top=e.clientY+i+"px"),s<0&&(this.menuElement.style.left=e.clientX+s+"px"),this.menuElement.style.transformOrigin=`${Math.max(0,-s)}px ${Math.max(0,-i)}px`}static close(){this.menuElement&&(this.menuElement.classList.add("exiting"),this.closeTimeout=setTimeout(()=>this.menuElement.replaceChildren(),300))}static buildMenu(e){const t=document.createElement("div");if(t.appendChild(this.createElement(e,{type:"selection",id:"cut"})),t.appendChild(this.createElement(e,{type:"selection",id:"copy"})),t.appendChild(this.createElement(e,{type:"selection",id:"paste"})),e.chartManager.getMode()==Y.Edit&&e.chartManager.hasNoteSelection()){const i=document.createElement("div");i.classList.add("separator"),t.appendChild(i),Vn.selection.options.slice(0,-2).forEach(s=>{t.appendChild(this.createElement(e,s))})}this.menuElement=t,t.id="context-menu",document.getElementById("context-menu")?.replaceWith(this.menuElement)}static createElement(e,t){if(t.type=="separator"){const i=document.createElement("div");return i.classList.add("separator"),i}if(t.type=="selection"||t.type=="checkbox"||t.type=="dropdown"){const i=document.createElement("div"),s=document.createElement("div"),n=document.createElement("div");let a;if(t.type=="selection"||t.type=="checkbox"){const o=dt[t.id];a=document.createElement("div"),a.innerText=$e.getKeybindString(t.id),a.classList.add("keybind","unselectable"),n.innerText=o?.label??t.id;let l=o?.disabled??!0;typeof l=="function"&&(l=l(e)),l&&i.classList.add("disabled"),i.addEventListener("click",()=>{l||(o?.callback(e),this.close())})}else a=document.createElement("img"),a.classList.add("icon"),a.src=He.CHEVRON,a.style.transform="rotate(-90deg)",n.innerText=typeof t.title=="function"?t.title(e):t.title;if(s.appendChild(n),s.appendChild(a),i.appendChild(s),i.classList.add("menu-item"),s.classList.add("menu-item-title","menu-hover"),n.classList.add("title","unselectable"),t.type=="dropdown"){const o=document.createElement("div");i.appendChild(o),o.classList.add("menubar-dropdown"),t.options.map(l=>this.createElement(e,l)).forEach(l=>o.appendChild(l))}if(t.type=="checkbox"){let o=t.checked;typeof o=="function"&&(o=o(e)),o&&(n.innerText="✓ "+n.innerText)}return i}if(t.type=="menu"){const i=document.createElement("div"),s=document.createElement("div"),n=document.createElement("div");return i.appendChild(s),s.innerText=t.title,i.appendChild(n),s.classList.add("title","unselectable"),i.classList.add("menu-item","menu-main"),s.classList.add("menu-hover"),n.classList.add("menubar-dropdown","unselectable"),i.onmouseenter=()=>{n.replaceChildren(...t.options.map(a=>this.createElement(e,a)))},i.onmouseleave=()=>{n.replaceChildren()},i}return document.createElement("div")}}const qT={fontName:"Main",fontSize:20,fill:["#ffffff"]};class QT extends xe{renderer;barlineMap=new Map;barlineLabelMap=new Map;barlinePool=new ha({create:()=>new ke(Z.WHITE)});barlineLabelPool=new ha({create:()=>new Fe("",qT)});constructor(e){super(),this.renderer=e;const t=()=>{this.barlineMap.clear(),this.barlineLabelMap.clear(),this.barlinePool.destroyAll(),this.barlineLabelPool.destroyAll()};$.on("timeSigChanged",t),this.on("destroyed",()=>$.off("timeSigChanged",t)),this.addChild(this.barlinePool,this.barlineLabelPool)}update(e,t){this.visible=this.renderer.shouldDisplayBarlines();for(const[i,s]of this.getBarlineBeats(e,t)){if(!this.barlineMap.has(i)){const n=this.barlinePool.createChild();if(!n)continue;Object.assign(n,{width:this.renderer.chart.gameType.notefieldWidth+128,height:s?4:1,visible:!0}),n.anchor.set(.5),this.barlineMap.set(i,n)}if(s&&!this.barlineLabelMap.has(i)){const n=this.barlineLabelPool.createChild();if(!n)continue;Object.assign(n,{x:(this.renderer.chart.gameType.notefieldWidth+128)/-2-16,text:`${Math.round(this.renderer.chart.timingData.getMeasure(i))}`,visible:!0}),n.anchor.set(1,.5),this.barlineLabelMap.set(i,n)}}for(const[i,s]of this.barlineMap.entries()){if(it){this.barlineMap.delete(i),this.barlinePool.destroyChild(s);continue}s.y=this.renderer.getYPosFromBeat(i)}for(const[i,s]of this.barlineLabelMap.entries()){if(it){this.barlineLabelMap.delete(i),this.barlineLabelPool.destroyChild(s);continue}s.y=this.renderer.getYPosFromBeat(i)}}*getBarlineBeats(e,t){e=Math.max(0,e);const i=this.renderer.chart.timingData,s=i.getTimingData("TIMESIGNATURES");let n=i.getEventAtBeat("TIMESIGNATURES",e),a=n?s.findIndex(d=>d.beat==n.beat):-1,o=i.getDivisionLength(e);const l=i.getDivisionOfMeasure(e)%1*o;let c=Math.max(0,e-l);c=s[a+1]?.beat&&(a++,n=s[a],c=n.beat,o=i.getDivisionLength(c),u=0,h=n.upper)}}class $T extends xe{previewArea=new ke(Z.WHITE);previewText=new Fe("SONG PREVIEW",{fontName:"Main",fontSize:13});renderer;constructor(e){super(),this.renderer=e,Object.assign(this.previewArea,{alpha:.2,tint:11052482,width:this.renderer.chart.gameType.notefieldWidth+96,height:64}),this.previewText.x=-this.previewArea.width/2+5,this.previewArea.anchor.x=.5,this.addChild(this.previewArea,this.previewText)}update(e,t){const i=Number(this.renderer.chart.sm.properties.SAMPLESTART),s=Number(this.renderer.chart.sm.properties.SAMPLELENGTH);if(Number.isNaN(i)||Number.isNaN(s)||!this.renderer.shouldDisplayBarlines()||this.renderer.chart.timingData.getBeatFromSeconds(i+s)t){this.visible=!1;return}this.visible=!0;let n=this.renderer.getYPosFromSecond(i),a=this.renderer.getYPosFromSecond(i+s);athis.renderer.getVisualBeat()),this.trackVariable(()=>this.renderer.getVisualTime()),this.trackVariable(()=>this.getSpeed(),s=>{this.speed=s,clearTimeout(this.lastSpeedTimeout),this.lastSpeedTimeout=setTimeout(()=>{this.blockCache.clear(),this.lastSpeed=this.speed,this.drawDirty=!0},200)}),this.trackVariable(()=>_.chart.zoom),this.trackVariable(()=>_.chart.CMod),this.trackVariable(()=>_.chart.doSpeedChanges),this.trackVariable(()=>_.chart.waveform.allowFilter),this.trackVariable(()=>_.chart.reverse),this.trackVariable(()=>_.chart.waveform.antialiasing,s=>{this.filters=s?[new nc]:[]}),this.trackVariable(()=>this.renderer.chartManager.app.renderer.screen.width,()=>this.resizeWaveform()),this.trackVariable(()=>this.renderer.chartManager.app.renderer.screen.height,()=>this.resizeWaveform()),this.trackVariable(()=>_.chart.waveform.opacity),this.trackVariable(()=>_.chart.waveform.filteredOpacity),this.trackVariable(()=>_.chart.waveform.filteredColor),this.trackVariable(()=>_.chart.waveform.color),this.trackVariable(()=>_.chart.waveform.speedChanges),this.trackVariable(()=>_.chart.receptorYPos),this.trackVariable(()=>_.chart.waveform.lineHeight,()=>{_.chart.waveform.lineHeight<=0&&(_.chart.waveform.lineHeight=1),this.updateLineHeight()}),this.trackVariable(()=>_.chart.zoom,()=>this.resizeWaveform()),this.trackVariable(()=>this.renderer.chartManager.chartAudio.hasFilters()),this.anchor.set(.5),this.renderer.chartManager.chartAudio.onUpdate(()=>this.getData()),this.getData(),this.resizeWaveform(),this.filters=_.chart.waveform.antialiasing?[new nc]:[];const t=()=>this.drawDirty=!0,i=()=>{this.getData(),this.resizeWaveform(),this.renderer.chartManager.chartAudio.onUpdate(()=>this.getData())};$.on("timingModified",t),this.on("destroyed",()=>{$.off("timingModified",t)}),$.on("audioLoaded",i),this.on("destroyed",()=>{$.off("audioLoaded",i)})}getData(){this.rawData=this.renderer.chartManager.chartAudio.getRawData(),this.filteredRawData=this.renderer.chartManager.chartAudio.getFilteredRawData(),this.sampleRate=this.renderer.chartManager.chartAudio.getSampleRate(),this.blockCache.clear(),this.drawDirty=!0}resizeWaveform(){this.waveformTex.resize(Ve((this.rawData?.length??0)*288*_.chart.zoom,1,this.renderer.chartManager.app.renderer.screen.width),this.renderer.chartManager.app.renderer.screen.height)}update(){this.visible=_.chart.waveform.enabled&&this.renderer.shouldDisplayBarlines(),_.chart.waveform.enabled&&((this.drawDirty||this.variableChanged())&&(this.drawDirty=!1,this.renderData(),this.renderer.chartManager.app.renderer.render(this.lineContainer,{renderTexture:this.waveformTex})),this.scale.set(1/_.chart.zoom))}trackVariable(e,t){this.trackedVariables.set(e,{value:e(),cb:t})}variableChanged(){let e=!1;for(const[t,i]of this.trackedVariables.entries())t()!=i.value&&(this.trackedVariables.get(t).value=t(),this.trackedVariables.get(t).cb?.(t()),e=!0);return e}getSample(e,t,i){if(t<0)return 0;const s=this.sampleRate/(this.lastSpeed*4),n=Math.floor(t*this.lastSpeed*4);if(this.blockCache.get(i)?.[n]!==void 0)return this.blockCache.get(i)[n];const a=Math.floor(n*s),o=e.slice(a,Math.floor(a+s)).reduce((l,c)=>l+Math.abs(c),0)/s;return this.blockCache.has(i)||this.blockCache.set(i,[]),this.blockCache.get(i)[n]=o,o}renderData(){this.resetPool();const e=_.chart.waveform.allowFilter&&this.renderer.chartManager.chartAudio.hasFilters();if(_.chart.waveform.speedChanges&&!_.chart.CMod&&_.chart.doSpeedChanges){const t=_.chart.speed,i=this.renderer.chart.timingData.getSpeedMult(this.renderer.getVisualBeat(),this.renderer.getVisualTime()),s=i>=0!=_.chart.reverse?1:-1,n=this.renderer.getVisualBeat()+_.chart.maxDrawBeats,a=[...this.renderer.chart.timingData.getTimingData("SCROLLS")];a[0]?.beat!=0&&a.unshift({type:"SCROLLS",beat:0,value:1});const o=this.renderer.chart.timingData.getOffset(),l=this.renderer.chart.timingData.getEventAtBeat("BPMS",0)?.value??120,c=this.renderer.chart.timingData.getBeatTiming(),u=100/t/Math.abs(i)/64/_.chart.zoom,h=this.renderer.chartManager.app.renderer.screen.height;let d=!1,p=hi(a,this.renderer.getVisualBeat()-_.chart.maxDrawBeatsBack,y=>y.beat),f=a[p]?.beat??0;f==0&&(f=-_.chart.maxDrawBeatsBack);let m=this.renderer.chart.getSecondsFromBeat(f),g=Math.round(this.renderer.getYPosFromBeat(f)*_.chart.zoom+this.parent.y);for(;fh||y.value*s>0&&A<0)){p++,f=a[p].beat,g=Math.round(A);continue}const v=u/Math.abs(y.value);for(;fh){if(y.value*s>0){d=!0;break}f+=v*(g-h),g=h;continue}f+=v*_.chart.waveform.lineHeight,g+=(y.value*s>0?1:-1)*_.chart.waveform.lineHeight,m=this.calculateSecond(f,c,o,l),this.drawLine(m,g,e)}p++,f=b,g=A}}else if(_.chart.CMod){let t=this.renderer.getSecondFromYPos((-this.parent.y+(_.chart.reverse?this.renderer.chartManager.app.renderer.screen.height:0))/_.chart.zoom);const i=this.renderer.getPixelsToSecondsRatio()/_.chart.zoom;t=Math.floor(t/i)*i;const s=n=>{t+=i*_.chart.waveform.lineHeight,this.drawLine(t,n,e)};if(_.chart.reverse)for(let n=this.renderer.chartManager.app.renderer.screen.height;n>=0;n-=_.chart.waveform.lineHeight)s(n);else for(let n=0;n<=this.renderer.chartManager.app.renderer.screen.height;n+=_.chart.waveform.lineHeight)s(n)}else{let t=this.renderer.getBeatFromYPos((-this.parent.y+(_.chart.reverse?this.renderer.chartManager.app.renderer.screen.height:0))/_.chart.zoom);const i=this.renderer.chart.timingData.getOffset(),s=this.renderer.chart.timingData.getEventAtBeat("BPMS",0)?.value??120,n=this.renderer.chart.timingData.getBeatTiming(),a=this.renderer.getPixelsToEffectiveBeatsRatio()/_.chart.zoom;t=Math.floor(t/a)*a;let o=this.renderer.chart.getSecondsFromBeat(t);const l=c=>{t+=a*_.chart.waveform.lineHeight,o=this.calculateSecond(t,n,i,s),this.drawLine(o,c,e)};if(_.chart.reverse)for(let c=this.renderer.chartManager.app.renderer.screen.height;c>=0;c-=_.chart.waveform.lineHeight)l(c);else for(let c=0;c<=this.renderer.chartManager.app.renderer.screen.height;c+=_.chart.waveform.lineHeight)l(c)}this.purgePool()}calculateSecond(e,t,i,s){const n=Math.floor(e*1e3)/1e3;if(e<=0)return-i+e*60/s;if(n>=t[1]?.beat){for(;n>=t[1]?.beat;)t.shift();return this.renderer.chart.getSecondsFromBeat(e)}else{let o=(e-t[0].beat)*60/t[0].bpm;return t[0].warped&&(o=0),Math.max(t[0].secondClamp,t[0].secondAfter+o)}}drawLine(e,t,i){if(!(e<0))for(let s=0;st>=this.poolSearch)}updateLineHeight(){for(const e of this.lineContainer.children){const t=e;t.height=_.chart.waveform.lineHeight}}getLine(){if(this.lineContainer.children[this.poolSearch]){const t=this.lineContainer.children[this.poolSearch];return t.visible=!0,this.poolSearch++,t}const e=new ke(Z.WHITE);return e.height=_.chart.waveform.lineHeight,e.anchor.set(.5),e.visible=!0,this.poolSearch++,this.lineContainer.addChild(e),e}getSpeed(){return Math.min(_.chart.speed,eS)}}class iS{renderer;constructor(e){this.renderer=e}}const rS="/smeditor/assets/decent-f3f8a110.png",sS="/smeditor/assets/excellent-84718ac0.png",nS="/smeditor/assets/fantastic-1755e773.png",aS="/smeditor/assets/great-0e864574.png",oS="/smeditor/assets/hold-7b947e11.png",lS="/smeditor/assets/mine-590d445e.png",hS="/smeditor/assets/way_off-8bc3fd65.png",cS="/smeditor/assets/white_fantastic-b65b4f11.png",dS=Z.from(oS),xh={w0:Z.from(nS),w1:Z.from(cS),w2:Z.from(sS),w3:Z.from(aS),w4:Z.from(rS),w5:Z.from(hS),mine:Z.from(lS)};class ca extends ke{createTime=0;type="flash";constructor(e){super(e),this.anchor.set(.5),this.createTime=Date.now()}update(){switch(this.type){case"flash":{const e=(Date.now()-this.createTime)/150;this.scale.set(1.1-e*.1),this.alpha=1.2-e*1.2;break}case"mine":{const e=(Date.now()-this.createTime)/600;this.rotation=e*-Math.PI,this.alpha=Math.min(1,2-2*e);break}case"hold":this.alpha=Math.sin(Date.now())*.2+1.2}Date.now()-this.createTime>150&&this.type=="flash"&&this.destroy()}static createJudgment(e){let t;if(Vi(e)&&(t=xh[e.id]),ms(e)&&(t=xh.mine),Rr(e)&&(t=xh.w2),!t)return;const i=new ca(t);return i.type="flash",ms(e)&&(i.type="mine",i.blendMode=Ee.ADD),i}static createHoldJudgment(){const e=new ca(dS);return e.type="hold",e}}const uS="/smeditor/assets/parts-0c8fa692.png",pS="/smeditor/assets/frame-d599a2fe.png",fS="/smeditor/assets/parts-b37af2cf.png",mS="/smeditor/assets/parts-9668caec.png",gS=`precision mediump float; +clear(): clear parity highlights`)}getActionCost(e,t,i){const s=t[i],n=e.resultState.second-e.initialState.second;let a=0;const o=new Array(e.resultState.columns.length).fill(0);for(let R=0;RR!=0))for(const R of e.resultState.movedFeet)switch(R){case 1:case 2:e.initialState.columns.includes(3)||e.initialState.columns.includes(4)||(a+=500);break;case 3:case 4:e.initialState.columns.includes(1)||e.initialState.columns.includes(4)||(a+=500);break}const f=e.resultState.movedFeet.has(1)||e.resultState.movedFeet.has(2),m=e.resultState.movedFeet.has(3)||e.resultState.movedFeet.has(4),g=(e.initialState.movedFeet.has(1)&&!e.initialState.holdFeet.has(1)||e.initialState.movedFeet.has(2)&&!e.initialState.holdFeet.has(2))&&(e.initialState.movedFeet.has(3)&&!e.initialState.holdFeet.has(3)||e.initialState.movedFeet.has(4)&&!e.initialState.holdFeet.has(4));let y=!1,b=!1;if(g||(u!=-1&&f&&(e.initialState.columns[u]==1&&!e.resultState.holdFeet.has(1)&&(e.initialState.movedFeet.has(1)&&!e.initialState.holdFeet.has(1)||e.initialState.movedFeet.has(2)&&!e.initialState.holdFeet.has(2))&&(y=!0),e.initialState.columns[h]==2&&!e.resultState.holdFeet.has(2)&&(e.initialState.movedFeet.has(1)&&!e.initialState.holdFeet.has(1)||e.initialState.movedFeet.has(2)&&!e.initialState.holdFeet.has(2))&&(y=!0)),d!=-1&&m&&(e.initialState.columns[d]==3&&!e.resultState.holdFeet.has(3)&&(e.initialState.movedFeet.has(3)&&!e.initialState.holdFeet.has(3)||e.initialState.movedFeet.has(4)&&!e.initialState.holdFeet.has(4))&&(b=!0),e.initialState.columns[p]==4&&!e.resultState.holdFeet.has(4)&&(e.initialState.movedFeet.has(3)&&!e.initialState.holdFeet.has(3)||e.initialState.movedFeet.has(4)&&!e.initialState.holdFeet.has(4))&&(b=!0))),f!=m&&(f||m)&&e.resultState.holdFeet.size==0&&!g){let R=!1;f&&!y&&(e.initialState.movedFeet.has(1)&&!e.initialState.holdFeet.has(1)||e.initialState.movedFeet.has(2)&&!e.initialState.holdFeet.has(2))&&(R=!0),m&&!b&&(e.initialState.movedFeet.has(3)&&!e.initialState.holdFeet.has(3)||e.initialState.movedFeet.has(4)&&!e.initialState.holdFeet.has(4))&&(R=!0);const G=t[i-1];if(G!==void 0)for(const D of G.holds){if(D===void 0)continue;const O=this.app.chartManager.loadedChart.timingData.getBeatFromSeconds(s.second),ee=this.app.chartManager.loadedChart.timingData.getBeatFromSeconds(G.second);D.beat+D.hold>ee&&D.beat+D.hold=O&&(R=!1)}R&&(a+=lt.DOUBLESTEP),y&&e.resultState.movedFeet.has(1)&&e.resultState.movedFeet.has(2)&&(a+=lt.BRACKETJACK),b&&e.resultState.movedFeet.has(3)&&e.resultState.movedFeet.has(4)&&(a+=lt.BRACKETJACK)}f&&m&&s.notes.filter(R=>R!==void 0).length>=2&&(a+=lt.JUMP/n);let A=-1,v=-1,E=-1,C=-1;for(let R=0;R0&&(a+=H*lt.FACING),T>0&&(a+=T*lt.FACING),S>0&&(a+=S*lt.FACING),w>0&&(a+=w*lt.FACING);const F=this.averagePoint(e.initialState.columns.indexOf(1),e.initialState.columns.indexOf(2)),z=this.averagePoint(e.initialState.columns.indexOf(3),e.initialState.columns.indexOf(4)),L=this.averagePoint(A,v),te=this.averagePoint(E,C);if(te.xF.y&&(a+=lt.SPIN),te.xL.y&&z.y=.25&&!s.mines.some(R=>R!==void 0)&&!s.fakeMines.some(R=>R!==void 0)){const R=n-.25;for(let G=0;GR!==void 0)||s.fakeMines.some(R=>R!==void 0))&&(a+=lt.MISSED_FOOTSWITCH),n<=.15&&f!=m){const R=.15-n;(y||b)&&(a+=(1/R-1/.15)*lt.JACK)}for(const R of e.resultState.movedFeet){const G=e.initialState.columns.indexOf(R);G!=-1&&(a+=Math.sqrt(this.getDistanceSq(this.layout[G],this.layout[e.resultState.columns.indexOf(R)]))*lt.DISTANCE/n)}e.cost=a,e.resultState.columns=o,this.costCache[i]===void 0&&(this.costCache[i]=new Map),this.exploreCounter++,this.costCache[i].set(l,a)}getPossibleActions(e,t,i){const s=t[i];return this.permuteColumn(s,new Array(4).fill(0),0).map(n=>{const a={initialState:e,resultState:{columns:n,movedFeet:new Set(n.filter((o,l)=>o===0?!1:s.holds[l]?e.columns[l]!=o:!0)),holdFeet:new Set(n.filter((o,l)=>o===0?!1:s.holds[l]!==void 0)),second:s.second},cost:0};return this.getActionCost(a,t,i),a})}permuteColumn(e,t,i){if(i>=t.length){let n=-1,a=-1,o=-1,l=-1;for(let c=0;c0?u.fake?l[u.col]=u.second:o[u.col]=u.second:u.fake?a[u.col]=u.second:n[u.col]=u.second;continue}u.fake||(i!=u.second&&(i!=null&&c.push({notes:s,holds:t.map(h=>{if(!(h===void 0||h.second>=i))return h}),holdTails:new Set(t.filter(h=>!(h===void 0||Math.abs(h.beat+h.hold-this.app.chartManager.loadedChart.timingData.getBeatFromSeconds(i))>5e-4)).map(h=>h.col)),mines:o,fakeMines:l,second:i}),i=u.second,s=[],o=n,l=a,n=[],a=[],t=t.map(h=>{if(!(h===void 0||u.beat>h.beat+h.hold))return h})),s[u.col]=u,Be(u)&&(t[u.col]=u))}return c.push({notes:s,holds:t.map(u=>{if(!(u===void 0||u.second>=i))return u}),holdTails:new Set(t.filter(u=>!(u===void 0||Math.abs(u.beat+u.hold-this.app.chartManager.loadedChart.timingData.getBeatFromSeconds(i))>5e-4)).map(u=>u.col)),mines:o,fakeMines:l,second:i}),c}analyze(e={}){const{log:t=!1,delay:i=0,searchBreadth:s=30,searchDepth:n=16}=e;this.SEARCH_BREADTH=s,this.SEARCH_DEPTH=n,t&&console.time("Analyze");let a={columns:[0,0,0,0],movedFeet:new Set,holdFeet:new Set,second:-1};this.costCache=[],this.cacheCounter=0,this.exploreCounter=0;const o=this.app.chartManager.loadedChart?.getNotedata();if(!o)return;const l=this.createRows(o);let c=0;if(this.stop=!1,i==0){for(;c!=l.length&&!this.stop;){const u=this.getBestMoveLookahead(a,l,c),h=u[0].head??u[0];t&&console.log(c,u,l[c].second);for(let d=0;d{const h=this.getBestMoveLookahead(a,l,c),d=h[0].head??h[0];t&&console.log(c,h,l[c].second);for(let p=0;pn.cost-a.cost);for(let n=1;n{const o=this.getPossibleActions(a.resultState,t,i+n);return o.forEach(l=>{l.cost=l.cost*Math.pow(.95,n)+a.cost,l.head=a.head??a,l.parent=a}),o}).sort((a,o)=>a.cost-o.cost).slice(0,this.SEARCH_BREADTH);return s}bracketCheck(e,t){const i=this.layout[e],s=this.layout[t];return this.getDistanceSq(i,s)<=2}getDistanceSq(e,t){return(e.y-t.y)*(e.y-t.y)+(e.x-t.x)*(e.x-t.x)}getPosition(e){if(e.length==0)return;if(e.length==1)return this.layout[e[0]];const t=this.layout[e[0]],i=this.layout[e[1]];return{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}getPlayerAngle(e,t){const i=t.x-e.x,s=t.y-e.y,n=1,a=0,o=i*n+s*a,l=i*a-s*n;return Math.atan2(l,o)}compareCols(e,t){if(e===t)return!0;if(e==null||t==null||e.length!==t.length)return!1;for(let i=0;it.parity=void 0)}}class KT{static menuElement;static closeTimeout;static open(e,t){e.chartManager.getMode()!=Y.View&&(this.buildMenu(e),this.menuElement.style.display="none",setTimeout(()=>this.fitContextMenu(t)),this.menuElement.classList.add("entering"),clearTimeout(this.closeTimeout),setTimeout(()=>this.menuElement?.classList.remove("entering"),300),this.menuElement.style.left=t.clientX+"px",this.menuElement.style.top=t.clientY+"px")}static fitContextMenu(e){this.menuElement.style.display="";const t=this.menuElement.getBoundingClientRect(),i=window.innerHeight-t.bottom-20,s=window.innerWidth-t.right-20;i<0&&(this.menuElement.style.top=e.clientY+i+"px"),s<0&&(this.menuElement.style.left=e.clientX+s+"px"),this.menuElement.style.transformOrigin=`${Math.max(0,-s)}px ${Math.max(0,-i)}px`}static close(){this.menuElement&&(this.menuElement.classList.add("exiting"),this.closeTimeout=setTimeout(()=>this.menuElement.replaceChildren(),300))}static buildMenu(e){const t=document.createElement("div");if(t.appendChild(this.createElement(e,{type:"selection",id:"cut"})),t.appendChild(this.createElement(e,{type:"selection",id:"copy"})),t.appendChild(this.createElement(e,{type:"selection",id:"paste"})),e.chartManager.getMode()==Y.Edit&&e.chartManager.hasNoteSelection()){const i=document.createElement("div");i.classList.add("separator"),t.appendChild(i),Vn.selection.options.slice(0,-2).forEach(s=>{t.appendChild(this.createElement(e,s))})}this.menuElement=t,t.id="context-menu",document.getElementById("context-menu")?.replaceWith(this.menuElement)}static createElement(e,t){if(t.type=="separator"){const i=document.createElement("div");return i.classList.add("separator"),i}if(t.type=="selection"||t.type=="checkbox"||t.type=="dropdown"){const i=document.createElement("div"),s=document.createElement("div"),n=document.createElement("div");let a;if(t.type=="selection"||t.type=="checkbox"){const o=dt[t.id];a=document.createElement("div"),a.innerText=$e.getKeybindString(t.id),a.classList.add("keybind","unselectable"),n.innerText=o?.label??t.id;let l=o?.disabled??!0;typeof l=="function"&&(l=l(e)),l&&i.classList.add("disabled"),i.addEventListener("click",()=>{l||(o?.callback(e),this.close())})}else a=document.createElement("img"),a.classList.add("icon"),a.src=He.CHEVRON,a.style.transform="rotate(-90deg)",n.innerText=typeof t.title=="function"?t.title(e):t.title;if(s.appendChild(n),s.appendChild(a),i.appendChild(s),i.classList.add("menu-item"),s.classList.add("menu-item-title","menu-hover"),n.classList.add("title","unselectable"),t.type=="dropdown"){const o=document.createElement("div");i.appendChild(o),o.classList.add("menubar-dropdown"),t.options.map(l=>this.createElement(e,l)).forEach(l=>o.appendChild(l))}if(t.type=="checkbox"){let o=t.checked;typeof o=="function"&&(o=o(e)),o&&(n.innerText="✓ "+n.innerText)}return i}if(t.type=="menu"){const i=document.createElement("div"),s=document.createElement("div"),n=document.createElement("div");return i.appendChild(s),s.innerText=t.title,i.appendChild(n),s.classList.add("title","unselectable"),i.classList.add("menu-item","menu-main"),s.classList.add("menu-hover"),n.classList.add("menubar-dropdown","unselectable"),i.onmouseenter=()=>{n.replaceChildren(...t.options.map(a=>this.createElement(e,a)))},i.onmouseleave=()=>{n.replaceChildren()},i}return document.createElement("div")}}const qT={fontName:"Main",fontSize:20,fill:["#ffffff"]};class QT extends xe{renderer;barlineMap=new Map;barlineLabelMap=new Map;barlinePool=new ha({create:()=>new ke(Z.WHITE)});barlineLabelPool=new ha({create:()=>new Fe("",qT)});constructor(e){super(),this.renderer=e;const t=()=>{this.barlineMap.clear(),this.barlineLabelMap.clear(),this.barlinePool.destroyAll(),this.barlineLabelPool.destroyAll()};$.on("timeSigChanged",t),this.on("destroyed",()=>$.off("timeSigChanged",t)),this.addChild(this.barlinePool,this.barlineLabelPool)}update(e,t){this.visible=this.renderer.shouldDisplayBarlines();for(const[i,s]of this.getBarlineBeats(e,t)){if(!this.barlineMap.has(i)){const n=this.barlinePool.createChild();if(!n)continue;Object.assign(n,{width:this.renderer.chart.gameType.notefieldWidth+128,height:s?4:1,visible:!0}),n.anchor.set(.5),this.barlineMap.set(i,n)}if(s&&!this.barlineLabelMap.has(i)){const n=this.barlineLabelPool.createChild();if(!n)continue;Object.assign(n,{x:(this.renderer.chart.gameType.notefieldWidth+128)/-2-16,text:`${Math.round(this.renderer.chart.timingData.getMeasure(i))}`,visible:!0}),n.anchor.set(1,.5),this.barlineLabelMap.set(i,n)}}for(const[i,s]of this.barlineMap.entries()){if(it){this.barlineMap.delete(i),this.barlinePool.destroyChild(s);continue}s.y=this.renderer.getYPosFromBeat(i)}for(const[i,s]of this.barlineLabelMap.entries()){if(it){this.barlineLabelMap.delete(i),this.barlineLabelPool.destroyChild(s);continue}s.y=this.renderer.getYPosFromBeat(i)}}*getBarlineBeats(e,t){e=Math.max(0,e);const i=this.renderer.chart.timingData,s=i.getTimingData("TIMESIGNATURES");let n=i.getEventAtBeat("TIMESIGNATURES",e),a=n?s.findIndex(d=>d.beat==n.beat):-1,o=i.getDivisionLength(e);const l=i.getDivisionOfMeasure(e)%1*o;let c=Math.max(0,e-l);c=s[a+1]?.beat&&(a++,n=s[a],c=n.beat,o=i.getDivisionLength(c),u=0,h=n.upper)}}class $T extends xe{previewArea=new ke(Z.WHITE);previewText=new Fe("SONG PREVIEW",{fontName:"Main",fontSize:13});renderer;constructor(e){super(),this.renderer=e,Object.assign(this.previewArea,{alpha:.2,tint:11052482,width:this.renderer.chart.gameType.notefieldWidth+96,height:64}),this.previewText.x=-this.previewArea.width/2+5,this.previewArea.anchor.x=.5,this.addChild(this.previewArea,this.previewText)}update(e,t){const i=Number(this.renderer.chart.sm.properties.SAMPLESTART),s=Number(this.renderer.chart.sm.properties.SAMPLELENGTH);if(Number.isNaN(i)||Number.isNaN(s)||!this.renderer.shouldDisplayBarlines()||this.renderer.chart.timingData.getBeatFromSeconds(i+s)t){this.visible=!1;return}this.visible=!0;let n=this.renderer.getYPosFromSecond(i),a=this.renderer.getYPosFromSecond(i+s);athis.renderer.getVisualBeat()),this.trackVariable(()=>this.renderer.getVisualTime()),this.trackVariable(()=>this.getSpeed(),s=>{this.speed=s,clearTimeout(this.lastSpeedTimeout),this.lastSpeedTimeout=setTimeout(()=>{this.blockCache.clear(),this.lastSpeed=this.speed,this.drawDirty=!0},200)}),this.trackVariable(()=>_.chart.zoom),this.trackVariable(()=>_.chart.CMod),this.trackVariable(()=>_.chart.doSpeedChanges),this.trackVariable(()=>_.chart.waveform.allowFilter),this.trackVariable(()=>_.chart.reverse),this.trackVariable(()=>_.chart.waveform.antialiasing,s=>{this.filters=s?[new nc]:[]}),this.trackVariable(()=>this.renderer.chartManager.app.renderer.screen.width,()=>this.resizeWaveform()),this.trackVariable(()=>this.renderer.chartManager.app.renderer.screen.height,()=>this.resizeWaveform()),this.trackVariable(()=>_.chart.waveform.opacity),this.trackVariable(()=>_.chart.waveform.filteredOpacity),this.trackVariable(()=>_.chart.waveform.filteredColor),this.trackVariable(()=>_.chart.waveform.color),this.trackVariable(()=>_.chart.waveform.speedChanges),this.trackVariable(()=>_.chart.receptorYPos),this.trackVariable(()=>_.chart.waveform.lineHeight,()=>{_.chart.waveform.lineHeight<=0&&(_.chart.waveform.lineHeight=1),this.updateLineHeight()}),this.trackVariable(()=>_.chart.zoom,()=>this.resizeWaveform()),this.trackVariable(()=>this.renderer.chartManager.chartAudio.hasFilters()),this.anchor.set(.5),this.renderer.chartManager.chartAudio.onUpdate(()=>this.getData()),this.getData(),this.resizeWaveform(),this.filters=_.chart.waveform.antialiasing?[new nc]:[];const t=()=>this.drawDirty=!0,i=()=>{this.getData(),this.resizeWaveform(),this.renderer.chartManager.chartAudio.onUpdate(()=>this.getData())};$.on("timingModified",t),this.on("destroyed",()=>{$.off("timingModified",t)}),$.on("audioLoaded",i),this.on("destroyed",()=>{$.off("audioLoaded",i)})}getData(){this.rawData=this.renderer.chartManager.chartAudio.getRawData(),this.filteredRawData=this.renderer.chartManager.chartAudio.getFilteredRawData(),this.sampleRate=this.renderer.chartManager.chartAudio.getSampleRate(),this.blockCache.clear(),this.drawDirty=!0}resizeWaveform(){this.waveformTex.resize(Ve((this.rawData?.length??0)*288*_.chart.zoom,1,this.renderer.chartManager.app.renderer.screen.width),this.renderer.chartManager.app.renderer.screen.height)}update(){this.visible=_.chart.waveform.enabled&&this.renderer.shouldDisplayBarlines(),_.chart.waveform.enabled&&((this.drawDirty||this.variableChanged())&&(this.drawDirty=!1,this.renderData(),this.renderer.chartManager.app.renderer.render(this.lineContainer,{renderTexture:this.waveformTex})),this.scale.set(1/_.chart.zoom))}trackVariable(e,t){this.trackedVariables.set(e,{value:e(),cb:t})}variableChanged(){let e=!1;for(const[t,i]of this.trackedVariables.entries())t()!=i.value&&(this.trackedVariables.get(t).value=t(),this.trackedVariables.get(t).cb?.(t()),e=!0);return e}getSample(e,t,i){if(t<0)return 0;const s=this.sampleRate/(this.lastSpeed*4),n=Math.floor(t*this.lastSpeed*4);if(this.blockCache.get(i)?.[n]!==void 0)return this.blockCache.get(i)[n];const a=Math.floor(n*s),o=e.slice(a,Math.floor(a+s)).reduce((l,c)=>l+Math.abs(c),0)/s;return this.blockCache.has(i)||this.blockCache.set(i,[]),this.blockCache.get(i)[n]=o,o}renderData(){this.resetPool();const e=_.chart.waveform.allowFilter&&this.renderer.chartManager.chartAudio.hasFilters();if(_.chart.waveform.speedChanges&&!_.chart.CMod&&_.chart.doSpeedChanges){const t=_.chart.speed,i=this.renderer.chart.timingData.getSpeedMult(this.renderer.getVisualBeat(),this.renderer.getVisualTime()),s=i>=0!=_.chart.reverse?1:-1,n=this.renderer.getVisualBeat()+_.chart.maxDrawBeats,a=[...this.renderer.chart.timingData.getTimingData("SCROLLS")];a[0]?.beat!=0&&a.unshift({type:"SCROLLS",beat:0,value:1});const o=this.renderer.chart.timingData.getOffset(),l=this.renderer.chart.timingData.getEventAtBeat("BPMS",0)?.value??120,c=this.renderer.chart.timingData.getBeatTiming(),u=100/t/Math.abs(i)/64/_.chart.zoom,h=this.renderer.chartManager.app.renderer.screen.height;let d=!1,p=hi(a,this.renderer.getVisualBeat()-_.chart.maxDrawBeatsBack,y=>y.beat),f=a[p]?.beat??0;f==0&&(f=-_.chart.maxDrawBeatsBack);let m=this.renderer.chart.getSecondsFromBeat(f),g=Math.round(this.renderer.getYPosFromBeat(f)*_.chart.zoom+this.parent.y);for(;fh||y.value*s>0&&A<0)){p++,f=a[p].beat,g=Math.round(A);continue}const v=u/Math.abs(y.value);for(;fh){if(y.value*s>0){d=!0;break}f+=v*(g-h),g=h;continue}f+=v*_.chart.waveform.lineHeight,g+=(y.value*s>0?1:-1)*_.chart.waveform.lineHeight,m=this.calculateSecond(f,c,o,l),this.drawLine(m,g,e)}p++,f=b,g=A}}else if(_.chart.CMod){let t=this.renderer.getSecondFromYPos((-this.parent.y+(_.chart.reverse?this.renderer.chartManager.app.renderer.screen.height:0))/_.chart.zoom);const i=this.renderer.getPixelsToSecondsRatio()/_.chart.zoom;t=Math.floor(t/i)*i;const s=n=>{t+=i*_.chart.waveform.lineHeight,this.drawLine(t,n,e)};if(_.chart.reverse)for(let n=this.renderer.chartManager.app.renderer.screen.height;n>=0;n-=_.chart.waveform.lineHeight)s(n);else for(let n=0;n<=this.renderer.chartManager.app.renderer.screen.height;n+=_.chart.waveform.lineHeight)s(n)}else{let t=this.renderer.getBeatFromYPos((-this.parent.y+(_.chart.reverse?this.renderer.chartManager.app.renderer.screen.height:0))/_.chart.zoom);const i=this.renderer.chart.timingData.getOffset(),s=this.renderer.chart.timingData.getEventAtBeat("BPMS",0)?.value??120,n=this.renderer.chart.timingData.getBeatTiming(),a=this.renderer.getPixelsToEffectiveBeatsRatio()/_.chart.zoom;t=Math.floor(t/a)*a;let o=this.renderer.chart.getSecondsFromBeat(t);const l=c=>{t+=a*_.chart.waveform.lineHeight,o=this.calculateSecond(t,n,i,s),this.drawLine(o,c,e)};if(_.chart.reverse)for(let c=this.renderer.chartManager.app.renderer.screen.height;c>=0;c-=_.chart.waveform.lineHeight)l(c);else for(let c=0;c<=this.renderer.chartManager.app.renderer.screen.height;c+=_.chart.waveform.lineHeight)l(c)}this.purgePool()}calculateSecond(e,t,i,s){const n=Math.floor(e*1e3)/1e3;if(e<=0)return-i+e*60/s;if(n>=t[1]?.beat){for(;n>=t[1]?.beat;)t.shift();return this.renderer.chart.getSecondsFromBeat(e)}else{let o=(e-t[0].beat)*60/t[0].bpm;return t[0].warped&&(o=0),Math.max(t[0].secondClamp,t[0].secondAfter+o)}}drawLine(e,t,i){if(!(e<0))for(let s=0;st>=this.poolSearch)}updateLineHeight(){for(const e of this.lineContainer.children){const t=e;t.height=_.chart.waveform.lineHeight}}getLine(){if(this.lineContainer.children[this.poolSearch]){const t=this.lineContainer.children[this.poolSearch];return t.visible=!0,this.poolSearch++,t}const e=new ke(Z.WHITE);return e.height=_.chart.waveform.lineHeight,e.anchor.set(.5),e.visible=!0,this.poolSearch++,this.lineContainer.addChild(e),e}getSpeed(){return Math.min(_.chart.speed,eS)}}class iS{renderer;constructor(e){this.renderer=e}}const rS="/smeditor/assets/decent-f3f8a110.png",sS="/smeditor/assets/excellent-84718ac0.png",nS="/smeditor/assets/fantastic-1755e773.png",aS="/smeditor/assets/great-0e864574.png",oS="/smeditor/assets/hold-7b947e11.png",lS="/smeditor/assets/mine-590d445e.png",hS="/smeditor/assets/way_off-8bc3fd65.png",cS="/smeditor/assets/white_fantastic-b65b4f11.png",dS=Z.from(oS),xh={w0:Z.from(nS),w1:Z.from(cS),w2:Z.from(sS),w3:Z.from(aS),w4:Z.from(rS),w5:Z.from(hS),mine:Z.from(lS)};class ca extends ke{createTime=0;type="flash";constructor(e){super(e),this.anchor.set(.5),this.createTime=Date.now()}update(){switch(this.type){case"flash":{const e=(Date.now()-this.createTime)/150;this.scale.set(1.1-e*.1),this.alpha=1.2-e*1.2;break}case"mine":{const e=(Date.now()-this.createTime)/600;this.rotation=e*-Math.PI,this.alpha=Math.min(1,2-2*e);break}case"hold":this.alpha=Math.sin(Date.now())*.2+1.2}Date.now()-this.createTime>150&&this.type=="flash"&&this.destroy()}static createJudgment(e){let t;if(Vi(e)&&(t=xh[e.id]),ms(e)&&(t=xh.mine),Dr(e)&&(t=xh.w2),!t)return;const i=new ca(t);return i.type="flash",ms(e)&&(i.type="mine",i.blendMode=Ee.ADD),i}static createHoldJudgment(){const e=new ca(dS);return e.type="hold",e}}const uS="/smeditor/assets/parts-0c8fa692.png",pS="/smeditor/assets/frame-d599a2fe.png",fS="/smeditor/assets/parts-b37af2cf.png",mS="/smeditor/assets/parts-9668caec.png",gS=`precision mediump float; varying vec2 vUvs; @@ -1715,4 +1715,4 @@ void main() { 31 43 42 31 20 43 20 32 43`,ES=Z.from(pS);class Ge{static arrowPartsTex=Me.from(mS,{mipmap:Xt.OFF});static minePartsTex=Me.from(fS,{mipmap:Xt.OFF});static liftPartsTex=Me.from(uS,{mipmap:Xt.OFF});static arrowBodyGeom;static arrowFrameGeom;static liftBodyGeom;static mineBodyGeom;static arrowFrameTex;static arrowFrame;static arrowTex;static arrowContainer=new xe;static liftTex;static liftContainer=new xe;static mineTex;static mineConainer=new xe;static loaded=!1;static async initArrowTex(e){if(!this.loaded){Ge.arrowFrameTex=mt.create({width:64,height:64,resolution:_.performance.resolution}),Ge.arrowTex=mt.create({width:256,height:320,resolution:_.performance.resolution}),Ge.liftTex=mt.create({width:256,height:320,resolution:_.performance.resolution}),Ge.mineTex=mt.create({width:64,height:64,resolution:_.performance.resolution}),this.arrowBodyGeom=await this.loadGeometry(AS),this.arrowFrameGeom=await this.loadGeometry(wS),this.mineBodyGeom=await this.loadGeometry(_S),this.liftBodyGeom=await this.loadGeometry(xS);{const t=Ot.from(so,bS,{sampler0:this.arrowPartsTex}),i=new ls(Ge.arrowFrameGeom,t);i.x=32,i.y=32,i.rotation=-Math.PI/2,this.arrowFrame=i}for(let t=0;t<10;t++){const i=Ot.from(so,gS,{sampler0:this.arrowPartsTex,time:0,quant:t}),s=new ke(Ge.arrowFrameTex);s.x=t%3*64,s.y=Math.floor(t/3)*64;const n=new ls(Ge.arrowBodyGeom,i);n.x=t%3*64+32,n.y=Math.floor(t/3)*64+32,n.rotation=-Math.PI/2,n.name="body"+t,Ge.arrowContainer.addChild(s),Ge.arrowContainer.addChild(n)}for(let t=0;t<10;t++){const i=Ot.from(so,yS,{sampler0:this.liftPartsTex,time:0,quant:t}),s=new ls(Ge.liftBodyGeom,i);s.x=t%3*64+32,s.y=Math.floor(t/3)*64+32,s.rotation=-Math.PI/2,s.name="body"+t,Ge.liftContainer.addChild(s)}{const t=Ot.from(so,vS,{sampler0:this.minePartsTex,time:0}),i=new ls(Ge.mineBodyGeom,t),s=new ke(ES);s.width=64,s.height=64,s.anchor.set(.5),s.pivot.y=3,Ge.mineConainer.position.set(32),Ge.mineConainer.addChild(i),Ge.mineConainer.addChild(s)}e.ticker.add(()=>{e.renderer.render(Ge.arrowFrame,{renderTexture:Ge.arrowFrameTex}),e.renderer.render(Ge.arrowContainer,{renderTexture:Ge.arrowTex}),e.renderer.render(Ge.mineConainer,{renderTexture:Ge.mineTex}),e.renderer.render(Ge.liftContainer,{renderTexture:Ge.liftTex})}),this.loaded=!0}}static async loadGeometry(e){const t=e.split(` -`),i=parseInt(t[0]),s=parseInt(t[i+1]),n=[],a=[],o=[];for(let l=0;l.6&&t<.8){const i=(t-.6)/.2*(t-.6)/.2;e.scale.set(.3*(1-i))}}Wi(this.children,e=>Date.now()-e.createTime>800)}addJudge(e,t){if(!yn(t)&&!Rr(t))return;const i=new ke(yn(t)?os.dropped_tex:os.held_tex);i.anchor.set(.5),i.x=this.notefield.getColumnX(e),i.createTime=Date.now(),i.scale.set(0),this.addChild(i)}}const VS={L:233724,l:11261687,R:16559363,r:16442809};class zS extends xe{notefield;arrowMap=new Map;notesDirty=!1;children=[];constructor(e){super(),this.notefield=e,this.sortableChildren=!0;const t=()=>{this.arrowMap.clear(),this.removeChildren()},i=()=>this.notesDirty=!0;$.on("timeSigChanged",t),$.on("chartModified",i),this.on("destroyed",()=>{$.off("timeSigChanged",t),$.on("chartModified",i)})}update(e,t){const i=this.notefield.renderer.chart.getNotedata();if(this.notesDirty){for(const[s,n]of this.arrowMap.entries())i.includes(s)||(n.destroy(),this.arrowMap.delete(s));this.notesDirty=!1}for(const s of i){if(s.beat>t)break;if(this.shouldDisplayNote(s,e,t)&&!this.arrowMap.has(s)){const n=new xe,a=this.notefield.noteskin.createNote(s);Object.assign(n,{x:this.notefield.getColumnX(s.col),zIndex:s.beat}),a.note.rotation=this.notefield.getColumnRotation(s.col);const o=new ke(Z.WHITE),l=a.getBounds();o.x=l.x,o.y=l.y,o.width=l.width,o.height=l.height,o.alpha=0;const c=new ke(Z.WHITE);c.x=l.x,c.y=l.y,c.width=l.width,c.height=l.height,c.alpha=0,this.notefield.renderer.registerDragNote(n,s),n.object=a,n.selection=o,n.parity=c,this.arrowMap.set(s,n),n.addChild(a,o,c),this.addChild(n)}}for(const[s,n]of this.arrowMap.entries()){if(!this.shouldDisplayNote(s,e,t)){n.destroy(),this.arrowMap.delete(s);continue}if(n.object.update(this.notefield.renderer),n.y=this.notefield.renderer.getActualReceptorYPos(),(!Be(s)||!s.gameplay?.lastHoldActivation||this.notefield.renderer.getVisualBeat(){e.flashes.children.forEach(t=>t.update(this.notefield.renderer)),e.holdFlashes.children.forEach(t=>t.update(this.notefield.renderer))})}createNoteFlash(e,t){(Rr(t)||yn(t))&&this.children[e].holdFlashes.removeChildren();const i=this.notefield.noteskin.createNoteFlash(t);i&&this.children[e].flashes.addChild(i)}createHoldNoteFlash(e){const t=this.notefield.noteskin.createHoldNoteFlash();t&&this.children[e].holdFlashes.addChild(t)}reset(){this.children.forEach(e=>{e.flashes.removeChildren(),e.holdFlashes.removeChildren()})}}class YS extends xe{notefield;children=[];constructor(e){super(),this.notefield=e;for(let t=0;tt.update(this.notefield.renderer,e))}keyDown(e){this.children[e].keyDown()}keyUp(e){this.children[e].keyUp()}}class XS extends xe{notefield;arrowMap=new Map;children=[];lastBeatShift=0;lastColShift=0;constructor(e){super(),this.notefield=e,this.sortableChildren=!0}update(e,t){if(!this.notefield.renderer.chartManager.selection.shift){this.removeChildren(),this.arrowMap.clear();return}const i=this.notefield.renderer.chartManager.selection.shift.beatShift,s=this.notefield.renderer.chartManager.selection.shift.columnShift;if(this.lastBeatShift!=i||this.lastColShift!=s){this.lastBeatShift=i,this.lastColShift=s;for(const[n,a]of this.arrowMap.entries()){const o={...n,beat:n.beat+i,col:n.col+s};a.x=this.notefield.getColumnX(o.col),a.object.destroy(),a.object.alpha=.4,a.object=this.notefield.noteskin.createNote(o),a.object.note.rotation=this.notefield.getColumnRotation(o.col);const l=a.object.getBounds();a.selection.x=l.x,a.selection.y=l.y,a.selection.width=l.width,a.selection.height=l.height,a.addChild(a.object,a.selection)}}for(const n of this.notefield.renderer.chartManager.selection.notes)if(!(n.beat+i+(Be(n)?n.hold:0)t)&&!this.arrowMap.has(n)){const a={...n,beat:n.beat+i,col:n.col+s},o=new xe,l=this.notefield.noteskin.createNote(a);Object.assign(o,{x:this.notefield.getColumnX(a.col),zIndex:a.beat,alpha:.4}),l.note.rotation=this.notefield.getColumnRotation(a.col);const c=new ke(Z.WHITE),u=l.getBounds();c.x=u.x,c.y=u.y,c.width=u.width,c.height=u.height,c.alpha=0,this.notefield.renderer.registerDragNote(l,a),o.object=l,o.selection=c,this.arrowMap.set(n,o),o.addChild(l,c),this.addChild(o)}for(const[n,a]of this.arrowMap.entries()){if(n.beat+i+(Be(n)?n.hold:0)t){a.destroy(),this.arrowMap.delete(n);continue}const o=n.beat+i;if(a.y=this.notefield.renderer.getYPosFromBeat(o),a.selection.alpha=Math.sin(Date.now()/320)*.1+.3,Be(n)){const l=this.notefield.renderer.getYPosFromBeat(o+(Be(n)?n.hold:0))-a.y;this.setHoldLength(a.object,l),this.setHoldBrightness(a.object,.8);const c=a.object.getLocalBounds();a.selection.x=c.x,a.selection.y=c.y,a.selection.width=c.width,a.selection.height=c.height}}}setHoldLength(e,t){e.hold&&(e.hold.holdBody.height=t,e.hold.holdBody.y=t,e.hold.holdCap.y=t,e.hold.holdCap.scale.y=t<0?-.5:.5)}setHoldBrightness(e,t){e.hold&&(e.hold.holdBody.tint=Ur(t*255,t*255,t*255),e.hold.holdCap.tint=Ur(t*255,t*255,t*255))}}class KS extends xe{noteskinOptions;noteskin;gameType;renderer;receptors;notes;selectionNotes;flashes;holdJudges;ghostNote;ghostNoteEntry;columnX=[];constructor(e){super(),this.renderer=e,this.gameType=e.chart.gameType;const t=sn.getNoteSkin(this.gameType,_.chart.noteskin[e.chart.gameType.id]);if(!t){Ce.createFormatted("Couldn't find an available noteskin!","error");return}let i=0;for(let s=0;s=e&&this.ghostNoteEntry.beat<=t&&this.ghostNoteEntry.beat>=0)}onJudgment(e,t){this.flashes.createNoteFlash(e,t),this.holdJudges.addJudge(e,t)}endPlay(){this.flashes.reset()}keyDown(e){this.receptors.keyDown(e)}keyUp(e){this.receptors.keyUp(e)}activateHold(e){this.flashes.createHoldNoteFlash(e)}getColumnX(e){return this.columnX[e]??0}getColumnRotation(e){return this.noteskinOptions.rotateColumns?this.gameType.columnRotations[e]/180*Math.PI:0}}class qS extends Fe{renderer;constructor(e){super("",{fontName:"Fancy"}),this.anchor.set(.5),this.renderer=e}update(){this.y=_.chart.reverse?-50:50;const e=this.renderer.chartManager.gameStats;if(this.visible=this.renderer.chartManager.getMode()==Y.Play,!e)return;const t=e.getCombo()==0?e.getMissCombo():e.getCombo();t<4?this.text="":this.text=t+"",e.getCombo()==0?this.tint=qe.getCollection(_.play.timingCollection).getMissJudgment().color:e.getBestJudge()?this.tint=Pg(e.getBestJudge().color,Math.sin(Date.now()/225)*.2+1.2):this.tint=16777215}}const QS=1,Qp=15,$S={fontName:"Fancy",fontSize:12};class JS extends xe{barlines=new xe;barline;currentMedian;errorText=new Fe("",$S);errorTextTime=-1;renderer;target=0;constructor(e){super(),this.renderer=e,this.barline=new ke(Z.WHITE),this.barline.anchor.set(.5),this.barline.height=1,this.barline.alpha=.5;const t=new ke(Z.WHITE);t.width=2,t.height=Qp,t.anchor.set(.5),this.currentMedian=new ma,this.currentMedian.beginFill(16777215),this.currentMedian.moveTo(0,-10),this.currentMedian.lineTo(5,-15),this.currentMedian.lineTo(-5,-15),this.currentMedian.lineTo(0,-10),this.errorText.y=-25,this.errorText.anchor.set(.5),this.addChild(this.barline,t,this.barlines,this.currentMedian,this.errorText)}update(){this.y=_.chart.reverse?-10:10,this.errorText.y=_.chart.reverse?25:-25,this.visible=this.renderer.chartManager.getMode()==Y.Play;for(const e of this.barlines.children){const t=(Date.now()-e.createTime)/5e3;t<.05?e.alpha=1:t<.3?e.alpha=sr(1,.2,(t-.05)/.25):t<.9?e.alpha=.2:e.alpha=(1-t)*3}this.errorText.alpha=Ve((2e3-(Date.now()-this.errorTextTime))/1e3,0,1),this.barline.width=qe.getCollection(_.play.timingCollection).maxWindowMS()/1e3*2*400,Wi(this.barlines.children,e=>Date.now()-e.createTime>5e3),_.general.smoothAnimations?this.currentMedian.x=(this.currentMedian.x-this.target)*.8+this.target:this.currentMedian.x=this.target}addBar(e,t){if(!ni(t)&&!Vi(t))return;const i=new ke(Z.WHITE);i.width=QS,i.height=Qp,i.anchor.set(.5),i.x=e*400,i.tint=t.color,i.createTime=Date.now(),i.miss=ni(t),i.ms=Math.round(e*1e3),this.errorText.tint=t.color,this.errorText.text=(e*1e3).toFixed(1)+"ms",this.errorTextTime=Date.now(),this.barlines.addChild(i),this.target=fl(this.barlines.children.filter(s=>!s.miss).map(s=>s.ms))*.4}reset(){this.currentMedian.x=0,this.target=0,Wi(this.barlines.children,()=>!0)}}class ZS extends ke{createTime=-1;active=!1;type=dg;constructor(){super(),this.anchor.set(.5)}update(){if(this.y=_.chart.reverse?40:-40,this.visible=this.active,this.active){const e=(Date.now()-this.createTime)/1e3;let t=1.2;if(qe.getCollection(_.play.timingCollection).shouldHideNote(this.type)||(t=.8),e<.1){const i=1-(1-e/.1)*(1-e/.1),s=(1-t)*i+t;this.scale.x=.4*s,this.scale.y=.4*s}else if(e>.6&&e<.8){const i=(e-.6)/.2*(e-.6)/.2;this.scale.x=.4*(1-i),this.scale.y=.4*(1-i)}else e>.8&&(this.active=!1)}}doJudge(e,t){if(!Vi(t)&&!ni(t))return;const i=t.judgmentTexture.getTexture(e,t);i&&(this.texture=i,this.texture.updateUvs(),this.active=!0,this.type=t,this.createTime=Date.now(),_.play.judgmentTilt?this.rotation=Ve(e,-.05,.05)*300/180*Math.PI:this.rotation=0)}reset(){this.active=!1}}const $p={BPMS:{title:"BPM Event",rows:[{label:"Tempo",key:"value",input:{type:"spinner",precision:3}}]},STOPS:{title:"Stop Event",description:"Stops for a number of seconds. Notes on this beat are hit before the stop occurs.",rows:[{label:"Seconds",key:"value",input:{type:"spinner",precision:3}}]},WARPS:{title:"Warp Event",description:"Warps ahead a number of beats. Warped notes do not count towards score.",rows:[{label:"Beats",key:"value",input:{type:"spinner",precision:3,min:0}}]},DELAYS:{title:"Delay Event",description:"Stops for a number of seconds. Notes on this beat are hit after the delay occurs.",rows:[{label:"Seconds",key:"value",input:{type:"spinner",precision:3}}]},SCROLLS:{title:"Scroll Event",description:"Notes after this event will scroll at the specified speed.",rows:[{label:"Multiplier",key:"value",input:{type:"spinner",precision:3}}]},TICKCOUNTS:{title:"Tickcount Event",description:"Number of ticks per beat in a hold. Only applies to pump gamemodes.",rows:[{label:"Ticks",key:"value",input:{type:"spinner",step:1,precision:0,min:0}}]},FAKES:{title:"Fake Event",description:"Creates an area of notes that cannot be hit and do not count towards score.",rows:[{label:"Beats",key:"value",input:{type:"spinner",precision:3,min:0}}]},LABELS:{title:"Label Event",rows:[{label:"Label",key:"value",input:{type:"text"}}]},SPEEDS:{title:"Speed Event",width:200,description:"The entire playfield scrolls at the specified speed. Can slowly ease over a certain amount of time.",rows:[{label:"Multiplier",key:"value",input:{type:"spinner",precision:3}},{label:"Ease time",key:"delay",input:{type:"spinner",precision:3,min:0}},{label:"Ease unit",key:"unit",input:{type:"dropdown",items:["Beats","Seconds"],transformers:{serialize:r=>r=="B"?"Beats":"Seconds",deserialize:r=>r=="Beats"?"B":"T"}}}]},TIMESIGNATURES:{title:"Time Signature Event",width:200,rows:[{label:"Upper",key:"upper",input:{type:"spinner",step:1,precision:0,min:1}},{label:"Lower",key:"lower",input:{type:"spinner",step:1,precision:0,min:1}}]},COMBOS:{title:"Combo Event",width:200,description:"Multiplies the combo gained from hitting/missing notes after this event.",rows:[{label:"Hit multiplier",key:"hitMult",input:{type:"spinner",step:1,precision:0,min:0}},{label:"Miss multiplier",key:"missMult",input:{type:"spinner",step:1,precision:0,min:0}}]},ATTACKS:{title:"Attack Event",width:200,description:"Applies a modifier to the playfield. Can specify the length of the applied attack in seconds or the end time of the attack.",rows:[{label:"Timing type",key:"endType",input:{type:"dropdown",items:["Length","End"],transformers:{serialize:r=>r=="LEN"?"Length":"End",deserialize:r=>r=="Length"?"LEN":"END"}}},{label:"Seconds",key:"value",input:{type:"spinner",precision:3}},{label:"Mods",key:"mods",input:{type:"text"}}]},BGCHANGES:{title:"BG Change Event",width:250,rows:[{label:"File",key:"file",input:{type:"text"}},{label:"Update rate",key:"updateRate",input:{type:"spinner",precision:3,min:0}},{label:"Crossfade",key:"crossfade",input:{type:"checkbox"}},{label:"StretchRewind",key:"stretchRewind",input:{type:"checkbox"}},{label:"StretchNoLoop",key:"StretchNoLoop",input:{type:"checkbox"}},{label:"Effect",key:"effect",input:{type:"text"}},{label:"File2",key:"file2",input:{type:"text"}},{label:"Transition",key:"transition",input:{type:"text"}},{label:"Color1",key:"color1",input:{type:"text"}},{label:"Color2",key:"color2",input:{type:"text"}}]},FGCHANGES:{title:"FG Change Event",width:250,rows:[{label:"File",key:"file",input:{type:"text"}},{label:"Update rate",key:"updateRate",input:{type:"spinner",precision:3,min:0}},{label:"Crossfade",key:"crossfade",input:{type:"checkbox"}},{label:"StretchRewind",key:"stretchRewind",input:{type:"checkbox"}},{label:"StretchNoLoop",key:"StretchNoLoop",input:{type:"checkbox"}},{label:"Effect",key:"effect",input:{type:"text"}},{label:"File2",key:"file2",input:{type:"text"}},{label:"Transition",key:"transition",input:{type:"text"}},{label:"Color1",key:"color1",input:{type:"text"}},{label:"Color2",key:"color2",input:{type:"text"}}]}};class St{static activePopup;timingBox;popup;zoomer;editText;timingData;rows=[];onTimingChange;clickOutside;moveInterval;modifyBox;onConfirm=()=>{};persistent=!1;constructor(e,t,i=!1){e.popup=this,this.timingBox=e,this.timingData=t,this.modifyBox=i,this.popup=this.build(),this.popup.style.display="none",setTimeout(()=>this.movePosition()),this.onTimingChange=this.updateValues.bind(this),this.clickOutside=s=>{this.popup.contains(s.target)||this.close()},$.on("timingModified",this.onTimingChange),St.activePopup?.persistent?e.popup=void 0:(document.getElementById("popups")?.appendChild(this.popup),this.moveInterval=setInterval(()=>this.movePosition(),150),St.activePopup?.close(),St.activePopup=this)}movePosition(){this.popup.style.display="";const e=this.timingBox.backgroundObj.getBounds(),t=e.left+e.width/2,i=$p[this.timingBox.event.type].width??150,s=i/2+15,n=window.innerWidth-i/2-15;this.popup.style.left=`${Ve(t,s,n)}px`;const a=e.top+35+e.height/2;this.popup.style.top=`${e.top+e.height+35}px`,a+this.popup.clientHeight>window.innerHeight-15&&(this.popup.style.transform="translate(-50%, -100%)",this.popup.style.top=`${e.top-e.height/2+35}px`)}build(){const e=$p[this.timingBox.event.type],t=document.createElement("div");t.classList.add("popup");const i=document.createElement("div");i.classList.add("popup-zoomer"),i.style.width=e.width?`${e.width}px`:"150px",i.style.backgroundColor=Cc(Lr[this.timingBox.event.type].toString(16).padStart(6,"0"),"#333333",.75),this.zoomer=i,t.appendChild(i);const s=document.createElement("div");if(s.innerText=e.title,s.classList.add("popup-title"),i.appendChild(s),e.description){const u=document.createElement("div");u.innerText=e.description,i.appendChild(u),u.classList.add("popup-desc")}const n=document.createElement("div");n.classList.add("popup-grid"),i.appendChild(n),e.rows.forEach(u=>n.append(...this.buildRow(u)));const a=document.createElement("div");a.innerText="click to edit",a.style.marginTop="4px",a.style.height="10px",i.appendChild(a),a.classList.add("popup-desc"),this.editText=a;const o=document.createElement("div");o.classList.add("popup-options");const l=document.createElement("button");l.innerText="Ok",l.onclick=()=>{this.close(),this.onConfirm(this.timingBox.event)},l.classList.add("confirm"),o.append(l);const c=document.createElement("button");return c.innerText="Delete",c.onclick=()=>{this.modifyBox||this.timingData.delete([{type:this.timingBox.event.type,[this.timingBox.event.type=="ATTACKS"?"second":"beat"]:this.timingBox.event.type=="ATTACKS"?this.timingBox.event.second:this.timingBox.event.beat}]),this.close()},c.classList.add("delete"),o.append(c),i.append(o),t}buildRow(e){const t=structuredClone(this.timingBox.event),i=document.createElement("div");i.innerText=e.label,i.classList.add("popup-label");const s=[];switch(s.push(i),e.input.type){case"spinner":{const n=Ze.create(t[e.key],e.input.step,e.input.precision,e.input.min,e.input.max);n.onChange=a=>{a!==void 0&&this.modifyEvent(e.key,a)},this.rows.push({data:e,el:n}),s.push(n.view);break}case"text":{const n=document.createElement("input");n.type="text",n.autocomplete="off",n.spellcheck=!1,n.onkeydown=a=>{a.key=="Enter"&&n.blur()},n.onblur=()=>{this.modifyEvent(e.key,n.value)},n.value=t[e.key],this.rows.push({data:e,el:n}),s.push(n);break}case"dropdown":{if(e.input.transformers){const n=e.input.transformers.deserialize,a=e.input.transformers.serialize,o=pi.create(e.input.items,a(t[e.key]));o.onChange(l=>{this.modifyEvent(e.key,n(l))}),this.rows.push({data:e,el:o}),s.push(o.view)}else{const n=pi.create(e.input.items,t[e.key]);n.onChange(a=>{this.modifyEvent(e.key,a)}),this.rows.push({data:e,el:n}),s.push(n.view)}break}case"checkbox":{const n=document.createElement("input");n.type="checkbox",n.checked=t[e.key],n.onchange=()=>{this.modifyEvent(e.key,n.checked)},this.rows.push({data:e,el:n}),s.push(n);break}}return s}modifyEvent(e,t){this.modifyBox?Object.assign(this.timingBox.event,{[e]:t}):this.timingData.modify([[structuredClone(this.timingBox.event),Object.assign(this.timingBox.event,{[e]:t})]])}updateValues(){const e=this.timingData.getEventAtBeat(this.timingBox.event.type,this.timingBox.event.beat,!1);if(!this.timingBox||!e||e.beat!=this.timingBox.event.beat){this.close();return}this.rows.forEach(t=>{switch(t.data.input.type){case"spinner":{t.el.setValue(e[t.data.key]);break}case"text":{t.el.value=e[t.data.key];break}case"dropdown":{const i=t.el;t.data.input.transformers?i.setSelected(t.data.input.transformers.serialize(e[t.data.key])):i.setSelected(e[t.data.key]);break}case"checkbox":{t.el.checked=e[t.data.key];break}}})}close(){this.persistent=!1,$.off("timingModified",this.onTimingChange),window.removeEventListener("click",this.clickOutside),clearInterval(this.moveInterval),this.popup.classList.add("exiting"),setTimeout(()=>this.popup.remove(),200),this.timingBox.popup=void 0,St.activePopup=void 0}select(){this.persistent=!0,this.zoomer.classList.add("selected"),this.editText.style.transform="scale(0)",this.editText.style.height="0px",setTimeout(()=>window.addEventListener("click",this.clickOutside),200)}detach(){clearInterval(this.moveInterval)}getEvent(){return this.timingBox.event}attach(e){clearInterval(this.moveInterval),this.moveInterval=setInterval(()=>this.movePosition(),150),this.timingBox=e}}const Bc={fontName:"Main",fontSize:15},Mr={BPMS:55,STOPS:55,DELAYS:55,WARPS:55,FAKES:55,COMBOS:40,SPEEDS:80,LABELS:80,SCROLLS:55,TIMESIGNATURES:40,TICKCOUNTS:40,BGCHANGES:55,FGCHANGES:55,ATTACKS:55};class eC extends xe{tracks=new xe;renderer;timingBoxMap=new Map;wasEditingTiming=!1;boxPool=new ha({create:()=>{const e=new xe;return e.textObj=new Fe("",Bc),e.backgroundObj=new Nt,e.selection=new Nt("onlyBorder"),e.selection.tint=3841008,e.addChild(e.backgroundObj,e.textObj,e.selection),e}});ghostBox;timingDirty=!1;constructor(e){super(),this.renderer=e,this.boxPool.sortableChildren=!0,this.sortableChildren=!0,this.addChild(this.tracks,this.boxPool);const t=()=>this.timingDirty=!0;$.on("timingModified",t),this.on("destroyed",()=>$.off("timingModified",t))}update(e,t){this.renderer.chartManager.editTimingMode!=De.Add&&(this.ghostBox?.removeFromParent(),this.ghostBox?.destroy(),this.ghostBox=void 0),this.updateTracks(),this.updateBoxes(e,t)}createTrack(e,t){const i=Object.assign(new ke(Z.WHITE),{alpha:0,width:Mr[e],name:e,height:5e3,x:t,type:e,lastX:0,tint:2503250,targetAlpha:0});return i.anchor.y=.5,this.tracks.addChild(i),i}initializeBox(e,t){if(Object.assign(e,{event:t,isChartTiming:this.renderer.chart.timingData.isPropertyChartSpecific(t.type),lastX:void 0,lastAnchor:void 0,animationId:void 0,zIndex:t.beat,eventMode:"static"}),e.textObj.text=this.getLabelFromEvent(t),e.textObj.anchor.set(.5,.55),e.backgroundObj.width=e.textObj.width+10,e.backgroundObj.height=25,e.backgroundObj.position.x=-e.backgroundObj.width/2,e.backgroundObj.position.y=-25/2,e.selection.width=e.textObj.width+10,e.selection.height=25,e.selection.position=e.backgroundObj.position,e.popup=void 0,St.activePopup){const i=St.activePopup.getEvent();i.type=="ATTACKS"&&t.type=="ATTACKS"&&i.second==t.second&&(St.activePopup.attach(e),e.popup=St.activePopup),i.type!="ATTACKS"&&t.type!="ATTACKS"&&i.type==t.type&&i.beat==t.beat&&(St.activePopup.attach(e),e.popup=St.activePopup)}}addDragListeners(e,t){e.on("mouseenter",()=>{e?.popup?.persistent!==!0&&(this.renderer.chartManager.eventSelection.timingEvents.length>0||this.renderer.isDragSelecting()||(e.popup?.close(),this.renderer.chartManager.getMode()==Y.Edit&&(new St(e,this.getTargetTimingData(e.event.isChartTiming)),e.popup&&(e.popup.onConfirm=()=>{this.renderer.chartManager.removeEventFromSelection(t)}))))}),e.on("mouseleave",()=>{e?.popup?.persistent!==!0&&e.popup?.close()});let i=0,s;const n=a=>{const o=s,l=this.toLocal(a.global);if(Math.abs(l.y-i)<32){this.renderer.chartManager.eventSelection.shift&&(this.renderer.chartManager.eventSelection.shift={beatShift:0});return}e.popup?.close();const c=this.renderer.getBeatFromYPos(l.y),u=_.chart.snap==0?1/1e3:_.chart.snap;let h=Math.round(c/u)*u;Math.abs(h-c)>Math.abs(c-o.beat)&&(h=o.beat),this.renderer.chartManager.eventSelection.shift||={beatShift:0},this.renderer.chartManager.eventSelection.shift.beatShift=Math.max(-Math.min(...this.renderer.chartManager.eventSelection.timingEvents.map(d=>d.beat)),h-o.beat)};e.on("pointerdown",a=>{if(Tc(a)){this.renderer.chartManager.clearSelections(),this.renderer.chartManager.addEventToSelection(t),St.activePopup?.close();return}if(a.stopImmediatePropagation(),this.renderer.chartManager.isEventInSelection(t)?(a.getModifierState("Control")||a.getModifierState("Meta"))&&this.renderer.chartManager.removeEventFromSelection(t):(!a.getModifierState("Control")&&!a.getModifierState("Meta")&&!a.getModifierState("Shift")&&this.renderer.chartManager.clearSelections(),this.renderer.chartManager.addEventToSelection(t)),this.renderer.chartManager.getMode()==Y.Edit&&this.renderer.chartManager.eventSelection.timingEvents.length==1&&(e?.popup||(St.activePopup?.close(),new St(e,this.getTargetTimingData(e.event.isChartTiming)),e.popup.onConfirm=()=>{this.renderer.chartManager.removeEventFromSelection(t)})),e.popup&&!a.getModifierState("Control")&&!a.getModifierState("Meta")&&!a.getModifierState("Shift")?e.popup.select():e.popup?.close(),i=e.y,s=t,this.renderer.chartManager.editTimingMode==De.Add)return;this.renderer.on("pointermove",n);const o=()=>{this.renderer.off("pointermove",n),this.renderer.off("pointerup",o),(this.renderer.chartManager.eventSelection.shift?.beatShift??0)!=0&&this.renderer.chartManager.modifyEventSelection(l=>(l.type=="ATTACKS"&&(l.second=this.renderer.chart.timingData.getSecondsFromBeat(l.beat+this.renderer.chartManager.eventSelection.shift.beatShift)),l.beat+=this.renderer.chartManager.eventSelection.shift.beatShift,l)),this.renderer.chartManager.eventSelection.shift=void 0};this.renderer.on("pointerup",o)})}updateTracks(){const e=_.chart.timingEventOrder.left,t=_.chart.timingEventOrder.right,i=this.renderer.chartManager.editTimingMode!=De.Off&&this.renderer.chartManager.getMode()==Y.Edit;let s=-this.renderer.chart.gameType.notefieldWidth*.5-128;for(let n=e.length-1;n>=0;n--){const a=e[n],o=this.tracks.getChildByName(a)??this.createTrack(a,s);o.lastX!=s&&(o.lastX=s,o.targetAlpha=n%2==0?.1:0,It.animate(o,{0:{x:"inherit","anchor.x":"inherit"},1:{x:s,"anchor.x":1}},.3,Yt(0,0,.16,1.01),()=>{},`track-${a}-x`),It.animate(o,{0:{alpha:"inherit"},1:{alpha:i?o.targetAlpha:0}},.3,Yt(0,0,.16,1.01),()=>{},`track-${a}-alpha`)),s-=Mr[a]}s=this.renderer.chart.gameType.notefieldWidth*.5+128;for(let n=0;n{},`track-${a}-x`),It.animate(o,{0:{alpha:"inherit"},1:{alpha:i?o.targetAlpha:0}},.3,Yt(0,0,.16,1.01),()=>{},`track-${a}-alpha`)),s+=Mr[a]}if(this.wasEditingTiming!=i){this.wasEditingTiming=i;for(const n of this.tracks.children)It.animate(n,{0:{alpha:"inherit"},1:{alpha:i?n.targetAlpha:0}},.3,Yt(0,0,.16,1.01),()=>{},`track-${n.type}-alpha`)}}updateBoxes(e,t){this.timingDirty&&(this.timingBoxMap.clear(),this.boxPool.destroyAll(),this.timingDirty=!1);const i=this.renderer.chartManager.editTimingMode!=De.Off&&this.renderer.chartManager.getMode()==Y.Edit;this.boxPool.visible=this.renderer.shouldDisplayBarlines();for(const n of this.renderer.chart.timingData.getTimingData()){if(tn.beat)&&!this.timingBoxMap.has(n)){const a=this.boxPool.createChild();if(!a)break;this.initializeBox(a,n),this.addDragListeners(a,n),this.timingBoxMap.set(n,a)}}const s={beat:-Number.MAX_SAFE_INTEGER,second:-Number.MAX_SAFE_INTEGER,leftOffset:0,rightOffset:0};for(const[n,a]of this.timingBoxMap.entries()){if(n.beatt){this.timingBoxMap.delete(n),a.popup?.persistent?a.popup?.detach():a.popup?.close(),this.boxPool.destroyChild(a);continue}let o=0,l=0;const c=a.backgroundObj.width,u=_.chart.timingEventOrder.right.includes(n.type)?"right":"left";i?(o=this.tracks.getChildByName(n.type)?.x??a.x,o+=Mr[n.type]/2*(o>0?1:-1),l=.5):(o=(u=="right"?1:-1)*(this.renderer.chart.gameType.notefieldWidth*.5+80),u=="left"&&(o-=30),(s.beat!=n.beat||n.second&&s.second!=n.second)&&(s.leftOffset=0,s.rightOffset=0,s.beat=n.beat,s.second=n.second),u=="left"?(o-=s.leftOffset,s.leftOffset+=c+5):(o+=s.rightOffset,s.rightOffset+=c+5),l=u=="right"?0:1),a.lastX===void 0||a.lastAnchor===void 0?(a.position.x=o,a.pivot.x=(l-.5)*c):(a.lastX!=o||a.lastAnchor!=l)&&(a.animationId=It.animate(a,{0:{x:"inherit","pivot.x":"inherit"},1:{x:o,"pivot.x":(l-.5)*c}},.3,Yt(0,0,.16,1.01),()=>{},a.animationId)),a.lastX=o,a.lastAnchor=l,a.y=_.chart.CMod&&n.type=="ATTACKS"?this.renderer.getYPosFromSecond(n.second):this.renderer.getYPosFromBeat(n.beat);const h=this.renderer.chartManager.getMode()!=Y.Play&&this.renderer.chartManager.isEventInSelection(n);if(a.backgroundObj.tint=h?Pg(Lr[n.type]??0,Math.sin(Date.now()/320)*.4+1.5):Lr[n.type]??0,a.selection.alpha=h?1:0,a.visible=!h||!this.renderer.chartManager.eventSelection.shift,this.renderer.chartManager.editTimingMode!=De.Off){const d=this.renderer.selectionTest(a);!h&&d&&this.renderer.chartManager.addEventToDragSelection(n),h&&!d&&this.renderer.chartManager.removeEventFromDragSelection(n)}}}updateGhostEvent(e){const t=_.chart.snap==0?.001:_.chart.snap,i=Math.round(this.renderer.getBeatFromYPos(e.y)/t)*t,s=this.ghostBox?.popup?this.ghostBox.event.type:this.getClosestTrack(e.x)?.name;if(!s){this.ghostBox?.removeFromParent(),this.ghostBox?.destroy(),this.ghostBox=void 0;return}if(!this.ghostBox){const o=new xe;o.textObj=new Fe("",Bc),o.backgroundObj=new Nt,o.selection=new Nt("onlyBorder"),o.guideLine=new ke(Z.WHITE),o.selection.tint=3841008,o.selection.alpha=0,o.addChild(o.guideLine,o.backgroundObj,o.textObj,o.selection),this.addChild(o),o.visible=!0,o.textObj.anchor.set(.5,.55),o.backgroundObj.height=25,o.selection.height=25,o.guideLine.height=1,o.guideLine.anchor.y=.5,this.ghostBox=o}!this.ghostBox?.popup&&(this.ghostBox.event?.beat!=i||this.ghostBox.event?.type!=s)&&(this.ghostBox.event=structuredClone(this.renderer.chart.timingData.getEventAtBeat(s,i))??this.renderer.chart.timingData.getDefaultEvent(s,i),this.ghostBox.event.beat=i,s=="ATTACKS"&&(this.ghostBox.event.second=this.renderer.chart.getSecondsFromBeat(i)),this.ghostBox.textObj.text=this.getLabelFromEvent(this.ghostBox.event),this.ghostBox.backgroundObj.width=this.ghostBox.textObj.width+10,this.ghostBox.selection.width=this.ghostBox.textObj.width+10),this.ghostBox.alpha=this.ghostBox?.popup?1:.4,this.ghostBox.selection.alpha=this.ghostBox?.popup?1:0,this.ghostBox.name=s;const n=this.renderer.getYPosFromBeat(this.ghostBox?.popup?this.ghostBox.event.beat:i);let a=this.tracks.getChildByName(s).x;a+=Mr[s]/2*(a>0?1:-1),this.ghostBox.position.x=a,this.ghostBox.backgroundObj.tint=Lr[s]??0,this.ghostBox.backgroundObj.position.x=-this.ghostBox.backgroundObj.width/2,this.ghostBox.backgroundObj.position.y=-25/2,this.ghostBox.guideLine.anchor.x=a<0?0:1,this.ghostBox.guideLine.width=Math.abs(this.ghostBox.position.x)+192-this.ghostBox.backgroundObj.width/2,this.ghostBox.guideLine.position.x=(a<0?1:-1)*this.ghostBox.backgroundObj.width/2,this.ghostBox.y=n,this.ghostBox.selection.position=this.ghostBox.backgroundObj.position}placeGhostEvent(){if(!this.ghostBox)return;const e=this.renderer.chart.timingData.getEventAtBeat(this.ghostBox.event.type,this.ghostBox.event.beat,!1);this.ghostBox.event.type=="ATTACKS"&&this.ghostBox.event.second==e?.second||this.ghostBox.event.type!="ATTACKS"&&this.ghostBox.event.beat==e?.beat||(this.renderer.chartManager.clearSelections(),this.ghostBox.event.isChartTiming=this.renderer.chart.timingData.isPropertyChartSpecific(this.ghostBox.event.type),new St(this.ghostBox,this.getTargetTimingData(this.ghostBox.event.isChartTiming),!0),this.ghostBox.popup?.select(),this.ghostBox.popup.onConfirm=t=>{this.getTargetTimingData(this.ghostBox.event.isChartTiming).insert([t])})}getClosestTrack(e){let t=Number.MAX_SAFE_INTEGER,i=this.tracks.children[0];for(const s of this.tracks.children){const n=Math.abs(s.x+(.5-s.anchor.x)*s.width-e);ni.width))return i}getLabelFromEvent(e){let t="";switch(e.type){case"BPMS":case"STOPS":case"WARPS":case"DELAYS":case"TICKCOUNTS":case"FAKES":case"SCROLLS":t=ne(e.value,3).toString();break;case"SPEEDS":t=`${ne(e.value,3)}/${ne(e.delay,3)}/${e.unit}`;break;case"LABELS":t=e.value;break;case"TIMESIGNATURES":t=`${ne(e.upper,3)}/${ne(e.lower,3)}`;break;case"COMBOS":t=`${ne(e.hitMult,3)}/${ne(e.missMult,3)}`;break;case"BGCHANGES":case"FGCHANGES":t=e.file;break;case"ATTACKS":t=`${e.mods}`}return t}getTargetTimingData(e){return e?this.renderer.chart.timingData:this.renderer.chart.timingData.simfileTimingData}}class tC extends xe{children=[];renderer;timingBoxMap=new Map;trackPosCache=new Map;timingBoxPool=new ha({create:()=>{const e=new xe;return e.guideLine=new ke(Z.WHITE),e.textObj=new Fe("",Bc),e.backgroundObj=new Nt,e.addChild(e.guideLine,e.backgroundObj,e.textObj),e}});constructor(e){super(),this.renderer=e,this.timingBoxPool.sortableChildren=!0,this.addChild(this.timingBoxPool)}update(e,t){if(!this.renderer.chartManager.eventSelection.shift){this.timingBoxPool.destroyAll(),this.timingBoxMap.clear(),this.trackPosCache.clear();return}const i=this.renderer.chartManager.eventSelection.shift.beatShift;for(const s of this.renderer.chartManager.eventSelection.timingEvents)if(!(ts.beat+i)&&!this.timingBoxMap.has(s)){const n=this.timingBoxPool.createChild();if(!n)continue;this.timingBoxMap.set(s,n);let a="";switch(s.type){case"BPMS":case"STOPS":case"WARPS":case"DELAYS":case"TICKCOUNTS":case"FAKES":case"SCROLLS":a=ne(s.value,3).toString();break;case"SPEEDS":a=`${ne(s.value,3)}/${ne(s.delay,3)}/${s.unit}`;break;case"LABELS":a=s.value;break;case"TIMESIGNATURES":a=`${ne(s.upper,3)}/${ne(s.lower,3)}`;break;case"COMBOS":a=`${ne(s.hitMult,3)}/${ne(s.missMult,3)}`;break;case"BGCHANGES":case"FGCHANGES":a=s.file;break;case"ATTACKS":a=`${s.mods} (${s.endType}=${s.value})`}const o=_.chart.timingEventOrder.right.includes(s.type)?"right":"left";if(Object.assign(n,{alpha:.4,isChartTiming:this.renderer.chart.timingData.isPropertyChartSpecific(s.type),zIndex:s.beat}),n.textObj.text=a,n.textObj.anchor.set(.5,.55),n.backgroundObj.width=n.textObj.width+10,n.backgroundObj.height=25,n.backgroundObj.tint=Lr[s.type]??0,n.backgroundObj.position.x=-n.backgroundObj.width/2,n.backgroundObj.position.y=-n.backgroundObj.height/2,n.guideLine.height=1,n.guideLine.anchor.set(o=="left"?0:1,.5),n.guideLine.width=Math.abs(n.position.x)+192-n.backgroundObj.width/2,n.guideLine.position.x=(o=="left"?1:-1)*n.backgroundObj.width/2,this.renderer.chartManager.editTimingMode!=De.Off){let l=this.getTrackPos(s.type);l+=Mr[s.type]/2*(l>0?1:-1),n.position.x=l,n.pivot.x=0}else{let l=(o=="right"?1:-1)*(this.renderer.chart.gameType.notefieldWidth*.5+80);o=="left"&&(l-=30),n.position.x=l,n.pivot.x=o=="right"?-n.backgroundObj.width/2:n.backgroundObj.width/2}}for(const[s,n]of this.timingBoxMap.entries()){if(ts.beat+i){this.timingBoxPool.destroyChild(n),this.timingBoxMap.delete(s);continue}n.y=_.chart.CMod&&s.second?this.renderer.getYPosFromSecond(s.second):this.renderer.getYPosFromBeat(s.beat+i)}}getTrackPos(e){if(this.trackPosCache.has(e))return this.trackPosCache.get(e);const t=_.chart.timingEventOrder.left,i=_.chart.timingEventOrder.right;let s=-this.renderer.chart.gameType.notefieldWidth*.5-128;for(let n=t.length-1;n>=0;n--){const a=t[n];this.trackPosCache.set(a,s),s-=Mr[a]}s=this.renderer.chart.gameType.notefieldWidth*.5+128;for(let n=0;n{if(this.editingCol!=-1){const a=_.chart.snap==0?.020833333333333332:_.chart.snap,o=Math.round(this.getBeatFromYPos(this.lastMousePos.y)/a)*a;this.chartManager.editHoldBeat(this.editingCol,o,n.shiftKey)}};let i=0;const s=()=>{if(!this.chartManager.selection.shift&&!this.selectionBounds||i==0)return;const n=this.getYPosFromBeat(Math.max(0,this.chartManager.getBeat()+i));this.chartManager.setBeat(Math.max(0,this.chartManager.getBeat()+i)),this.selectionBounds&&(this.selectionBounds.start.y+=_.chart.receptorYPos/_.chart.zoom-n,this.selectionBoundary.update())};this.chartManager.app.ticker.add(s),window.addEventListener("keydown",t),this.on("destroyed",()=>{window.removeEventListener("keydown",t),this.removeAllListeners(),this.chartManager.app.ticker.remove(s)}),this.on("pointerdown",n=>{Tc(n)||this.chartManager.getMode()==Y.Play||this.chartManager.getMode()==Y.View||(this.chartManager.editTimingMode==De.Add&&this.lastMousePos?this.timingTracks.placeGhostEvent():this.chartManager.editTimingMode==De.Off&&_.chart.mousePlacement&&this.lastMouseBeat!=-1&&this.lastMouseCol!=-1&&!n.getModifierState("Shift")?(this.chartManager.clearSelections(),this.editingCol=this.lastMouseCol,this.chartManager.setNote(this.lastMouseCol,"mouse",this.lastMouseBeat)):(!n.getModifierState("Control")&&!n.getModifierState("Meta")&&!n.getModifierState("Shift")&&this.chartManager.clearSelections(),this.chartManager[this.chartManager.editTimingMode==De.Off?"startDragSelection":"startDragEventSelection"](),this.selectionBounds={start:this.toLocal(n.global),end:this.toLocal(n.global)},this.selectionBoundary.update()))}),this.on("mousemove",n=>{if(this.lastMousePos=this.toLocal(n.global),this.editingCol!=-1){const a=_.chart.snap==0?.020833333333333332:_.chart.snap,o=Math.round(this.getBeatFromYPos(this.lastMousePos.y)/a)*a;this.chartManager.editHoldBeat(this.editingCol,o,n.shiftKey)}this.selectionBounds&&(this.selectionBounds.end=this.toLocal(n.global),this.selectionBoundary.update()),i=Math.max(0,this.lastMousePos.y-this.getLowerBound()+100)/600,this.lastMousePos.y<0&&(i=Math.min(0,this.lastMousePos.y-this.getUpperBound()-100)/600)}),this.on("pointerup",()=>{this.editingCol!=-1&&(this.chartManager.endEditing(this.editingCol),this.editingCol=-1),this.chartManager[this.chartManager.editTimingMode==De.Off?"endDragSelection":"endDragEventSelection"](),this.selectionBounds=void 0,this.selectionBoundary.update(),i=0})}isDragSelecting(){return!!this.selectionBounds}doJudgment(e,t,i){this.chartManager.getMode()==Y.Play&&(this.judgment.doJudge(t,i),this.timingBar.addBar(t,i)),this.notefield.onJudgment(e.col,i)}activateHold(e){this.notefield.activateHold(e)}keyDown(e){this.notefield.keyDown(e)}keyUp(e){this.notefield.keyUp(e)}endPlay(){this.notefield.endPlay(),this.timingBar.reset(),this.judgment.reset()}update(){const e=this.getVisualBeat(),t=this.getVisualTime();this.speedMult=_.chart.doSpeedChanges?this.chart.timingData.getSpeedMult(e,t):1;const i=this.getUpperBoundBeat(),s=this.getLowerBoundBeat();if(this.scale.x=_.chart.zoom,this.scale.y=_.chart.zoom,this.children.forEach(n=>n.update(i,s)),this.notefield.alpha=this.chartManager.editTimingMode==De.Off||this.chartManager.getMode()==Y.Play?1:.3,_.chart.mousePlacement&&this.lastMousePos&&this.chartManager.getMode()!=Y.Play){const n=_.chart.snap==0?.020833333333333332:_.chart.snap,a=Math.round(this.getBeatFromYPos(this.lastMousePos.y)/n)*n;let o=-1;for(let l=0;lu-c/2){o=l;break}}(a!=this.lastMouseBeat||o!=this.lastMouseCol||this.chartManager.getEditingNoteType()!=this.lastNoteType)&&(this.lastMouseBeat=a,this.lastMouseCol=o,this.lastNoteType=this.chartManager.getEditingNoteType(),this.editingCol!=-1&&this.chartManager.editHoldBeat(this.editingCol,a,!1),o===-1?(this.lastMouseBeat=-1,this.lastMouseCol=-1,this.notefield.setGhostNote()):this.notefield.setGhostNote(this.chart.computeNote({beat:a,col:this.lastMouseCol,type:this.chartManager.getEditingNoteType()})))}this.lastMousePos&&this.chartManager.editTimingMode==De.Add&&this.timingTracks.updateGhostEvent(this.lastMousePos)}getTimeWithOffset(){let e=this.chartManager.getTime();return(this.chartManager.getMode()==Y.Play||this.chartManager.getMode()==Y.Record)&&(e+=_.play.offset*_.audio.rate),e}getBeatWithOffset(){let e=this.chartManager.getBeat();return(this.chartManager.getMode()==Y.Play||this.chartManager.getMode()==Y.Record)&&(e=this.chart.getBeatFromSeconds(this.getTimeWithOffset())),e}getVisualTime(){let e=this.chartManager.getTime();return(this.chartManager.getMode()==Y.Play||this.chartManager.getMode()==Y.Record)&&(e+=(_.play.offset+_.play.visualOffset)*_.audio.rate),e}getVisualBeat(){let e=this.chartManager.getBeat();return(this.chartManager.getMode()==Y.Play||this.chartManager.getMode()==Y.Record)&&(e=this.chart.getBeatFromSeconds(this.getVisualTime())),e}getYPosFromBeat(e){const t=this.getVisualTime(),i=this.getVisualBeat(),s=_.chart.reverse?-1:1;return _.chart.CMod?(this.chart.getSecondsFromBeat(e)-t)*this.getSecondsToPixelsRatio()*s+this.getActualReceptorYPos():i==e?this.getActualReceptorYPos():(_.chart.doSpeedChanges?this.chart.timingData.getEffectiveBeat(e)-this.chart.timingData.getEffectiveBeat(i):e-i)*this.getEffectiveBeatsToPixelsRatio()*s+this.getActualReceptorYPos()}getYPosFromSecond(e){const t=this.getVisualTime(),i=_.chart.reverse?-1:1;return _.chart.CMod?(e-t)*this.getSecondsToPixelsRatio()*i+this.getActualReceptorYPos():this.getYPosFromBeat(this.chart.timingData.getBeatFromSeconds(e))}getSecondFromYPos(e){const t=_.chart.reverse?-1:1;if(_.chart.CMod){const i=this.getPixelsToSecondsRatio(),s=this.getVisualTime(),a=(e-this.getActualReceptorYPos())*i*t;return s+a}return this.chart.getSecondsFromBeat(this.getBeatFromYPos(e))}getBeatFromYPos(e,t){const i=this.getVisualBeat(),s=_.chart.reverse?-1:1;if(_.chart.CMod)return this.chart.getBeatFromSeconds(this.getSecondFromYPos(e));const a=(e-this.getActualReceptorYPos())*this.getPixelsToEffectiveBeatsRatio()*s;if(_.chart.doSpeedChanges&&!t){const o=this.chart.timingData.getEffectiveBeat(i)+a;return this.chart.getBeatFromEffectiveBeat(o)}return i+a}getActualReceptorYPos(){return _.chart.receptorYPos/_.chart.zoom*(_.chart.reverse?-1:1)}getEffectiveBeatsToPixelsRatio(){return _.chart.speed/100*64*this.speedMult}getPixelsToEffectiveBeatsRatio(){return 1/this.getEffectiveBeatsToPixelsRatio()}getSecondsToPixelsRatio(){return _.chart.speed/100*64*4}getPixelsToSecondsRatio(){return 1/this.getSecondsToPixelsRatio()}isNegScroll(e){return _.chart.doSpeedChanges&&(this.speedMult<0||(this.chart.timingData.getEventAtBeat("SCROLLS",e)?.value??1)<0||(this.chart.timingData.getEventAtBeat("BPMS",e)?.value??120)<0)}getUpperBound(){return _.chart.reverse?(this.chartManager.app.renderer.screen.height-this.y)/_.chart.zoom+32:-this.y/_.chart.zoom-32}getLowerBound(){return _.chart.reverse?-this.y/_.chart.zoom-32:(this.chartManager.app.renderer.screen.height-this.y)/_.chart.zoom+32}getUpperBoundBeat(){if(_.chart.waveform.speedChanges&&!_.chart.CMod&&_.chart.doSpeedChanges){const e=_.chart.speed,t=this.chart.timingData.getSpeedMult(this.getVisualBeat(),this.getVisualTime()),i=t>=0!=_.chart.reverse?1:-1,s=this.chart.timingData.getTimingData("SCROLLS"),n=100/e/Math.abs(t)/64/_.chart.zoom,a=this.getUpperBound(),o=this.getLowerBound();let l=hi(s,this.getVisualBeat()-_.chart.maxDrawBeatsBack,m=>m.beat);for(;s[l]?.beat0&&b>a&&(go||!s[l-1]||s[l-1].beat0?s[l-1]?.value==0&&this.getYPosFromBeat(s[l-1].beat)>f?this.getVisualBeat()-_.chart.maxDrawBeatsBack:Math.max(this.getVisualBeat()-_.chart.maxDrawBeatsBack,c+d*(f-u)):s[l-1]?.value==0&&this.getYPosFromBeat(s[l-1].beat)=0!=_.chart.reverse?1:-1,s=this.chart.timingData.getTimingData("SCROLLS"),n=100/e/Math.abs(t)/64/_.chart.zoom,a=this.getUpperBound(),o=this.getLowerBound();let l=hi(s,this.getVisualBeat()+_.chart.maxDrawBeats,m=>m.beat);for(;s[l]?.beat>this.getVisualBeat()-_.chart.maxDrawBeatsBack;){const m=s[l],g=this.getYPosFromBeat(m.beat),y=s[l+1]?.beat??this.getVisualBeat()+_.chart.maxDrawBeats,b=this.getYPosFromBeat(y);if(m.value*i>0&&go||!s[l+1]||s[l+1].beat>this.getVisualBeat()+_.chart.maxDrawBeatsBack||s[l+1].value==0)||m.value*i<0&&g>a&&(bthis.getVisualBeat()+_.chart.maxDrawBeatsBack||s[l+1].value==0))break;l--}const c=s[l]?.beat??0,u=this.getYPosFromBeat(c),h=s[l]?.value??1,d=n/Math.abs(h)*_.chart.zoom,p=_.chart.reverse?o:a,f=_.chart.reverse?a:o;return h*i>0?s[l+1]?.value==0&&this.getYPosFromBeat(s[l+1].beat)p?this.getVisualBeat()+_.chart.maxDrawBeats:Math.min(this.getVisualBeat()+_.chart.maxDrawBeats,c+d*(u-p))}return _.chart.CMod?this.getBeatFromYPos(this.getLowerBound()):Math.min(this.getVisualBeat()+_.chart.maxDrawBeats,this.getBeatFromYPos(this.getLowerBound()))}selectionTest(e){if(!this.selectionBounds)return!1;const t=this.selectionBoundary.getBounds(),i=e.getBounds(),s=16*_.chart.zoom;return t.x+t.width>i.x+s&&t.xi.y+s&&t.y{const u=o,h=this.toLocal(c.global);if(Math.abs(h.y-a-n)**2+Math.abs(h.x-s)**2<32*32){this.chartManager.selection.shift&&(this.chartManager.selection.shift={columnShift:0,beatShift:0});return}const d=this.getBeatFromYPos(h.y-a),p=_.chart.snap==0?1/48:_.chart.snap;let f=Math.round(d/p)*p;Math.abs(f-d)>Math.abs(d-u.beat)&&(f=u.beat);const m=Math.round((h.x+96)/64);this.chartManager.selection.shift||={columnShift:0,beatShift:0},i!=m-u.col&&(i=m-u.col,this.chartManager.selection.notes.every(g=>{const y=g.col+i;return y>=0&&yg.beat)),f-u.beat)};e.on("pointerdown",c=>{if(this.chartManager.getMode()==Y.View)return;if(Tc(c)){this.chartManager.isNoteInSelection(t)||(this.chartManager.clearSelections(),this.chartManager.addNoteToSelection(t)),KT.open(this.chartManager.app,c),c.preventDefault();return}if(_.chart.mousePlacement&&!c.getModifierState("Meta")&&!c.getModifierState("Control")&&!c.getModifierState("Shift")&&!this.chartManager.isNoteInSelection(t))return;c.stopImmediatePropagation(),this.chartManager.isNoteInSelection(t)?(c.getModifierState("Control")||c.getModifierState("Meta"))&&this.chartManager.removeNoteFromSelection(t):(!c.getModifierState("Control")&&!c.getModifierState("Meta")&&!c.getModifierState("Shift")&&this.chartManager.clearSelections(),this.chartManager.addNoteToSelection(t)),s=e.x,n=e.y,a=this.toLocal(c.global).y-e.y,o=t,this.on("pointermove",l);const u=()=>{this.off("pointermove",l),this.off("pointerup",u),((this.chartManager.selection.shift?.beatShift??0)!=0||(this.chartManager.selection.shift?.columnShift??0)!=0)&&this.chartManager.modifySelection(h=>(h.beat+=this.chartManager.selection.shift.beatShift,h.col+=this.chartManager.selection.shift.columnShift,h)),this.chartManager.selection.shift=void 0};this.on("pointerup",u)}),e.on("destroyed",()=>{e?.removeAllListeners()})}getNotefield(){return this.notefield}getSelectionBounds(){return this.selectionBounds}shouldDisplayBarlines(){return(this.chartManager.getMode()!=Y.Play||!_.play.hideBarlines)&&Ie.barlines}}class Ad extends AudioBufferSourceNode{started=!1;start(e,t,i){this.started||super.start(e,t,i),this.started=!0}stop(e){this.started&&super.stop(e),this.started=!1}static create(e){const t=e;return t.started=!1,Object.setPrototypeOf(t,Ad.prototype),t}}class rC extends BiquadFilterNode{enabled=!1;static create(e){const t=e;return t.enabled=!1,t}}class no{_audioAnalyzer;_filteredAudioAnalyzer;_freqData;_filteredFreqData;_gainNode;type;_audioContext=new AudioContext;_source;_playbackTime=0;_startTimestamp=0;_rate=1;_isPlaying=!1;_buffer;_filteredBuffer;_loadedBuffer;_delay;_loadListeners=[];_updateListeners=[];_volume=1;_destroyed=!1;_renderTimeout;_filters=[this.createFilter({type:"highpass",frequency:20,Q:.71}),this.createFilter({type:"lowshelf",frequency:75,gain:0}),this.createFilter({type:"peaking",frequency:100,gain:0,Q:.6}),this.createFilter({type:"peaking",frequency:250,gain:0,Q:.3}),this.createFilter({type:"peaking",frequency:1040,gain:0,Q:.41}),this.createFilter({type:"peaking",frequency:2500,gain:0,Q:.2}),this.createFilter({type:"highshelf",frequency:7500,gain:0}),this.createFilter({type:"lowpass",frequency:2e4,Q:.71})];_filtersEnabled=!1;loaded;constructor(e,t){this.type=t??"",this._filters[0].gain.value=-25,this._audioAnalyzer=this._audioContext.createAnalyser(),this._audioAnalyzer.fftSize=4096,this._audioAnalyzer.maxDecibels=0,this._freqData=new Uint8Array(this._audioAnalyzer.frequencyBinCount),this._filteredAudioAnalyzer=this._audioContext.createAnalyser(),this._filteredAudioAnalyzer.fftSize=4096,this._filteredAudioAnalyzer.maxDecibels=0,this._filteredFreqData=new Uint8Array(this._filteredAudioAnalyzer.frequencyBinCount),this._gainNode=this._audioContext.createGain(),this._buffer=this._audioContext.createBuffer(2,1,44100),this._filteredBuffer=this._audioContext.createBuffer(2,1,44100),this._loadedBuffer=this._audioContext.createBuffer(2,1,44100),this.initSource(),this.loaded=new Promise(i=>{this.decodeData(e).then(s=>{if(s)return this._loadedBuffer=s,s}).then(async s=>(await this.renderBuffer(s),await this.renderFilteredBuffer(s),s)).catch(s=>{s.name=="EncodingError"?Ce.createFormatted("Failed to load audio: file format not supported","error"):Ce.createFormatted("Failed to load audio: "+s.message,"error")}).finally(()=>{this.initSource(),this.callLoadListeners(),this.callUpdateListeners(),i()})})}async renderBuffer(e){if(!e)return;const t=new OfflineAudioContext(e.numberOfChannels,e.length,e.sampleRate),i=t.createBufferSource();return i.buffer=e,i.connect(t.destination),i.start(),await t.startRendering().then(s=>{this._buffer=s}).catch(()=>{Ce.createFormatted("Failed to load audio: audio rendering failed","error")})}async renderFilteredBuffer(e){if(!e)return;const t=new OfflineAudioContext(e.numberOfChannels,e.length,e.sampleRate),i=t.createBufferSource();i.buffer=e;let s=i;for(const n of this._filters){if(!n.enabled)continue;const a=t.createBiquadFilter();a.type=n.type,a.Q.setValueAtTime(n.Q.value,0),a.frequency.setValueAtTime(n.frequency.value,0),a.gain.setValueAtTime(n.gain.value,0),s.connect(a),s=a}return s.connect(t.destination),i.start(),await t.startRendering().then(n=>{this._filteredBuffer=n}).catch(()=>{Ce.createFormatted("Failed to load audio: audio rendering failed","error")})}createFilter(e){const t=rC.create(this._audioContext.createBiquadFilter());return t.type=e.type,e.Q!==void 0&&(t.Q.value=e.Q),e.gain!==void 0&&(t.gain.value=e.gain),e.frequency!==void 0&&(t.frequency.value=e.frequency),t}getFilters(){return this._filters}getFilter(e){return this._filters[e]}updateFilter(e,t){this._filters[e]&&(t.Q!==void 0&&(this._filters[e].Q.value=t.Q),t.frequency!==void 0&&(this._filters[e].frequency.value=t.frequency),t.gain!==void 0&&(this._filters[e].gain.value=t.gain),clearTimeout(this._renderTimeout),this._renderTimeout=setTimeout(()=>this.renderFilteredBuffer(this._loadedBuffer).then(()=>this.callUpdateListeners()),500))}enableFilter(e){this._filters[e].enabled=!0,this.initSource(),clearTimeout(this._renderTimeout),this._renderTimeout=setTimeout(()=>this.renderFilteredBuffer(this._loadedBuffer).then(()=>this.callUpdateListeners()),500),this._filtersEnabled=!0}disableFilter(e){this._filters[e].enabled=!1,this.initSource(),clearTimeout(this._renderTimeout),this._renderTimeout=setTimeout(()=>this.renderFilteredBuffer(this._loadedBuffer).then(()=>this.callUpdateListeners()),500),this._filtersEnabled=this._filters.some(t=>t.enabled)}hasFilters(){return this._filtersEnabled}onLoad(e){this._loadListeners.push(e)}offLoad(e){this._loadListeners=this._loadListeners.filter(t=>t!=e)}onUpdate(e){this._updateListeners.push(e)}offUpdate(e){this._updateListeners=this._updateListeners.filter(t=>t!=e)}getSongLength(){return this._buffer.length/this._buffer.sampleRate}getFrequencyData(){return this._destroyed?new Uint8Array:(this._audioAnalyzer.getByteFrequencyData(this._freqData),this._freqData)}getFilteredFrequencyData(){return this._destroyed?new Uint8Array:(this._filteredAudioAnalyzer.getByteFrequencyData(this._filteredFreqData),this._filteredFreqData)}getSampleRate(){return this._buffer.sampleRate}getFFTSize(){return this._audioAnalyzer.fftSize}getRawData(){if(this._destroyed)return[];const e=[];for(let t=0;ti.enabled)?this._filters.filter(i=>i.enabled).map(i=>{const s=new Float32Array(e.length);return i.getFrequencyResponse(t,s,new Float32Array(e.length)),[...s]}).reduce((i,s)=>i.map((n,a)=>n*s[a])):new Array(e.length).fill(1)}callLoadListeners(){this._loadListeners.forEach(e=>e())}callUpdateListeners(){this._updateListeners.forEach(e=>e())}async decodeData(e){return new Promise((t,i)=>{if(!e){t();return}(async()=>{try{t(await this._audioContext.decodeAudioData(e))}catch(s){if(this.type==".ogg"){const n=(await ui(()=>import("./OggDec-2941c3fd.js"),[])).default;try{t(await n.decodeOggData(e))}catch(a){i(a)}return}i(s)}})()})}initSource(){for(const t of this._filters)t.disconnect();this._audioAnalyzer.disconnect(),this._filteredAudioAnalyzer.disconnect(),this._gainNode.disconnect(),this._audioContext.destination.disconnect(),this._source?.stop(),this._source=Ad.create(this._audioContext.createBufferSource()),this._source.buffer=this._buffer,this._source.connect(this._audioAnalyzer);let e=this._audioAnalyzer;for(const t of this._filters)t.enabled&&(e.connect(t),e=t);e.connect(this._filteredAudioAnalyzer),_.audio.allowFilter?this._filteredAudioAnalyzer.connect(this._gainNode):this._audioAnalyzer.connect(this._gainNode),this._gainNode.connect(this._audioContext.destination),this._source.playbackRate.value=this._rate,this._isPlaying&&(this.pause(),this.play())}volume(e){this._destroyed||this._volume!=e&&(this._volume=e,this._gainNode.gain.setValueAtTime(e,this._audioContext.currentTime))}rate(e){this._destroyed||this._rate!=e&&(this._rate=e,this._source&&(this._isPlaying&&(this._playbackTime+=(this._audioContext.currentTime-this._startTimestamp)*this._source.playbackRate.value),this._startTimestamp=this._audioContext.currentTime,this._source.playbackRate.value=e))}play(){this._destroyed||this._source&&(this._isPlaying||(this.initSource(),this._playbackTime<=this._buffer.duration&&(this._playbackTime<0?(clearTimeout(this._delay),this._delay=setInterval(()=>{this.seek()>0&&(clearInterval(this._delay),this._source?.start(0,0))})):this._source.start(0,this._playbackTime)),this._startTimestamp=this._audioContext.currentTime,this._isPlaying=!0))}seek(e){if(!this._destroyed&&this._source){if(e===void 0)return this._isPlaying?(this._audioContext.currentTime-this._startTimestamp)*this._source.playbackRate.value+this._playbackTime:this._playbackTime;this._isPlaying?(this.stop(),this._playbackTime=e,this.play()):this._playbackTime=e}}pause(){this._destroyed||this.stop(!0)}stop(e){this._destroyed||this._source&&this._isPlaying&&(clearTimeout(this._delay),this._isPlaying=!1,this._playbackTime<=this._buffer.duration&&this._source.stop(),this._playbackTime=e?(this._audioContext.currentTime-this._startTimestamp)*this._source.playbackRate.value+this._playbackTime:0)}}class sC{judgmentCounts=new Map;holdJudgmentCounts=new Map;dancePoints=0;maxCumulativeDancePoints=0;maxDancePoints=0;chartManager;notedata;dataPoints=[];handlers=[];combo=0;missCombo=0;maxCombo=0;bestJudge;constructor(e){this.notedata=e.loadedChart.getNotedata(),this.chartManager=e,this.bestJudge=qe.getCollection(_.play.timingCollection).getStandardWindows()[0],this.calculateMaxDP()}onJudge(e){this.handlers.push(e)}applyOffset(e){this.dataPoints=this.dataPoints.map(t=>ni(t.judgment)||!Vi(t.judgment)?t:{...t,error:t.error+e}),this.recalculate()}addDataPoint(e,t,i){this.judgmentCounts.has(t)||this.judgmentCounts.set(t,0),this.judgmentCounts.set(t,this.judgmentCounts.get(t)+1),this.dancePoints+=t.dancePoints;const s=this.chartManager.loadedChart.timingData.getEventAtBeat("COMBOS",e[0].beat),n=s?.hitMult??1,a=s?.missMult??1;ms(t)||(this.maxCumulativeDancePoints+=qe.getCollection(_.play.timingCollection).getMaxDancePoints()),ni(t)?(this.maxCumulativeDancePoints+=e.filter(Be).reduce((o,l)=>o+qe.getCollection(_.play.timingCollection).getMaxHoldDancePoints(l.type),0),this.combo=0,this.missCombo+=a,this.bestJudge=void 0):Vi(t)&&(qe.getCollection(_.play.timingCollection).shouldHideNote(t)?(this.combo+=e.length*n,this.combo>this.maxCombo&&(this.maxCombo=this.combo),this.missCombo=0,this.bestJudge&&t.getTimingWindowMS()>this.bestJudge.getTimingWindowMS()&&(this.bestJudge=t)):(this.bestJudge=void 0,this.combo=0)),this.handlers.forEach(o=>o(i,t)),this.dataPoints.push({second:e[0].second,error:i,judgment:t,notes:e})}addHoldDataPoint(e,t){this.judgmentCounts.has(t)||this.judgmentCounts.set(t,0),this.judgmentCounts.set(t,this.judgmentCounts.get(t)+1);const i=qe.getCollection(_.play.timingCollection).getHeldJudgement(e);this.holdJudgmentCounts.has(i)||this.holdJudgmentCounts.set(i,[0,0]);const s=this.holdJudgmentCounts.get(i);Rr(t)?s[0]++:s[1]++,this.holdJudgmentCounts.set(i,s),this.dancePoints+=t.dancePoints,this.maxCumulativeDancePoints+=qe.getCollection(_.play.timingCollection).getMaxHoldDancePoints(e.type),this.handlers.forEach(n=>n(0,t)),yn(t)&&(this.bestJudge=void 0)}getScore(){return this.maxDancePoints==0?0:this.dancePoints/this.maxDancePoints}getCumulativeScore(){return this.maxCumulativeDancePoints==0?0:this.dancePoints/this.maxCumulativeDancePoints}getDataPoints(){return this.dataPoints}getMedian(){return fl(this.dataPoints.filter(e=>!ni(e.judgment)&&Vi(e.judgment)).map(e=>e.error))}getMaxCombo(){return this.maxCombo}recalculate(){this.calculateMaxDP(),this.dancePoints=0,this.maxCumulativeDancePoints=0;for(const e of this.holdJudgmentCounts.entries()){const t=e[0];this.dancePoints+=e[0].dancePoints*e[1][0],this.maxCumulativeDancePoints+=(e[1][0]+e[1][1])*qe.getCollection(_.play.timingCollection).getMaxHoldDancePoints(t.noteType)}this.judgmentCounts.clear();for(const e of this.dataPoints){let t=qe.getCollection(_.play.timingCollection).judgeInput(e.error);(ni(e.judgment)||ms(e.judgment))&&(t=e.judgment),this.judgmentCounts.has(t)||this.judgmentCounts.set(t,0),this.judgmentCounts.set(t,this.judgmentCounts.get(t)+1),this.dancePoints+=t.dancePoints,e.judgment=t,ms(t)||(this.maxCumulativeDancePoints+=qe.getCollection(_.play.timingCollection).getMaxDancePoints()),ni(t)&&(this.maxCumulativeDancePoints+=e.notes.filter(Be).reduce((i,s)=>i+qe.getCollection(_.play.timingCollection).getMaxHoldDancePoints(s.type),0))}}calculateMaxDP(){const e=new Map,t=new Map;for(const i of this.notedata)i.type=="Mine"||i.fake||(Be(i)&&(t.has(i.type)||t.set(i.type,0),t.set(i.type,t.get(i.type)+1)),e.has(i.beat)||e.set(i.beat,[]),e.get(i.beat).push(i));this.maxDancePoints=e.size*qe.getCollection(_.play.timingCollection).getMaxDancePoints(),this.maxDancePoints+=Array.from(t.entries()).reduce((i,s)=>i+s[1]*qe.getCollection(_.play.timingCollection).getMaxHoldDancePoints(s[0]),0)}getCount(e){return this.judgmentCounts.get(e)??0}getCombo(){return this.combo}getMissCombo(){return this.missCombo}getBestJudge(){return this.bestJudge}}const Zt=[1,2,3,4,6,8,12,16,24,48,-1];var Y=(r=>(r.View="View Mode",r.Edit="Edit Mode",r.Play="Play Mode",r.Record="Record Mode",r))(Y||{}),De=(r=>(r[r.Off=0]="Off",r[r.Edit=1]="Edit",r[r.Add=2]="Add",r))(De||{});class dC{app;chartAudio=new no;chartView;widgetManager;assistTick=new hs.Howl({src:y_,volume:.5});me_high=new hs.Howl({src:rg,volume:.5});me_low=new hs.Howl({src:sg,volume:.5});mine=new hs.Howl({src:v_,volume:.5});loadedSM;smPath="";loadedChart;selection={notes:[],inProgressNotes:[]};eventSelection={timingEvents:[],inProgressTimingEvents:[]};editTimingMode=0;beat=0;time=0;holdEditing=[];editNoteTypeIndex=0;partialScroll=0;noteIndex=0;lastMetronomeDivision=-1;lastMetronomeMeasure=-1;lastSong="";mode="Edit Mode";lastMode="Edit Mode";noChartTextA;noChartTextB;virtualClipboard="";startRegion;endRegion;gameStats;constructor(e){this.app=e,document.addEventListener("cut",i=>{if(i.target.classList.contains("inlineEdit")||i.target instanceof HTMLTextAreaElement||i.target instanceof HTMLInputElement||this.mode!="Edit Mode")return;const s=this.copy();s&&i.clipboardData?.setData("text/plain",s),this.deleteSelection(),i.preventDefault()},!0),document.addEventListener("copy",i=>{if(i.target.classList.contains("inlineEdit")||i.target instanceof HTMLTextAreaElement||i.target instanceof HTMLInputElement||this.mode!="Edit Mode")return;const s=this.copy();s&&i.clipboardData?.setData("text/plain",s),i.preventDefault(),i.stopImmediatePropagation()},!0),document.addEventListener("paste",i=>{if(i.target.classList.contains("inlineEdit")||i.target instanceof HTMLTextAreaElement||i.target instanceof HTMLInputElement||this.mode!="Edit Mode")return;const s=i.clipboardData?.getData("text/plain");s&&this.paste(s),i.preventDefault(),i.stopImmediatePropagation()},!0),e.view.addEventListener?.("wheel",i=>{if(!(this.loadedSM==null||this.loadedChart==null||this.chartView==null))if(i.preventDefault(),ys&&i.metaKey||!ys&&i.ctrlKey){const s=i.deltaY/5*_.chart.scroll.scrollSensitivity*(_.chart.scroll.invertZoomScroll?-1:1);_.chart.speed=Ve(_.chart.speed*Math.pow(1.01,s),10,35e3)}else{if(this.mode=="Play Mode"||this.mode=="Record Mode")return;let s=this.beat;const n=_.chart.snap,a=_.chart.speed*(_.chart.reverse&&_.chart.scroll.invertReverseScroll?-1:1),o=i.deltaY/a*_.chart.scroll.scrollSensitivity;if(n==0?(this.partialScroll=0,s=this.beat+o):_.chart.scroll.scrollSnapEveryScroll?i.deltaY<0?s=Math.round((this.beat-n)/n)*n:s=Math.round((this.beat+n)/n)*n:(this.partialScroll+=o,Math.abs(this.partialScroll)>n&&(this.partialScroll<0?s=Math.round((this.beat+Math.ceil(this.partialScroll/n)*n)/n)*n:s=Math.round((this.beat+Math.floor(this.partialScroll/n)*n)/n)*n,this.partialScroll%=n)),s=Math.max(0,s),s!=this.beat&&this.setBeat(s),!this.holdEditing.every(l=>l==null))for(let l=0;l{this.noChartTextB.tint=8952234}),this.noChartTextB.on("mouseleave",()=>{this.noChartTextB.tint=5596791}),this.noChartTextB.on("mousedown",()=>{this.app.windowManager.openWindow(new Ag(e,Ke.getGameType("dance-single")))}),this.noChartTextA.visible=!1,this.noChartTextB.visible=!1;const t=()=>{this.noChartTextA.x=this.app.renderer.screen.width/2,this.noChartTextA.y=this.app.renderer.screen.height/2-20,this.noChartTextB.x=this.app.renderer.screen.width/2,this.noChartTextB.y=this.app.renderer.screen.height/2+10};t(),this.app.stage.addChild(this.noChartTextB),this.app.ticker.add(()=>{const i=performance.now();this.widgetManager.update(),this.loadedSM&&this.loadedChart&&this.chartView&&this.chartView.update(),la.instance?.addDrawUpdateTimeValue(performance.now()-i)}),setInterval(()=>{if(!this.loadedSM||!this.loadedChart||!this.chartView)return;const i=performance.now(),s=this.chartAudio.seek();if(this.chartAudio.isPlaying()&&(this.setTime(s,!0),!this.holdEditing.every(u=>!u)))for(let u=0;u.3&&this.editHoldBeat(u,p,!1)}const n=this.loadedChart.getNotedata();let a=!1;for(;this.noteIndexn[this.noteIndex].second+_.play.effectOffset;)this.mode!="Record Mode"&&this.chartAudio.isPlaying()&&this.loadedChart.gameType.gameLogic.shouldAssistTick(n[this.noteIndex])&&(this.mode!="Play Mode"&&this.chartView.doJudgment(n[this.noteIndex],0,dg),!a&&_.audio.assistTick&&Ie.assist&&(this.assistTick.play(),a=!0)),this.noteIndex++;const o=this.loadedChart.getBeatFromSeconds(this.time+_.play.effectOffset),l=Math.floor(this.loadedChart.timingData.getDivisionOfMeasure(o)),c=Math.floor(this.loadedChart.timingData.getMeasure(o));(c!=this.lastMetronomeMeasure||l!=this.lastMetronomeDivision)&&(this.lastMetronomeDivision=l,this.lastMetronomeMeasure=c,this.chartAudio.isPlaying()&&_.audio.metronome&&Ie.assist&&(l==0?this.me_high.play():this.me_low.play())),this.mode=="Play Mode"&&this.loadedChart.gameType.gameLogic.update(this),this.updateSoundProperties(),TT(),la.instance?.addUpdateTimeValue(performance.now()-i)},5),$.on("resize",()=>{this.chartView&&(this.chartView.x=this.app.renderer.screen.width/2,this.chartView.y=this.app.renderer.screen.height/2),t()}),$.on("chartModified",()=>{this.loadedChart&&(this.loadedChart.recalculateStats(),$.emit("chartModifiedAfter"))}),window.addEventListener("keyup",i=>{if(this.mode=="Edit Mode"&&i.code.startsWith("Digit")){const s=parseInt(i.code.slice(5))-1;this.endEditing(s)}},!0),window.addEventListener("keydown",i=>{const s=$e.getKeyNameFromCode(i.code);if(this.mode=="Edit Mode"&&!i.target.classList.contains("inlineEdit")&&!(i.target instanceof HTMLTextAreaElement)&&!(i.target instanceof HTMLInputElement)){if(i.code.startsWith("Digit")&&!i.repeat&&!i.ctrlKey&&!i.metaKey&&!i.altKey&&!i.ctrlKey){const n=parseInt(i.code.slice(5))-1;n<(this.loadedChart?.gameType.numCols??4)&&n>-1&&(this.setNote(n,"key"),i.preventDefault(),i.stopImmediatePropagation())}if(!this.holdEditing.every(n=>n==null)){const n=["cursorUp","cursorDown","previousNote","nextNote","previousMeasure","nextMeasure","jumpChartStart","jumpChartEnd","jumpSongStart","jumpSongEnd"];for(const a of n)if($e.getCombosForKeybind(a).map(o=>o.key).includes(s)){i.preventDefault(),i.stopImmediatePropagation(),dt[a].callback(this.app);for(let o=0;oo.key).includes(s)){this.holdEditing=[];return}}}},!0),window.addEventListener("keydown",i=>{this.mode!="Play Mode"&&this.mode!="Record Mode"||i.key=="Escape"&&(this.setMode(this.lastMode),this.chartAudio.pause())},!0)}getBeat(){return this.beat}getTime(){return this.time}setBeat(e){this.loadedChart&&(this.beat=e,this.time=this.loadedChart.getSecondsFromBeat(this.beat),this.chartAudio.seek(this.time),this.getAssistTickIndex())}setTime(e,t){this.loadedChart&&(this.time=e,this.beat=this.loadedChart.getBeatFromSeconds(this.time),t||(this.chartAudio.seek(this.time),this.getAssistTickIndex()))}async loadSM(e){if(ET.close(),ht.instance.isDirty()){const s=new fd(this.app,"Save","Do you wish to save the current file?",[{label:"Cancel",type:"default"},{label:"No",type:"default"},{label:"Yes",type:"confirm"}]);this.app.windowManager.openWindow(s);const n=await s.resolved;if(n=="Cancel")return;n=="Yes"&&this.save()}if(ht.instance.setLimit(),!e){this.smPath="",this.loadedSM=void 0,this.chartAudio.stop(),this.noChartTextA.visible=!1,this.noChartTextB.visible=!1,this.chartView?.destroy({children:!0});return}this.chartAudio.stop(),this.lastSong="",this.smPath=e,this.time=0,this.beat=0;const t=await Re.getFileHandle(this.smPath);if(!t){Ce.createFormatted("Couldn't load the file at "+this.smPath,"error"),this.app.windowManager.openWindow(new RT(this.app));return}const i=await t.getFile();this.loadedSM=new Cg(i),await this.loadedSM.loaded,this.noChartTextA.visible=!0,this.noChartTextB.visible=!0,this.editTimingMode=0,$.emit("smLoaded"),await this.loadChart(),$.emit("smLoadedAfter"),this.time==0&&this.setBeat(0),Rg.addSM(this.smPath,this.loadedSM)}async loadChart(e){if(this.loadedSM!=null){if(e==null){if(this.loadedChart){const t=this.loadedSM.charts[this.loadedChart.gameType.id];t&&t.length>0&&(e=t.at(-1))}if(!e)for(const t of Ke.getPriority()){const i=this.loadedSM.charts[t.id];if(i&&i.length>0){e=i.at(-1);break}}if(!e){this.chartView?.destroy({children:!0}),this.chartView?.removeChildren(),this.beat=0,this.time=0,this.loadedChart=void 0,this.chartView=void 0,this.noChartTextA.visible=!0,this.noChartTextB.visible=!0,$.emit("chartLoaded"),$.emit("chartModified");return}}if(e!=this.loadedChart){if(this.chartView?.destroy({children:!0}),this.chartView?.removeChildren(),this.clearSelections(),this.loadedChart=e,this.beat=this.loadedChart.getBeatFromSeconds(this.time),ht.instance.reset(),_.play.timingCollection=_.play.defaultTimingCollection[e.gameType.id]??"ITG",this.getAssistTickIndex(),this.chartView=new iC(this),this.chartView.x=this.app.renderer.screen.width/2,this.chartView.y=this.app.renderer.screen.height/2,(this.mode=="Play Mode"||this.mode=="Record Mode")&&this.setMode(this.lastMode),Ie.viewMode&&this.setMode("View Mode"),this.loadedChart.getMusicPath()!=this.lastSong){this.lastSong=this.loadedChart.getMusicPath();const t=this.chartAudio.isPlaying();await this.loadAudio(),$.emit("audioLoaded"),t&&this.chartAudio.play()}this.noChartTextA.visible=!1,this.noChartTextB.visible=!1,Ce.create("Loaded chart "+e.difficulty+" "+e.meter+" "+e.gameType.id),$.emit("chartLoaded"),$.emit("audioLoaded"),$.emit("chartModified"),this.loadedChart.gameType.id=="dance-single"?window.Parity=new XT(this.app,this.loadedChart.gameType.id):window.Parity=void 0,Ie.autoPlay&&this.playPause()}}}async loadAudio(){if(!this.loadedSM||!this.loadedChart)return;this.chartAudio.stop(),this.chartAudio?.destroy();const e=this.loadedChart.getMusicPath();if(e==""){Ce.createFormatted("Failed to load audio: no audio file","error"),this.chartAudio=new no(void 0);return}const t=await this.getAudioHandle(e);if(t==null){Ce.createFormatted("Failed to load audio: couldn't find audio file "+e,"error"),this.chartAudio=new no(void 0);return}const i=await t.getFile();this.chartAudio=new no(await i.arrayBuffer(),Ui(i.name)),this.chartAudio.seek(this.time),this.getAssistTickIndex()}async getAudioHandle(e){let t=await Re.getFileHandleRelativeTo(this.smPath,e);if(t)return t;try{const i=await Re.getDirectoryFiles(jt(this.smPath));if(t=i.filter(s=>s.name.toLowerCase()==Zi(e).toLowerCase())[0],t)return Ce.createFormatted("Failed to locate audio file "+e+", using file "+t.name+" instead","warn"),t;t=i.filter(s=>ol.includes(Ui(s.name)))[0],t&&Ce.createFormatted("Failed to locate audio file "+e+", using file "+t.name+" instead","warn")}catch{return}return t}getAudio(){return this.chartAudio}updateSoundProperties(){this.setEffectVolume(_.audio.soundEffectVolume*_.audio.masterVolume),this.setVolume(_.audio.songVolume*_.audio.masterVolume),this.setRate(_.audio.rate)}setRate(e){this.chartAudio.rate(e)}setVolume(e){this.chartAudio.volume(e)}setEffectVolume(e){this.assistTick.volume()!=e&&this.assistTick.volume(e),this.me_high.volume()!=e&&this.me_high.volume(e),this.me_low.volume()!=e&&this.me_low.volume(e),this.mine.volume()!=e&&this.mine.volume(e)}getAssistTickIndex(){if(this.loadedSM==null||this.loadedChart==null||this.chartView==null||this.loadedChart.getNotedata().length==0){this.noteIndex=0;return}this.noteIndex=hi(this.loadedChart.getNotedata(),this.time,e=>e.second)+1,this.noteIndex>=1&&this.time<=this.loadedChart.getNotedata()[this.noteIndex-1].second&&this.noteIndex--}playPause(){this.chartAudio.isPlaying()?this.chartAudio.pause():this.chartAudio.play()}getClosestTick(e,t){if(!this.loadedChart)return 0;const i=Math.max(.001,4/t),s=this.loadedChart.timingData.getBeatOfMeasure(e),n=e-s,a=Math.round(s/i)*i;return Math.max(0,n+a)}snapToNearestTick(e){this.setBeat(Math.max(0,this.getClosestTick(e,4/_.chart.snap)))}snapToPreviousTick(){if(!this.loadedChart)return;const e=Math.max(.001,_.chart.snap),t=Math.floor(this.loadedChart.timingData.getMeasure(this.beat)),i=this.loadedChart.timingData.getBeatFromMeasure(t),s=Math.floor((this.beat-i)/e)*e,n=Math.abs(s-(this.beat-i))<5e-4?s-e:s,a=n+i;if(n<0){const o=this.loadedChart.timingData.getBeatFromMeasure(t-1),l=Math.round((a-o)/e)*e;this.setBeat(Math.max(0,o+l));return}this.setBeat(Math.max(0,a))}snapToNextTick(){if(!this.loadedChart)return;const e=Math.max(.001,_.chart.snap),t=Math.floor(this.loadedChart.timingData.getMeasure(this.beat)),i=this.loadedChart.timingData.getBeatFromMeasure(t),a=Math.floor((this.beat-i+5e-4)/e)*e+e+i,o=this.loadedChart.timingData.getBeatFromMeasure(t+1);if(a>o){this.setBeat(o);return}this.setBeat(a)}previousSnap(){let e=this.getSnapIndex()-1;e=(e+Zt.length)%Zt.length,_.chart.snap=Zt[e]==-1?0:1/Zt[e],$.emit("snapChanged")}nextSnap(){let e=this.getSnapIndex();(e==Zt.length-1||Math.abs(1/_.chart.snap-Zt[e])<=5e-4)&&e++,e=(e+Zt.length)%Zt.length,_.chart.snap=Zt[e]==-1?0:1/Zt[e],$.emit("snapChanged")}getSnapIndex(){return _.chart.snap==0?Zt.length-1:Zt.findIndex(e=>1/e<=_.chart.snap)}removeDuplicateBeats(e){if(e.length===0)return e;const t=[e[0]];for(let i=1;ii.beat+i.hold),t=this.loadedChart.getNotedata().map(i=>i.beat).concat(e).sort((i,s)=>i-s);return this.removeDuplicateBeats(t)}previousNote(){const e=this.getRows();if(e.length==0)return;let t=hi(e,this.beat);this.beat==e[t]&&t--,this.setBeat(e[Math.max(0,t)])}nextNote(){const e=this.getRows();if(e.length==0)return;let t=hi(e,this.beat);this.beat>=e[t]&&t++,this.setBeat(e[Math.min(e.length-1,t)])}firstNote(){if(this.loadedSM==null||this.loadedChart==null||this.chartView==null)return;const e=this.loadedChart.getNotedata();e.length!=0&&this.setBeat(e[0].beat)}lastNote(){if(this.loadedSM==null||this.loadedChart==null||this.chartView==null)return;const e=this.loadedChart.getNotedata();if(e.length==0)return;const t=e[e.length-1];this.setBeat(t.beat+(Be(t)?t.hold:0))}truncateHold(e,t){const i=Ve(Math.round((t-Math.max(.020833333333333332,_.chart.snap))*48)/48,e.beat,e.beat+e.hold-.020833333333333332);return i==e.beat?{beat:e.beat,col:e.col,type:"Tap"}:{beat:e.beat,col:e.col,type:e.type,hold:i-e.beat}}setNote(e,t,i=this.beat){if(this.loadedSM==null||this.loadedChart==null||this.chartView==null)return;i=Math.max(0,Math.round(i*48)/48);const s=this.loadedChart.getNotedata().filter(o=>o.col!=e?!1:Math.abs(o.beat-i)<.003?!0:Be(o)&&o.beat==i),n=this.loadedChart.getNotedata().filter(o=>Be(o)&&o.col==e&&i>o.beat&&i<=o.beat+o.hold).map(o=>({oldNote:o,newNote:this.truncateHold(o,i)})),a={startBeat:i,endBeat:i,roll:!1,originalNote:void 0,type:t,removedNotes:s,truncatedHolds:n};this.holdEditing[e]=a,s.length==0&&(a.originalNote={beat:i,col:e,type:this.getEditingNoteType()}),this.getAssistTickIndex(),this.app.actionHistory.run({action:()=>{a.removedNotes.forEach(o=>this.loadedChart.removeNote(o)),a.truncatedHolds.forEach(o=>this.loadedChart.modifyNote(o.oldNote,o.newNote)),a.originalNote&&this.loadedChart.addNote(a.originalNote)},undo:()=>{a.originalNote&&this.loadedChart.removeNote(a.originalNote),a.truncatedHolds.forEach(o=>this.loadedChart.modifyNote(o.newNote,o.oldNote)),a.removedNotes.forEach(o=>this.loadedChart.addNote(o))}})}editHoldBeat(e,t,i){if(this.loadedSM==null||this.loadedChart==null||this.chartView==null)return;const s=this.holdEditing[e];if(s==null||t==s.startBeat&&t==s.endBeat)return;if(s.endBeat=Math.max(s.startBeat,Math.round(t*48)/48),s.roll||=i,!s.originalNote)this.loadedChart.addNote({beat:s.startBeat,col:e,type:s.roll?"Roll":"Hold",hold:s.endBeat-s.startBeat});else{const a={beat:s.startBeat,type:s.roll?"Roll":"Hold",hold:s.endBeat-s.startBeat};s.endBeat-s.startBeat==0&&(a.hold=void 0,a.type="Tap"),(a.beat!=s.originalNote.beat||a.type!=s.originalNote.type||Be(s.originalNote)&&a.hold!=s.originalNote.hold)&&this.loadedChart.modifyNote(s.originalNote,a)}s.originalNote={beat:s.startBeat,col:e,type:s.endBeat-s.startBeat==0?"Tap":s.roll?"Roll":"Hold",hold:s.endBeat-s.startBeat==0?void 0:s.endBeat-s.startBeat};const n=this.loadedChart.getNotedata().filter(a=>a.beat==s.originalNote.beat&&a.col==s.originalNote.col||a.col!=e?!1:a.beat>=s.startBeat&&a.beat<=s.endBeat?!0:Be(a)&&a.beat+a.hold>=s.startBeat&&a.beat+a.hold<=s.endBeat);s.removedNotes=s.removedNotes.concat(n),n.forEach(a=>this.loadedChart.removeNote(a)),this.getAssistTickIndex()}endEditing(e){this.holdEditing[e]=void 0}previousNoteType(){const e=this.loadedChart?.gameType.editNoteTypes.length??0;this.editNoteTypeIndex=(this.editNoteTypeIndex-1+e)%e}nextNoteType(){const e=this.loadedChart?.gameType.editNoteTypes.length??0;this.editNoteTypeIndex=(this.editNoteTypeIndex+1+e)%e}getEditingNoteType(){return this.loadedChart?.gameType.editNoteTypes[this.editNoteTypeIndex]??null}setEditingNoteType(e){if(!this.loadedChart)return;const i=(this.loadedChart?.gameType.editNoteTypes).indexOf(e);i!=-1&&(this.editNoteTypeIndex=i)}getMode(){return this.mode}setMode(e){if(!this.loadedChart||!this.chartView)return;if(this.mode==e){(e=="Play Mode"||e=="Record Mode")&&(this.setMode(this.lastMode),this.getAssistTickIndex(),this.chartAudio.pause());return}(this.mode=="View Mode"||this.mode=="Edit Mode")&&(this.lastMode=this.mode),this.mode=e;const t=this.loadedChart.getNotedata();if(this.mode=="Play Mode"){t.forEach(i=>{i.gameplay={hideNote:!1,hasHit:!1}});for(const i of t)if(i.secondi.gameplay=void 0))}judgeCol(e){if(!(!this.loadedChart||!this.chartView)){if(this.mode=="Play Mode")this.loadedChart.gameType.gameLogic.keyDown(this,e);else if(this.mode=="Record Mode"){const t=this.loadedChart.getBeatFromSeconds(this.time+_.play.offset),i=_.chart.snap==0?1/48:_.chart.snap,s=Math.round(t/i)*i;this.setNote(e,"key",s)}}}judgeColUp(e){!this.loadedChart||!this.chartView||(this.mode=="Play Mode"?this.loadedChart.gameType.gameLogic.keyUp(this,e):this.mode=="Record Mode"&&this.endEditing(e))}async save(){if(!this.loadedSM)return;let e,t;if(window.nw){const s=window.nw.require("path"),n=s.parse(this.smPath);e=s.resolve(n.dir,n.name+".sm"),t=s.resolve(n.dir,n.name+".ssc")}else{const s=jt(this.smPath),n=Zi(this.smPath),a=n.includes(".")?n.split(".").slice(0,-1).join("."):n;e=s+"/"+a+".sm",t=s+"/"+a+".ssc"}let i=null;!this.loadedSM.usesChartTiming()&&await Re.getFileHandle(e)&&await Re.writeFile(e,this.loadedSM.serialize("sm")).catch(s=>{const n=s.message;n.includes(Go.GONE[0])||(i=n)}),(this.loadedSM.requiresSSC()||await Re.getFileHandle(t))&&await Re.writeFile(t,this.loadedSM.serialize("ssc")).catch(s=>{const n=s.message;n.includes(Go.GONE[0])||(i=n)}),i==null?this.loadedSM.usesChartTiming()?Ce.create("Saved. No SM file since split timing was used."):Ce.create("Saved"):Ce.createFormatted("Failed to save file: "+i,"error"),ht.instance.setLimit()}hasSelection(){return this.hasNoteSelection()||this.hasEventSelection()}hasNoteSelection(){return this.selection.notes.length>0||this.startRegion!==void 0&&this.endRegion!==void 0}hasEventSelection(){return this.eventSelection.timingEvents.length>0}hasRange(){return this.selection.notes.length>1||this.eventSelection.timingEvents.length>1||this.startRegion!==void 0&&this.endRegion!==void 0}clearSelections(){this.selection={notes:[],inProgressNotes:[]},this.eventSelection={timingEvents:[],inProgressTimingEvents:[]}}startDragSelection(){this.selection.inProgressNotes=[]}endDragSelection(){let e=0,t=0;const i=[],s=this.selection.inProgressNotes,n=this.selection.notes,a=(o,l)=>o.beat==l.beat?o.col-l.col:o.beat-l.beat;if(s.length==0||n.length==0){this.selection.notes=s.concat(n),this.selection.inProgressNotes=[];return}for(;;)if(a(s[e],n[t])<0){if(i.push(s[e]),e++,e>=s.length){this.selection.notes=i.concat(n.slice(t));break}}else if(i.push(n[t]),t++,t>=n.length){this.selection.notes=i.concat(s.slice(e));break}this.selection.inProgressNotes=[]}startDragEventSelection(){this.eventSelection.inProgressTimingEvents=[]}endDragEventSelection(){let e=0,t=0;const i=[],s=this.eventSelection.inProgressTimingEvents,n=this.eventSelection.timingEvents,a=(o,l)=>o.beat-l.beat;if(s.length==0||n.length==0){this.eventSelection.timingEvents=s.concat(n),this.eventSelection.inProgressTimingEvents=[];return}for(;;)if(a(s[e],n[t])<0){if(i.push(s[e]),e++,e>=s.length){this.eventSelection.timingEvents=i.concat(n.slice(t));break}}else if(i.push(n[t]),t++,t>=n.length){this.eventSelection.timingEvents=i.concat(s.slice(e));break}this.eventSelection.inProgressTimingEvents=[]}addNoteToDragSelection(e){this.addNoteSelection(this.selection.inProgressNotes,e)}removeNoteFromDragSelection(e){this.removeNoteSelection(this.selection.inProgressNotes,e)}addEventToDragSelection(e){this.addEventSelection(this.eventSelection.inProgressTimingEvents,e)}removeEventFromDragSelection(e){this.removeEventSelection(this.eventSelection.inProgressTimingEvents,e)}addNoteToSelection(e){this.addNoteSelection(this.selection.notes,e)}removeNoteFromSelection(e){this.removeNoteSelection(this.selection.notes,e)}setNoteSelection(e){this.selection.inProgressNotes=[],this.selection.notes=[...e].sort((t,i)=>t.beat==i.beat?t.col-i.col:t.beat-i.beat)}addEventToSelection(e){this.addEventSelection(this.eventSelection.timingEvents,e)}removeEventFromSelection(e){this.removeEventSelection(this.eventSelection.timingEvents,e)}setEventSelection(e){this.eventSelection.inProgressTimingEvents=[],this.eventSelection.timingEvents=e.sort((t,i)=>t.beat-i.beat)}isNoteInSelection(e){return this.getNoteSelectionIndex(this.selection.notes,e)!=-1||this.getNoteSelectionIndex(this.selection.inProgressNotes,e)!=-1}isEventInSelection(e){return this.getEventSelectionIndex(this.eventSelection.timingEvents,e)!=-1||this.getEventSelectionIndex(this.eventSelection.inProgressTimingEvents,e)!=-1}addNoteSelection(e,t){let i=Ka(e,t.beat,s=>s.beat);for(;e[i]&&(e[i].beats.beat);for(;e[i]&&e[i].beat==t.beat;){if(Tp(e[i],t))return i;i++}return-1}addEventSelection(e,t){let i=Ka(e,t.beat,s=>s.beat);for(;e[i]&&e[i].beat<=t.beat;)i++;e.splice(i,0,t)}removeEventSelection(e,t){const i=this.getEventSelectionIndex(e,t);i!=-1&&e.splice(i,1)}getEventSelectionIndex(e,t){let i=Ka(e,t.beat,s=>s.beat);for(;e[i]&&e[i].beat==t.beat;){if(Tp(e[i],t))return i;i++}return-1}selectRegion(){if(this.loadedChart){if(this.endRegion!==void 0&&(this.startRegion=void 0,this.endRegion=void 0),this.startRegion===void 0){this.clearSelections(),this.startRegion=this.beat;return}this.endRegion=this.beat,this.endRegione.beat>=this.startRegion&&e.beat<=this.endRegion).filter(e=>!this.selection.notes.includes(e)).forEach(e=>this.addNoteToSelection(e))}}modifySelection(e){if(!this.loadedChart)return;const t=this.selection.notes,i=structuredClone(this.selection.notes).map(e).sort((o,l)=>o.beat==l.beat?o.col-l.col:o.beat-l.beat);if(i.length==0)return;const s=[];for(const o of i){const l=s.at(-1);l!==void 0&&l.beat==o.beat&&l.col==o.col||s.push(o)}if(s.length==0)return;const{removedNotes:n,truncatedHolds:a}=this.checkConflicts(s,t);this.app.actionHistory.run({action:()=>{this.loadedChart.removeNotes(t.concat(n),!1),a.forEach(o=>this.loadedChart.modifyNote(o.oldNote,o.newNote,!1)),this.clearSelections(),this.setNoteSelection(this.loadedChart.addNotes(s))},undo:()=>{this.loadedChart.removeNotes(s,!1),a.forEach(o=>this.loadedChart.modifyNote(o.newNote,o.oldNote,!1)),this.loadedChart.addNotes(n,!1),this.clearSelections(),this.setNoteSelection(this.loadedChart.addNotes(t))}})}checkConflicts(e,t=[]){if(e.length==0)return{removedNotes:[],truncatedHolds:[]};const i=this.loadedChart.getNotedata();let s=i.findIndex(c=>e[0].beat<=(Be(c)?c.beat+c.hold:c.beat));const n=[],a=[],o=[];let l=null;for(const c of e){if(l==null)l=c;else if(c.beat==l.beat&&c.col==l.col)continue;for(;i[s];){const u=i[s],h=Be(c)?c.beat+c.hold:c.beat;u.col==c.col&&!t.includes(u)&&!o.includes(u)&&(c.beat<=u.beat&&h>=u.beat?(o.push(u),n.push(u)):Be(u)&&u.beat+u.hold>=c.beat&&u.beath){s--;break}}}return{removedNotes:n,truncatedHolds:a}}modifyEventSelection(e){!this.loadedChart||!this.loadedSM||this.loadedChart.timingData.modify(this.eventSelection.timingEvents.map(t=>[t,e(structuredClone(t))]))}deleteSelection(){if(this.selection.notes.length==0)return;const e=this.selection.notes;this.app.actionHistory.run({action:()=>{this.loadedChart.removeNotes(e),this.clearSelections()},undo:()=>{this.selection.notes=this.loadedChart.addNotes(e)}})}deleteEventSelection(){this.eventSelection.timingEvents.length!=0&&(!this.loadedChart||!this.loadedSM||this.loadedChart.timingData.delete(this.eventSelection.timingEvents))}paste(e){if(this.loadedChart&&(e.startsWith("ArrowVortex:notes:")&&(this.pasteNotes(e)||this.pasteNotes(this.virtualClipboard)),e.startsWith("ArrowVortex:tempo:")||e.startsWith("SMEditor:tempo:"))){this.pasteTempo(e)||this.pasteTempo(this.virtualClipboard);return}}pasteNotes(e){if(!this.loadedChart)return!0;const t=OT(e);return!t||t.length==0?!1:(this.insertNotes(t.map(i=>(i.beat+=this.beat,i.beat=Math.round(i.beat*48)/48,i))),!0)}insertNotes(e){e.sort((s,n)=>s.beat==n.beat?s.col-n.col:s.beat-n.beat);const{removedNotes:t,truncatedHolds:i}=this.checkConflicts(e);this.app.actionHistory.run({action:()=>{this.loadedChart.removeNotes(t,!1),i.forEach(s=>{this.loadedChart.modifyNote(s.oldNote,s.newNote,!1)}),this.clearSelections(),this.setNoteSelection(this.loadedChart.addNotes(e))},undo:()=>{this.loadedChart.removeNotes(e,!1),i.forEach(s=>{this.loadedChart.modifyNote(s.newNote,s.oldNote,!1)}),this.setNoteSelection(this.loadedChart.addNotes(t)),this.clearSelections()}})}pasteTempo(e){if(!this.loadedChart||!this.loadedSM)return!0;const t=VT(e);if(!t||t.length==0)return!1;const i=this.loadedChart.timingData;return t.forEach(s=>{s.type=="ATTACKS"?s.second+=this.time:s.beat+=this.beat}),t.forEach(s=>s.isChartTiming=i.isPropertyChartSpecific(s.type)),i.insert(t),!0}copy(){if(this.selection.notes.length!=0){const e=Math.min(...this.selection.notes.map(s=>s.beat)),t=structuredClone(this.selection.notes).map(s=>(s.beat-=e,s)).sort((s,n)=>s.beat==n.beat?s.col-n.col:s.beat-n.beat),i=FT(t);return this.virtualClipboard=i,i}else if(this.eventSelection.timingEvents.length!=0){const e=Math.min(...this.eventSelection.timingEvents.map(n=>n.beat)),t=this.loadedChart.timingData.getSecondsFromBeat(e),i=structuredClone(this.eventSelection.timingEvents).map(n=>n.type=="ATTACKS"?(n.second-=t,n):(n.beat-=e,n)).sort((n,a)=>n.type!=a.type?n.type.localeCompare(a.type):n.type=="ATTACKS"?n.second-a.second:n.beat-a.beat),s=GT(i);return this.virtualClipboard=s,s}}}export{ht as A,Nt as B,KT as C,la as D,$ as E,Ie as F,Ke as G,He as I,dt as K,Vn as M,_ as O,Vc as R,Cg as S,Ft as T,As as U,Ce as W,ui as _,$e as a,xe as b,dC as c,Re as d,RT as e,Ar as f,da as g,sl as h,aC as i,Ui as j,ml as k,oC as l,ET as m,cC as n,pi as o,EE as p,si as q,L0 as r,Go as s,Mt as t,f_ as u,Nr as v,vn as w}; +`),i=parseInt(t[0]),s=parseInt(t[i+1]),n=[],a=[],o=[];for(let l=0;l.6&&t<.8){const i=(t-.6)/.2*(t-.6)/.2;e.scale.set(.3*(1-i))}}Wi(this.children,e=>Date.now()-e.createTime>800)}addJudge(e,t){if(!yn(t)&&!Dr(t))return;const i=new ke(yn(t)?os.dropped_tex:os.held_tex);i.anchor.set(.5),i.x=this.notefield.getColumnX(e),i.createTime=Date.now(),i.scale.set(0),this.addChild(i)}}const VS={L:233724,l:11261687,R:16559363,r:16442809};class zS extends xe{notefield;arrowMap=new Map;notesDirty=!1;children=[];constructor(e){super(),this.notefield=e,this.sortableChildren=!0;const t=()=>{this.arrowMap.clear(),this.removeChildren()},i=()=>this.notesDirty=!0;$.on("timeSigChanged",t),$.on("chartModified",i),this.on("destroyed",()=>{$.off("timeSigChanged",t),$.on("chartModified",i)})}update(e,t){const i=this.notefield.renderer.chart.getNotedata();if(this.notesDirty){for(const[s,n]of this.arrowMap.entries())i.includes(s)||(n.destroy(),this.arrowMap.delete(s));this.notesDirty=!1}for(const s of i){if(s.beat>t)break;if(this.shouldDisplayNote(s,e,t)&&!this.arrowMap.has(s)){const n=new xe,a=this.notefield.noteskin.createNote(s);Object.assign(n,{x:this.notefield.getColumnX(s.col),zIndex:s.beat}),a.note.rotation=this.notefield.getColumnRotation(s.col);const o=new ke(Z.WHITE),l=a.getBounds();o.x=l.x,o.y=l.y,o.width=l.width,o.height=l.height,o.alpha=0;const c=new ke(Z.WHITE);c.x=l.x,c.y=l.y,c.width=l.width,c.height=l.height,c.alpha=0,this.notefield.renderer.registerDragNote(n,s),n.object=a,n.selection=o,n.parity=c,this.arrowMap.set(s,n),n.addChild(a,o,c),this.addChild(n)}}for(const[s,n]of this.arrowMap.entries()){if(!this.shouldDisplayNote(s,e,t)){n.destroy(),this.arrowMap.delete(s);continue}if(n.object.update(this.notefield.renderer),n.y=this.notefield.renderer.getActualReceptorYPos(),(!Be(s)||!s.gameplay?.lastHoldActivation||this.notefield.renderer.getVisualBeat(){e.flashes.children.forEach(t=>t.update(this.notefield.renderer)),e.holdFlashes.children.forEach(t=>t.update(this.notefield.renderer))})}createNoteFlash(e,t){(Dr(t)||yn(t))&&this.children[e].holdFlashes.removeChildren();const i=this.notefield.noteskin.createNoteFlash(t);i&&this.children[e].flashes.addChild(i)}createHoldNoteFlash(e){const t=this.notefield.noteskin.createHoldNoteFlash();t&&this.children[e].holdFlashes.addChild(t)}reset(){this.children.forEach(e=>{e.flashes.removeChildren(),e.holdFlashes.removeChildren()})}}class YS extends xe{notefield;children=[];constructor(e){super(),this.notefield=e;for(let t=0;tt.update(this.notefield.renderer,e))}keyDown(e){this.children[e].keyDown()}keyUp(e){this.children[e].keyUp()}}class XS extends xe{notefield;arrowMap=new Map;children=[];lastBeatShift=0;lastColShift=0;constructor(e){super(),this.notefield=e,this.sortableChildren=!0}update(e,t){if(!this.notefield.renderer.chartManager.selection.shift){this.removeChildren(),this.arrowMap.clear();return}const i=this.notefield.renderer.chartManager.selection.shift.beatShift,s=this.notefield.renderer.chartManager.selection.shift.columnShift;if(this.lastBeatShift!=i||this.lastColShift!=s){this.lastBeatShift=i,this.lastColShift=s;for(const[n,a]of this.arrowMap.entries()){const o={...n,beat:n.beat+i,col:n.col+s};a.x=this.notefield.getColumnX(o.col),a.object.destroy(),a.object.alpha=.4,a.object=this.notefield.noteskin.createNote(o),a.object.note.rotation=this.notefield.getColumnRotation(o.col);const l=a.object.getBounds();a.selection.x=l.x,a.selection.y=l.y,a.selection.width=l.width,a.selection.height=l.height,a.addChild(a.object,a.selection)}}for(const n of this.notefield.renderer.chartManager.selection.notes)if(!(n.beat+i+(Be(n)?n.hold:0)t)&&!this.arrowMap.has(n)){const a={...n,beat:n.beat+i,col:n.col+s},o=new xe,l=this.notefield.noteskin.createNote(a);Object.assign(o,{x:this.notefield.getColumnX(a.col),zIndex:a.beat,alpha:.4}),l.note.rotation=this.notefield.getColumnRotation(a.col);const c=new ke(Z.WHITE),u=l.getBounds();c.x=u.x,c.y=u.y,c.width=u.width,c.height=u.height,c.alpha=0,this.notefield.renderer.registerDragNote(l,a),o.object=l,o.selection=c,this.arrowMap.set(n,o),o.addChild(l,c),this.addChild(o)}for(const[n,a]of this.arrowMap.entries()){if(n.beat+i+(Be(n)?n.hold:0)t){a.destroy(),this.arrowMap.delete(n);continue}const o=n.beat+i;if(a.y=this.notefield.renderer.getYPosFromBeat(o),a.selection.alpha=Math.sin(Date.now()/320)*.1+.3,Be(n)){const l=this.notefield.renderer.getYPosFromBeat(o+(Be(n)?n.hold:0))-a.y;this.setHoldLength(a.object,l),this.setHoldBrightness(a.object,.8);const c=a.object.getLocalBounds();a.selection.x=c.x,a.selection.y=c.y,a.selection.width=c.width,a.selection.height=c.height}}}setHoldLength(e,t){e.hold&&(e.hold.holdBody.height=t,e.hold.holdBody.y=t,e.hold.holdCap.y=t,e.hold.holdCap.scale.y=t<0?-.5:.5)}setHoldBrightness(e,t){e.hold&&(e.hold.holdBody.tint=Ur(t*255,t*255,t*255),e.hold.holdCap.tint=Ur(t*255,t*255,t*255))}}class KS extends xe{noteskinOptions;noteskin;gameType;renderer;receptors;notes;selectionNotes;flashes;holdJudges;ghostNote;ghostNoteEntry;columnX=[];constructor(e){super(),this.renderer=e,this.gameType=e.chart.gameType;const t=sn.getNoteSkin(this.gameType,_.chart.noteskin[e.chart.gameType.id]);if(!t){Ce.createFormatted("Couldn't find an available noteskin!","error");return}let i=0;for(let s=0;s=e&&this.ghostNoteEntry.beat<=t&&this.ghostNoteEntry.beat>=0)}onJudgment(e,t){this.flashes.createNoteFlash(e,t),this.holdJudges.addJudge(e,t)}endPlay(){this.flashes.reset()}keyDown(e){this.receptors.keyDown(e)}keyUp(e){this.receptors.keyUp(e)}activateHold(e){this.flashes.createHoldNoteFlash(e)}getColumnX(e){return this.columnX[e]??0}getColumnRotation(e){return this.noteskinOptions.rotateColumns?this.gameType.columnRotations[e]/180*Math.PI:0}}class qS extends Fe{renderer;constructor(e){super("",{fontName:"Fancy"}),this.anchor.set(.5),this.renderer=e}update(){this.y=_.chart.reverse?-50:50;const e=this.renderer.chartManager.gameStats;if(this.visible=this.renderer.chartManager.getMode()==Y.Play,!e)return;const t=e.getCombo()==0?e.getMissCombo():e.getCombo();t<4?this.text="":this.text=t+"",e.getCombo()==0?this.tint=qe.getCollection(_.play.timingCollection).getMissJudgment().color:e.getBestJudge()?this.tint=Pg(e.getBestJudge().color,Math.sin(Date.now()/225)*.2+1.2):this.tint=16777215}}const QS=1,Qp=15,$S={fontName:"Fancy",fontSize:12};class JS extends xe{barlines=new xe;barline;currentMedian;errorText=new Fe("",$S);errorTextTime=-1;renderer;target=0;constructor(e){super(),this.renderer=e,this.barline=new ke(Z.WHITE),this.barline.anchor.set(.5),this.barline.height=1,this.barline.alpha=.5;const t=new ke(Z.WHITE);t.width=2,t.height=Qp,t.anchor.set(.5),this.currentMedian=new ma,this.currentMedian.beginFill(16777215),this.currentMedian.moveTo(0,-10),this.currentMedian.lineTo(5,-15),this.currentMedian.lineTo(-5,-15),this.currentMedian.lineTo(0,-10),this.errorText.y=-25,this.errorText.anchor.set(.5),this.addChild(this.barline,t,this.barlines,this.currentMedian,this.errorText)}update(){this.y=_.chart.reverse?-10:10,this.errorText.y=_.chart.reverse?25:-25,this.visible=this.renderer.chartManager.getMode()==Y.Play;for(const e of this.barlines.children){const t=(Date.now()-e.createTime)/5e3;t<.05?e.alpha=1:t<.3?e.alpha=sr(1,.2,(t-.05)/.25):t<.9?e.alpha=.2:e.alpha=(1-t)*3}this.errorText.alpha=Ve((2e3-(Date.now()-this.errorTextTime))/1e3,0,1),this.barline.width=qe.getCollection(_.play.timingCollection).maxWindowMS()/1e3*2*400,Wi(this.barlines.children,e=>Date.now()-e.createTime>5e3),_.general.smoothAnimations?this.currentMedian.x=(this.currentMedian.x-this.target)*.8+this.target:this.currentMedian.x=this.target}addBar(e,t){if(!ni(t)&&!Vi(t))return;const i=new ke(Z.WHITE);i.width=QS,i.height=Qp,i.anchor.set(.5),i.x=e*400,i.tint=t.color,i.createTime=Date.now(),i.miss=ni(t),i.ms=Math.round(e*1e3),this.errorText.tint=t.color,this.errorText.text=(e*1e3).toFixed(1)+"ms",this.errorTextTime=Date.now(),this.barlines.addChild(i),this.target=fl(this.barlines.children.filter(s=>!s.miss).map(s=>s.ms))*.4}reset(){this.currentMedian.x=0,this.target=0,Wi(this.barlines.children,()=>!0)}}class ZS extends ke{createTime=-1;active=!1;type=dg;constructor(){super(),this.anchor.set(.5)}update(){if(this.y=_.chart.reverse?40:-40,this.visible=this.active,this.active){const e=(Date.now()-this.createTime)/1e3;let t=1.2;if(qe.getCollection(_.play.timingCollection).shouldHideNote(this.type)||(t=.8),e<.1){const i=1-(1-e/.1)*(1-e/.1),s=(1-t)*i+t;this.scale.x=.4*s,this.scale.y=.4*s}else if(e>.6&&e<.8){const i=(e-.6)/.2*(e-.6)/.2;this.scale.x=.4*(1-i),this.scale.y=.4*(1-i)}else e>.8&&(this.active=!1)}}doJudge(e,t){if(!Vi(t)&&!ni(t))return;const i=t.judgmentTexture.getTexture(e,t);i&&(this.texture=i,this.texture.updateUvs(),this.active=!0,this.type=t,this.createTime=Date.now(),_.play.judgmentTilt?this.rotation=Ve(e,-.05,.05)*300/180*Math.PI:this.rotation=0)}reset(){this.active=!1}}const $p={BPMS:{title:"BPM Event",rows:[{label:"Tempo",key:"value",input:{type:"spinner",precision:3}}]},STOPS:{title:"Stop Event",description:"Stops for a number of seconds. Notes on this beat are hit before the stop occurs.",rows:[{label:"Seconds",key:"value",input:{type:"spinner",precision:3}}]},WARPS:{title:"Warp Event",description:"Warps ahead a number of beats. Warped notes do not count towards score.",rows:[{label:"Beats",key:"value",input:{type:"spinner",precision:3,min:0}}]},DELAYS:{title:"Delay Event",description:"Stops for a number of seconds. Notes on this beat are hit after the delay occurs.",rows:[{label:"Seconds",key:"value",input:{type:"spinner",precision:3}}]},SCROLLS:{title:"Scroll Event",description:"Notes after this event will scroll at the specified speed.",rows:[{label:"Multiplier",key:"value",input:{type:"spinner",precision:3}}]},TICKCOUNTS:{title:"Tickcount Event",description:"Number of ticks per beat in a hold. Only applies to pump gamemodes.",rows:[{label:"Ticks",key:"value",input:{type:"spinner",step:1,precision:0,min:0}}]},FAKES:{title:"Fake Event",description:"Creates an area of notes that cannot be hit and do not count towards score.",rows:[{label:"Beats",key:"value",input:{type:"spinner",precision:3,min:0}}]},LABELS:{title:"Label Event",rows:[{label:"Label",key:"value",input:{type:"text"}}]},SPEEDS:{title:"Speed Event",width:200,description:"The entire playfield scrolls at the specified speed. Can slowly ease over a certain amount of time.",rows:[{label:"Multiplier",key:"value",input:{type:"spinner",precision:3}},{label:"Ease time",key:"delay",input:{type:"spinner",precision:3,min:0}},{label:"Ease unit",key:"unit",input:{type:"dropdown",items:["Beats","Seconds"],transformers:{serialize:r=>r=="B"?"Beats":"Seconds",deserialize:r=>r=="Beats"?"B":"T"}}}]},TIMESIGNATURES:{title:"Time Signature Event",width:200,rows:[{label:"Upper",key:"upper",input:{type:"spinner",step:1,precision:0,min:1}},{label:"Lower",key:"lower",input:{type:"spinner",step:1,precision:0,min:1}}]},COMBOS:{title:"Combo Event",width:200,description:"Multiplies the combo gained from hitting/missing notes after this event.",rows:[{label:"Hit multiplier",key:"hitMult",input:{type:"spinner",step:1,precision:0,min:0}},{label:"Miss multiplier",key:"missMult",input:{type:"spinner",step:1,precision:0,min:0}}]},ATTACKS:{title:"Attack Event",width:200,description:"Applies a modifier to the playfield. Can specify the length of the applied attack in seconds or the end time of the attack.",rows:[{label:"Timing type",key:"endType",input:{type:"dropdown",items:["Length","End"],transformers:{serialize:r=>r=="LEN"?"Length":"End",deserialize:r=>r=="Length"?"LEN":"END"}}},{label:"Seconds",key:"value",input:{type:"spinner",precision:3}},{label:"Mods",key:"mods",input:{type:"text"}}]},BGCHANGES:{title:"BG Change Event",width:250,rows:[{label:"File",key:"file",input:{type:"text"}},{label:"Update rate",key:"updateRate",input:{type:"spinner",precision:3,min:0}},{label:"Crossfade",key:"crossfade",input:{type:"checkbox"}},{label:"StretchRewind",key:"stretchRewind",input:{type:"checkbox"}},{label:"StretchNoLoop",key:"StretchNoLoop",input:{type:"checkbox"}},{label:"Effect",key:"effect",input:{type:"text"}},{label:"File2",key:"file2",input:{type:"text"}},{label:"Transition",key:"transition",input:{type:"text"}},{label:"Color1",key:"color1",input:{type:"text"}},{label:"Color2",key:"color2",input:{type:"text"}}]},FGCHANGES:{title:"FG Change Event",width:250,rows:[{label:"File",key:"file",input:{type:"text"}},{label:"Update rate",key:"updateRate",input:{type:"spinner",precision:3,min:0}},{label:"Crossfade",key:"crossfade",input:{type:"checkbox"}},{label:"StretchRewind",key:"stretchRewind",input:{type:"checkbox"}},{label:"StretchNoLoop",key:"StretchNoLoop",input:{type:"checkbox"}},{label:"Effect",key:"effect",input:{type:"text"}},{label:"File2",key:"file2",input:{type:"text"}},{label:"Transition",key:"transition",input:{type:"text"}},{label:"Color1",key:"color1",input:{type:"text"}},{label:"Color2",key:"color2",input:{type:"text"}}]}};class St{static activePopup;timingBox;popup;zoomer;editText;timingData;rows=[];onTimingChange;clickOutside;moveInterval;modifyBox;onConfirm=()=>{};persistent=!1;constructor(e,t,i=!1){e.popup=this,this.timingBox=e,this.timingData=t,this.modifyBox=i,this.popup=this.build(),this.popup.style.display="none",setTimeout(()=>this.movePosition()),this.onTimingChange=this.updateValues.bind(this),this.clickOutside=s=>{this.popup.contains(s.target)||this.close()},$.on("timingModified",this.onTimingChange),St.activePopup?.persistent?e.popup=void 0:(document.getElementById("popups")?.appendChild(this.popup),this.moveInterval=setInterval(()=>this.movePosition(),150),St.activePopup?.close(),St.activePopup=this)}movePosition(){this.popup.style.display="";const e=this.timingBox.backgroundObj.getBounds(),t=e.left+e.width/2,i=$p[this.timingBox.event.type].width??150,s=i/2+15,n=window.innerWidth-i/2-15;this.popup.style.left=`${Ve(t,s,n)}px`;const a=e.top+35+e.height/2;this.popup.style.top=`${e.top+e.height+35}px`,a+this.popup.clientHeight>window.innerHeight-15&&(this.popup.style.transform="translate(-50%, -100%)",this.popup.style.top=`${e.top-e.height/2+35}px`)}build(){const e=$p[this.timingBox.event.type],t=document.createElement("div");t.classList.add("popup");const i=document.createElement("div");i.classList.add("popup-zoomer"),i.style.width=e.width?`${e.width}px`:"150px",i.style.backgroundColor=Cc(Lr[this.timingBox.event.type].toString(16).padStart(6,"0"),"#333333",.75),this.zoomer=i,t.appendChild(i);const s=document.createElement("div");if(s.innerText=e.title,s.classList.add("popup-title"),i.appendChild(s),e.description){const u=document.createElement("div");u.innerText=e.description,i.appendChild(u),u.classList.add("popup-desc")}const n=document.createElement("div");n.classList.add("popup-grid"),i.appendChild(n),e.rows.forEach(u=>n.append(...this.buildRow(u)));const a=document.createElement("div");a.innerText="click to edit",a.style.marginTop="4px",a.style.height="10px",i.appendChild(a),a.classList.add("popup-desc"),this.editText=a;const o=document.createElement("div");o.classList.add("popup-options");const l=document.createElement("button");l.innerText="Ok",l.onclick=()=>{this.close(),this.onConfirm(this.timingBox.event)},l.classList.add("confirm"),o.append(l);const c=document.createElement("button");return c.innerText="Delete",c.onclick=()=>{this.modifyBox||this.timingData.delete([{type:this.timingBox.event.type,[this.timingBox.event.type=="ATTACKS"?"second":"beat"]:this.timingBox.event.type=="ATTACKS"?this.timingBox.event.second:this.timingBox.event.beat}]),this.close()},c.classList.add("delete"),o.append(c),i.append(o),t}buildRow(e){const t=structuredClone(this.timingBox.event),i=document.createElement("div");i.innerText=e.label,i.classList.add("popup-label");const s=[];switch(s.push(i),e.input.type){case"spinner":{const n=Ze.create(t[e.key],e.input.step,e.input.precision,e.input.min,e.input.max);n.onChange=a=>{a!==void 0&&this.modifyEvent(e.key,a)},this.rows.push({data:e,el:n}),s.push(n.view);break}case"text":{const n=document.createElement("input");n.type="text",n.autocomplete="off",n.spellcheck=!1,n.onkeydown=a=>{a.key=="Enter"&&n.blur()},n.onblur=()=>{this.modifyEvent(e.key,n.value)},n.value=t[e.key],this.rows.push({data:e,el:n}),s.push(n);break}case"dropdown":{if(e.input.transformers){const n=e.input.transformers.deserialize,a=e.input.transformers.serialize,o=pi.create(e.input.items,a(t[e.key]));o.onChange(l=>{this.modifyEvent(e.key,n(l))}),this.rows.push({data:e,el:o}),s.push(o.view)}else{const n=pi.create(e.input.items,t[e.key]);n.onChange(a=>{this.modifyEvent(e.key,a)}),this.rows.push({data:e,el:n}),s.push(n.view)}break}case"checkbox":{const n=document.createElement("input");n.type="checkbox",n.checked=t[e.key],n.onchange=()=>{this.modifyEvent(e.key,n.checked)},this.rows.push({data:e,el:n}),s.push(n);break}}return s}modifyEvent(e,t){this.modifyBox?Object.assign(this.timingBox.event,{[e]:t}):this.timingData.modify([[structuredClone(this.timingBox.event),Object.assign(this.timingBox.event,{[e]:t})]])}updateValues(){const e=this.timingData.getEventAtBeat(this.timingBox.event.type,this.timingBox.event.beat,!1);if(!this.timingBox||!e||e.beat!=this.timingBox.event.beat){this.close();return}this.rows.forEach(t=>{switch(t.data.input.type){case"spinner":{t.el.setValue(e[t.data.key]);break}case"text":{t.el.value=e[t.data.key];break}case"dropdown":{const i=t.el;t.data.input.transformers?i.setSelected(t.data.input.transformers.serialize(e[t.data.key])):i.setSelected(e[t.data.key]);break}case"checkbox":{t.el.checked=e[t.data.key];break}}})}close(){this.persistent=!1,$.off("timingModified",this.onTimingChange),window.removeEventListener("click",this.clickOutside),clearInterval(this.moveInterval),this.popup.classList.add("exiting"),setTimeout(()=>this.popup.remove(),200),this.timingBox.popup=void 0,St.activePopup=void 0}select(){this.persistent=!0,this.zoomer.classList.add("selected"),this.editText.style.transform="scale(0)",this.editText.style.height="0px",setTimeout(()=>window.addEventListener("click",this.clickOutside),200)}detach(){clearInterval(this.moveInterval)}getEvent(){return this.timingBox.event}attach(e){clearInterval(this.moveInterval),this.moveInterval=setInterval(()=>this.movePosition(),150),this.timingBox=e}}const Bc={fontName:"Main",fontSize:15},Ir={BPMS:55,STOPS:55,DELAYS:55,WARPS:55,FAKES:55,COMBOS:40,SPEEDS:80,LABELS:80,SCROLLS:55,TIMESIGNATURES:40,TICKCOUNTS:40,BGCHANGES:55,FGCHANGES:55,ATTACKS:55};class eC extends xe{tracks=new xe;renderer;timingBoxMap=new Map;wasEditingTiming=!1;boxPool=new ha({create:()=>{const e=new xe;return e.textObj=new Fe("",Bc),e.backgroundObj=new Nt,e.selection=new Nt("onlyBorder"),e.selection.tint=3841008,e.addChild(e.backgroundObj,e.textObj,e.selection),e}});ghostBox;timingDirty=!1;constructor(e){super(),this.renderer=e,this.boxPool.sortableChildren=!0,this.sortableChildren=!0,this.addChild(this.tracks,this.boxPool);const t=()=>this.timingDirty=!0;$.on("timingModified",t),this.on("destroyed",()=>$.off("timingModified",t))}update(e,t){this.renderer.chartManager.editTimingMode!=De.Add&&(this.ghostBox?.removeFromParent(),this.ghostBox?.destroy(),this.ghostBox=void 0),this.updateTracks(),this.updateBoxes(e,t)}createTrack(e,t){const i=Object.assign(new ke(Z.WHITE),{alpha:0,width:Ir[e],name:e,height:5e3,x:t,type:e,lastX:0,tint:2503250,targetAlpha:0});return i.anchor.y=.5,this.tracks.addChild(i),i}initializeBox(e,t){if(Object.assign(e,{event:t,isChartTiming:this.renderer.chart.timingData.isPropertyChartSpecific(t.type),lastX:void 0,lastAnchor:void 0,animationId:void 0,zIndex:t.beat,eventMode:"static"}),e.textObj.text=this.getLabelFromEvent(t),e.textObj.anchor.set(.5,.55),e.backgroundObj.width=e.textObj.width+10,e.backgroundObj.height=25,e.backgroundObj.position.x=-e.backgroundObj.width/2,e.backgroundObj.position.y=-25/2,e.selection.width=e.textObj.width+10,e.selection.height=25,e.selection.position=e.backgroundObj.position,e.popup=void 0,St.activePopup){const i=St.activePopup.getEvent();i.type=="ATTACKS"&&t.type=="ATTACKS"&&i.second==t.second&&(St.activePopup.attach(e),e.popup=St.activePopup),i.type!="ATTACKS"&&t.type!="ATTACKS"&&i.type==t.type&&i.beat==t.beat&&(St.activePopup.attach(e),e.popup=St.activePopup)}}addDragListeners(e,t){e.on("mouseenter",()=>{e?.popup?.persistent!==!0&&(this.renderer.chartManager.eventSelection.timingEvents.length>0||this.renderer.isDragSelecting()||(e.popup?.close(),this.renderer.chartManager.getMode()==Y.Edit&&(new St(e,this.getTargetTimingData(e.event.isChartTiming)),e.popup&&(e.popup.onConfirm=()=>{this.renderer.chartManager.removeEventFromSelection(t)}))))}),e.on("mouseleave",()=>{e?.popup?.persistent!==!0&&e.popup?.close()});let i=0,s;const n=a=>{const o=s,l=this.toLocal(a.global);if(Math.abs(l.y-i)<32){this.renderer.chartManager.eventSelection.shift&&(this.renderer.chartManager.eventSelection.shift={beatShift:0});return}e.popup?.close();const c=this.renderer.getBeatFromYPos(l.y),u=_.chart.snap==0?1/1e3:_.chart.snap;let h=Math.round(c/u)*u;Math.abs(h-c)>Math.abs(c-o.beat)&&(h=o.beat),this.renderer.chartManager.eventSelection.shift||={beatShift:0},this.renderer.chartManager.eventSelection.shift.beatShift=Math.max(-Math.min(...this.renderer.chartManager.eventSelection.timingEvents.map(d=>d.beat)),h-o.beat)};e.on("pointerdown",a=>{if(Tc(a)){this.renderer.chartManager.clearSelections(),this.renderer.chartManager.addEventToSelection(t),St.activePopup?.close();return}if(a.stopImmediatePropagation(),this.renderer.chartManager.isEventInSelection(t)?(a.getModifierState("Control")||a.getModifierState("Meta"))&&this.renderer.chartManager.removeEventFromSelection(t):(!a.getModifierState("Control")&&!a.getModifierState("Meta")&&!a.getModifierState("Shift")&&this.renderer.chartManager.clearSelections(),this.renderer.chartManager.addEventToSelection(t)),this.renderer.chartManager.getMode()==Y.Edit&&this.renderer.chartManager.eventSelection.timingEvents.length==1&&(e?.popup||(St.activePopup?.close(),new St(e,this.getTargetTimingData(e.event.isChartTiming)),e.popup.onConfirm=()=>{this.renderer.chartManager.removeEventFromSelection(t)})),e.popup&&!a.getModifierState("Control")&&!a.getModifierState("Meta")&&!a.getModifierState("Shift")?e.popup.select():e.popup?.close(),i=e.y,s=t,this.renderer.chartManager.editTimingMode==De.Add)return;this.renderer.on("pointermove",n);const o=()=>{this.renderer.off("pointermove",n),this.renderer.off("pointerup",o),(this.renderer.chartManager.eventSelection.shift?.beatShift??0)!=0&&this.renderer.chartManager.modifyEventSelection(l=>(l.type=="ATTACKS"&&(l.second=this.renderer.chart.timingData.getSecondsFromBeat(l.beat+this.renderer.chartManager.eventSelection.shift.beatShift)),l.beat+=this.renderer.chartManager.eventSelection.shift.beatShift,l)),this.renderer.chartManager.eventSelection.shift=void 0};this.renderer.on("pointerup",o)})}updateTracks(){const e=_.chart.timingEventOrder.left,t=_.chart.timingEventOrder.right,i=this.renderer.chartManager.editTimingMode!=De.Off&&this.renderer.chartManager.getMode()==Y.Edit;let s=-this.renderer.chart.gameType.notefieldWidth*.5-128;for(let n=e.length-1;n>=0;n--){const a=e[n],o=this.tracks.getChildByName(a)??this.createTrack(a,s);o.lastX!=s&&(o.lastX=s,o.targetAlpha=n%2==0?.1:0,It.animate(o,{0:{x:"inherit","anchor.x":"inherit"},1:{x:s,"anchor.x":1}},.3,Yt(0,0,.16,1.01),()=>{},`track-${a}-x`),It.animate(o,{0:{alpha:"inherit"},1:{alpha:i?o.targetAlpha:0}},.3,Yt(0,0,.16,1.01),()=>{},`track-${a}-alpha`)),s-=Ir[a]}s=this.renderer.chart.gameType.notefieldWidth*.5+128;for(let n=0;n{},`track-${a}-x`),It.animate(o,{0:{alpha:"inherit"},1:{alpha:i?o.targetAlpha:0}},.3,Yt(0,0,.16,1.01),()=>{},`track-${a}-alpha`)),s+=Ir[a]}if(this.wasEditingTiming!=i){this.wasEditingTiming=i;for(const n of this.tracks.children)It.animate(n,{0:{alpha:"inherit"},1:{alpha:i?n.targetAlpha:0}},.3,Yt(0,0,.16,1.01),()=>{},`track-${n.type}-alpha`)}}updateBoxes(e,t){this.timingDirty&&(this.timingBoxMap.clear(),this.boxPool.destroyAll(),this.timingDirty=!1);const i=this.renderer.chartManager.editTimingMode!=De.Off&&this.renderer.chartManager.getMode()==Y.Edit;this.boxPool.visible=this.renderer.shouldDisplayBarlines(),this.ghostBox&&(this.ghostBox.visible=this.renderer.shouldDisplayBarlines());for(const n of this.renderer.chart.timingData.getTimingData()){if(tn.beat)&&!this.timingBoxMap.has(n)){const a=this.boxPool.createChild();if(!a)break;this.initializeBox(a,n),this.addDragListeners(a,n),this.timingBoxMap.set(n,a)}}const s={beat:-Number.MAX_SAFE_INTEGER,second:-Number.MAX_SAFE_INTEGER,leftOffset:0,rightOffset:0};for(const[n,a]of this.timingBoxMap.entries()){if(n.beatt){this.timingBoxMap.delete(n),a.popup?.persistent?a.popup?.detach():a.popup?.close(),this.boxPool.destroyChild(a);continue}let o=0,l=0;const c=a.backgroundObj.width,u=_.chart.timingEventOrder.right.includes(n.type)?"right":"left";i?(o=this.tracks.getChildByName(n.type)?.x??a.x,o+=Ir[n.type]/2*(o>0?1:-1),l=.5):(o=(u=="right"?1:-1)*(this.renderer.chart.gameType.notefieldWidth*.5+80),u=="left"&&(o-=30),(s.beat!=n.beat||n.second&&s.second!=n.second)&&(s.leftOffset=0,s.rightOffset=0,s.beat=n.beat,s.second=n.second),u=="left"?(o-=s.leftOffset,s.leftOffset+=c+5):(o+=s.rightOffset,s.rightOffset+=c+5),l=u=="right"?0:1),a.lastX===void 0||a.lastAnchor===void 0?(a.position.x=o,a.pivot.x=(l-.5)*c):(a.lastX!=o||a.lastAnchor!=l)&&(a.animationId=It.animate(a,{0:{x:"inherit","pivot.x":"inherit"},1:{x:o,"pivot.x":(l-.5)*c}},.3,Yt(0,0,.16,1.01),()=>{},a.animationId)),a.lastX=o,a.lastAnchor=l,a.y=_.chart.CMod&&n.type=="ATTACKS"?this.renderer.getYPosFromSecond(n.second):this.renderer.getYPosFromBeat(n.beat);const h=this.renderer.chartManager.getMode()!=Y.Play&&this.renderer.chartManager.isEventInSelection(n);if(a.backgroundObj.tint=h?Pg(Lr[n.type]??0,Math.sin(Date.now()/320)*.4+1.5):Lr[n.type]??0,a.selection.alpha=h?1:0,a.visible=!h||!this.renderer.chartManager.eventSelection.shift,this.renderer.chartManager.editTimingMode!=De.Off){const d=this.renderer.selectionTest(a);!h&&d&&this.renderer.chartManager.addEventToDragSelection(n),h&&!d&&this.renderer.chartManager.removeEventFromDragSelection(n)}}}updateGhostEvent(e){const t=_.chart.snap==0?.001:_.chart.snap,i=Math.round(this.renderer.getBeatFromYPos(e.y)/t)*t,s=this.ghostBox?.popup?this.ghostBox.event.type:this.getClosestTrack(e.x)?.name;if(!s){this.ghostBox?.removeFromParent(),this.ghostBox?.destroy(),this.ghostBox=void 0;return}if(!this.ghostBox){const o=new xe;o.textObj=new Fe("",Bc),o.backgroundObj=new Nt,o.selection=new Nt("onlyBorder"),o.guideLine=new ke(Z.WHITE),o.selection.tint=3841008,o.selection.alpha=0,o.addChild(o.guideLine,o.backgroundObj,o.textObj,o.selection),this.addChild(o),o.visible=this.renderer.shouldDisplayBarlines(),o.textObj.anchor.set(.5,.55),o.backgroundObj.height=25,o.selection.height=25,o.guideLine.height=1,o.guideLine.anchor.y=.5,this.ghostBox=o}!this.ghostBox?.popup&&(this.ghostBox.event?.beat!=i||this.ghostBox.event?.type!=s)&&(this.ghostBox.event=structuredClone(this.renderer.chart.timingData.getEventAtBeat(s,i))??this.renderer.chart.timingData.getDefaultEvent(s,i),this.ghostBox.event.beat=i,s=="ATTACKS"&&(this.ghostBox.event.second=this.renderer.chart.getSecondsFromBeat(i)),this.ghostBox.textObj.text=this.getLabelFromEvent(this.ghostBox.event),this.ghostBox.backgroundObj.width=this.ghostBox.textObj.width+10,this.ghostBox.selection.width=this.ghostBox.textObj.width+10),this.ghostBox.alpha=this.ghostBox?.popup?1:.4,this.ghostBox.selection.alpha=this.ghostBox?.popup?1:0,this.ghostBox.name=s;const n=this.renderer.getYPosFromBeat(this.ghostBox?.popup?this.ghostBox.event.beat:i);let a=this.tracks.getChildByName(s).x;a+=Ir[s]/2*(a>0?1:-1),this.ghostBox.position.x=a,this.ghostBox.backgroundObj.tint=Lr[s]??0,this.ghostBox.backgroundObj.position.x=-this.ghostBox.backgroundObj.width/2,this.ghostBox.backgroundObj.position.y=-25/2,this.ghostBox.guideLine.anchor.x=a<0?0:1,this.ghostBox.guideLine.width=Math.abs(this.ghostBox.position.x)+192-this.ghostBox.backgroundObj.width/2,this.ghostBox.guideLine.position.x=(a<0?1:-1)*this.ghostBox.backgroundObj.width/2,this.ghostBox.y=n,this.ghostBox.selection.position=this.ghostBox.backgroundObj.position}placeGhostEvent(){if(!this.ghostBox)return;const e=this.renderer.chart.timingData.getEventAtBeat(this.ghostBox.event.type,this.ghostBox.event.beat,!1);this.ghostBox.event.type=="ATTACKS"&&this.ghostBox.event.second==e?.second||this.ghostBox.event.type!="ATTACKS"&&this.ghostBox.event.beat==e?.beat||(this.renderer.chartManager.clearSelections(),this.ghostBox.event.isChartTiming=this.renderer.chart.timingData.isPropertyChartSpecific(this.ghostBox.event.type),new St(this.ghostBox,this.getTargetTimingData(this.ghostBox.event.isChartTiming),!0),this.ghostBox.popup?.select(),this.ghostBox.popup.onConfirm=t=>{this.getTargetTimingData(this.ghostBox.event.isChartTiming).insert([t])})}getClosestTrack(e){let t=Number.MAX_SAFE_INTEGER,i=this.tracks.children[0];for(const s of this.tracks.children){const n=Math.abs(s.x+(.5-s.anchor.x)*s.width-e);ni.width))return i}getLabelFromEvent(e){let t="";switch(e.type){case"BPMS":case"STOPS":case"WARPS":case"DELAYS":case"TICKCOUNTS":case"FAKES":case"SCROLLS":t=ne(e.value,3).toString();break;case"SPEEDS":t=`${ne(e.value,3)}/${ne(e.delay,3)}/${e.unit}`;break;case"LABELS":t=e.value;break;case"TIMESIGNATURES":t=`${ne(e.upper,3)}/${ne(e.lower,3)}`;break;case"COMBOS":t=`${ne(e.hitMult,3)}/${ne(e.missMult,3)}`;break;case"BGCHANGES":case"FGCHANGES":t=e.file;break;case"ATTACKS":t=`${e.mods}`}return t}getTargetTimingData(e){return e?this.renderer.chart.timingData:this.renderer.chart.timingData.simfileTimingData}}class tC extends xe{children=[];renderer;timingBoxMap=new Map;trackPosCache=new Map;timingBoxPool=new ha({create:()=>{const e=new xe;return e.guideLine=new ke(Z.WHITE),e.textObj=new Fe("",Bc),e.backgroundObj=new Nt,e.addChild(e.guideLine,e.backgroundObj,e.textObj),e}});constructor(e){super(),this.renderer=e,this.timingBoxPool.sortableChildren=!0,this.addChild(this.timingBoxPool)}update(e,t){if(!this.renderer.chartManager.eventSelection.shift){this.timingBoxPool.destroyAll(),this.timingBoxMap.clear(),this.trackPosCache.clear();return}const i=this.renderer.chartManager.eventSelection.shift.beatShift;for(const s of this.renderer.chartManager.eventSelection.timingEvents)if(!(ts.beat+i)&&!this.timingBoxMap.has(s)){const n=this.timingBoxPool.createChild();if(!n)continue;this.timingBoxMap.set(s,n);let a="";switch(s.type){case"BPMS":case"STOPS":case"WARPS":case"DELAYS":case"TICKCOUNTS":case"FAKES":case"SCROLLS":a=ne(s.value,3).toString();break;case"SPEEDS":a=`${ne(s.value,3)}/${ne(s.delay,3)}/${s.unit}`;break;case"LABELS":a=s.value;break;case"TIMESIGNATURES":a=`${ne(s.upper,3)}/${ne(s.lower,3)}`;break;case"COMBOS":a=`${ne(s.hitMult,3)}/${ne(s.missMult,3)}`;break;case"BGCHANGES":case"FGCHANGES":a=s.file;break;case"ATTACKS":a=`${s.mods} (${s.endType}=${s.value})`}const o=_.chart.timingEventOrder.right.includes(s.type)?"right":"left";if(Object.assign(n,{alpha:.4,isChartTiming:this.renderer.chart.timingData.isPropertyChartSpecific(s.type),zIndex:s.beat}),n.textObj.text=a,n.textObj.anchor.set(.5,.55),n.backgroundObj.width=n.textObj.width+10,n.backgroundObj.height=25,n.backgroundObj.tint=Lr[s.type]??0,n.backgroundObj.position.x=-n.backgroundObj.width/2,n.backgroundObj.position.y=-n.backgroundObj.height/2,n.guideLine.height=1,n.guideLine.anchor.set(o=="left"?0:1,.5),n.guideLine.width=Math.abs(n.position.x)+192-n.backgroundObj.width/2,n.guideLine.position.x=(o=="left"?1:-1)*n.backgroundObj.width/2,this.renderer.chartManager.editTimingMode!=De.Off){let l=this.getTrackPos(s.type);l+=Ir[s.type]/2*(l>0?1:-1),n.position.x=l,n.pivot.x=0}else{let l=(o=="right"?1:-1)*(this.renderer.chart.gameType.notefieldWidth*.5+80);o=="left"&&(l-=30),n.position.x=l,n.pivot.x=o=="right"?-n.backgroundObj.width/2:n.backgroundObj.width/2}}for(const[s,n]of this.timingBoxMap.entries()){if(ts.beat+i){this.timingBoxPool.destroyChild(n),this.timingBoxMap.delete(s);continue}n.y=_.chart.CMod&&s.second?this.renderer.getYPosFromSecond(s.second):this.renderer.getYPosFromBeat(s.beat+i)}}getTrackPos(e){if(this.trackPosCache.has(e))return this.trackPosCache.get(e);const t=_.chart.timingEventOrder.left,i=_.chart.timingEventOrder.right;let s=-this.renderer.chart.gameType.notefieldWidth*.5-128;for(let n=t.length-1;n>=0;n--){const a=t[n];this.trackPosCache.set(a,s),s-=Ir[a]}s=this.renderer.chart.gameType.notefieldWidth*.5+128;for(let n=0;n{if(this.editingCol!=-1){const a=_.chart.snap==0?.020833333333333332:_.chart.snap,o=Math.round(this.getBeatFromYPos(this.lastMousePos.y)/a)*a;this.chartManager.editHoldBeat(this.editingCol,o,n.shiftKey)}};let i=0;const s=()=>{if(!this.chartManager.selection.shift&&!this.selectionBounds||i==0)return;const n=this.getYPosFromBeat(Math.max(0,this.chartManager.getBeat()+i));this.chartManager.setBeat(Math.max(0,this.chartManager.getBeat()+i)),this.selectionBounds&&(this.selectionBounds.start.y+=_.chart.receptorYPos/_.chart.zoom-n,this.selectionBoundary.update())};this.chartManager.app.ticker.add(s),window.addEventListener("keydown",t),this.on("destroyed",()=>{window.removeEventListener("keydown",t),this.removeAllListeners(),this.chartManager.app.ticker.remove(s)}),this.on("pointerdown",n=>{Tc(n)||this.chartManager.getMode()==Y.Play||this.chartManager.getMode()==Y.View||(this.chartManager.editTimingMode==De.Add&&this.lastMousePos?this.timingTracks.placeGhostEvent():this.chartManager.editTimingMode==De.Off&&_.chart.mousePlacement&&this.lastMouseBeat!=-1&&this.lastMouseCol!=-1&&!n.getModifierState("Shift")?(this.chartManager.clearSelections(),this.editingCol=this.lastMouseCol,this.chartManager.setNote(this.lastMouseCol,"mouse",this.lastMouseBeat)):(!n.getModifierState("Control")&&!n.getModifierState("Meta")&&!n.getModifierState("Shift")&&this.chartManager.clearSelections(),this.chartManager[this.chartManager.editTimingMode==De.Off?"startDragSelection":"startDragEventSelection"](),this.selectionBounds={start:this.toLocal(n.global),end:this.toLocal(n.global)},this.selectionBoundary.update()))}),this.on("mousemove",n=>{if(this.lastMousePos=this.toLocal(n.global),this.editingCol!=-1){const a=_.chart.snap==0?.020833333333333332:_.chart.snap,o=Math.round(this.getBeatFromYPos(this.lastMousePos.y)/a)*a;this.chartManager.editHoldBeat(this.editingCol,o,n.shiftKey)}this.selectionBounds&&(this.selectionBounds.end=this.toLocal(n.global),this.selectionBoundary.update()),i=Math.max(0,this.lastMousePos.y-this.getLowerBound()+100)/600,this.lastMousePos.y<0&&(i=Math.min(0,this.lastMousePos.y-this.getUpperBound()-100)/600)}),this.on("pointerup",()=>{this.editingCol!=-1&&(this.chartManager.endEditing(this.editingCol),this.editingCol=-1),this.chartManager[this.chartManager.editTimingMode==De.Off?"endDragSelection":"endDragEventSelection"](),this.selectionBounds=void 0,this.selectionBoundary.update(),i=0})}isDragSelecting(){return!!this.selectionBounds}doJudgment(e,t,i){this.chartManager.getMode()==Y.Play&&(this.judgment.doJudge(t,i),this.timingBar.addBar(t,i)),this.notefield.onJudgment(e.col,i)}activateHold(e){this.notefield.activateHold(e)}keyDown(e){this.notefield.keyDown(e)}keyUp(e){this.notefield.keyUp(e)}endPlay(){this.notefield.endPlay(),this.timingBar.reset(),this.judgment.reset()}update(){const e=this.getVisualBeat(),t=this.getVisualTime();this.speedMult=_.chart.doSpeedChanges?this.chart.timingData.getSpeedMult(e,t):1;const i=this.getUpperBoundBeat(),s=this.getLowerBoundBeat();if(this.scale.x=_.chart.zoom,this.scale.y=_.chart.zoom,this.children.forEach(n=>n.update(i,s)),this.notefield.alpha=this.chartManager.editTimingMode==De.Off||this.chartManager.getMode()==Y.Play?1:.3,_.chart.mousePlacement&&this.lastMousePos&&this.chartManager.getMode()!=Y.Play){const n=_.chart.snap==0?.020833333333333332:_.chart.snap,a=Math.round(this.getBeatFromYPos(this.lastMousePos.y)/n)*n;let o=-1;for(let l=0;lu-c/2){o=l;break}}(a!=this.lastMouseBeat||o!=this.lastMouseCol||this.chartManager.getEditingNoteType()!=this.lastNoteType)&&(this.lastMouseBeat=a,this.lastMouseCol=o,this.lastNoteType=this.chartManager.getEditingNoteType(),this.editingCol!=-1&&this.chartManager.editHoldBeat(this.editingCol,a,!1),o===-1?(this.lastMouseBeat=-1,this.lastMouseCol=-1,this.notefield.setGhostNote()):this.notefield.setGhostNote(this.chart.computeNote({beat:a,col:this.lastMouseCol,type:this.chartManager.getEditingNoteType()})))}this.lastMousePos&&this.chartManager.editTimingMode==De.Add&&this.timingTracks.updateGhostEvent(this.lastMousePos)}getTimeWithOffset(){let e=this.chartManager.getTime();return(this.chartManager.getMode()==Y.Play||this.chartManager.getMode()==Y.Record)&&(e+=_.play.offset*_.audio.rate),e}getBeatWithOffset(){let e=this.chartManager.getBeat();return(this.chartManager.getMode()==Y.Play||this.chartManager.getMode()==Y.Record)&&(e=this.chart.getBeatFromSeconds(this.getTimeWithOffset())),e}getVisualTime(){let e=this.chartManager.getTime();return(this.chartManager.getMode()==Y.Play||this.chartManager.getMode()==Y.Record)&&(e+=(_.play.offset+_.play.visualOffset)*_.audio.rate),e}getVisualBeat(){let e=this.chartManager.getBeat();return(this.chartManager.getMode()==Y.Play||this.chartManager.getMode()==Y.Record)&&(e=this.chart.getBeatFromSeconds(this.getVisualTime())),e}getYPosFromBeat(e){const t=this.getVisualTime(),i=this.getVisualBeat(),s=_.chart.reverse?-1:1;return _.chart.CMod?(this.chart.getSecondsFromBeat(e)-t)*this.getSecondsToPixelsRatio()*s+this.getActualReceptorYPos():i==e?this.getActualReceptorYPos():(_.chart.doSpeedChanges?this.chart.timingData.getEffectiveBeat(e)-this.chart.timingData.getEffectiveBeat(i):e-i)*this.getEffectiveBeatsToPixelsRatio()*s+this.getActualReceptorYPos()}getYPosFromSecond(e){const t=this.getVisualTime(),i=_.chart.reverse?-1:1;return _.chart.CMod?(e-t)*this.getSecondsToPixelsRatio()*i+this.getActualReceptorYPos():this.getYPosFromBeat(this.chart.timingData.getBeatFromSeconds(e))}getSecondFromYPos(e){const t=_.chart.reverse?-1:1;if(_.chart.CMod){const i=this.getPixelsToSecondsRatio(),s=this.getVisualTime(),a=(e-this.getActualReceptorYPos())*i*t;return s+a}return this.chart.getSecondsFromBeat(this.getBeatFromYPos(e))}getBeatFromYPos(e,t){const i=this.getVisualBeat(),s=_.chart.reverse?-1:1;if(_.chart.CMod)return this.chart.getBeatFromSeconds(this.getSecondFromYPos(e));const a=(e-this.getActualReceptorYPos())*this.getPixelsToEffectiveBeatsRatio()*s;if(_.chart.doSpeedChanges&&!t){const o=this.chart.timingData.getEffectiveBeat(i)+a;return this.chart.getBeatFromEffectiveBeat(o)}return i+a}getActualReceptorYPos(){return _.chart.receptorYPos/_.chart.zoom*(_.chart.reverse?-1:1)}getEffectiveBeatsToPixelsRatio(){return _.chart.speed/100*64*this.speedMult}getPixelsToEffectiveBeatsRatio(){return 1/this.getEffectiveBeatsToPixelsRatio()}getSecondsToPixelsRatio(){return _.chart.speed/100*64*4}getPixelsToSecondsRatio(){return 1/this.getSecondsToPixelsRatio()}isNegScroll(e){return _.chart.doSpeedChanges&&(this.speedMult<0||(this.chart.timingData.getEventAtBeat("SCROLLS",e)?.value??1)<0||(this.chart.timingData.getEventAtBeat("BPMS",e)?.value??120)<0)}getUpperBound(){return _.chart.reverse?(this.chartManager.app.renderer.screen.height-this.y)/_.chart.zoom+32:-this.y/_.chart.zoom-32}getLowerBound(){return _.chart.reverse?-this.y/_.chart.zoom-32:(this.chartManager.app.renderer.screen.height-this.y)/_.chart.zoom+32}getUpperBoundBeat(){if(_.chart.waveform.speedChanges&&!_.chart.CMod&&_.chart.doSpeedChanges){const e=_.chart.speed,t=this.chart.timingData.getSpeedMult(this.getVisualBeat(),this.getVisualTime()),i=t>=0!=_.chart.reverse?1:-1,s=this.chart.timingData.getTimingData("SCROLLS"),n=100/e/Math.abs(t)/64/_.chart.zoom,a=this.getUpperBound(),o=this.getLowerBound();let l=hi(s,this.getVisualBeat()-_.chart.maxDrawBeatsBack,m=>m.beat);for(;s[l]?.beat0&&b>a&&(go||!s[l-1]||s[l-1].beat0?s[l-1]?.value==0&&this.getYPosFromBeat(s[l-1].beat)>f?this.getVisualBeat()-_.chart.maxDrawBeatsBack:Math.max(this.getVisualBeat()-_.chart.maxDrawBeatsBack,c+d*(f-u)):s[l-1]?.value==0&&this.getYPosFromBeat(s[l-1].beat)=0!=_.chart.reverse?1:-1,s=this.chart.timingData.getTimingData("SCROLLS"),n=100/e/Math.abs(t)/64/_.chart.zoom,a=this.getUpperBound(),o=this.getLowerBound();let l=hi(s,this.getVisualBeat()+_.chart.maxDrawBeats,m=>m.beat);for(;s[l]?.beat>this.getVisualBeat()-_.chart.maxDrawBeatsBack;){const m=s[l],g=this.getYPosFromBeat(m.beat),y=s[l+1]?.beat??this.getVisualBeat()+_.chart.maxDrawBeats,b=this.getYPosFromBeat(y);if(m.value*i>0&&go||!s[l+1]||s[l+1].beat>this.getVisualBeat()+_.chart.maxDrawBeatsBack||s[l+1].value==0)||m.value*i<0&&g>a&&(bthis.getVisualBeat()+_.chart.maxDrawBeatsBack||s[l+1].value==0))break;l--}const c=s[l]?.beat??0,u=this.getYPosFromBeat(c),h=s[l]?.value??1,d=n/Math.abs(h)*_.chart.zoom,p=_.chart.reverse?o:a,f=_.chart.reverse?a:o;return h*i>0?s[l+1]?.value==0&&this.getYPosFromBeat(s[l+1].beat)p?this.getVisualBeat()+_.chart.maxDrawBeats:Math.min(this.getVisualBeat()+_.chart.maxDrawBeats,c+d*(u-p))}return _.chart.CMod?this.getBeatFromYPos(this.getLowerBound()):Math.min(this.getVisualBeat()+_.chart.maxDrawBeats,this.getBeatFromYPos(this.getLowerBound()))}selectionTest(e){if(!this.selectionBounds)return!1;const t=this.selectionBoundary.getBounds(),i=e.getBounds(),s=16*_.chart.zoom;return t.x+t.width>i.x+s&&t.xi.y+s&&t.y{const u=o,h=this.toLocal(c.global);if(Math.abs(h.y-a-n)**2+Math.abs(h.x-s)**2<32*32){this.chartManager.selection.shift&&(this.chartManager.selection.shift={columnShift:0,beatShift:0});return}const d=this.getBeatFromYPos(h.y-a),p=_.chart.snap==0?1/48:_.chart.snap;let f=Math.round(d/p)*p;Math.abs(f-d)>Math.abs(d-u.beat)&&(f=u.beat);const m=Math.round((h.x+96)/64);this.chartManager.selection.shift||={columnShift:0,beatShift:0},i!=m-u.col&&(i=m-u.col,this.chartManager.selection.notes.every(g=>{const y=g.col+i;return y>=0&&yg.beat)),f-u.beat)};e.on("pointerdown",c=>{if(this.chartManager.getMode()==Y.View)return;if(Tc(c)){this.chartManager.isNoteInSelection(t)||(this.chartManager.clearSelections(),this.chartManager.addNoteToSelection(t)),KT.open(this.chartManager.app,c),c.preventDefault();return}if(_.chart.mousePlacement&&!c.getModifierState("Meta")&&!c.getModifierState("Control")&&!c.getModifierState("Shift")&&!this.chartManager.isNoteInSelection(t))return;c.stopImmediatePropagation(),this.chartManager.isNoteInSelection(t)?(c.getModifierState("Control")||c.getModifierState("Meta"))&&this.chartManager.removeNoteFromSelection(t):(!c.getModifierState("Control")&&!c.getModifierState("Meta")&&!c.getModifierState("Shift")&&this.chartManager.clearSelections(),this.chartManager.addNoteToSelection(t)),s=e.x,n=e.y,a=this.toLocal(c.global).y-e.y,o=t,this.on("pointermove",l);const u=()=>{this.off("pointermove",l),this.off("pointerup",u),((this.chartManager.selection.shift?.beatShift??0)!=0||(this.chartManager.selection.shift?.columnShift??0)!=0)&&this.chartManager.modifySelection(h=>(h.beat+=this.chartManager.selection.shift.beatShift,h.col+=this.chartManager.selection.shift.columnShift,h)),this.chartManager.selection.shift=void 0};this.on("pointerup",u)}),e.on("destroyed",()=>{e?.removeAllListeners()})}getNotefield(){return this.notefield}getSelectionBounds(){return this.selectionBounds}shouldDisplayBarlines(){return(this.chartManager.getMode()!=Y.Play||!_.play.hideBarlines)&&Ie.barlines}}class Ad extends AudioBufferSourceNode{started=!1;start(e,t,i){this.started||super.start(e,t,i),this.started=!0}stop(e){this.started&&super.stop(e),this.started=!1}static create(e){const t=e;return t.started=!1,Object.setPrototypeOf(t,Ad.prototype),t}}class rC extends BiquadFilterNode{enabled=!1;static create(e){const t=e;return t.enabled=!1,t}}class no{_audioAnalyzer;_filteredAudioAnalyzer;_freqData;_filteredFreqData;_gainNode;type;_audioContext=new AudioContext;_source;_playbackTime=0;_startTimestamp=0;_rate=1;_isPlaying=!1;_buffer;_filteredBuffer;_loadedBuffer;_delay;_loadListeners=[];_updateListeners=[];_volume=1;_destroyed=!1;_renderTimeout;_filters=[this.createFilter({type:"highpass",frequency:20,Q:.71}),this.createFilter({type:"lowshelf",frequency:75,gain:0}),this.createFilter({type:"peaking",frequency:100,gain:0,Q:.6}),this.createFilter({type:"peaking",frequency:250,gain:0,Q:.3}),this.createFilter({type:"peaking",frequency:1040,gain:0,Q:.41}),this.createFilter({type:"peaking",frequency:2500,gain:0,Q:.2}),this.createFilter({type:"highshelf",frequency:7500,gain:0}),this.createFilter({type:"lowpass",frequency:2e4,Q:.71})];_filtersEnabled=!1;loaded;constructor(e,t){this.type=t??"",this._filters[0].gain.value=-25,this._audioAnalyzer=this._audioContext.createAnalyser(),this._audioAnalyzer.fftSize=4096,this._audioAnalyzer.maxDecibels=0,this._freqData=new Uint8Array(this._audioAnalyzer.frequencyBinCount),this._filteredAudioAnalyzer=this._audioContext.createAnalyser(),this._filteredAudioAnalyzer.fftSize=4096,this._filteredAudioAnalyzer.maxDecibels=0,this._filteredFreqData=new Uint8Array(this._filteredAudioAnalyzer.frequencyBinCount),this._gainNode=this._audioContext.createGain(),this._buffer=this._audioContext.createBuffer(2,1,44100),this._filteredBuffer=this._audioContext.createBuffer(2,1,44100),this._loadedBuffer=this._audioContext.createBuffer(2,1,44100),this.initSource(),this.loaded=new Promise(i=>{this.decodeData(e).then(s=>{if(s)return this._loadedBuffer=s,s}).then(async s=>(await this.renderBuffer(s),await this.renderFilteredBuffer(s),s)).catch(s=>{s.name=="EncodingError"?Ce.createFormatted("Failed to load audio: file format not supported","error"):Ce.createFormatted("Failed to load audio: "+s.message,"error")}).finally(()=>{this.initSource(),this.callLoadListeners(),this.callUpdateListeners(),i()})})}async renderBuffer(e){if(!e)return;const t=new OfflineAudioContext(e.numberOfChannels,e.length,e.sampleRate),i=t.createBufferSource();return i.buffer=e,i.connect(t.destination),i.start(),await t.startRendering().then(s=>{this._buffer=s}).catch(()=>{Ce.createFormatted("Failed to load audio: audio rendering failed","error")})}async renderFilteredBuffer(e){if(!e)return;const t=new OfflineAudioContext(e.numberOfChannels,e.length,e.sampleRate),i=t.createBufferSource();i.buffer=e;let s=i;for(const n of this._filters){if(!n.enabled)continue;const a=t.createBiquadFilter();a.type=n.type,a.Q.setValueAtTime(n.Q.value,0),a.frequency.setValueAtTime(n.frequency.value,0),a.gain.setValueAtTime(n.gain.value,0),s.connect(a),s=a}return s.connect(t.destination),i.start(),await t.startRendering().then(n=>{this._filteredBuffer=n}).catch(()=>{Ce.createFormatted("Failed to load audio: audio rendering failed","error")})}createFilter(e){const t=rC.create(this._audioContext.createBiquadFilter());return t.type=e.type,e.Q!==void 0&&(t.Q.value=e.Q),e.gain!==void 0&&(t.gain.value=e.gain),e.frequency!==void 0&&(t.frequency.value=e.frequency),t}getFilters(){return this._filters}getFilter(e){return this._filters[e]}updateFilter(e,t){this._filters[e]&&(t.Q!==void 0&&(this._filters[e].Q.value=t.Q),t.frequency!==void 0&&(this._filters[e].frequency.value=t.frequency),t.gain!==void 0&&(this._filters[e].gain.value=t.gain),clearTimeout(this._renderTimeout),this._renderTimeout=setTimeout(()=>this.renderFilteredBuffer(this._loadedBuffer).then(()=>this.callUpdateListeners()),500))}enableFilter(e){this._filters[e].enabled=!0,this.initSource(),clearTimeout(this._renderTimeout),this._renderTimeout=setTimeout(()=>this.renderFilteredBuffer(this._loadedBuffer).then(()=>this.callUpdateListeners()),500),this._filtersEnabled=!0}disableFilter(e){this._filters[e].enabled=!1,this.initSource(),clearTimeout(this._renderTimeout),this._renderTimeout=setTimeout(()=>this.renderFilteredBuffer(this._loadedBuffer).then(()=>this.callUpdateListeners()),500),this._filtersEnabled=this._filters.some(t=>t.enabled)}hasFilters(){return this._filtersEnabled}onLoad(e){this._loadListeners.push(e)}offLoad(e){this._loadListeners=this._loadListeners.filter(t=>t!=e)}onUpdate(e){this._updateListeners.push(e)}offUpdate(e){this._updateListeners=this._updateListeners.filter(t=>t!=e)}getSongLength(){return this._buffer.length/this._buffer.sampleRate}getFrequencyData(){return this._destroyed?new Uint8Array:(this._audioAnalyzer.getByteFrequencyData(this._freqData),this._freqData)}getFilteredFrequencyData(){return this._destroyed?new Uint8Array:(this._filteredAudioAnalyzer.getByteFrequencyData(this._filteredFreqData),this._filteredFreqData)}getSampleRate(){return this._buffer.sampleRate}getFFTSize(){return this._audioAnalyzer.fftSize}getRawData(){if(this._destroyed)return[];const e=[];for(let t=0;ti.enabled)?this._filters.filter(i=>i.enabled).map(i=>{const s=new Float32Array(e.length);return i.getFrequencyResponse(t,s,new Float32Array(e.length)),[...s]}).reduce((i,s)=>i.map((n,a)=>n*s[a])):new Array(e.length).fill(1)}callLoadListeners(){this._loadListeners.forEach(e=>e())}callUpdateListeners(){this._updateListeners.forEach(e=>e())}async decodeData(e){return new Promise((t,i)=>{if(!e){t();return}(async()=>{try{t(await this._audioContext.decodeAudioData(e))}catch(s){if(this.type==".ogg"){const n=(await ui(()=>import("./OggDec-2941c3fd.js"),[])).default;try{t(await n.decodeOggData(e))}catch(a){i(a)}return}i(s)}})()})}initSource(){for(const t of this._filters)t.disconnect();this._audioAnalyzer.disconnect(),this._filteredAudioAnalyzer.disconnect(),this._gainNode.disconnect(),this._audioContext.destination.disconnect(),this._source?.stop(),this._source=Ad.create(this._audioContext.createBufferSource()),this._source.buffer=this._buffer,this._source.connect(this._audioAnalyzer);let e=this._audioAnalyzer;for(const t of this._filters)t.enabled&&(e.connect(t),e=t);e.connect(this._filteredAudioAnalyzer),_.audio.allowFilter?this._filteredAudioAnalyzer.connect(this._gainNode):this._audioAnalyzer.connect(this._gainNode),this._gainNode.connect(this._audioContext.destination),this._source.playbackRate.value=this._rate,this._isPlaying&&(this.pause(),this.play())}volume(e){this._destroyed||this._volume!=e&&(this._volume=e,this._gainNode.gain.setValueAtTime(e,this._audioContext.currentTime))}rate(e){this._destroyed||this._rate!=e&&(this._rate=e,this._source&&(this._isPlaying&&(this._playbackTime+=(this._audioContext.currentTime-this._startTimestamp)*this._source.playbackRate.value),this._startTimestamp=this._audioContext.currentTime,this._source.playbackRate.value=e))}play(){this._destroyed||this._source&&(this._isPlaying||(this.initSource(),this._playbackTime<=this._buffer.duration&&(this._playbackTime<0?(clearTimeout(this._delay),this._delay=setInterval(()=>{this.seek()>0&&(clearInterval(this._delay),this._source?.start(0,0))})):this._source.start(0,this._playbackTime)),this._startTimestamp=this._audioContext.currentTime,this._isPlaying=!0))}seek(e){if(!this._destroyed&&this._source){if(e===void 0)return this._isPlaying?(this._audioContext.currentTime-this._startTimestamp)*this._source.playbackRate.value+this._playbackTime:this._playbackTime;this._isPlaying?(this.stop(),this._playbackTime=e,this.play()):this._playbackTime=e}}pause(){this._destroyed||this.stop(!0)}stop(e){this._destroyed||this._source&&this._isPlaying&&(clearTimeout(this._delay),this._isPlaying=!1,this._playbackTime<=this._buffer.duration&&this._source.stop(),this._playbackTime=e?(this._audioContext.currentTime-this._startTimestamp)*this._source.playbackRate.value+this._playbackTime:0)}}class sC{judgmentCounts=new Map;holdJudgmentCounts=new Map;dancePoints=0;maxCumulativeDancePoints=0;maxDancePoints=0;chartManager;notedata;dataPoints=[];handlers=[];combo=0;missCombo=0;maxCombo=0;bestJudge;constructor(e){this.notedata=e.loadedChart.getNotedata(),this.chartManager=e,this.bestJudge=qe.getCollection(_.play.timingCollection).getStandardWindows()[0],this.calculateMaxDP()}onJudge(e){this.handlers.push(e)}applyOffset(e){this.dataPoints=this.dataPoints.map(t=>ni(t.judgment)||!Vi(t.judgment)?t:{...t,error:t.error+e}),this.recalculate()}addDataPoint(e,t,i){this.judgmentCounts.has(t)||this.judgmentCounts.set(t,0),this.judgmentCounts.set(t,this.judgmentCounts.get(t)+1),this.dancePoints+=t.dancePoints;const s=this.chartManager.loadedChart.timingData.getEventAtBeat("COMBOS",e[0].beat),n=s?.hitMult??1,a=s?.missMult??1;ms(t)||(this.maxCumulativeDancePoints+=qe.getCollection(_.play.timingCollection).getMaxDancePoints()),ni(t)?(this.maxCumulativeDancePoints+=e.filter(Be).reduce((o,l)=>o+qe.getCollection(_.play.timingCollection).getMaxHoldDancePoints(l.type),0),this.combo=0,this.missCombo+=a,this.bestJudge=void 0):Vi(t)&&(qe.getCollection(_.play.timingCollection).shouldHideNote(t)?(this.combo+=e.length*n,this.combo>this.maxCombo&&(this.maxCombo=this.combo),this.missCombo=0,this.bestJudge&&t.getTimingWindowMS()>this.bestJudge.getTimingWindowMS()&&(this.bestJudge=t)):(this.bestJudge=void 0,this.combo=0)),this.handlers.forEach(o=>o(i,t)),this.dataPoints.push({second:e[0].second,error:i,judgment:t,notes:e})}addHoldDataPoint(e,t){this.judgmentCounts.has(t)||this.judgmentCounts.set(t,0),this.judgmentCounts.set(t,this.judgmentCounts.get(t)+1);const i=qe.getCollection(_.play.timingCollection).getHeldJudgement(e);this.holdJudgmentCounts.has(i)||this.holdJudgmentCounts.set(i,[0,0]);const s=this.holdJudgmentCounts.get(i);Dr(t)?s[0]++:s[1]++,this.holdJudgmentCounts.set(i,s),this.dancePoints+=t.dancePoints,this.maxCumulativeDancePoints+=qe.getCollection(_.play.timingCollection).getMaxHoldDancePoints(e.type),this.handlers.forEach(n=>n(0,t)),yn(t)&&(this.bestJudge=void 0)}getScore(){return this.maxDancePoints==0?0:this.dancePoints/this.maxDancePoints}getCumulativeScore(){return this.maxCumulativeDancePoints==0?0:this.dancePoints/this.maxCumulativeDancePoints}getDataPoints(){return this.dataPoints}getMedian(){return fl(this.dataPoints.filter(e=>!ni(e.judgment)&&Vi(e.judgment)).map(e=>e.error))}getMaxCombo(){return this.maxCombo}recalculate(){this.calculateMaxDP(),this.dancePoints=0,this.maxCumulativeDancePoints=0;for(const e of this.holdJudgmentCounts.entries()){const t=e[0];this.dancePoints+=e[0].dancePoints*e[1][0],this.maxCumulativeDancePoints+=(e[1][0]+e[1][1])*qe.getCollection(_.play.timingCollection).getMaxHoldDancePoints(t.noteType)}this.judgmentCounts.clear();for(const e of this.dataPoints){let t=qe.getCollection(_.play.timingCollection).judgeInput(e.error);(ni(e.judgment)||ms(e.judgment))&&(t=e.judgment),this.judgmentCounts.has(t)||this.judgmentCounts.set(t,0),this.judgmentCounts.set(t,this.judgmentCounts.get(t)+1),this.dancePoints+=t.dancePoints,e.judgment=t,ms(t)||(this.maxCumulativeDancePoints+=qe.getCollection(_.play.timingCollection).getMaxDancePoints()),ni(t)&&(this.maxCumulativeDancePoints+=e.notes.filter(Be).reduce((i,s)=>i+qe.getCollection(_.play.timingCollection).getMaxHoldDancePoints(s.type),0))}}calculateMaxDP(){const e=new Map,t=new Map;for(const i of this.notedata)i.type=="Mine"||i.fake||(Be(i)&&(t.has(i.type)||t.set(i.type,0),t.set(i.type,t.get(i.type)+1)),e.has(i.beat)||e.set(i.beat,[]),e.get(i.beat).push(i));this.maxDancePoints=e.size*qe.getCollection(_.play.timingCollection).getMaxDancePoints(),this.maxDancePoints+=Array.from(t.entries()).reduce((i,s)=>i+s[1]*qe.getCollection(_.play.timingCollection).getMaxHoldDancePoints(s[0]),0)}getCount(e){return this.judgmentCounts.get(e)??0}getCombo(){return this.combo}getMissCombo(){return this.missCombo}getBestJudge(){return this.bestJudge}}const Zt=[1,2,3,4,6,8,12,16,24,48,-1];var Y=(r=>(r.View="View Mode",r.Edit="Edit Mode",r.Play="Play Mode",r.Record="Record Mode",r))(Y||{}),De=(r=>(r[r.Off=0]="Off",r[r.Edit=1]="Edit",r[r.Add=2]="Add",r))(De||{});class dC{app;chartAudio=new no;chartView;widgetManager;assistTick=new hs.Howl({src:y_,volume:.5});me_high=new hs.Howl({src:rg,volume:.5});me_low=new hs.Howl({src:sg,volume:.5});mine=new hs.Howl({src:v_,volume:.5});loadedSM;smPath="";loadedChart;selection={notes:[],inProgressNotes:[]};eventSelection={timingEvents:[],inProgressTimingEvents:[]};editTimingMode=0;beat=0;time=0;holdEditing=[];editNoteTypeIndex=0;partialScroll=0;noteIndex=0;lastMetronomeDivision=-1;lastMetronomeMeasure=-1;lastSong="";mode="Edit Mode";lastMode="Edit Mode";noChartTextA;noChartTextB;virtualClipboard="";startRegion;endRegion;gameStats;constructor(e){this.app=e,document.addEventListener("cut",i=>{if(i.target.classList.contains("inlineEdit")||i.target instanceof HTMLTextAreaElement||i.target instanceof HTMLInputElement||this.mode!="Edit Mode")return;const s=this.copy();s&&i.clipboardData?.setData("text/plain",s),this.eventSelection.timingEvents.length>0?this.deleteEventSelection():this.deleteSelection(),i.preventDefault()},!0),document.addEventListener("copy",i=>{if(i.target.classList.contains("inlineEdit")||i.target instanceof HTMLTextAreaElement||i.target instanceof HTMLInputElement||this.mode!="Edit Mode")return;const s=this.copy();s&&i.clipboardData?.setData("text/plain",s),i.preventDefault(),i.stopImmediatePropagation()},!0),document.addEventListener("paste",i=>{if(i.target.classList.contains("inlineEdit")||i.target instanceof HTMLTextAreaElement||i.target instanceof HTMLInputElement||this.mode!="Edit Mode")return;const s=i.clipboardData?.getData("text/plain");s&&this.paste(s),i.preventDefault(),i.stopImmediatePropagation()},!0),e.view.addEventListener?.("wheel",i=>{if(!(this.loadedSM==null||this.loadedChart==null||this.chartView==null))if(i.preventDefault(),ys&&i.metaKey||!ys&&i.ctrlKey){const s=i.deltaY/5*_.chart.scroll.scrollSensitivity*(_.chart.scroll.invertZoomScroll?-1:1);_.chart.speed=Ve(_.chart.speed*Math.pow(1.01,s),10,35e3)}else{if(this.mode=="Play Mode"||this.mode=="Record Mode")return;let s=this.beat;const n=_.chart.snap,a=_.chart.speed*(_.chart.reverse&&_.chart.scroll.invertReverseScroll?-1:1),o=i.deltaY/a*_.chart.scroll.scrollSensitivity;if(n==0?(this.partialScroll=0,s=this.beat+o):_.chart.scroll.scrollSnapEveryScroll?i.deltaY<0?s=Math.round((this.beat-n)/n)*n:s=Math.round((this.beat+n)/n)*n:(this.partialScroll+=o,Math.abs(this.partialScroll)>n&&(this.partialScroll<0?s=Math.round((this.beat+Math.ceil(this.partialScroll/n)*n)/n)*n:s=Math.round((this.beat+Math.floor(this.partialScroll/n)*n)/n)*n,this.partialScroll%=n)),s=Math.max(0,s),s!=this.beat&&this.setBeat(s),!this.holdEditing.every(l=>l==null))for(let l=0;l{this.noChartTextB.tint=8952234}),this.noChartTextB.on("mouseleave",()=>{this.noChartTextB.tint=5596791}),this.noChartTextB.on("mousedown",()=>{this.app.windowManager.openWindow(new Ag(e,Ke.getGameType("dance-single")))}),this.noChartTextA.visible=!1,this.noChartTextB.visible=!1;const t=()=>{this.noChartTextA.x=this.app.renderer.screen.width/2,this.noChartTextA.y=this.app.renderer.screen.height/2-20,this.noChartTextB.x=this.app.renderer.screen.width/2,this.noChartTextB.y=this.app.renderer.screen.height/2+10};t(),this.app.stage.addChild(this.noChartTextB),this.app.ticker.add(()=>{const i=performance.now();this.widgetManager.update(),this.loadedSM&&this.loadedChart&&this.chartView&&this.chartView.update(),la.instance?.addDrawUpdateTimeValue(performance.now()-i)}),setInterval(()=>{if(!this.loadedSM||!this.loadedChart||!this.chartView)return;const i=performance.now(),s=this.chartAudio.seek();if(this.chartAudio.isPlaying()&&(this.setTime(s,!0),!this.holdEditing.every(u=>!u)))for(let u=0;u.3&&this.editHoldBeat(u,p,!1)}const n=this.loadedChart.getNotedata();let a=!1;for(;this.noteIndexn[this.noteIndex].second+_.play.effectOffset;)this.mode!="Record Mode"&&this.chartAudio.isPlaying()&&this.loadedChart.gameType.gameLogic.shouldAssistTick(n[this.noteIndex])&&(this.mode!="Play Mode"&&this.chartView.doJudgment(n[this.noteIndex],0,dg),!a&&_.audio.assistTick&&Ie.assist&&(this.assistTick.play(),a=!0)),this.noteIndex++;const o=this.loadedChart.getBeatFromSeconds(this.time+_.play.effectOffset),l=Math.floor(this.loadedChart.timingData.getDivisionOfMeasure(o)),c=Math.floor(this.loadedChart.timingData.getMeasure(o));(c!=this.lastMetronomeMeasure||l!=this.lastMetronomeDivision)&&(this.lastMetronomeDivision=l,this.lastMetronomeMeasure=c,this.chartAudio.isPlaying()&&_.audio.metronome&&Ie.assist&&(l==0?this.me_high.play():this.me_low.play())),this.mode=="Play Mode"&&this.loadedChart.gameType.gameLogic.update(this),this.updateSoundProperties(),TT(),la.instance?.addUpdateTimeValue(performance.now()-i)},5),$.on("resize",()=>{this.chartView&&(this.chartView.x=this.app.renderer.screen.width/2,this.chartView.y=this.app.renderer.screen.height/2),t()}),$.on("chartModified",()=>{this.loadedChart&&(this.loadedChart.recalculateStats(),$.emit("chartModifiedAfter"))}),window.addEventListener("keyup",i=>{if(this.mode=="Edit Mode"&&i.code.startsWith("Digit")){const s=parseInt(i.code.slice(5))-1;this.endEditing(s)}},!0),window.addEventListener("keydown",i=>{const s=$e.getKeyNameFromCode(i.code);if(this.mode=="Edit Mode"&&!i.target.classList.contains("inlineEdit")&&!(i.target instanceof HTMLTextAreaElement)&&!(i.target instanceof HTMLInputElement)){if(i.code.startsWith("Digit")&&!i.repeat&&!i.ctrlKey&&!i.metaKey&&!i.altKey&&!i.ctrlKey){const n=parseInt(i.code.slice(5))-1;n<(this.loadedChart?.gameType.numCols??4)&&n>-1&&(this.setNote(n,"key"),i.preventDefault(),i.stopImmediatePropagation())}if(!this.holdEditing.every(n=>n==null)){const n=["cursorUp","cursorDown","previousNote","nextNote","previousMeasure","nextMeasure","jumpChartStart","jumpChartEnd","jumpSongStart","jumpSongEnd"];for(const a of n)if($e.getCombosForKeybind(a).map(o=>o.key).includes(s)){i.preventDefault(),i.stopImmediatePropagation(),dt[a].callback(this.app);for(let o=0;oo.key).includes(s)){this.holdEditing=[];return}}}},!0),window.addEventListener("keydown",i=>{this.mode!="Play Mode"&&this.mode!="Record Mode"||i.key=="Escape"&&(this.setMode(this.lastMode),this.chartAudio.pause())},!0)}getBeat(){return this.beat}getTime(){return this.time}setBeat(e){this.loadedChart&&(this.beat=e,this.time=this.loadedChart.getSecondsFromBeat(this.beat),this.chartAudio.seek(this.time),this.getAssistTickIndex())}setTime(e,t){this.loadedChart&&(this.time=e,this.beat=this.loadedChart.getBeatFromSeconds(this.time),t||(this.chartAudio.seek(this.time),this.getAssistTickIndex()))}async loadSM(e){if(ET.close(),ht.instance.isDirty()){const s=new fd(this.app,"Save","Do you wish to save the current file?",[{label:"Cancel",type:"default"},{label:"No",type:"default"},{label:"Yes",type:"confirm"}]);this.app.windowManager.openWindow(s);const n=await s.resolved;if(n=="Cancel")return;n=="Yes"&&this.save()}if(ht.instance.setLimit(),!e){this.smPath="",this.loadedSM=void 0,this.chartAudio.stop(),this.noChartTextA.visible=!1,this.noChartTextB.visible=!1,this.chartView?.destroy({children:!0});return}this.chartAudio.stop(),this.lastSong="",this.smPath=e,this.time=0,this.beat=0;const t=await Re.getFileHandle(this.smPath);if(!t){Ce.createFormatted("Couldn't load the file at "+this.smPath,"error"),this.app.windowManager.openWindow(new RT(this.app));return}const i=await t.getFile();this.loadedSM=new Cg(i),await this.loadedSM.loaded,this.noChartTextA.visible=!0,this.noChartTextB.visible=!0,this.editTimingMode=0,$.emit("smLoaded"),await this.loadChart(),$.emit("smLoadedAfter"),this.time==0&&this.setBeat(0),Rg.addSM(this.smPath,this.loadedSM)}async loadChart(e){if(this.loadedSM!=null){if(e==null){if(this.loadedChart){const t=this.loadedSM.charts[this.loadedChart.gameType.id];t&&t.length>0&&(e=t.at(-1))}if(!e)for(const t of Ke.getPriority()){const i=this.loadedSM.charts[t.id];if(i&&i.length>0){e=i.at(-1);break}}if(!e){this.chartView?.destroy({children:!0}),this.chartView?.removeChildren(),this.beat=0,this.time=0,this.loadedChart=void 0,this.chartView=void 0,this.noChartTextA.visible=!0,this.noChartTextB.visible=!0,$.emit("chartLoaded"),$.emit("chartModified");return}}if(e!=this.loadedChart){if(this.chartView?.destroy({children:!0}),this.chartView?.removeChildren(),this.clearSelections(),this.loadedChart=e,this.beat=this.loadedChart.getBeatFromSeconds(this.time),ht.instance.reset(),_.play.timingCollection=_.play.defaultTimingCollection[e.gameType.id]??"ITG",this.getAssistTickIndex(),this.chartView=new iC(this),this.chartView.x=this.app.renderer.screen.width/2,this.chartView.y=this.app.renderer.screen.height/2,(this.mode=="Play Mode"||this.mode=="Record Mode")&&this.setMode(this.lastMode),Ie.viewMode&&this.setMode("View Mode"),this.loadedChart.getMusicPath()!=this.lastSong){this.lastSong=this.loadedChart.getMusicPath();const t=this.chartAudio.isPlaying();await this.loadAudio(),$.emit("audioLoaded"),t&&this.chartAudio.play()}this.noChartTextA.visible=!1,this.noChartTextB.visible=!1,Ce.create("Loaded chart "+e.difficulty+" "+e.meter+" "+e.gameType.id),$.emit("chartLoaded"),$.emit("audioLoaded"),$.emit("chartModified"),this.loadedChart.gameType.id=="dance-single"?window.Parity=new XT(this.app,this.loadedChart.gameType.id):window.Parity=void 0,Ie.autoPlay&&this.playPause()}}}async loadAudio(){if(!this.loadedSM||!this.loadedChart)return;this.chartAudio.stop(),this.chartAudio?.destroy();const e=this.loadedChart.getMusicPath();if(e==""){Ce.createFormatted("Failed to load audio: no audio file","error"),this.chartAudio=new no(void 0);return}const t=await this.getAudioHandle(e);if(t==null){Ce.createFormatted("Failed to load audio: couldn't find audio file "+e,"error"),this.chartAudio=new no(void 0);return}const i=await t.getFile();this.chartAudio=new no(await i.arrayBuffer(),Ui(i.name)),this.chartAudio.seek(this.time),this.getAssistTickIndex()}async getAudioHandle(e){let t=await Re.getFileHandleRelativeTo(this.smPath,e);if(t)return t;try{const i=await Re.getDirectoryFiles(jt(this.smPath));if(t=i.filter(s=>s.name.toLowerCase()==Zi(e).toLowerCase())[0],t)return Ce.createFormatted("Failed to locate audio file "+e+", using file "+t.name+" instead","warn"),t;t=i.filter(s=>ol.includes(Ui(s.name)))[0],t&&Ce.createFormatted("Failed to locate audio file "+e+", using file "+t.name+" instead","warn")}catch{return}return t}getAudio(){return this.chartAudio}updateSoundProperties(){this.setEffectVolume(_.audio.soundEffectVolume*_.audio.masterVolume),this.setVolume(_.audio.songVolume*_.audio.masterVolume),this.setRate(_.audio.rate)}setRate(e){this.chartAudio.rate(e)}setVolume(e){this.chartAudio.volume(e)}setEffectVolume(e){this.assistTick.volume()!=e&&this.assistTick.volume(e),this.me_high.volume()!=e&&this.me_high.volume(e),this.me_low.volume()!=e&&this.me_low.volume(e),this.mine.volume()!=e&&this.mine.volume(e)}getAssistTickIndex(){if(this.loadedSM==null||this.loadedChart==null||this.chartView==null||this.loadedChart.getNotedata().length==0){this.noteIndex=0;return}this.noteIndex=hi(this.loadedChart.getNotedata(),this.time,e=>e.second)+1,this.noteIndex>=1&&this.time<=this.loadedChart.getNotedata()[this.noteIndex-1].second&&this.noteIndex--}playPause(){this.chartAudio.isPlaying()?this.chartAudio.pause():this.chartAudio.play()}getClosestTick(e,t){if(!this.loadedChart)return 0;const i=Math.max(.001,4/t),s=this.loadedChart.timingData.getBeatOfMeasure(e),n=e-s,a=Math.round(s/i)*i;return Math.max(0,n+a)}snapToNearestTick(e){this.setBeat(Math.max(0,this.getClosestTick(e,4/_.chart.snap)))}snapToPreviousTick(){if(!this.loadedChart)return;const e=Math.max(.001,_.chart.snap),t=Math.floor(this.loadedChart.timingData.getMeasure(this.beat)),i=this.loadedChart.timingData.getBeatFromMeasure(t),s=Math.floor((this.beat-i)/e)*e,n=Math.abs(s-(this.beat-i))<5e-4?s-e:s,a=n+i;if(n<0){const o=this.loadedChart.timingData.getBeatFromMeasure(t-1),l=Math.round((a-o)/e)*e;this.setBeat(Math.max(0,o+l));return}this.setBeat(Math.max(0,a))}snapToNextTick(){if(!this.loadedChart)return;const e=Math.max(.001,_.chart.snap),t=Math.floor(this.loadedChart.timingData.getMeasure(this.beat)),i=this.loadedChart.timingData.getBeatFromMeasure(t),a=Math.floor((this.beat-i+5e-4)/e)*e+e+i,o=this.loadedChart.timingData.getBeatFromMeasure(t+1);if(a>o){this.setBeat(o);return}this.setBeat(a)}previousSnap(){let e=this.getSnapIndex()-1;e=(e+Zt.length)%Zt.length,_.chart.snap=Zt[e]==-1?0:1/Zt[e],$.emit("snapChanged")}nextSnap(){let e=this.getSnapIndex();(e==Zt.length-1||Math.abs(1/_.chart.snap-Zt[e])<=5e-4)&&e++,e=(e+Zt.length)%Zt.length,_.chart.snap=Zt[e]==-1?0:1/Zt[e],$.emit("snapChanged")}getSnapIndex(){return _.chart.snap==0?Zt.length-1:Zt.findIndex(e=>1/e<=_.chart.snap)}removeDuplicateBeats(e){if(e.length===0)return e;const t=[e[0]];for(let i=1;ii.beat+i.hold),t=this.loadedChart.getNotedata().map(i=>i.beat).concat(e).sort((i,s)=>i-s);return this.removeDuplicateBeats(t)}previousNote(){const e=this.getRows();if(e.length==0)return;let t=hi(e,this.beat);this.beat==e[t]&&t--,this.setBeat(e[Math.max(0,t)])}nextNote(){const e=this.getRows();if(e.length==0)return;let t=hi(e,this.beat);this.beat>=e[t]&&t++,this.setBeat(e[Math.min(e.length-1,t)])}firstNote(){if(this.loadedSM==null||this.loadedChart==null||this.chartView==null)return;const e=this.loadedChart.getNotedata();e.length!=0&&this.setBeat(e[0].beat)}lastNote(){if(this.loadedSM==null||this.loadedChart==null||this.chartView==null)return;const e=this.loadedChart.getNotedata();if(e.length==0)return;const t=e[e.length-1];this.setBeat(t.beat+(Be(t)?t.hold:0))}truncateHold(e,t){const i=Ve(Math.round((t-Math.max(.020833333333333332,_.chart.snap))*48)/48,e.beat,e.beat+e.hold-.020833333333333332);return i==e.beat?{beat:e.beat,col:e.col,type:"Tap"}:{beat:e.beat,col:e.col,type:e.type,hold:i-e.beat}}setNote(e,t,i=this.beat){if(this.loadedSM==null||this.loadedChart==null||this.chartView==null)return;i=Math.max(0,Math.round(i*48)/48);const s=this.loadedChart.getNotedata().filter(o=>o.col!=e?!1:Math.abs(o.beat-i)<.003?!0:Be(o)&&o.beat==i),n=this.loadedChart.getNotedata().filter(o=>Be(o)&&o.col==e&&i>o.beat&&i<=o.beat+o.hold).map(o=>({oldNote:o,newNote:this.truncateHold(o,i)})),a={startBeat:i,endBeat:i,roll:!1,originalNote:void 0,type:t,removedNotes:s,truncatedHolds:n};this.holdEditing[e]=a,s.length==0&&(a.originalNote={beat:i,col:e,type:this.getEditingNoteType()}),this.getAssistTickIndex(),this.app.actionHistory.run({action:()=>{a.removedNotes.forEach(o=>this.loadedChart.removeNote(o)),a.truncatedHolds.forEach(o=>this.loadedChart.modifyNote(o.oldNote,o.newNote)),a.originalNote&&this.loadedChart.addNote(a.originalNote)},undo:()=>{a.originalNote&&this.loadedChart.removeNote(a.originalNote),a.truncatedHolds.forEach(o=>this.loadedChart.modifyNote(o.newNote,o.oldNote)),a.removedNotes.forEach(o=>this.loadedChart.addNote(o))}})}editHoldBeat(e,t,i){if(this.loadedSM==null||this.loadedChart==null||this.chartView==null)return;const s=this.holdEditing[e];if(s==null||t==s.startBeat&&t==s.endBeat)return;if(s.endBeat=Math.max(s.startBeat,Math.round(t*48)/48),s.roll||=i,!s.originalNote)this.loadedChart.addNote({beat:s.startBeat,col:e,type:s.roll?"Roll":"Hold",hold:s.endBeat-s.startBeat});else{const a={beat:s.startBeat,type:s.roll?"Roll":"Hold",hold:s.endBeat-s.startBeat};s.endBeat-s.startBeat==0&&(a.hold=void 0,a.type="Tap"),(a.beat!=s.originalNote.beat||a.type!=s.originalNote.type||Be(s.originalNote)&&a.hold!=s.originalNote.hold)&&this.loadedChart.modifyNote(s.originalNote,a)}s.originalNote={beat:s.startBeat,col:e,type:s.endBeat-s.startBeat==0?"Tap":s.roll?"Roll":"Hold",hold:s.endBeat-s.startBeat==0?void 0:s.endBeat-s.startBeat};const n=this.loadedChart.getNotedata().filter(a=>a.beat==s.originalNote.beat&&a.col==s.originalNote.col||a.col!=e?!1:a.beat>=s.startBeat&&a.beat<=s.endBeat?!0:Be(a)&&a.beat+a.hold>=s.startBeat&&a.beat+a.hold<=s.endBeat);s.removedNotes=s.removedNotes.concat(n),n.forEach(a=>this.loadedChart.removeNote(a)),this.getAssistTickIndex()}endEditing(e){this.holdEditing[e]=void 0}previousNoteType(){const e=this.loadedChart?.gameType.editNoteTypes.length??0;this.editNoteTypeIndex=(this.editNoteTypeIndex-1+e)%e}nextNoteType(){const e=this.loadedChart?.gameType.editNoteTypes.length??0;this.editNoteTypeIndex=(this.editNoteTypeIndex+1+e)%e}getEditingNoteType(){return this.loadedChart?.gameType.editNoteTypes[this.editNoteTypeIndex]??null}setEditingNoteType(e){if(!this.loadedChart)return;const i=(this.loadedChart?.gameType.editNoteTypes).indexOf(e);i!=-1&&(this.editNoteTypeIndex=i)}getMode(){return this.mode}setMode(e){if(!this.loadedChart||!this.chartView)return;if(this.mode==e){(e=="Play Mode"||e=="Record Mode")&&(this.setMode(this.lastMode),this.getAssistTickIndex(),this.chartAudio.pause());return}(this.mode=="View Mode"||this.mode=="Edit Mode")&&(this.lastMode=this.mode),this.mode=e;const t=this.loadedChart.getNotedata();if(this.mode=="Play Mode"){t.forEach(i=>{i.gameplay={hideNote:!1,hasHit:!1}});for(const i of t)if(i.secondi.gameplay=void 0))}judgeCol(e){if(!(!this.loadedChart||!this.chartView)){if(this.mode=="Play Mode")this.loadedChart.gameType.gameLogic.keyDown(this,e);else if(this.mode=="Record Mode"){const t=this.loadedChart.getBeatFromSeconds(this.time+_.play.offset),i=_.chart.snap==0?1/48:_.chart.snap,s=Math.round(t/i)*i;this.setNote(e,"key",s)}}}judgeColUp(e){!this.loadedChart||!this.chartView||(this.mode=="Play Mode"?this.loadedChart.gameType.gameLogic.keyUp(this,e):this.mode=="Record Mode"&&this.endEditing(e))}async save(){if(!this.loadedSM)return;let e,t;if(window.nw){const s=window.nw.require("path"),n=s.parse(this.smPath);e=s.resolve(n.dir,n.name+".sm"),t=s.resolve(n.dir,n.name+".ssc")}else{const s=jt(this.smPath),n=Zi(this.smPath),a=n.includes(".")?n.split(".").slice(0,-1).join("."):n;e=s+"/"+a+".sm",t=s+"/"+a+".ssc"}let i=null;!this.loadedSM.usesChartTiming()&&await Re.getFileHandle(e)&&await Re.writeFile(e,this.loadedSM.serialize("sm")).catch(s=>{const n=s.message;n.includes(Go.GONE[0])||(i=n)}),(this.loadedSM.requiresSSC()||await Re.getFileHandle(t))&&await Re.writeFile(t,this.loadedSM.serialize("ssc")).catch(s=>{const n=s.message;n.includes(Go.GONE[0])||(i=n)}),i==null?this.loadedSM.usesChartTiming()?Ce.create("Saved. No SM file since split timing was used."):Ce.create("Saved"):Ce.createFormatted("Failed to save file: "+i,"error"),ht.instance.setLimit()}hasSelection(){return this.hasNoteSelection()||this.hasEventSelection()}hasNoteSelection(){return this.selection.notes.length>0||this.startRegion!==void 0&&this.endRegion!==void 0}hasEventSelection(){return this.eventSelection.timingEvents.length>0}hasRange(){return this.selection.notes.length>1||this.eventSelection.timingEvents.length>1||this.startRegion!==void 0&&this.endRegion!==void 0}clearSelections(){this.selection={notes:[],inProgressNotes:[]},this.eventSelection={timingEvents:[],inProgressTimingEvents:[]}}startDragSelection(){this.selection.inProgressNotes=[]}endDragSelection(){let e=0,t=0;const i=[],s=this.selection.inProgressNotes,n=this.selection.notes,a=(o,l)=>o.beat==l.beat?o.col-l.col:o.beat-l.beat;if(s.length==0||n.length==0){this.selection.notes=s.concat(n),this.selection.inProgressNotes=[];return}for(;;)if(a(s[e],n[t])<0){if(i.push(s[e]),e++,e>=s.length){this.selection.notes=i.concat(n.slice(t));break}}else if(i.push(n[t]),t++,t>=n.length){this.selection.notes=i.concat(s.slice(e));break}this.selection.inProgressNotes=[]}startDragEventSelection(){this.eventSelection.inProgressTimingEvents=[]}endDragEventSelection(){let e=0,t=0;const i=[],s=this.eventSelection.inProgressTimingEvents,n=this.eventSelection.timingEvents,a=(o,l)=>o.beat-l.beat;if(s.length==0||n.length==0){this.eventSelection.timingEvents=s.concat(n),this.eventSelection.inProgressTimingEvents=[];return}for(;;)if(a(s[e],n[t])<0){if(i.push(s[e]),e++,e>=s.length){this.eventSelection.timingEvents=i.concat(n.slice(t));break}}else if(i.push(n[t]),t++,t>=n.length){this.eventSelection.timingEvents=i.concat(s.slice(e));break}this.eventSelection.inProgressTimingEvents=[]}addNoteToDragSelection(e){this.addNoteSelection(this.selection.inProgressNotes,e)}removeNoteFromDragSelection(e){this.removeNoteSelection(this.selection.inProgressNotes,e)}addEventToDragSelection(e){this.addEventSelection(this.eventSelection.inProgressTimingEvents,e)}removeEventFromDragSelection(e){this.removeEventSelection(this.eventSelection.inProgressTimingEvents,e)}addNoteToSelection(e){this.addNoteSelection(this.selection.notes,e)}removeNoteFromSelection(e){this.removeNoteSelection(this.selection.notes,e)}setNoteSelection(e){this.selection.inProgressNotes=[],this.selection.notes=[...e].sort((t,i)=>t.beat==i.beat?t.col-i.col:t.beat-i.beat)}addEventToSelection(e){this.addEventSelection(this.eventSelection.timingEvents,e)}removeEventFromSelection(e){this.removeEventSelection(this.eventSelection.timingEvents,e)}setEventSelection(e){this.eventSelection.inProgressTimingEvents=[],this.eventSelection.timingEvents=e.sort((t,i)=>t.beat-i.beat)}isNoteInSelection(e){return this.getNoteSelectionIndex(this.selection.notes,e)!=-1||this.getNoteSelectionIndex(this.selection.inProgressNotes,e)!=-1}isEventInSelection(e){return this.getEventSelectionIndex(this.eventSelection.timingEvents,e)!=-1||this.getEventSelectionIndex(this.eventSelection.inProgressTimingEvents,e)!=-1}addNoteSelection(e,t){let i=Ka(e,t.beat,s=>s.beat);for(;e[i]&&(e[i].beats.beat);for(;e[i]&&e[i].beat==t.beat;){if(Tp(e[i],t))return i;i++}return-1}addEventSelection(e,t){let i=Ka(e,t.beat,s=>s.beat);for(;e[i]&&e[i].beat<=t.beat;)i++;e.splice(i,0,t)}removeEventSelection(e,t){const i=this.getEventSelectionIndex(e,t);i!=-1&&e.splice(i,1)}getEventSelectionIndex(e,t){let i=Ka(e,t.beat,s=>s.beat);for(;e[i]&&e[i].beat==t.beat;){if(Tp(e[i],t))return i;i++}return-1}selectRegion(){if(this.loadedChart){if(this.endRegion!==void 0&&(this.startRegion=void 0,this.endRegion=void 0),this.startRegion===void 0){this.clearSelections(),this.startRegion=this.beat;return}this.endRegion=this.beat,this.endRegione.beat>=this.startRegion&&e.beat<=this.endRegion).filter(e=>!this.selection.notes.includes(e))):this.setEventSelection(ar.flatMap(e=>this.loadedChart.timingData.getColumn(e).events))}}modifySelection(e){if(!this.loadedChart)return;const t=this.selection.notes,i=structuredClone(this.selection.notes).map(e).sort((o,l)=>o.beat==l.beat?o.col-l.col:o.beat-l.beat);if(i.length==0)return;const s=[];for(const o of i){const l=s.at(-1);l!==void 0&&l.beat==o.beat&&l.col==o.col||s.push(o)}if(s.length==0)return;const{removedNotes:n,truncatedHolds:a}=this.checkConflicts(s,t);this.app.actionHistory.run({action:()=>{this.loadedChart.removeNotes(t.concat(n),!1),a.forEach(o=>this.loadedChart.modifyNote(o.oldNote,o.newNote,!1)),this.clearSelections(),this.setNoteSelection(this.loadedChart.addNotes(s))},undo:()=>{this.loadedChart.removeNotes(s,!1),a.forEach(o=>this.loadedChart.modifyNote(o.newNote,o.oldNote,!1)),this.loadedChart.addNotes(n,!1),this.clearSelections(),this.setNoteSelection(this.loadedChart.addNotes(t))}})}checkConflicts(e,t=[]){if(e.length==0)return{removedNotes:[],truncatedHolds:[]};const i=this.loadedChart.getNotedata();let s=i.findIndex(c=>e[0].beat<=(Be(c)?c.beat+c.hold:c.beat));const n=[],a=[],o=[];let l=null;for(const c of e){if(l==null)l=c;else if(c.beat==l.beat&&c.col==l.col)continue;for(;i[s];){const u=i[s],h=Be(c)?c.beat+c.hold:c.beat;u.col==c.col&&!t.includes(u)&&!o.includes(u)&&(c.beat<=u.beat&&h>=u.beat?(o.push(u),n.push(u)):Be(u)&&u.beat+u.hold>=c.beat&&u.beath){s--;break}}}return{removedNotes:n,truncatedHolds:a}}modifyEventSelection(e){!this.loadedChart||!this.loadedSM||this.loadedChart.timingData.modify(this.eventSelection.timingEvents.map(t=>[t,e(structuredClone(t))]))}deleteSelection(){if(this.selection.notes.length==0)return;const e=this.selection.notes;this.app.actionHistory.run({action:()=>{this.loadedChart.removeNotes(e),this.clearSelections()},undo:()=>{this.selection.notes=this.loadedChart.addNotes(e)}})}deleteEventSelection(){this.eventSelection.timingEvents.length!=0&&(!this.loadedChart||!this.loadedSM||this.loadedChart.timingData.delete(this.eventSelection.timingEvents))}paste(e){if(this.loadedChart&&(e.startsWith("ArrowVortex:notes:")&&(this.pasteNotes(e)||this.pasteNotes(this.virtualClipboard)),e.startsWith("ArrowVortex:tempo:")||e.startsWith("SMEditor:tempo:"))){this.pasteTempo(e)||this.pasteTempo(this.virtualClipboard);return}}pasteNotes(e){if(!this.loadedChart)return!0;const t=OT(e);return!t||t.length==0?!1:(this.insertNotes(t.map(i=>(i.beat+=this.beat,i.beat=Math.round(i.beat*48)/48,i))),!0)}insertNotes(e){e.sort((s,n)=>s.beat==n.beat?s.col-n.col:s.beat-n.beat);const{removedNotes:t,truncatedHolds:i}=this.checkConflicts(e);this.app.actionHistory.run({action:()=>{this.loadedChart.removeNotes(t,!1),i.forEach(s=>{this.loadedChart.modifyNote(s.oldNote,s.newNote,!1)}),this.clearSelections(),this.setNoteSelection(this.loadedChart.addNotes(e))},undo:()=>{this.loadedChart.removeNotes(e,!1),i.forEach(s=>{this.loadedChart.modifyNote(s.newNote,s.oldNote,!1)}),this.setNoteSelection(this.loadedChart.addNotes(t)),this.clearSelections()}})}pasteTempo(e){if(!this.loadedChart||!this.loadedSM)return!0;const t=VT(e);if(!t||t.length==0)return!1;const i=this.loadedChart.timingData;return t.forEach(s=>{s.type=="ATTACKS"?s.second+=this.time:s.beat+=this.beat}),t.forEach(s=>s.isChartTiming=i.isPropertyChartSpecific(s.type)),i.insert(t),!0}copy(){if(this.selection.notes.length!=0){const e=Math.min(...this.selection.notes.map(s=>s.beat)),t=structuredClone(this.selection.notes).map(s=>(s.beat-=e,s)).sort((s,n)=>s.beat==n.beat?s.col-n.col:s.beat-n.beat),i=FT(t);return this.virtualClipboard=i,i}else if(this.eventSelection.timingEvents.length!=0){const e=Math.min(...this.eventSelection.timingEvents.map(n=>n.beat)),t=this.loadedChart.timingData.getSecondsFromBeat(e),i=structuredClone(this.eventSelection.timingEvents).map(n=>n.type=="ATTACKS"?(n.second-=t,n):(n.beat-=e,n)).sort((n,a)=>n.type!=a.type?n.type.localeCompare(a.type):n.type=="ATTACKS"?n.second-a.second:n.beat-a.beat),s=GT(i);return this.virtualClipboard=s,s}}}export{ht as A,Nt as B,KT as C,la as D,$ as E,Ie as F,Ke as G,He as I,dt as K,Vn as M,_ as O,Vc as R,Cg as S,Ft as T,As as U,Ce as W,ui as _,$e as a,xe as b,dC as c,Re as d,RT as e,wr as f,da as g,sl as h,aC as i,Ui as j,ml as k,oC as l,ET as m,cC as n,pi as o,EE as p,si as q,L0 as r,Go as s,Mt as t,f_ as u,Nr as v,vn as w}; diff --git a/NodeFileHandler-b249bb9f.js b/NodeFileHandler-32fac6e8.js similarity index 99% rename from NodeFileHandler-b249bb9f.js rename to NodeFileHandler-32fac6e8.js index b35b6d65..2788e89d 100644 --- a/NodeFileHandler-b249bb9f.js +++ b/NodeFileHandler-32fac6e8.js @@ -1,4 +1,4 @@ -import{q as vr,r as jr,g as Bo,s as ri,u as To,v as Hn,w as Yn,W as Ao}from"./ChartManager-b5a8bd39.js";var or={exports:{}},Qn;function Po(){return Qn||(Qn=1,function(B,u){(function(p,d){d(u)})(vr,function(p){const d=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol:e=>`Symbol(${e})`;function _(){}function R(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof vr<"u")return vr}const E=R();function c(e){return typeof e=="object"&&e!==null||typeof e=="function"}const Y=_,Q=Promise,U=Promise.prototype.then,j=Promise.resolve.bind(Q),G=Promise.reject.bind(Q);function S(e){return new Q(e)}function g(e){return j(e)}function w(e){return G(e)}function k(e,t,i){return U.call(e,t,i)}function O(e,t,i){k(k(e,t,i),void 0,Y)}function L(e,t){O(e,t)}function V(e,t){O(e,void 0,t)}function ee(e,t,i){return k(e,t,i)}function z(e){k(e,void 0,Y)}const Fe=(()=>{const e=E&&E.queueMicrotask;if(typeof e=="function")return e;const t=g(void 0);return i=>k(t,i)})();function xe(e,t,i){if(typeof e!="function")throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,i)}function me(e,t,i){try{return g(xe(e,t,i))}catch(s){return w(s)}}const St=16384;class ae{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(t){const i=this._back;let s=i;i._elements.length===St-1&&(s={_elements:[],_next:void 0}),i._elements.push(t),s!==i&&(this._back=s,i._next=s),++this._size}shift(){const t=this._front;let i=t;const s=this._cursor;let f=s+1;const m=t._elements,y=m[s];return f===St&&(i=t._next,f=0),--this._size,this._cursor=f,t!==i&&(this._front=i),m[s]=void 0,y}forEach(t){let i=this._cursor,s=this._front,f=s._elements;for(;(i!==f.length||s._next!==void 0)&&!(i===f.length&&(s=s._next,f=s._elements,i=0,f.length===0));)t(f[i]),++i}peek(){const t=this._front,i=this._cursor;return t._elements[i]}}function Rt(e,t){e._ownerReadableStream=t,t._reader=e,t._state==="readable"?Ue(e):t._state==="closed"?lr(e):Et(e,t._storedError)}function rt(e,t){const i=e._ownerReadableStream;return de(i,t)}function fe(e){e._ownerReadableStream._state==="readable"?nt(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):fr(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),e._ownerReadableStream._reader=void 0,e._ownerReadableStream=void 0}function ye(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function Ue(e){e._closedPromise=S((t,i)=>{e._closedPromise_resolve=t,e._closedPromise_reject=i})}function Et(e,t){Ue(e),nt(e,t)}function lr(e){Ue(e),Ct(e)}function nt(e,t){e._closedPromise_reject!==void 0&&(z(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function fr(e,t){Et(e,t)}function Ct(e){e._closedPromise_resolve!==void 0&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const N=d("[[AbortSteps]]"),X=d("[[ErrorSteps]]"),je=d("[[CancelSteps]]"),Le=d("[[PullSteps]]"),it=Number.isFinite||function(e){return typeof e=="number"&&isFinite(e)},Bt=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function Tt(e){return typeof e=="object"||typeof e=="function"}function K(e,t){if(e!==void 0&&!Tt(e))throw new TypeError(`${t} is not an object.`)}function te(e,t){if(typeof e!="function")throw new TypeError(`${t} is not a function.`)}function At(e){return typeof e=="object"&&e!==null||typeof e=="function"}function Pt(e,t){if(!At(e))throw new TypeError(`${t} is not an object.`)}function ue(e,t,i){if(e===void 0)throw new TypeError(`Parameter ${t} is required in '${i}'.`)}function pe(e,t,i){if(e===void 0)throw new TypeError(`${t} is required in '${i}'.`)}function _e(e){return Number(e)}function It(e){return e===0?0:e}function cr(e){return It(Bt(e))}function $e(e,t){const s=Number.MAX_SAFE_INTEGER;let f=Number(e);if(f=It(f),!it(f))throw new TypeError(`${t} is not a finite number`);if(f=cr(f),f<0||f>s)throw new TypeError(`${t} is outside the accepted range of 0 to ${s}, inclusive`);return!it(f)||f===0?0:f}function ot(e,t){if(!Te(e))throw new TypeError(`${t} is not a ReadableStream.`)}function Se(e){return new We(e)}function at(e,t){e._reader._readRequests.push(t)}function Re(e,t,i){const f=e._reader._readRequests.shift();i?f._closeSteps():f._chunkSteps(t)}function re(e){return e._reader._readRequests.length}function Ne(e){const t=e._reader;return!(t===void 0||!J(t))}class We{constructor(t){if(ue(t,1,"ReadableStreamDefaultReader"),ot(t,"First parameter"),Ae(t))throw new TypeError("This stream has already been locked for exclusive reading by another reader");Rt(this,t),this._readRequests=new ae}get closed(){return J(this)?this._closedPromise:w(o("closed"))}cancel(t=void 0){return J(this)?this._ownerReadableStream===void 0?w(ye("cancel")):rt(this,t):w(o("cancel"))}read(){if(!J(this))return w(o("read"));if(this._ownerReadableStream===void 0)return w(ye("read from"));let t,i;const s=S((m,y)=>{t=m,i=y});return qe(this,{_chunkSteps:m=>t({value:m,done:!1}),_closeSteps:()=>t({value:void 0,done:!0}),_errorSteps:m=>i(m)}),s}releaseLock(){if(!J(this))throw o("releaseLock");if(this._ownerReadableStream!==void 0){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");fe(this)}}}Object.defineProperties(We.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(We.prototype,d.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});function J(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_readRequests")?!1:e instanceof We}function qe(e,t){const i=e._ownerReadableStream;i._disturbed=!0,i._state==="closed"?t._closeSteps():i._state==="errored"?t._errorSteps(i._storedError):i._readableStreamController[Le](t)}function o(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}const r=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype);class n{constructor(t,i){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=t,this._preventCancel=i}next(){const t=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?ee(this._ongoingPromise,t,t):t(),this._ongoingPromise}return(t){const i=()=>this._returnSteps(t);return this._ongoingPromise?ee(this._ongoingPromise,i,i):i()}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const t=this._reader;if(t._ownerReadableStream===void 0)return w(ye("iterate"));let i,s;const f=S((y,C)=>{i=y,s=C});return qe(t,{_chunkSteps:y=>{this._ongoingPromise=void 0,Fe(()=>i({value:y,done:!1}))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,fe(t),i({value:void 0,done:!0})},_errorSteps:y=>{this._ongoingPromise=void 0,this._isFinished=!0,fe(t),s(y)}}),f}_returnSteps(t){if(this._isFinished)return Promise.resolve({value:t,done:!0});this._isFinished=!0;const i=this._reader;if(i._ownerReadableStream===void 0)return w(ye("finish iterating"));if(!this._preventCancel){const s=rt(i,t);return fe(i),ee(s,()=>({value:t,done:!0}))}return fe(i),g({value:t,done:!0})}}const a={next(){return h(this)?this._asyncIteratorImpl.next():w(b("next"))},return(e){return h(this)?this._asyncIteratorImpl.return(e):w(b("return"))}};r!==void 0&&Object.setPrototypeOf(a,r);function l(e,t){const i=Se(e),s=new n(i,t),f=Object.create(a);return f._asyncIteratorImpl=s,f}function h(e){if(!c(e)||!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof n}catch{return!1}}function b(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}const A=Number.isNaN||function(e){return e!==e};function v(e){return e.slice()}function D(e,t,i,s,f){new Uint8Array(e).set(new Uint8Array(i,s,f),t)}function $(e){return e}function x(e){return!1}function Qr(e,t,i){if(e.slice)return e.slice(t,i);const s=i-t,f=new ArrayBuffer(s);return D(f,0,e,t,s),f}function ai(e){return!(typeof e!="number"||A(e)||e<0)}function Gr(e){const t=Qr(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function dr(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function hr(e,t,i){if(!ai(i)||i===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:t,size:i}),e._queueTotalSize+=i}function si(e){return e._queue.peek().value}function Ee(e){e._queue=new ae,e._queueTotalSize=0}class st{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!pr(this))throw _r("view");return this._view}respond(t){if(!pr(this))throw _r("respond");if(ue(t,1,"respond"),t=$e(t,"First parameter"),this._associatedReadableByteStreamController===void 0)throw new TypeError("This BYOB request has been invalidated");x(this._view.buffer),Ot(this._associatedReadableByteStreamController,t)}respondWithNewView(t){if(!pr(this))throw _r("respondWithNewView");if(ue(t,1,"respondWithNewView"),!ArrayBuffer.isView(t))throw new TypeError("You can only respond with array buffer views");if(this._associatedReadableByteStreamController===void 0)throw new TypeError("This BYOB request has been invalidated");x(t.buffer),vt(this._associatedReadableByteStreamController,t)}}Object.defineProperties(st.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(st.prototype,d.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class He{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!Oe(this))throw lt("byobRequest");return yr(this)}get desiredSize(){if(!Oe(this))throw lt("desiredSize");return rn(this)}close(){if(!Oe(this))throw lt("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const t=this._controlledReadableByteStream._state;if(t!=="readable")throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be closed`);ut(this)}enqueue(t){if(!Oe(this))throw lt("enqueue");if(ue(t,1,"enqueue"),!ArrayBuffer.isView(t))throw new TypeError("chunk must be an array buffer view");if(t.byteLength===0)throw new TypeError("chunk must have non-zero byteLength");if(t.buffer.byteLength===0)throw new TypeError("chunk's buffer must have non-zero byteLength");if(this._closeRequested)throw new TypeError("stream is closed or draining");const i=this._controlledReadableByteStream._state;if(i!=="readable")throw new TypeError(`The stream (in ${i} state) is not in the readable state and cannot be enqueued to`);qt(this,t)}error(t=void 0){if(!Oe(this))throw lt("error");ce(this,t)}[je](t){Vr(this),Ee(this);const i=this._cancelAlgorithm(t);return Wt(this),i}[Le](t){const i=this._controlledReadableByteStream;if(this._queueTotalSize>0){const f=this._queue.shift();this._queueTotalSize-=f.byteLength,Kr(this);const m=new Uint8Array(f.buffer,f.byteOffset,f.byteLength);t._chunkSteps(m);return}const s=this._autoAllocateChunkSize;if(s!==void 0){let f;try{f=new ArrayBuffer(s)}catch(y){t._errorSteps(y);return}const m={buffer:f,bufferByteLength:s,byteOffset:0,byteLength:s,bytesFilled:0,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(m)}at(i,t),ve(this)}}Object.defineProperties(He.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(He.prototype,d.toStringTag,{value:"ReadableByteStreamController",configurable:!0});function Oe(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")?!1:e instanceof He}function pr(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")?!1:e instanceof st}function ve(e){if(!ci(e))return;if(e._pulling){e._pullAgain=!0;return}e._pulling=!0;const i=e._pullAlgorithm();O(i,()=>{e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,ve(e))},s=>{ce(e,s)})}function Vr(e){mr(e),e._pendingPullIntos=new ae}function br(e,t){let i=!1;e._state==="closed"&&(i=!0);const s=Xr(t);t.readerType==="default"?Re(e,s,i):pi(e,s,i)}function Xr(e){const t=e.bytesFilled,i=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/i)}function Ft(e,t,i,s){e._queue.push({buffer:t,byteOffset:i,byteLength:s}),e._queueTotalSize+=s}function Jr(e,t){const i=t.elementSize,s=t.bytesFilled-t.bytesFilled%i,f=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),m=t.bytesFilled+f,y=m-m%i;let C=f,P=!1;y>s&&(C=y-t.bytesFilled,P=!0);const F=e._queue;for(;C>0;){const W=F.peek(),q=Math.min(C,W.byteLength),H=t.byteOffset+t.bytesFilled;D(t.buffer,H,W.buffer,W.byteOffset,q),W.byteLength===q?F.shift():(W.byteOffset+=q,W.byteLength-=q),e._queueTotalSize-=q,Zr(e,q,t),C-=q}return P}function Zr(e,t,i){i.bytesFilled+=t}function Kr(e){e._queueTotalSize===0&&e._closeRequested?(Wt(e),yt(e._controlledReadableByteStream)):ve(e)}function mr(e){e._byobRequest!==null&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function en(e){for(;e._pendingPullIntos.length>0;){if(e._queueTotalSize===0)return;const t=e._pendingPullIntos.peek();Jr(e,t)&&(xt(e),br(e._controlledReadableByteStream,t))}}function ui(e,t,i){const s=e._controlledReadableByteStream;let f=1;t.constructor!==DataView&&(f=t.constructor.BYTES_PER_ELEMENT);const m=t.constructor,y=t.buffer,C={buffer:y,bufferByteLength:y.byteLength,byteOffset:t.byteOffset,byteLength:t.byteLength,bytesFilled:0,elementSize:f,viewConstructor:m,readerType:"byob"};if(e._pendingPullIntos.length>0){e._pendingPullIntos.push(C),an(s,i);return}if(s._state==="closed"){const P=new m(C.buffer,C.byteOffset,0);i._closeSteps(P);return}if(e._queueTotalSize>0){if(Jr(e,C)){const P=Xr(C);Kr(e),i._chunkSteps(P);return}if(e._closeRequested){const P=new TypeError("Insufficient bytes to fill elements in the given buffer");ce(e,P),i._errorSteps(P);return}}e._pendingPullIntos.push(C),an(s,i),ve(e)}function li(e,t){const i=e._controlledReadableByteStream;if(wr(i))for(;sn(i)>0;){const s=xt(e);br(i,s)}}function fi(e,t,i){if(Zr(e,t,i),i.bytesFilled0){const f=i.byteOffset+i.bytesFilled,m=Qr(i.buffer,f-s,f);Ft(e,m,0,m.byteLength)}i.bytesFilled-=s,br(e._controlledReadableByteStream,i),en(e)}function tn(e,t){const i=e._pendingPullIntos.peek();mr(e),e._controlledReadableByteStream._state==="closed"?li(e):fi(e,t,i),ve(e)}function xt(e){return e._pendingPullIntos.shift()}function ci(e){const t=e._controlledReadableByteStream;return t._state!=="readable"||e._closeRequested||!e._started?!1:!!(Ne(t)&&re(t)>0||wr(t)&&sn(t)>0||rn(e)>0)}function Wt(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function ut(e){const t=e._controlledReadableByteStream;if(!(e._closeRequested||t._state!=="readable")){if(e._queueTotalSize>0){e._closeRequested=!0;return}if(e._pendingPullIntos.length>0&&e._pendingPullIntos.peek().bytesFilled>0){const s=new TypeError("Insufficient bytes to fill elements in the given buffer");throw ce(e,s),s}Wt(e),yt(t)}}function qt(e,t){const i=e._controlledReadableByteStream;if(e._closeRequested||i._state!=="readable")return;const s=t.buffer,f=t.byteOffset,m=t.byteLength,y=s;if(e._pendingPullIntos.length>0){const C=e._pendingPullIntos.peek();x(C.buffer),C.buffer=C.buffer}if(mr(e),Ne(i))if(re(i)===0)Ft(e,y,f,m);else{e._pendingPullIntos.length>0&&xt(e);const C=new Uint8Array(y,f,m);Re(i,C,!1)}else wr(i)?(Ft(e,y,f,m),en(e)):Ft(e,y,f,m);ve(e)}function ce(e,t){const i=e._controlledReadableByteStream;i._state==="readable"&&(Vr(e),Ee(e),Wt(e),xn(i,t))}function yr(e){if(e._byobRequest===null&&e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek(),i=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),s=Object.create(st.prototype);hi(s,e,i),e._byobRequest=s}return e._byobRequest}function rn(e){const t=e._controlledReadableByteStream._state;return t==="errored"?null:t==="closed"?0:e._strategyHWM-e._queueTotalSize}function Ot(e,t){const i=e._pendingPullIntos.peek();if(e._controlledReadableByteStream._state==="closed"){if(t!==0)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(t===0)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(i.bytesFilled+t>i.byteLength)throw new RangeError("bytesWritten out of range")}i.buffer=i.buffer,tn(e,t)}function vt(e,t){const i=e._pendingPullIntos.peek();if(e._controlledReadableByteStream._state==="closed"){if(t.byteLength!==0)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(t.byteLength===0)throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");if(i.byteOffset+i.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(i.bufferByteLength!==t.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(i.bytesFilled+t.byteLength>i.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");const f=t.byteLength;i.buffer=t.buffer,tn(e,f)}function nn(e,t,i,s,f,m,y){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,Ee(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=m,t._pullAlgorithm=s,t._cancelAlgorithm=f,t._autoAllocateChunkSize=y,t._pendingPullIntos=new ae,e._readableStreamController=t;const C=i();O(g(C),()=>{t._started=!0,ve(t)},P=>{ce(t,P)})}function di(e,t,i){const s=Object.create(He.prototype);let f=()=>{},m=()=>g(void 0),y=()=>g(void 0);t.start!==void 0&&(f=()=>t.start(s)),t.pull!==void 0&&(m=()=>t.pull(s)),t.cancel!==void 0&&(y=P=>t.cancel(P));const C=t.autoAllocateChunkSize;if(C===0)throw new TypeError("autoAllocateChunkSize must be greater than 0");nn(e,s,f,m,y,i,C)}function hi(e,t,i){e._associatedReadableByteStreamController=t,e._view=i}function _r(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function lt(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function on(e){return new ft(e)}function an(e,t){e._reader._readIntoRequests.push(t)}function pi(e,t,i){const f=e._reader._readIntoRequests.shift();i?f._closeSteps(t):f._chunkSteps(t)}function sn(e){return e._reader._readIntoRequests.length}function wr(e){const t=e._reader;return!(t===void 0||!ke(t))}class ft{constructor(t){if(ue(t,1,"ReadableStreamBYOBReader"),ot(t,"First parameter"),Ae(t))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!Oe(t._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");Rt(this,t),this._readIntoRequests=new ae}get closed(){return ke(this)?this._closedPromise:w(kt("closed"))}cancel(t=void 0){return ke(this)?this._ownerReadableStream===void 0?w(ye("cancel")):rt(this,t):w(kt("cancel"))}read(t){if(!ke(this))return w(kt("read"));if(!ArrayBuffer.isView(t))return w(new TypeError("view must be an array buffer view"));if(t.byteLength===0)return w(new TypeError("view must have non-zero byteLength"));if(t.buffer.byteLength===0)return w(new TypeError("view's buffer must have non-zero byteLength"));if(x(t.buffer),this._ownerReadableStream===void 0)return w(ye("read from"));let i,s;const f=S((y,C)=>{i=y,s=C});return un(this,t,{_chunkSteps:y=>i({value:y,done:!1}),_closeSteps:y=>i({value:y,done:!0}),_errorSteps:y=>s(y)}),f}releaseLock(){if(!ke(this))throw kt("releaseLock");if(this._ownerReadableStream!==void 0){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");fe(this)}}}Object.defineProperties(ft.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(ft.prototype,d.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});function ke(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")?!1:e instanceof ft}function un(e,t,i){const s=e._ownerReadableStream;s._disturbed=!0,s._state==="errored"?i._errorSteps(s._storedError):ui(s._readableStreamController,t,i)}function kt(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function ct(e,t){const{highWaterMark:i}=e;if(i===void 0)return t;if(A(i)||i<0)throw new RangeError("Invalid highWaterMark");return i}function Dt(e){const{size:t}=e;return t||(()=>1)}function zt(e,t){K(e,t);const i=e?.highWaterMark,s=e?.size;return{highWaterMark:i===void 0?void 0:_e(i),size:s===void 0?void 0:bi(s,`${t} has member 'size' that`)}}function bi(e,t){return te(e,t),i=>_e(e(i))}function mi(e,t){K(e,t);const i=e?.abort,s=e?.close,f=e?.start,m=e?.type,y=e?.write;return{abort:i===void 0?void 0:yi(i,e,`${t} has member 'abort' that`),close:s===void 0?void 0:_i(s,e,`${t} has member 'close' that`),start:f===void 0?void 0:wi(f,e,`${t} has member 'start' that`),write:y===void 0?void 0:gi(y,e,`${t} has member 'write' that`),type:m}}function yi(e,t,i){return te(e,i),s=>me(e,t,[s])}function _i(e,t,i){return te(e,i),()=>me(e,t,[])}function wi(e,t,i){return te(e,i),s=>xe(e,t,[s])}function gi(e,t,i){return te(e,i),(s,f)=>me(e,t,[s,f])}function ln(e,t){if(!Ye(e))throw new TypeError(`${t} is not a WritableStream.`)}function Si(e){if(typeof e!="object"||e===null)return!1;try{return typeof e.aborted=="boolean"}catch{return!1}}const Ri=typeof AbortController=="function";function Ei(){if(Ri)return new AbortController}class dt{constructor(t={},i={}){t===void 0?t=null:Pt(t,"First parameter");const s=zt(i,"Second parameter"),f=mi(t,"First parameter");if(cn(this),f.type!==void 0)throw new RangeError("Invalid type is specified");const y=Dt(s),C=ct(s,1);Di(this,f,C,y)}get locked(){if(!Ye(this))throw $t("locked");return Qe(this)}abort(t=void 0){return Ye(this)?Qe(this)?w(new TypeError("Cannot abort a stream that already has a writer")):Mt(this,t):w($t("abort"))}close(){return Ye(this)?Qe(this)?w(new TypeError("Cannot close a stream that already has a writer")):be(this)?w(new TypeError("Cannot close an already-closing stream")):dn(this):w($t("close"))}getWriter(){if(!Ye(this))throw $t("getWriter");return fn(this)}}Object.defineProperties(dt.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(dt.prototype,d.toStringTag,{value:"WritableStream",configurable:!0});function fn(e){return new ht(e)}function Ci(e,t,i,s,f=1,m=()=>1){const y=Object.create(dt.prototype);cn(y);const C=Object.create(Ge.prototype);return _n(y,C,e,t,i,s,f,m),y}function cn(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new ae,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function Ye(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")?!1:e instanceof dt}function Qe(e){return e._writer!==void 0}function Mt(e,t){var i;if(e._state==="closed"||e._state==="errored")return g(void 0);e._writableStreamController._abortReason=t,(i=e._writableStreamController._abortController)===null||i===void 0||i.abort();const s=e._state;if(s==="closed"||s==="errored")return g(void 0);if(e._pendingAbortRequest!==void 0)return e._pendingAbortRequest._promise;let f=!1;s==="erroring"&&(f=!0,t=void 0);const m=S((y,C)=>{e._pendingAbortRequest={_promise:void 0,_resolve:y,_reject:C,_reason:t,_wasAlreadyErroring:f}});return e._pendingAbortRequest._promise=m,f||Sr(e,t),m}function dn(e){const t=e._state;if(t==="closed"||t==="errored")return w(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const i=S((f,m)=>{const y={_resolve:f,_reject:m};e._closeRequest=y}),s=e._writer;return s!==void 0&&e._backpressure&&t==="writable"&&Fr(s),zi(e._writableStreamController),i}function Bi(e){return S((i,s)=>{const f={_resolve:i,_reject:s};e._writeRequests.push(f)})}function gr(e,t){if(e._state==="writable"){Sr(e,t);return}Rr(e)}function Sr(e,t){const i=e._writableStreamController;e._state="erroring",e._storedError=t;const s=e._writer;s!==void 0&&pn(s,t),!Fi(e)&&i._started&&Rr(e)}function Rr(e){e._state="errored",e._writableStreamController[X]();const t=e._storedError;if(e._writeRequests.forEach(f=>{f._reject(t)}),e._writeRequests=new ae,e._pendingAbortRequest===void 0){Ut(e);return}const i=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,i._wasAlreadyErroring){i._reject(t),Ut(e);return}const s=e._writableStreamController[N](i._reason);O(s,()=>{i._resolve(),Ut(e)},f=>{i._reject(f),Ut(e)})}function Ti(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}function Ai(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,gr(e,t)}function Pi(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,e._state==="erroring"&&(e._storedError=void 0,e._pendingAbortRequest!==void 0&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const i=e._writer;i!==void 0&&Rn(i)}function Ii(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,e._pendingAbortRequest!==void 0&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),gr(e,t)}function be(e){return!(e._closeRequest===void 0&&e._inFlightCloseRequest===void 0)}function Fi(e){return!(e._inFlightWriteRequest===void 0&&e._inFlightCloseRequest===void 0)}function xi(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0}function Wi(e){e._inFlightWriteRequest=e._writeRequests.shift()}function Ut(e){e._closeRequest!==void 0&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;t!==void 0&&Pr(t,e._storedError)}function Er(e,t){const i=e._writer;i!==void 0&&t!==e._backpressure&&(t?Hi(i):Fr(i)),e._backpressure=t}class ht{constructor(t){if(ue(t,1,"WritableStreamDefaultWriter"),ln(t,"First parameter"),Qe(t))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=t,t._writer=this;const i=t._state;if(i==="writable")!be(t)&&t._backpressure?Ht(this):En(this),Nt(this);else if(i==="erroring")Ir(this,t._storedError),Nt(this);else if(i==="closed")En(this),$i(this);else{const s=t._storedError;Ir(this,s),Sn(this,s)}}get closed(){return De(this)?this._closedPromise:w(ze("closed"))}get desiredSize(){if(!De(this))throw ze("desiredSize");if(this._ownerWritableStream===void 0)throw pt("desiredSize");return ki(this)}get ready(){return De(this)?this._readyPromise:w(ze("ready"))}abort(t=void 0){return De(this)?this._ownerWritableStream===void 0?w(pt("abort")):qi(this,t):w(ze("abort"))}close(){if(!De(this))return w(ze("close"));const t=this._ownerWritableStream;return t===void 0?w(pt("close")):be(t)?w(new TypeError("Cannot close an already-closing stream")):hn(this)}releaseLock(){if(!De(this))throw ze("releaseLock");this._ownerWritableStream!==void 0&&bn(this)}write(t=void 0){return De(this)?this._ownerWritableStream===void 0?w(pt("write to")):mn(this,t):w(ze("write"))}}Object.defineProperties(ht.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(ht.prototype,d.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});function De(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")?!1:e instanceof ht}function qi(e,t){const i=e._ownerWritableStream;return Mt(i,t)}function hn(e){const t=e._ownerWritableStream;return dn(t)}function Oi(e){const t=e._ownerWritableStream,i=t._state;return be(t)||i==="closed"?g(void 0):i==="errored"?w(t._storedError):hn(e)}function vi(e,t){e._closedPromiseState==="pending"?Pr(e,t):Ni(e,t)}function pn(e,t){e._readyPromiseState==="pending"?Cn(e,t):Yi(e,t)}function ki(e){const t=e._ownerWritableStream,i=t._state;return i==="errored"||i==="erroring"?null:i==="closed"?0:wn(t._writableStreamController)}function bn(e){const t=e._ownerWritableStream,i=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");pn(e,i),vi(e,i),t._writer=void 0,e._ownerWritableStream=void 0}function mn(e,t){const i=e._ownerWritableStream,s=i._writableStreamController,f=Mi(s,t);if(i!==e._ownerWritableStream)return w(pt("write to"));const m=i._state;if(m==="errored")return w(i._storedError);if(be(i)||m==="closed")return w(new TypeError("The stream is closing or closed and cannot be written to"));if(m==="erroring")return w(i._storedError);const y=Bi(i);return Ui(s,t,f),y}const yn={};class Ge{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!Cr(this))throw Ar("abortReason");return this._abortReason}get signal(){if(!Cr(this))throw Ar("signal");if(this._abortController===void 0)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(t=void 0){if(!Cr(this))throw Ar("error");this._controlledWritableStream._state==="writable"&&gn(this,t)}[N](t){const i=this._abortAlgorithm(t);return jt(this),i}[X](){Ee(this)}}Object.defineProperties(Ge.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(Ge.prototype,d.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});function Cr(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")?!1:e instanceof Ge}function _n(e,t,i,s,f,m,y,C){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,Ee(t),t._abortReason=void 0,t._abortController=Ei(),t._started=!1,t._strategySizeAlgorithm=C,t._strategyHWM=y,t._writeAlgorithm=s,t._closeAlgorithm=f,t._abortAlgorithm=m;const P=Tr(t);Er(e,P);const F=i(),W=g(F);O(W,()=>{t._started=!0,Lt(t)},q=>{t._started=!0,gr(e,q)})}function Di(e,t,i,s){const f=Object.create(Ge.prototype);let m=()=>{},y=()=>g(void 0),C=()=>g(void 0),P=()=>g(void 0);t.start!==void 0&&(m=()=>t.start(f)),t.write!==void 0&&(y=F=>t.write(F,f)),t.close!==void 0&&(C=()=>t.close()),t.abort!==void 0&&(P=F=>t.abort(F)),_n(e,f,m,y,C,P,i,s)}function jt(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function zi(e){hr(e,yn,0),Lt(e)}function Mi(e,t){try{return e._strategySizeAlgorithm(t)}catch(i){return Br(e,i),1}}function wn(e){return e._strategyHWM-e._queueTotalSize}function Ui(e,t,i){try{hr(e,t,i)}catch(f){Br(e,f);return}const s=e._controlledWritableStream;if(!be(s)&&s._state==="writable"){const f=Tr(e);Er(s,f)}Lt(e)}function Lt(e){const t=e._controlledWritableStream;if(!e._started||t._inFlightWriteRequest!==void 0)return;if(t._state==="erroring"){Rr(t);return}if(e._queue.length===0)return;const s=si(e);s===yn?ji(e):Li(e,s)}function Br(e,t){e._controlledWritableStream._state==="writable"&&gn(e,t)}function ji(e){const t=e._controlledWritableStream;xi(t),dr(e);const i=e._closeAlgorithm();jt(e),O(i,()=>{Pi(t)},s=>{Ii(t,s)})}function Li(e,t){const i=e._controlledWritableStream;Wi(i);const s=e._writeAlgorithm(t);O(s,()=>{Ti(i);const f=i._state;if(dr(e),!be(i)&&f==="writable"){const m=Tr(e);Er(i,m)}Lt(e)},f=>{i._state==="writable"&&jt(e),Ai(i,f)})}function Tr(e){return wn(e)<=0}function gn(e,t){const i=e._controlledWritableStream;jt(e),Sr(i,t)}function $t(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function Ar(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function ze(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function pt(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function Nt(e){e._closedPromise=S((t,i)=>{e._closedPromise_resolve=t,e._closedPromise_reject=i,e._closedPromiseState="pending"})}function Sn(e,t){Nt(e),Pr(e,t)}function $i(e){Nt(e),Rn(e)}function Pr(e,t){e._closedPromise_reject!==void 0&&(z(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function Ni(e,t){Sn(e,t)}function Rn(e){e._closedPromise_resolve!==void 0&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function Ht(e){e._readyPromise=S((t,i)=>{e._readyPromise_resolve=t,e._readyPromise_reject=i}),e._readyPromiseState="pending"}function Ir(e,t){Ht(e),Cn(e,t)}function En(e){Ht(e),Fr(e)}function Cn(e,t){e._readyPromise_reject!==void 0&&(z(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function Hi(e){Ht(e)}function Yi(e,t){Ir(e,t)}function Fr(e){e._readyPromise_resolve!==void 0&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}const Bn=typeof DOMException<"u"?DOMException:void 0;function Qi(e){if(!(typeof e=="function"||typeof e=="object"))return!1;try{return new e,!0}catch{return!1}}function Gi(){const e=function(i,s){this.message=i||"",this.name=s||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return e.prototype=Object.create(Error.prototype),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,configurable:!0}),e}const Vi=Qi(Bn)?Bn:Gi();function Tn(e,t,i,s,f,m){const y=Se(e),C=fn(t);e._disturbed=!0;let P=!1,F=g(void 0);return S((W,q)=>{let H;if(m!==void 0){if(H=()=>{const T=new Vi("Aborted","AbortError"),I=[];s||I.push(()=>t._state==="writable"?Mt(t,T):g(void 0)),f||I.push(()=>e._state==="readable"?de(e,T):g(void 0)),ie(()=>Promise.all(I.map(M=>M())),!0,T)},m.aborted){H();return}m.addEventListener("abort",H)}function he(){return S((T,I)=>{function M(se){se?T():k(Je(),M,I)}M(!1)})}function Je(){return P?g(!0):k(C._readyPromise,()=>S((T,I)=>{qe(y,{_chunkSteps:M=>{F=k(mn(C,M),void 0,_),T(!1)},_closeSteps:()=>T(!0),_errorSteps:I})}))}if(we(e,y._closedPromise,T=>{s?le(!0,T):ie(()=>Mt(t,T),!0,T)}),we(t,C._closedPromise,T=>{f?le(!0,T):ie(()=>de(e,T),!0,T)}),ne(e,y._closedPromise,()=>{i?le():ie(()=>Oi(C))}),be(t)||t._state==="closed"){const T=new TypeError("the destination writable stream closed before all data could be piped to it");f?le(!0,T):ie(()=>de(e,T),!0,T)}z(he());function Pe(){const T=F;return k(F,()=>T!==F?Pe():void 0)}function we(T,I,M){T._state==="errored"?M(T._storedError):V(I,M)}function ne(T,I,M){T._state==="closed"?M():L(I,M)}function ie(T,I,M){if(P)return;P=!0,t._state==="writable"&&!be(t)?L(Pe(),se):se();function se(){O(T(),()=>ge(I,M),Ze=>ge(!0,Ze))}}function le(T,I){P||(P=!0,t._state==="writable"&&!be(t)?L(Pe(),()=>ge(T,I)):ge(T,I))}function ge(T,I){bn(C),fe(y),m!==void 0&&m.removeEventListener("abort",H),T?q(I):W(void 0)}})}class Ve{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!Yt(this))throw Vt("desiredSize");return xr(this)}close(){if(!Yt(this))throw Vt("close");if(!Xe(this))throw new TypeError("The stream is not in a state that permits close");mt(this)}enqueue(t=void 0){if(!Yt(this))throw Vt("enqueue");if(!Xe(this))throw new TypeError("The stream is not in a state that permits enqueue");return Gt(this,t)}error(t=void 0){if(!Yt(this))throw Vt("error");Ce(this,t)}[je](t){Ee(this);const i=this._cancelAlgorithm(t);return Qt(this),i}[Le](t){const i=this._controlledReadableStream;if(this._queue.length>0){const s=dr(this);this._closeRequested&&this._queue.length===0?(Qt(this),yt(i)):bt(this),t._chunkSteps(s)}else at(i,t),bt(this)}}Object.defineProperties(Ve.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(Ve.prototype,d.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});function Yt(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")?!1:e instanceof Ve}function bt(e){if(!An(e))return;if(e._pulling){e._pullAgain=!0;return}e._pulling=!0;const i=e._pullAlgorithm();O(i,()=>{e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,bt(e))},s=>{Ce(e,s)})}function An(e){const t=e._controlledReadableStream;return!Xe(e)||!e._started?!1:!!(Ae(t)&&re(t)>0||xr(e)>0)}function Qt(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function mt(e){if(!Xe(e))return;const t=e._controlledReadableStream;e._closeRequested=!0,e._queue.length===0&&(Qt(e),yt(t))}function Gt(e,t){if(!Xe(e))return;const i=e._controlledReadableStream;if(Ae(i)&&re(i)>0)Re(i,t,!1);else{let s;try{s=e._strategySizeAlgorithm(t)}catch(f){throw Ce(e,f),f}try{hr(e,t,s)}catch(f){throw Ce(e,f),f}}bt(e)}function Ce(e,t){const i=e._controlledReadableStream;i._state==="readable"&&(Ee(e),Qt(e),xn(i,t))}function xr(e){const t=e._controlledReadableStream._state;return t==="errored"?null:t==="closed"?0:e._strategyHWM-e._queueTotalSize}function Xi(e){return!An(e)}function Xe(e){const t=e._controlledReadableStream._state;return!e._closeRequested&&t==="readable"}function Pn(e,t,i,s,f,m,y){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,Ee(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=y,t._strategyHWM=m,t._pullAlgorithm=s,t._cancelAlgorithm=f,e._readableStreamController=t;const C=i();O(g(C),()=>{t._started=!0,bt(t)},P=>{Ce(t,P)})}function Ji(e,t,i,s){const f=Object.create(Ve.prototype);let m=()=>{},y=()=>g(void 0),C=()=>g(void 0);t.start!==void 0&&(m=()=>t.start(f)),t.pull!==void 0&&(y=()=>t.pull(f)),t.cancel!==void 0&&(C=P=>t.cancel(P)),Pn(e,f,m,y,C,i,s)}function Vt(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function Zi(e,t){return Oe(e._readableStreamController)?eo(e):Ki(e)}function Ki(e,t){const i=Se(e);let s=!1,f=!1,m=!1,y=!1,C,P,F,W,q;const H=S(ne=>{q=ne});function he(){return s?(f=!0,g(void 0)):(s=!0,qe(i,{_chunkSteps:ie=>{Fe(()=>{f=!1;const le=ie,ge=ie;m||Gt(F._readableStreamController,le),y||Gt(W._readableStreamController,ge),s=!1,f&&he()})},_closeSteps:()=>{s=!1,m||mt(F._readableStreamController),y||mt(W._readableStreamController),(!m||!y)&&q(void 0)},_errorSteps:()=>{s=!1}}),g(void 0))}function Je(ne){if(m=!0,C=ne,y){const ie=v([C,P]),le=de(e,ie);q(le)}return H}function Pe(ne){if(y=!0,P=ne,m){const ie=v([C,P]),le=de(e,ie);q(le)}return H}function we(){}return F=Wr(we,he,Je),W=Wr(we,he,Pe),V(i._closedPromise,ne=>{Ce(F._readableStreamController,ne),Ce(W._readableStreamController,ne),(!m||!y)&&q(void 0)}),[F,W]}function eo(e){let t=Se(e),i=!1,s=!1,f=!1,m=!1,y=!1,C,P,F,W,q;const H=S(T=>{q=T});function he(T){V(T._closedPromise,I=>{T===t&&(ce(F._readableStreamController,I),ce(W._readableStreamController,I),(!m||!y)&&q(void 0))})}function Je(){ke(t)&&(fe(t),t=Se(e),he(t)),qe(t,{_chunkSteps:I=>{Fe(()=>{s=!1,f=!1;const M=I;let se=I;if(!m&&!y)try{se=Gr(I)}catch(Ze){ce(F._readableStreamController,Ze),ce(W._readableStreamController,Ze),q(de(e,Ze));return}m||qt(F._readableStreamController,M),y||qt(W._readableStreamController,se),i=!1,s?we():f&&ne()})},_closeSteps:()=>{i=!1,m||ut(F._readableStreamController),y||ut(W._readableStreamController),F._readableStreamController._pendingPullIntos.length>0&&Ot(F._readableStreamController,0),W._readableStreamController._pendingPullIntos.length>0&&Ot(W._readableStreamController,0),(!m||!y)&&q(void 0)},_errorSteps:()=>{i=!1}})}function Pe(T,I){J(t)&&(fe(t),t=on(e),he(t));const M=I?W:F,se=I?F:W;un(t,T,{_chunkSteps:Ke=>{Fe(()=>{s=!1,f=!1;const et=I?y:m;if(I?m:y)et||vt(M._readableStreamController,Ke);else{let Nn;try{Nn=Gr(Ke)}catch(Or){ce(M._readableStreamController,Or),ce(se._readableStreamController,Or),q(de(e,Or));return}et||vt(M._readableStreamController,Ke),qt(se._readableStreamController,Nn)}i=!1,s?we():f&&ne()})},_closeSteps:Ke=>{i=!1;const et=I?y:m,ir=I?m:y;et||ut(M._readableStreamController),ir||ut(se._readableStreamController),Ke!==void 0&&(et||vt(M._readableStreamController,Ke),!ir&&se._readableStreamController._pendingPullIntos.length>0&&Ot(se._readableStreamController,0)),(!et||!ir)&&q(void 0)},_errorSteps:()=>{i=!1}})}function we(){if(i)return s=!0,g(void 0);i=!0;const T=yr(F._readableStreamController);return T===null?Je():Pe(T._view,!1),g(void 0)}function ne(){if(i)return f=!0,g(void 0);i=!0;const T=yr(W._readableStreamController);return T===null?Je():Pe(T._view,!0),g(void 0)}function ie(T){if(m=!0,C=T,y){const I=v([C,P]),M=de(e,I);q(M)}return H}function le(T){if(y=!0,P=T,m){const I=v([C,P]),M=de(e,I);q(M)}return H}function ge(){}return F=Fn(ge,we,ie),W=Fn(ge,ne,le),he(t),[F,W]}function to(e,t){K(e,t);const i=e,s=i?.autoAllocateChunkSize,f=i?.cancel,m=i?.pull,y=i?.start,C=i?.type;return{autoAllocateChunkSize:s===void 0?void 0:$e(s,`${t} has member 'autoAllocateChunkSize' that`),cancel:f===void 0?void 0:ro(f,i,`${t} has member 'cancel' that`),pull:m===void 0?void 0:no(m,i,`${t} has member 'pull' that`),start:y===void 0?void 0:io(y,i,`${t} has member 'start' that`),type:C===void 0?void 0:oo(C,`${t} has member 'type' that`)}}function ro(e,t,i){return te(e,i),s=>me(e,t,[s])}function no(e,t,i){return te(e,i),s=>me(e,t,[s])}function io(e,t,i){return te(e,i),s=>xe(e,t,[s])}function oo(e,t){if(e=`${e}`,e!=="bytes")throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);return e}function ao(e,t){K(e,t);const i=e?.mode;return{mode:i===void 0?void 0:so(i,`${t} has member 'mode' that`)}}function so(e,t){if(e=`${e}`,e!=="byob")throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function uo(e,t){return K(e,t),{preventCancel:!!e?.preventCancel}}function In(e,t){K(e,t);const i=e?.preventAbort,s=e?.preventCancel,f=e?.preventClose,m=e?.signal;return m!==void 0&&lo(m,`${t} has member 'signal' that`),{preventAbort:!!i,preventCancel:!!s,preventClose:!!f,signal:m}}function lo(e,t){if(!Si(e))throw new TypeError(`${t} is not an AbortSignal.`)}function fo(e,t){K(e,t);const i=e?.readable;pe(i,"readable","ReadableWritablePair"),ot(i,`${t} has member 'readable' that`);const s=e?.writable;return pe(s,"writable","ReadableWritablePair"),ln(s,`${t} has member 'writable' that`),{readable:i,writable:s}}class Be{constructor(t={},i={}){t===void 0?t=null:Pt(t,"First parameter");const s=zt(i,"Second parameter"),f=to(t,"First parameter");if(qr(this),f.type==="bytes"){if(s.size!==void 0)throw new RangeError("The strategy for a byte stream cannot have a size function");const m=ct(s,0);di(this,f,m)}else{const m=Dt(s),y=ct(s,1);Ji(this,f,y,m)}}get locked(){if(!Te(this))throw Me("locked");return Ae(this)}cancel(t=void 0){return Te(this)?Ae(this)?w(new TypeError("Cannot cancel a stream that already has a reader")):de(this,t):w(Me("cancel"))}getReader(t=void 0){if(!Te(this))throw Me("getReader");return ao(t,"First parameter").mode===void 0?Se(this):on(this)}pipeThrough(t,i={}){if(!Te(this))throw Me("pipeThrough");ue(t,1,"pipeThrough");const s=fo(t,"First parameter"),f=In(i,"Second parameter");if(Ae(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(Qe(s.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");const m=Tn(this,s.writable,f.preventClose,f.preventAbort,f.preventCancel,f.signal);return z(m),s.readable}pipeTo(t,i={}){if(!Te(this))return w(Me("pipeTo"));if(t===void 0)return w("Parameter 1 is required in 'pipeTo'.");if(!Ye(t))return w(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let s;try{s=In(i,"Second parameter")}catch(f){return w(f)}return Ae(this)?w(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):Qe(t)?w(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):Tn(this,t,s.preventClose,s.preventAbort,s.preventCancel,s.signal)}tee(){if(!Te(this))throw Me("tee");const t=Zi(this);return v(t)}values(t=void 0){if(!Te(this))throw Me("values");const i=uo(t,"First parameter");return l(this,i.preventCancel)}}Object.defineProperties(Be.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(Be.prototype,d.toStringTag,{value:"ReadableStream",configurable:!0}),typeof d.asyncIterator=="symbol"&&Object.defineProperty(Be.prototype,d.asyncIterator,{value:Be.prototype.values,writable:!0,configurable:!0});function Wr(e,t,i,s=1,f=()=>1){const m=Object.create(Be.prototype);qr(m);const y=Object.create(Ve.prototype);return Pn(m,y,e,t,i,s,f),m}function Fn(e,t,i){const s=Object.create(Be.prototype);qr(s);const f=Object.create(He.prototype);return nn(s,f,e,t,i,0,void 0),s}function qr(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function Te(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")?!1:e instanceof Be}function Ae(e){return e._reader!==void 0}function de(e,t){if(e._disturbed=!0,e._state==="closed")return g(void 0);if(e._state==="errored")return w(e._storedError);yt(e);const i=e._reader;i!==void 0&&ke(i)&&(i._readIntoRequests.forEach(f=>{f._closeSteps(void 0)}),i._readIntoRequests=new ae);const s=e._readableStreamController[je](t);return ee(s,_)}function yt(e){e._state="closed";const t=e._reader;t!==void 0&&(Ct(t),J(t)&&(t._readRequests.forEach(i=>{i._closeSteps()}),t._readRequests=new ae))}function xn(e,t){e._state="errored",e._storedError=t;const i=e._reader;i!==void 0&&(nt(i,t),J(i)?(i._readRequests.forEach(s=>{s._errorSteps(t)}),i._readRequests=new ae):(i._readIntoRequests.forEach(s=>{s._errorSteps(t)}),i._readIntoRequests=new ae))}function Me(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function Wn(e,t){K(e,t);const i=e?.highWaterMark;return pe(i,"highWaterMark","QueuingStrategyInit"),{highWaterMark:_e(i)}}const qn=e=>e.byteLength;try{Object.defineProperty(qn,"name",{value:"size",configurable:!0})}catch{}class Xt{constructor(t){ue(t,1,"ByteLengthQueuingStrategy"),t=Wn(t,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=t.highWaterMark}get highWaterMark(){if(!vn(this))throw On("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!vn(this))throw On("size");return qn}}Object.defineProperties(Xt.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(Xt.prototype,d.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});function On(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function vn(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")?!1:e instanceof Xt}const kn=()=>1;try{Object.defineProperty(kn,"name",{value:"size",configurable:!0})}catch{}class Jt{constructor(t){ue(t,1,"CountQueuingStrategy"),t=Wn(t,"First parameter"),this._countQueuingStrategyHighWaterMark=t.highWaterMark}get highWaterMark(){if(!zn(this))throw Dn("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!zn(this))throw Dn("size");return kn}}Object.defineProperties(Jt.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(Jt.prototype,d.toStringTag,{value:"CountQueuingStrategy",configurable:!0});function Dn(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function zn(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")?!1:e instanceof Jt}function co(e,t){K(e,t);const i=e?.flush,s=e?.readableType,f=e?.start,m=e?.transform,y=e?.writableType;return{flush:i===void 0?void 0:ho(i,e,`${t} has member 'flush' that`),readableType:s,start:f===void 0?void 0:po(f,e,`${t} has member 'start' that`),transform:m===void 0?void 0:bo(m,e,`${t} has member 'transform' that`),writableType:y}}function ho(e,t,i){return te(e,i),s=>me(e,t,[s])}function po(e,t,i){return te(e,i),s=>xe(e,t,[s])}function bo(e,t,i){return te(e,i),(s,f)=>me(e,t,[s,f])}class Zt{constructor(t={},i={},s={}){t===void 0&&(t=null);const f=zt(i,"Second parameter"),m=zt(s,"Third parameter"),y=co(t,"First parameter");if(y.readableType!==void 0)throw new RangeError("Invalid readableType specified");if(y.writableType!==void 0)throw new RangeError("Invalid writableType specified");const C=ct(m,0),P=Dt(m),F=ct(f,1),W=Dt(f);let q;const H=S(he=>{q=he});mo(this,H,F,W,C,P),_o(this,y),y.start!==void 0?q(y.start(this._transformStreamController)):q(void 0)}get readable(){if(!Mn(this))throw $n("readable");return this._readable}get writable(){if(!Mn(this))throw $n("writable");return this._writable}}Object.defineProperties(Zt.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(Zt.prototype,d.toStringTag,{value:"TransformStream",configurable:!0});function mo(e,t,i,s,f,m){function y(){return t}function C(H){return So(e,H)}function P(H){return Ro(e,H)}function F(){return Eo(e)}e._writable=Ci(y,C,F,P,i,s);function W(){return Co(e)}function q(H){return er(e,H),g(void 0)}e._readable=Wr(y,W,q,f,m),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,tr(e,!0),e._transformStreamController=void 0}function Mn(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")?!1:e instanceof Zt}function Kt(e,t){Ce(e._readable._readableStreamController,t),er(e,t)}function er(e,t){Un(e._transformStreamController),Br(e._writable._writableStreamController,t),e._backpressure&&tr(e,!1)}function tr(e,t){e._backpressureChangePromise!==void 0&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=S(i=>{e._backpressureChangePromise_resolve=i}),e._backpressure=t}class _t{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!rr(this))throw nr("desiredSize");const t=this._controlledTransformStream._readable._readableStreamController;return xr(t)}enqueue(t=void 0){if(!rr(this))throw nr("enqueue");jn(this,t)}error(t=void 0){if(!rr(this))throw nr("error");wo(this,t)}terminate(){if(!rr(this))throw nr("terminate");go(this)}}Object.defineProperties(_t.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(_t.prototype,d.toStringTag,{value:"TransformStreamDefaultController",configurable:!0});function rr(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")?!1:e instanceof _t}function yo(e,t,i,s){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=i,t._flushAlgorithm=s}function _o(e,t){const i=Object.create(_t.prototype);let s=m=>{try{return jn(i,m),g(void 0)}catch(y){return w(y)}},f=()=>g(void 0);t.transform!==void 0&&(s=m=>t.transform(m,i)),t.flush!==void 0&&(f=()=>t.flush(i)),yo(e,i,s,f)}function Un(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function jn(e,t){const i=e._controlledTransformStream,s=i._readable._readableStreamController;if(!Xe(s))throw new TypeError("Readable side is not in a state that permits enqueue");try{Gt(s,t)}catch(m){throw er(i,m),i._readable._storedError}Xi(s)!==i._backpressure&&tr(i,!0)}function wo(e,t){Kt(e._controlledTransformStream,t)}function Ln(e,t){const i=e._transformAlgorithm(t);return ee(i,void 0,s=>{throw Kt(e._controlledTransformStream,s),s})}function go(e){const t=e._controlledTransformStream,i=t._readable._readableStreamController;mt(i);const s=new TypeError("TransformStream terminated");er(t,s)}function So(e,t){const i=e._transformStreamController;if(e._backpressure){const s=e._backpressureChangePromise;return ee(s,()=>{const f=e._writable;if(f._state==="erroring")throw f._storedError;return Ln(i,t)})}return Ln(i,t)}function Ro(e,t){return Kt(e,t),g(void 0)}function Eo(e){const t=e._readable,i=e._transformStreamController,s=i._flushAlgorithm();return Un(i),ee(s,()=>{if(t._state==="errored")throw t._storedError;mt(t._readableStreamController)},f=>{throw Kt(e,f),t._storedError})}function Co(e){return tr(e,!1),e._backpressureChangePromise}function nr(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function $n(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}p.ByteLengthQueuingStrategy=Xt,p.CountQueuingStrategy=Jt,p.ReadableByteStreamController=He,p.ReadableStream=Be,p.ReadableStreamBYOBReader=ft,p.ReadableStreamBYOBRequest=st,p.ReadableStreamDefaultController=Ve,p.ReadableStreamDefaultReader=We,p.TransformStream=Zt,p.TransformStreamDefaultController=_t,p.WritableStream=dt,p.WritableStreamDefaultController=Ge,p.WritableStreamDefaultWriter=ht,Object.defineProperty(p,"__esModule",{value:!0})})}(or,or.exports)),or.exports}var kr={},wt={},Gn;function Io(){if(Gn)return wt;Gn=1,wt.byteLength=c,wt.toByteArray=Q,wt.fromByteArray=G;for(var B=[],u=[],p=typeof Uint8Array<"u"?Uint8Array:Array,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_=0,R=d.length;_0)throw new Error("Invalid string. Length must be a multiple of 4");var w=S.indexOf("=");w===-1&&(w=g);var k=w===g?0:4-w%4;return[w,k]}function c(S){var g=E(S),w=g[0],k=g[1];return(w+k)*3/4-k}function Y(S,g,w){return(g+w)*3/4-w}function Q(S){var g,w=E(S),k=w[0],O=w[1],L=new p(Y(S,k,O)),V=0,ee=O>0?k-4:k,z;for(z=0;z>16&255,L[V++]=g>>8&255,L[V++]=g&255;return O===2&&(g=u[S.charCodeAt(z)]<<2|u[S.charCodeAt(z+1)]>>4,L[V++]=g&255),O===1&&(g=u[S.charCodeAt(z)]<<10|u[S.charCodeAt(z+1)]<<4|u[S.charCodeAt(z+2)]>>2,L[V++]=g>>8&255,L[V++]=g&255),L}function U(S){return B[S>>18&63]+B[S>>12&63]+B[S>>6&63]+B[S&63]}function j(S,g,w){for(var k,O=[],L=g;Lee?ee:V+L));return k===1?(g=S[w-1],O.push(B[g>>2]+B[g<<4&63]+"==")):k===2&&(g=(S[w-2]<<8)+S[w-1],O.push(B[g>>10]+B[g>>4&63]+B[g<<2&63]+"=")),O.join("")}return wt}var ar={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */var Vn;function Fo(){return Vn||(Vn=1,ar.read=function(B,u,p,d,_){var R,E,c=_*8-d-1,Y=(1<>1,U=-7,j=p?_-1:0,G=p?-1:1,S=B[u+j];for(j+=G,R=S&(1<<-U)-1,S>>=-U,U+=c;U>0;R=R*256+B[u+j],j+=G,U-=8);for(E=R&(1<<-U)-1,R>>=-U,U+=d;U>0;E=E*256+B[u+j],j+=G,U-=8);if(R===0)R=1-Q;else{if(R===Y)return E?NaN:(S?-1:1)*(1/0);E=E+Math.pow(2,d),R=R-Q}return(S?-1:1)*E*Math.pow(2,R-d)},ar.write=function(B,u,p,d,_,R){var E,c,Y,Q=R*8-_-1,U=(1<>1,G=_===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=d?0:R-1,g=d?1:-1,w=u<0||u===0&&1/u<0?1:0;for(u=Math.abs(u),isNaN(u)||u===1/0?(c=isNaN(u)?1:0,E=U):(E=Math.floor(Math.log(u)/Math.LN2),u*(Y=Math.pow(2,-E))<1&&(E--,Y*=2),E+j>=1?u+=G/Y:u+=G*Math.pow(2,1-j),u*Y>=2&&(E++,Y/=2),E+j>=U?(c=0,E=U):E+j>=1?(c=(u*Y-1)*Math.pow(2,_),E=E+j):(c=u*Math.pow(2,j-1)*Math.pow(2,_),E=0));_>=8;B[p+S]=c&255,S+=g,c/=256,_-=8);for(E=E<<_|c,Q+=_;Q>0;B[p+S]=E&255,S+=g,E/=256,Q-=8);B[p+S-g]|=w*128}),ar}/*! +import{q as vr,r as jr,g as Bo,s as ri,u as To,v as Hn,w as Yn,W as Ao}from"./ChartManager-bba9ffde.js";var or={exports:{}},Qn;function Po(){return Qn||(Qn=1,function(B,u){(function(p,d){d(u)})(vr,function(p){const d=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol:e=>`Symbol(${e})`;function _(){}function R(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof vr<"u")return vr}const E=R();function c(e){return typeof e=="object"&&e!==null||typeof e=="function"}const Y=_,Q=Promise,U=Promise.prototype.then,j=Promise.resolve.bind(Q),G=Promise.reject.bind(Q);function S(e){return new Q(e)}function g(e){return j(e)}function w(e){return G(e)}function k(e,t,i){return U.call(e,t,i)}function O(e,t,i){k(k(e,t,i),void 0,Y)}function L(e,t){O(e,t)}function V(e,t){O(e,void 0,t)}function ee(e,t,i){return k(e,t,i)}function z(e){k(e,void 0,Y)}const Fe=(()=>{const e=E&&E.queueMicrotask;if(typeof e=="function")return e;const t=g(void 0);return i=>k(t,i)})();function xe(e,t,i){if(typeof e!="function")throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,i)}function me(e,t,i){try{return g(xe(e,t,i))}catch(s){return w(s)}}const St=16384;class ae{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(t){const i=this._back;let s=i;i._elements.length===St-1&&(s={_elements:[],_next:void 0}),i._elements.push(t),s!==i&&(this._back=s,i._next=s),++this._size}shift(){const t=this._front;let i=t;const s=this._cursor;let f=s+1;const m=t._elements,y=m[s];return f===St&&(i=t._next,f=0),--this._size,this._cursor=f,t!==i&&(this._front=i),m[s]=void 0,y}forEach(t){let i=this._cursor,s=this._front,f=s._elements;for(;(i!==f.length||s._next!==void 0)&&!(i===f.length&&(s=s._next,f=s._elements,i=0,f.length===0));)t(f[i]),++i}peek(){const t=this._front,i=this._cursor;return t._elements[i]}}function Rt(e,t){e._ownerReadableStream=t,t._reader=e,t._state==="readable"?Ue(e):t._state==="closed"?lr(e):Et(e,t._storedError)}function rt(e,t){const i=e._ownerReadableStream;return de(i,t)}function fe(e){e._ownerReadableStream._state==="readable"?nt(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):fr(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),e._ownerReadableStream._reader=void 0,e._ownerReadableStream=void 0}function ye(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function Ue(e){e._closedPromise=S((t,i)=>{e._closedPromise_resolve=t,e._closedPromise_reject=i})}function Et(e,t){Ue(e),nt(e,t)}function lr(e){Ue(e),Ct(e)}function nt(e,t){e._closedPromise_reject!==void 0&&(z(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function fr(e,t){Et(e,t)}function Ct(e){e._closedPromise_resolve!==void 0&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const N=d("[[AbortSteps]]"),X=d("[[ErrorSteps]]"),je=d("[[CancelSteps]]"),Le=d("[[PullSteps]]"),it=Number.isFinite||function(e){return typeof e=="number"&&isFinite(e)},Bt=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function Tt(e){return typeof e=="object"||typeof e=="function"}function K(e,t){if(e!==void 0&&!Tt(e))throw new TypeError(`${t} is not an object.`)}function te(e,t){if(typeof e!="function")throw new TypeError(`${t} is not a function.`)}function At(e){return typeof e=="object"&&e!==null||typeof e=="function"}function Pt(e,t){if(!At(e))throw new TypeError(`${t} is not an object.`)}function ue(e,t,i){if(e===void 0)throw new TypeError(`Parameter ${t} is required in '${i}'.`)}function pe(e,t,i){if(e===void 0)throw new TypeError(`${t} is required in '${i}'.`)}function _e(e){return Number(e)}function It(e){return e===0?0:e}function cr(e){return It(Bt(e))}function $e(e,t){const s=Number.MAX_SAFE_INTEGER;let f=Number(e);if(f=It(f),!it(f))throw new TypeError(`${t} is not a finite number`);if(f=cr(f),f<0||f>s)throw new TypeError(`${t} is outside the accepted range of 0 to ${s}, inclusive`);return!it(f)||f===0?0:f}function ot(e,t){if(!Te(e))throw new TypeError(`${t} is not a ReadableStream.`)}function Se(e){return new We(e)}function at(e,t){e._reader._readRequests.push(t)}function Re(e,t,i){const f=e._reader._readRequests.shift();i?f._closeSteps():f._chunkSteps(t)}function re(e){return e._reader._readRequests.length}function Ne(e){const t=e._reader;return!(t===void 0||!J(t))}class We{constructor(t){if(ue(t,1,"ReadableStreamDefaultReader"),ot(t,"First parameter"),Ae(t))throw new TypeError("This stream has already been locked for exclusive reading by another reader");Rt(this,t),this._readRequests=new ae}get closed(){return J(this)?this._closedPromise:w(o("closed"))}cancel(t=void 0){return J(this)?this._ownerReadableStream===void 0?w(ye("cancel")):rt(this,t):w(o("cancel"))}read(){if(!J(this))return w(o("read"));if(this._ownerReadableStream===void 0)return w(ye("read from"));let t,i;const s=S((m,y)=>{t=m,i=y});return qe(this,{_chunkSteps:m=>t({value:m,done:!1}),_closeSteps:()=>t({value:void 0,done:!0}),_errorSteps:m=>i(m)}),s}releaseLock(){if(!J(this))throw o("releaseLock");if(this._ownerReadableStream!==void 0){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");fe(this)}}}Object.defineProperties(We.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(We.prototype,d.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});function J(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_readRequests")?!1:e instanceof We}function qe(e,t){const i=e._ownerReadableStream;i._disturbed=!0,i._state==="closed"?t._closeSteps():i._state==="errored"?t._errorSteps(i._storedError):i._readableStreamController[Le](t)}function o(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}const r=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype);class n{constructor(t,i){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=t,this._preventCancel=i}next(){const t=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?ee(this._ongoingPromise,t,t):t(),this._ongoingPromise}return(t){const i=()=>this._returnSteps(t);return this._ongoingPromise?ee(this._ongoingPromise,i,i):i()}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const t=this._reader;if(t._ownerReadableStream===void 0)return w(ye("iterate"));let i,s;const f=S((y,C)=>{i=y,s=C});return qe(t,{_chunkSteps:y=>{this._ongoingPromise=void 0,Fe(()=>i({value:y,done:!1}))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,fe(t),i({value:void 0,done:!0})},_errorSteps:y=>{this._ongoingPromise=void 0,this._isFinished=!0,fe(t),s(y)}}),f}_returnSteps(t){if(this._isFinished)return Promise.resolve({value:t,done:!0});this._isFinished=!0;const i=this._reader;if(i._ownerReadableStream===void 0)return w(ye("finish iterating"));if(!this._preventCancel){const s=rt(i,t);return fe(i),ee(s,()=>({value:t,done:!0}))}return fe(i),g({value:t,done:!0})}}const a={next(){return h(this)?this._asyncIteratorImpl.next():w(b("next"))},return(e){return h(this)?this._asyncIteratorImpl.return(e):w(b("return"))}};r!==void 0&&Object.setPrototypeOf(a,r);function l(e,t){const i=Se(e),s=new n(i,t),f=Object.create(a);return f._asyncIteratorImpl=s,f}function h(e){if(!c(e)||!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof n}catch{return!1}}function b(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}const A=Number.isNaN||function(e){return e!==e};function v(e){return e.slice()}function D(e,t,i,s,f){new Uint8Array(e).set(new Uint8Array(i,s,f),t)}function $(e){return e}function x(e){return!1}function Qr(e,t,i){if(e.slice)return e.slice(t,i);const s=i-t,f=new ArrayBuffer(s);return D(f,0,e,t,s),f}function ai(e){return!(typeof e!="number"||A(e)||e<0)}function Gr(e){const t=Qr(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function dr(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function hr(e,t,i){if(!ai(i)||i===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:t,size:i}),e._queueTotalSize+=i}function si(e){return e._queue.peek().value}function Ee(e){e._queue=new ae,e._queueTotalSize=0}class st{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!pr(this))throw _r("view");return this._view}respond(t){if(!pr(this))throw _r("respond");if(ue(t,1,"respond"),t=$e(t,"First parameter"),this._associatedReadableByteStreamController===void 0)throw new TypeError("This BYOB request has been invalidated");x(this._view.buffer),Ot(this._associatedReadableByteStreamController,t)}respondWithNewView(t){if(!pr(this))throw _r("respondWithNewView");if(ue(t,1,"respondWithNewView"),!ArrayBuffer.isView(t))throw new TypeError("You can only respond with array buffer views");if(this._associatedReadableByteStreamController===void 0)throw new TypeError("This BYOB request has been invalidated");x(t.buffer),vt(this._associatedReadableByteStreamController,t)}}Object.defineProperties(st.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(st.prototype,d.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class He{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!Oe(this))throw lt("byobRequest");return yr(this)}get desiredSize(){if(!Oe(this))throw lt("desiredSize");return rn(this)}close(){if(!Oe(this))throw lt("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const t=this._controlledReadableByteStream._state;if(t!=="readable")throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be closed`);ut(this)}enqueue(t){if(!Oe(this))throw lt("enqueue");if(ue(t,1,"enqueue"),!ArrayBuffer.isView(t))throw new TypeError("chunk must be an array buffer view");if(t.byteLength===0)throw new TypeError("chunk must have non-zero byteLength");if(t.buffer.byteLength===0)throw new TypeError("chunk's buffer must have non-zero byteLength");if(this._closeRequested)throw new TypeError("stream is closed or draining");const i=this._controlledReadableByteStream._state;if(i!=="readable")throw new TypeError(`The stream (in ${i} state) is not in the readable state and cannot be enqueued to`);qt(this,t)}error(t=void 0){if(!Oe(this))throw lt("error");ce(this,t)}[je](t){Vr(this),Ee(this);const i=this._cancelAlgorithm(t);return Wt(this),i}[Le](t){const i=this._controlledReadableByteStream;if(this._queueTotalSize>0){const f=this._queue.shift();this._queueTotalSize-=f.byteLength,Kr(this);const m=new Uint8Array(f.buffer,f.byteOffset,f.byteLength);t._chunkSteps(m);return}const s=this._autoAllocateChunkSize;if(s!==void 0){let f;try{f=new ArrayBuffer(s)}catch(y){t._errorSteps(y);return}const m={buffer:f,bufferByteLength:s,byteOffset:0,byteLength:s,bytesFilled:0,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(m)}at(i,t),ve(this)}}Object.defineProperties(He.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(He.prototype,d.toStringTag,{value:"ReadableByteStreamController",configurable:!0});function Oe(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")?!1:e instanceof He}function pr(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")?!1:e instanceof st}function ve(e){if(!ci(e))return;if(e._pulling){e._pullAgain=!0;return}e._pulling=!0;const i=e._pullAlgorithm();O(i,()=>{e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,ve(e))},s=>{ce(e,s)})}function Vr(e){mr(e),e._pendingPullIntos=new ae}function br(e,t){let i=!1;e._state==="closed"&&(i=!0);const s=Xr(t);t.readerType==="default"?Re(e,s,i):pi(e,s,i)}function Xr(e){const t=e.bytesFilled,i=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/i)}function Ft(e,t,i,s){e._queue.push({buffer:t,byteOffset:i,byteLength:s}),e._queueTotalSize+=s}function Jr(e,t){const i=t.elementSize,s=t.bytesFilled-t.bytesFilled%i,f=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),m=t.bytesFilled+f,y=m-m%i;let C=f,P=!1;y>s&&(C=y-t.bytesFilled,P=!0);const F=e._queue;for(;C>0;){const W=F.peek(),q=Math.min(C,W.byteLength),H=t.byteOffset+t.bytesFilled;D(t.buffer,H,W.buffer,W.byteOffset,q),W.byteLength===q?F.shift():(W.byteOffset+=q,W.byteLength-=q),e._queueTotalSize-=q,Zr(e,q,t),C-=q}return P}function Zr(e,t,i){i.bytesFilled+=t}function Kr(e){e._queueTotalSize===0&&e._closeRequested?(Wt(e),yt(e._controlledReadableByteStream)):ve(e)}function mr(e){e._byobRequest!==null&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function en(e){for(;e._pendingPullIntos.length>0;){if(e._queueTotalSize===0)return;const t=e._pendingPullIntos.peek();Jr(e,t)&&(xt(e),br(e._controlledReadableByteStream,t))}}function ui(e,t,i){const s=e._controlledReadableByteStream;let f=1;t.constructor!==DataView&&(f=t.constructor.BYTES_PER_ELEMENT);const m=t.constructor,y=t.buffer,C={buffer:y,bufferByteLength:y.byteLength,byteOffset:t.byteOffset,byteLength:t.byteLength,bytesFilled:0,elementSize:f,viewConstructor:m,readerType:"byob"};if(e._pendingPullIntos.length>0){e._pendingPullIntos.push(C),an(s,i);return}if(s._state==="closed"){const P=new m(C.buffer,C.byteOffset,0);i._closeSteps(P);return}if(e._queueTotalSize>0){if(Jr(e,C)){const P=Xr(C);Kr(e),i._chunkSteps(P);return}if(e._closeRequested){const P=new TypeError("Insufficient bytes to fill elements in the given buffer");ce(e,P),i._errorSteps(P);return}}e._pendingPullIntos.push(C),an(s,i),ve(e)}function li(e,t){const i=e._controlledReadableByteStream;if(wr(i))for(;sn(i)>0;){const s=xt(e);br(i,s)}}function fi(e,t,i){if(Zr(e,t,i),i.bytesFilled0){const f=i.byteOffset+i.bytesFilled,m=Qr(i.buffer,f-s,f);Ft(e,m,0,m.byteLength)}i.bytesFilled-=s,br(e._controlledReadableByteStream,i),en(e)}function tn(e,t){const i=e._pendingPullIntos.peek();mr(e),e._controlledReadableByteStream._state==="closed"?li(e):fi(e,t,i),ve(e)}function xt(e){return e._pendingPullIntos.shift()}function ci(e){const t=e._controlledReadableByteStream;return t._state!=="readable"||e._closeRequested||!e._started?!1:!!(Ne(t)&&re(t)>0||wr(t)&&sn(t)>0||rn(e)>0)}function Wt(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function ut(e){const t=e._controlledReadableByteStream;if(!(e._closeRequested||t._state!=="readable")){if(e._queueTotalSize>0){e._closeRequested=!0;return}if(e._pendingPullIntos.length>0&&e._pendingPullIntos.peek().bytesFilled>0){const s=new TypeError("Insufficient bytes to fill elements in the given buffer");throw ce(e,s),s}Wt(e),yt(t)}}function qt(e,t){const i=e._controlledReadableByteStream;if(e._closeRequested||i._state!=="readable")return;const s=t.buffer,f=t.byteOffset,m=t.byteLength,y=s;if(e._pendingPullIntos.length>0){const C=e._pendingPullIntos.peek();x(C.buffer),C.buffer=C.buffer}if(mr(e),Ne(i))if(re(i)===0)Ft(e,y,f,m);else{e._pendingPullIntos.length>0&&xt(e);const C=new Uint8Array(y,f,m);Re(i,C,!1)}else wr(i)?(Ft(e,y,f,m),en(e)):Ft(e,y,f,m);ve(e)}function ce(e,t){const i=e._controlledReadableByteStream;i._state==="readable"&&(Vr(e),Ee(e),Wt(e),xn(i,t))}function yr(e){if(e._byobRequest===null&&e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek(),i=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),s=Object.create(st.prototype);hi(s,e,i),e._byobRequest=s}return e._byobRequest}function rn(e){const t=e._controlledReadableByteStream._state;return t==="errored"?null:t==="closed"?0:e._strategyHWM-e._queueTotalSize}function Ot(e,t){const i=e._pendingPullIntos.peek();if(e._controlledReadableByteStream._state==="closed"){if(t!==0)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(t===0)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(i.bytesFilled+t>i.byteLength)throw new RangeError("bytesWritten out of range")}i.buffer=i.buffer,tn(e,t)}function vt(e,t){const i=e._pendingPullIntos.peek();if(e._controlledReadableByteStream._state==="closed"){if(t.byteLength!==0)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(t.byteLength===0)throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");if(i.byteOffset+i.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(i.bufferByteLength!==t.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(i.bytesFilled+t.byteLength>i.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");const f=t.byteLength;i.buffer=t.buffer,tn(e,f)}function nn(e,t,i,s,f,m,y){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,Ee(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=m,t._pullAlgorithm=s,t._cancelAlgorithm=f,t._autoAllocateChunkSize=y,t._pendingPullIntos=new ae,e._readableStreamController=t;const C=i();O(g(C),()=>{t._started=!0,ve(t)},P=>{ce(t,P)})}function di(e,t,i){const s=Object.create(He.prototype);let f=()=>{},m=()=>g(void 0),y=()=>g(void 0);t.start!==void 0&&(f=()=>t.start(s)),t.pull!==void 0&&(m=()=>t.pull(s)),t.cancel!==void 0&&(y=P=>t.cancel(P));const C=t.autoAllocateChunkSize;if(C===0)throw new TypeError("autoAllocateChunkSize must be greater than 0");nn(e,s,f,m,y,i,C)}function hi(e,t,i){e._associatedReadableByteStreamController=t,e._view=i}function _r(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function lt(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function on(e){return new ft(e)}function an(e,t){e._reader._readIntoRequests.push(t)}function pi(e,t,i){const f=e._reader._readIntoRequests.shift();i?f._closeSteps(t):f._chunkSteps(t)}function sn(e){return e._reader._readIntoRequests.length}function wr(e){const t=e._reader;return!(t===void 0||!ke(t))}class ft{constructor(t){if(ue(t,1,"ReadableStreamBYOBReader"),ot(t,"First parameter"),Ae(t))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!Oe(t._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");Rt(this,t),this._readIntoRequests=new ae}get closed(){return ke(this)?this._closedPromise:w(kt("closed"))}cancel(t=void 0){return ke(this)?this._ownerReadableStream===void 0?w(ye("cancel")):rt(this,t):w(kt("cancel"))}read(t){if(!ke(this))return w(kt("read"));if(!ArrayBuffer.isView(t))return w(new TypeError("view must be an array buffer view"));if(t.byteLength===0)return w(new TypeError("view must have non-zero byteLength"));if(t.buffer.byteLength===0)return w(new TypeError("view's buffer must have non-zero byteLength"));if(x(t.buffer),this._ownerReadableStream===void 0)return w(ye("read from"));let i,s;const f=S((y,C)=>{i=y,s=C});return un(this,t,{_chunkSteps:y=>i({value:y,done:!1}),_closeSteps:y=>i({value:y,done:!0}),_errorSteps:y=>s(y)}),f}releaseLock(){if(!ke(this))throw kt("releaseLock");if(this._ownerReadableStream!==void 0){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");fe(this)}}}Object.defineProperties(ft.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(ft.prototype,d.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});function ke(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")?!1:e instanceof ft}function un(e,t,i){const s=e._ownerReadableStream;s._disturbed=!0,s._state==="errored"?i._errorSteps(s._storedError):ui(s._readableStreamController,t,i)}function kt(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function ct(e,t){const{highWaterMark:i}=e;if(i===void 0)return t;if(A(i)||i<0)throw new RangeError("Invalid highWaterMark");return i}function Dt(e){const{size:t}=e;return t||(()=>1)}function zt(e,t){K(e,t);const i=e?.highWaterMark,s=e?.size;return{highWaterMark:i===void 0?void 0:_e(i),size:s===void 0?void 0:bi(s,`${t} has member 'size' that`)}}function bi(e,t){return te(e,t),i=>_e(e(i))}function mi(e,t){K(e,t);const i=e?.abort,s=e?.close,f=e?.start,m=e?.type,y=e?.write;return{abort:i===void 0?void 0:yi(i,e,`${t} has member 'abort' that`),close:s===void 0?void 0:_i(s,e,`${t} has member 'close' that`),start:f===void 0?void 0:wi(f,e,`${t} has member 'start' that`),write:y===void 0?void 0:gi(y,e,`${t} has member 'write' that`),type:m}}function yi(e,t,i){return te(e,i),s=>me(e,t,[s])}function _i(e,t,i){return te(e,i),()=>me(e,t,[])}function wi(e,t,i){return te(e,i),s=>xe(e,t,[s])}function gi(e,t,i){return te(e,i),(s,f)=>me(e,t,[s,f])}function ln(e,t){if(!Ye(e))throw new TypeError(`${t} is not a WritableStream.`)}function Si(e){if(typeof e!="object"||e===null)return!1;try{return typeof e.aborted=="boolean"}catch{return!1}}const Ri=typeof AbortController=="function";function Ei(){if(Ri)return new AbortController}class dt{constructor(t={},i={}){t===void 0?t=null:Pt(t,"First parameter");const s=zt(i,"Second parameter"),f=mi(t,"First parameter");if(cn(this),f.type!==void 0)throw new RangeError("Invalid type is specified");const y=Dt(s),C=ct(s,1);Di(this,f,C,y)}get locked(){if(!Ye(this))throw $t("locked");return Qe(this)}abort(t=void 0){return Ye(this)?Qe(this)?w(new TypeError("Cannot abort a stream that already has a writer")):Mt(this,t):w($t("abort"))}close(){return Ye(this)?Qe(this)?w(new TypeError("Cannot close a stream that already has a writer")):be(this)?w(new TypeError("Cannot close an already-closing stream")):dn(this):w($t("close"))}getWriter(){if(!Ye(this))throw $t("getWriter");return fn(this)}}Object.defineProperties(dt.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(dt.prototype,d.toStringTag,{value:"WritableStream",configurable:!0});function fn(e){return new ht(e)}function Ci(e,t,i,s,f=1,m=()=>1){const y=Object.create(dt.prototype);cn(y);const C=Object.create(Ge.prototype);return _n(y,C,e,t,i,s,f,m),y}function cn(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new ae,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function Ye(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")?!1:e instanceof dt}function Qe(e){return e._writer!==void 0}function Mt(e,t){var i;if(e._state==="closed"||e._state==="errored")return g(void 0);e._writableStreamController._abortReason=t,(i=e._writableStreamController._abortController)===null||i===void 0||i.abort();const s=e._state;if(s==="closed"||s==="errored")return g(void 0);if(e._pendingAbortRequest!==void 0)return e._pendingAbortRequest._promise;let f=!1;s==="erroring"&&(f=!0,t=void 0);const m=S((y,C)=>{e._pendingAbortRequest={_promise:void 0,_resolve:y,_reject:C,_reason:t,_wasAlreadyErroring:f}});return e._pendingAbortRequest._promise=m,f||Sr(e,t),m}function dn(e){const t=e._state;if(t==="closed"||t==="errored")return w(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const i=S((f,m)=>{const y={_resolve:f,_reject:m};e._closeRequest=y}),s=e._writer;return s!==void 0&&e._backpressure&&t==="writable"&&Fr(s),zi(e._writableStreamController),i}function Bi(e){return S((i,s)=>{const f={_resolve:i,_reject:s};e._writeRequests.push(f)})}function gr(e,t){if(e._state==="writable"){Sr(e,t);return}Rr(e)}function Sr(e,t){const i=e._writableStreamController;e._state="erroring",e._storedError=t;const s=e._writer;s!==void 0&&pn(s,t),!Fi(e)&&i._started&&Rr(e)}function Rr(e){e._state="errored",e._writableStreamController[X]();const t=e._storedError;if(e._writeRequests.forEach(f=>{f._reject(t)}),e._writeRequests=new ae,e._pendingAbortRequest===void 0){Ut(e);return}const i=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,i._wasAlreadyErroring){i._reject(t),Ut(e);return}const s=e._writableStreamController[N](i._reason);O(s,()=>{i._resolve(),Ut(e)},f=>{i._reject(f),Ut(e)})}function Ti(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}function Ai(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,gr(e,t)}function Pi(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,e._state==="erroring"&&(e._storedError=void 0,e._pendingAbortRequest!==void 0&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const i=e._writer;i!==void 0&&Rn(i)}function Ii(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,e._pendingAbortRequest!==void 0&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),gr(e,t)}function be(e){return!(e._closeRequest===void 0&&e._inFlightCloseRequest===void 0)}function Fi(e){return!(e._inFlightWriteRequest===void 0&&e._inFlightCloseRequest===void 0)}function xi(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0}function Wi(e){e._inFlightWriteRequest=e._writeRequests.shift()}function Ut(e){e._closeRequest!==void 0&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;t!==void 0&&Pr(t,e._storedError)}function Er(e,t){const i=e._writer;i!==void 0&&t!==e._backpressure&&(t?Hi(i):Fr(i)),e._backpressure=t}class ht{constructor(t){if(ue(t,1,"WritableStreamDefaultWriter"),ln(t,"First parameter"),Qe(t))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=t,t._writer=this;const i=t._state;if(i==="writable")!be(t)&&t._backpressure?Ht(this):En(this),Nt(this);else if(i==="erroring")Ir(this,t._storedError),Nt(this);else if(i==="closed")En(this),$i(this);else{const s=t._storedError;Ir(this,s),Sn(this,s)}}get closed(){return De(this)?this._closedPromise:w(ze("closed"))}get desiredSize(){if(!De(this))throw ze("desiredSize");if(this._ownerWritableStream===void 0)throw pt("desiredSize");return ki(this)}get ready(){return De(this)?this._readyPromise:w(ze("ready"))}abort(t=void 0){return De(this)?this._ownerWritableStream===void 0?w(pt("abort")):qi(this,t):w(ze("abort"))}close(){if(!De(this))return w(ze("close"));const t=this._ownerWritableStream;return t===void 0?w(pt("close")):be(t)?w(new TypeError("Cannot close an already-closing stream")):hn(this)}releaseLock(){if(!De(this))throw ze("releaseLock");this._ownerWritableStream!==void 0&&bn(this)}write(t=void 0){return De(this)?this._ownerWritableStream===void 0?w(pt("write to")):mn(this,t):w(ze("write"))}}Object.defineProperties(ht.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(ht.prototype,d.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});function De(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")?!1:e instanceof ht}function qi(e,t){const i=e._ownerWritableStream;return Mt(i,t)}function hn(e){const t=e._ownerWritableStream;return dn(t)}function Oi(e){const t=e._ownerWritableStream,i=t._state;return be(t)||i==="closed"?g(void 0):i==="errored"?w(t._storedError):hn(e)}function vi(e,t){e._closedPromiseState==="pending"?Pr(e,t):Ni(e,t)}function pn(e,t){e._readyPromiseState==="pending"?Cn(e,t):Yi(e,t)}function ki(e){const t=e._ownerWritableStream,i=t._state;return i==="errored"||i==="erroring"?null:i==="closed"?0:wn(t._writableStreamController)}function bn(e){const t=e._ownerWritableStream,i=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");pn(e,i),vi(e,i),t._writer=void 0,e._ownerWritableStream=void 0}function mn(e,t){const i=e._ownerWritableStream,s=i._writableStreamController,f=Mi(s,t);if(i!==e._ownerWritableStream)return w(pt("write to"));const m=i._state;if(m==="errored")return w(i._storedError);if(be(i)||m==="closed")return w(new TypeError("The stream is closing or closed and cannot be written to"));if(m==="erroring")return w(i._storedError);const y=Bi(i);return Ui(s,t,f),y}const yn={};class Ge{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!Cr(this))throw Ar("abortReason");return this._abortReason}get signal(){if(!Cr(this))throw Ar("signal");if(this._abortController===void 0)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(t=void 0){if(!Cr(this))throw Ar("error");this._controlledWritableStream._state==="writable"&&gn(this,t)}[N](t){const i=this._abortAlgorithm(t);return jt(this),i}[X](){Ee(this)}}Object.defineProperties(Ge.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(Ge.prototype,d.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});function Cr(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")?!1:e instanceof Ge}function _n(e,t,i,s,f,m,y,C){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,Ee(t),t._abortReason=void 0,t._abortController=Ei(),t._started=!1,t._strategySizeAlgorithm=C,t._strategyHWM=y,t._writeAlgorithm=s,t._closeAlgorithm=f,t._abortAlgorithm=m;const P=Tr(t);Er(e,P);const F=i(),W=g(F);O(W,()=>{t._started=!0,Lt(t)},q=>{t._started=!0,gr(e,q)})}function Di(e,t,i,s){const f=Object.create(Ge.prototype);let m=()=>{},y=()=>g(void 0),C=()=>g(void 0),P=()=>g(void 0);t.start!==void 0&&(m=()=>t.start(f)),t.write!==void 0&&(y=F=>t.write(F,f)),t.close!==void 0&&(C=()=>t.close()),t.abort!==void 0&&(P=F=>t.abort(F)),_n(e,f,m,y,C,P,i,s)}function jt(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function zi(e){hr(e,yn,0),Lt(e)}function Mi(e,t){try{return e._strategySizeAlgorithm(t)}catch(i){return Br(e,i),1}}function wn(e){return e._strategyHWM-e._queueTotalSize}function Ui(e,t,i){try{hr(e,t,i)}catch(f){Br(e,f);return}const s=e._controlledWritableStream;if(!be(s)&&s._state==="writable"){const f=Tr(e);Er(s,f)}Lt(e)}function Lt(e){const t=e._controlledWritableStream;if(!e._started||t._inFlightWriteRequest!==void 0)return;if(t._state==="erroring"){Rr(t);return}if(e._queue.length===0)return;const s=si(e);s===yn?ji(e):Li(e,s)}function Br(e,t){e._controlledWritableStream._state==="writable"&&gn(e,t)}function ji(e){const t=e._controlledWritableStream;xi(t),dr(e);const i=e._closeAlgorithm();jt(e),O(i,()=>{Pi(t)},s=>{Ii(t,s)})}function Li(e,t){const i=e._controlledWritableStream;Wi(i);const s=e._writeAlgorithm(t);O(s,()=>{Ti(i);const f=i._state;if(dr(e),!be(i)&&f==="writable"){const m=Tr(e);Er(i,m)}Lt(e)},f=>{i._state==="writable"&&jt(e),Ai(i,f)})}function Tr(e){return wn(e)<=0}function gn(e,t){const i=e._controlledWritableStream;jt(e),Sr(i,t)}function $t(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function Ar(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function ze(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function pt(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function Nt(e){e._closedPromise=S((t,i)=>{e._closedPromise_resolve=t,e._closedPromise_reject=i,e._closedPromiseState="pending"})}function Sn(e,t){Nt(e),Pr(e,t)}function $i(e){Nt(e),Rn(e)}function Pr(e,t){e._closedPromise_reject!==void 0&&(z(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function Ni(e,t){Sn(e,t)}function Rn(e){e._closedPromise_resolve!==void 0&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function Ht(e){e._readyPromise=S((t,i)=>{e._readyPromise_resolve=t,e._readyPromise_reject=i}),e._readyPromiseState="pending"}function Ir(e,t){Ht(e),Cn(e,t)}function En(e){Ht(e),Fr(e)}function Cn(e,t){e._readyPromise_reject!==void 0&&(z(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function Hi(e){Ht(e)}function Yi(e,t){Ir(e,t)}function Fr(e){e._readyPromise_resolve!==void 0&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}const Bn=typeof DOMException<"u"?DOMException:void 0;function Qi(e){if(!(typeof e=="function"||typeof e=="object"))return!1;try{return new e,!0}catch{return!1}}function Gi(){const e=function(i,s){this.message=i||"",this.name=s||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return e.prototype=Object.create(Error.prototype),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,configurable:!0}),e}const Vi=Qi(Bn)?Bn:Gi();function Tn(e,t,i,s,f,m){const y=Se(e),C=fn(t);e._disturbed=!0;let P=!1,F=g(void 0);return S((W,q)=>{let H;if(m!==void 0){if(H=()=>{const T=new Vi("Aborted","AbortError"),I=[];s||I.push(()=>t._state==="writable"?Mt(t,T):g(void 0)),f||I.push(()=>e._state==="readable"?de(e,T):g(void 0)),ie(()=>Promise.all(I.map(M=>M())),!0,T)},m.aborted){H();return}m.addEventListener("abort",H)}function he(){return S((T,I)=>{function M(se){se?T():k(Je(),M,I)}M(!1)})}function Je(){return P?g(!0):k(C._readyPromise,()=>S((T,I)=>{qe(y,{_chunkSteps:M=>{F=k(mn(C,M),void 0,_),T(!1)},_closeSteps:()=>T(!0),_errorSteps:I})}))}if(we(e,y._closedPromise,T=>{s?le(!0,T):ie(()=>Mt(t,T),!0,T)}),we(t,C._closedPromise,T=>{f?le(!0,T):ie(()=>de(e,T),!0,T)}),ne(e,y._closedPromise,()=>{i?le():ie(()=>Oi(C))}),be(t)||t._state==="closed"){const T=new TypeError("the destination writable stream closed before all data could be piped to it");f?le(!0,T):ie(()=>de(e,T),!0,T)}z(he());function Pe(){const T=F;return k(F,()=>T!==F?Pe():void 0)}function we(T,I,M){T._state==="errored"?M(T._storedError):V(I,M)}function ne(T,I,M){T._state==="closed"?M():L(I,M)}function ie(T,I,M){if(P)return;P=!0,t._state==="writable"&&!be(t)?L(Pe(),se):se();function se(){O(T(),()=>ge(I,M),Ze=>ge(!0,Ze))}}function le(T,I){P||(P=!0,t._state==="writable"&&!be(t)?L(Pe(),()=>ge(T,I)):ge(T,I))}function ge(T,I){bn(C),fe(y),m!==void 0&&m.removeEventListener("abort",H),T?q(I):W(void 0)}})}class Ve{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!Yt(this))throw Vt("desiredSize");return xr(this)}close(){if(!Yt(this))throw Vt("close");if(!Xe(this))throw new TypeError("The stream is not in a state that permits close");mt(this)}enqueue(t=void 0){if(!Yt(this))throw Vt("enqueue");if(!Xe(this))throw new TypeError("The stream is not in a state that permits enqueue");return Gt(this,t)}error(t=void 0){if(!Yt(this))throw Vt("error");Ce(this,t)}[je](t){Ee(this);const i=this._cancelAlgorithm(t);return Qt(this),i}[Le](t){const i=this._controlledReadableStream;if(this._queue.length>0){const s=dr(this);this._closeRequested&&this._queue.length===0?(Qt(this),yt(i)):bt(this),t._chunkSteps(s)}else at(i,t),bt(this)}}Object.defineProperties(Ve.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(Ve.prototype,d.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});function Yt(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")?!1:e instanceof Ve}function bt(e){if(!An(e))return;if(e._pulling){e._pullAgain=!0;return}e._pulling=!0;const i=e._pullAlgorithm();O(i,()=>{e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,bt(e))},s=>{Ce(e,s)})}function An(e){const t=e._controlledReadableStream;return!Xe(e)||!e._started?!1:!!(Ae(t)&&re(t)>0||xr(e)>0)}function Qt(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function mt(e){if(!Xe(e))return;const t=e._controlledReadableStream;e._closeRequested=!0,e._queue.length===0&&(Qt(e),yt(t))}function Gt(e,t){if(!Xe(e))return;const i=e._controlledReadableStream;if(Ae(i)&&re(i)>0)Re(i,t,!1);else{let s;try{s=e._strategySizeAlgorithm(t)}catch(f){throw Ce(e,f),f}try{hr(e,t,s)}catch(f){throw Ce(e,f),f}}bt(e)}function Ce(e,t){const i=e._controlledReadableStream;i._state==="readable"&&(Ee(e),Qt(e),xn(i,t))}function xr(e){const t=e._controlledReadableStream._state;return t==="errored"?null:t==="closed"?0:e._strategyHWM-e._queueTotalSize}function Xi(e){return!An(e)}function Xe(e){const t=e._controlledReadableStream._state;return!e._closeRequested&&t==="readable"}function Pn(e,t,i,s,f,m,y){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,Ee(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=y,t._strategyHWM=m,t._pullAlgorithm=s,t._cancelAlgorithm=f,e._readableStreamController=t;const C=i();O(g(C),()=>{t._started=!0,bt(t)},P=>{Ce(t,P)})}function Ji(e,t,i,s){const f=Object.create(Ve.prototype);let m=()=>{},y=()=>g(void 0),C=()=>g(void 0);t.start!==void 0&&(m=()=>t.start(f)),t.pull!==void 0&&(y=()=>t.pull(f)),t.cancel!==void 0&&(C=P=>t.cancel(P)),Pn(e,f,m,y,C,i,s)}function Vt(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function Zi(e,t){return Oe(e._readableStreamController)?eo(e):Ki(e)}function Ki(e,t){const i=Se(e);let s=!1,f=!1,m=!1,y=!1,C,P,F,W,q;const H=S(ne=>{q=ne});function he(){return s?(f=!0,g(void 0)):(s=!0,qe(i,{_chunkSteps:ie=>{Fe(()=>{f=!1;const le=ie,ge=ie;m||Gt(F._readableStreamController,le),y||Gt(W._readableStreamController,ge),s=!1,f&&he()})},_closeSteps:()=>{s=!1,m||mt(F._readableStreamController),y||mt(W._readableStreamController),(!m||!y)&&q(void 0)},_errorSteps:()=>{s=!1}}),g(void 0))}function Je(ne){if(m=!0,C=ne,y){const ie=v([C,P]),le=de(e,ie);q(le)}return H}function Pe(ne){if(y=!0,P=ne,m){const ie=v([C,P]),le=de(e,ie);q(le)}return H}function we(){}return F=Wr(we,he,Je),W=Wr(we,he,Pe),V(i._closedPromise,ne=>{Ce(F._readableStreamController,ne),Ce(W._readableStreamController,ne),(!m||!y)&&q(void 0)}),[F,W]}function eo(e){let t=Se(e),i=!1,s=!1,f=!1,m=!1,y=!1,C,P,F,W,q;const H=S(T=>{q=T});function he(T){V(T._closedPromise,I=>{T===t&&(ce(F._readableStreamController,I),ce(W._readableStreamController,I),(!m||!y)&&q(void 0))})}function Je(){ke(t)&&(fe(t),t=Se(e),he(t)),qe(t,{_chunkSteps:I=>{Fe(()=>{s=!1,f=!1;const M=I;let se=I;if(!m&&!y)try{se=Gr(I)}catch(Ze){ce(F._readableStreamController,Ze),ce(W._readableStreamController,Ze),q(de(e,Ze));return}m||qt(F._readableStreamController,M),y||qt(W._readableStreamController,se),i=!1,s?we():f&&ne()})},_closeSteps:()=>{i=!1,m||ut(F._readableStreamController),y||ut(W._readableStreamController),F._readableStreamController._pendingPullIntos.length>0&&Ot(F._readableStreamController,0),W._readableStreamController._pendingPullIntos.length>0&&Ot(W._readableStreamController,0),(!m||!y)&&q(void 0)},_errorSteps:()=>{i=!1}})}function Pe(T,I){J(t)&&(fe(t),t=on(e),he(t));const M=I?W:F,se=I?F:W;un(t,T,{_chunkSteps:Ke=>{Fe(()=>{s=!1,f=!1;const et=I?y:m;if(I?m:y)et||vt(M._readableStreamController,Ke);else{let Nn;try{Nn=Gr(Ke)}catch(Or){ce(M._readableStreamController,Or),ce(se._readableStreamController,Or),q(de(e,Or));return}et||vt(M._readableStreamController,Ke),qt(se._readableStreamController,Nn)}i=!1,s?we():f&&ne()})},_closeSteps:Ke=>{i=!1;const et=I?y:m,ir=I?m:y;et||ut(M._readableStreamController),ir||ut(se._readableStreamController),Ke!==void 0&&(et||vt(M._readableStreamController,Ke),!ir&&se._readableStreamController._pendingPullIntos.length>0&&Ot(se._readableStreamController,0)),(!et||!ir)&&q(void 0)},_errorSteps:()=>{i=!1}})}function we(){if(i)return s=!0,g(void 0);i=!0;const T=yr(F._readableStreamController);return T===null?Je():Pe(T._view,!1),g(void 0)}function ne(){if(i)return f=!0,g(void 0);i=!0;const T=yr(W._readableStreamController);return T===null?Je():Pe(T._view,!0),g(void 0)}function ie(T){if(m=!0,C=T,y){const I=v([C,P]),M=de(e,I);q(M)}return H}function le(T){if(y=!0,P=T,m){const I=v([C,P]),M=de(e,I);q(M)}return H}function ge(){}return F=Fn(ge,we,ie),W=Fn(ge,ne,le),he(t),[F,W]}function to(e,t){K(e,t);const i=e,s=i?.autoAllocateChunkSize,f=i?.cancel,m=i?.pull,y=i?.start,C=i?.type;return{autoAllocateChunkSize:s===void 0?void 0:$e(s,`${t} has member 'autoAllocateChunkSize' that`),cancel:f===void 0?void 0:ro(f,i,`${t} has member 'cancel' that`),pull:m===void 0?void 0:no(m,i,`${t} has member 'pull' that`),start:y===void 0?void 0:io(y,i,`${t} has member 'start' that`),type:C===void 0?void 0:oo(C,`${t} has member 'type' that`)}}function ro(e,t,i){return te(e,i),s=>me(e,t,[s])}function no(e,t,i){return te(e,i),s=>me(e,t,[s])}function io(e,t,i){return te(e,i),s=>xe(e,t,[s])}function oo(e,t){if(e=`${e}`,e!=="bytes")throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);return e}function ao(e,t){K(e,t);const i=e?.mode;return{mode:i===void 0?void 0:so(i,`${t} has member 'mode' that`)}}function so(e,t){if(e=`${e}`,e!=="byob")throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function uo(e,t){return K(e,t),{preventCancel:!!e?.preventCancel}}function In(e,t){K(e,t);const i=e?.preventAbort,s=e?.preventCancel,f=e?.preventClose,m=e?.signal;return m!==void 0&&lo(m,`${t} has member 'signal' that`),{preventAbort:!!i,preventCancel:!!s,preventClose:!!f,signal:m}}function lo(e,t){if(!Si(e))throw new TypeError(`${t} is not an AbortSignal.`)}function fo(e,t){K(e,t);const i=e?.readable;pe(i,"readable","ReadableWritablePair"),ot(i,`${t} has member 'readable' that`);const s=e?.writable;return pe(s,"writable","ReadableWritablePair"),ln(s,`${t} has member 'writable' that`),{readable:i,writable:s}}class Be{constructor(t={},i={}){t===void 0?t=null:Pt(t,"First parameter");const s=zt(i,"Second parameter"),f=to(t,"First parameter");if(qr(this),f.type==="bytes"){if(s.size!==void 0)throw new RangeError("The strategy for a byte stream cannot have a size function");const m=ct(s,0);di(this,f,m)}else{const m=Dt(s),y=ct(s,1);Ji(this,f,y,m)}}get locked(){if(!Te(this))throw Me("locked");return Ae(this)}cancel(t=void 0){return Te(this)?Ae(this)?w(new TypeError("Cannot cancel a stream that already has a reader")):de(this,t):w(Me("cancel"))}getReader(t=void 0){if(!Te(this))throw Me("getReader");return ao(t,"First parameter").mode===void 0?Se(this):on(this)}pipeThrough(t,i={}){if(!Te(this))throw Me("pipeThrough");ue(t,1,"pipeThrough");const s=fo(t,"First parameter"),f=In(i,"Second parameter");if(Ae(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(Qe(s.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");const m=Tn(this,s.writable,f.preventClose,f.preventAbort,f.preventCancel,f.signal);return z(m),s.readable}pipeTo(t,i={}){if(!Te(this))return w(Me("pipeTo"));if(t===void 0)return w("Parameter 1 is required in 'pipeTo'.");if(!Ye(t))return w(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let s;try{s=In(i,"Second parameter")}catch(f){return w(f)}return Ae(this)?w(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):Qe(t)?w(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):Tn(this,t,s.preventClose,s.preventAbort,s.preventCancel,s.signal)}tee(){if(!Te(this))throw Me("tee");const t=Zi(this);return v(t)}values(t=void 0){if(!Te(this))throw Me("values");const i=uo(t,"First parameter");return l(this,i.preventCancel)}}Object.defineProperties(Be.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(Be.prototype,d.toStringTag,{value:"ReadableStream",configurable:!0}),typeof d.asyncIterator=="symbol"&&Object.defineProperty(Be.prototype,d.asyncIterator,{value:Be.prototype.values,writable:!0,configurable:!0});function Wr(e,t,i,s=1,f=()=>1){const m=Object.create(Be.prototype);qr(m);const y=Object.create(Ve.prototype);return Pn(m,y,e,t,i,s,f),m}function Fn(e,t,i){const s=Object.create(Be.prototype);qr(s);const f=Object.create(He.prototype);return nn(s,f,e,t,i,0,void 0),s}function qr(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function Te(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")?!1:e instanceof Be}function Ae(e){return e._reader!==void 0}function de(e,t){if(e._disturbed=!0,e._state==="closed")return g(void 0);if(e._state==="errored")return w(e._storedError);yt(e);const i=e._reader;i!==void 0&&ke(i)&&(i._readIntoRequests.forEach(f=>{f._closeSteps(void 0)}),i._readIntoRequests=new ae);const s=e._readableStreamController[je](t);return ee(s,_)}function yt(e){e._state="closed";const t=e._reader;t!==void 0&&(Ct(t),J(t)&&(t._readRequests.forEach(i=>{i._closeSteps()}),t._readRequests=new ae))}function xn(e,t){e._state="errored",e._storedError=t;const i=e._reader;i!==void 0&&(nt(i,t),J(i)?(i._readRequests.forEach(s=>{s._errorSteps(t)}),i._readRequests=new ae):(i._readIntoRequests.forEach(s=>{s._errorSteps(t)}),i._readIntoRequests=new ae))}function Me(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function Wn(e,t){K(e,t);const i=e?.highWaterMark;return pe(i,"highWaterMark","QueuingStrategyInit"),{highWaterMark:_e(i)}}const qn=e=>e.byteLength;try{Object.defineProperty(qn,"name",{value:"size",configurable:!0})}catch{}class Xt{constructor(t){ue(t,1,"ByteLengthQueuingStrategy"),t=Wn(t,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=t.highWaterMark}get highWaterMark(){if(!vn(this))throw On("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!vn(this))throw On("size");return qn}}Object.defineProperties(Xt.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(Xt.prototype,d.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});function On(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function vn(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")?!1:e instanceof Xt}const kn=()=>1;try{Object.defineProperty(kn,"name",{value:"size",configurable:!0})}catch{}class Jt{constructor(t){ue(t,1,"CountQueuingStrategy"),t=Wn(t,"First parameter"),this._countQueuingStrategyHighWaterMark=t.highWaterMark}get highWaterMark(){if(!zn(this))throw Dn("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!zn(this))throw Dn("size");return kn}}Object.defineProperties(Jt.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(Jt.prototype,d.toStringTag,{value:"CountQueuingStrategy",configurable:!0});function Dn(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function zn(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")?!1:e instanceof Jt}function co(e,t){K(e,t);const i=e?.flush,s=e?.readableType,f=e?.start,m=e?.transform,y=e?.writableType;return{flush:i===void 0?void 0:ho(i,e,`${t} has member 'flush' that`),readableType:s,start:f===void 0?void 0:po(f,e,`${t} has member 'start' that`),transform:m===void 0?void 0:bo(m,e,`${t} has member 'transform' that`),writableType:y}}function ho(e,t,i){return te(e,i),s=>me(e,t,[s])}function po(e,t,i){return te(e,i),s=>xe(e,t,[s])}function bo(e,t,i){return te(e,i),(s,f)=>me(e,t,[s,f])}class Zt{constructor(t={},i={},s={}){t===void 0&&(t=null);const f=zt(i,"Second parameter"),m=zt(s,"Third parameter"),y=co(t,"First parameter");if(y.readableType!==void 0)throw new RangeError("Invalid readableType specified");if(y.writableType!==void 0)throw new RangeError("Invalid writableType specified");const C=ct(m,0),P=Dt(m),F=ct(f,1),W=Dt(f);let q;const H=S(he=>{q=he});mo(this,H,F,W,C,P),_o(this,y),y.start!==void 0?q(y.start(this._transformStreamController)):q(void 0)}get readable(){if(!Mn(this))throw $n("readable");return this._readable}get writable(){if(!Mn(this))throw $n("writable");return this._writable}}Object.defineProperties(Zt.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(Zt.prototype,d.toStringTag,{value:"TransformStream",configurable:!0});function mo(e,t,i,s,f,m){function y(){return t}function C(H){return So(e,H)}function P(H){return Ro(e,H)}function F(){return Eo(e)}e._writable=Ci(y,C,F,P,i,s);function W(){return Co(e)}function q(H){return er(e,H),g(void 0)}e._readable=Wr(y,W,q,f,m),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,tr(e,!0),e._transformStreamController=void 0}function Mn(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")?!1:e instanceof Zt}function Kt(e,t){Ce(e._readable._readableStreamController,t),er(e,t)}function er(e,t){Un(e._transformStreamController),Br(e._writable._writableStreamController,t),e._backpressure&&tr(e,!1)}function tr(e,t){e._backpressureChangePromise!==void 0&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=S(i=>{e._backpressureChangePromise_resolve=i}),e._backpressure=t}class _t{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!rr(this))throw nr("desiredSize");const t=this._controlledTransformStream._readable._readableStreamController;return xr(t)}enqueue(t=void 0){if(!rr(this))throw nr("enqueue");jn(this,t)}error(t=void 0){if(!rr(this))throw nr("error");wo(this,t)}terminate(){if(!rr(this))throw nr("terminate");go(this)}}Object.defineProperties(_t.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),typeof d.toStringTag=="symbol"&&Object.defineProperty(_t.prototype,d.toStringTag,{value:"TransformStreamDefaultController",configurable:!0});function rr(e){return!c(e)||!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")?!1:e instanceof _t}function yo(e,t,i,s){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=i,t._flushAlgorithm=s}function _o(e,t){const i=Object.create(_t.prototype);let s=m=>{try{return jn(i,m),g(void 0)}catch(y){return w(y)}},f=()=>g(void 0);t.transform!==void 0&&(s=m=>t.transform(m,i)),t.flush!==void 0&&(f=()=>t.flush(i)),yo(e,i,s,f)}function Un(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function jn(e,t){const i=e._controlledTransformStream,s=i._readable._readableStreamController;if(!Xe(s))throw new TypeError("Readable side is not in a state that permits enqueue");try{Gt(s,t)}catch(m){throw er(i,m),i._readable._storedError}Xi(s)!==i._backpressure&&tr(i,!0)}function wo(e,t){Kt(e._controlledTransformStream,t)}function Ln(e,t){const i=e._transformAlgorithm(t);return ee(i,void 0,s=>{throw Kt(e._controlledTransformStream,s),s})}function go(e){const t=e._controlledTransformStream,i=t._readable._readableStreamController;mt(i);const s=new TypeError("TransformStream terminated");er(t,s)}function So(e,t){const i=e._transformStreamController;if(e._backpressure){const s=e._backpressureChangePromise;return ee(s,()=>{const f=e._writable;if(f._state==="erroring")throw f._storedError;return Ln(i,t)})}return Ln(i,t)}function Ro(e,t){return Kt(e,t),g(void 0)}function Eo(e){const t=e._readable,i=e._transformStreamController,s=i._flushAlgorithm();return Un(i),ee(s,()=>{if(t._state==="errored")throw t._storedError;mt(t._readableStreamController)},f=>{throw Kt(e,f),t._storedError})}function Co(e){return tr(e,!1),e._backpressureChangePromise}function nr(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function $n(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}p.ByteLengthQueuingStrategy=Xt,p.CountQueuingStrategy=Jt,p.ReadableByteStreamController=He,p.ReadableStream=Be,p.ReadableStreamBYOBReader=ft,p.ReadableStreamBYOBRequest=st,p.ReadableStreamDefaultController=Ve,p.ReadableStreamDefaultReader=We,p.TransformStream=Zt,p.TransformStreamDefaultController=_t,p.WritableStream=dt,p.WritableStreamDefaultController=Ge,p.WritableStreamDefaultWriter=ht,Object.defineProperty(p,"__esModule",{value:!0})})}(or,or.exports)),or.exports}var kr={},wt={},Gn;function Io(){if(Gn)return wt;Gn=1,wt.byteLength=c,wt.toByteArray=Q,wt.fromByteArray=G;for(var B=[],u=[],p=typeof Uint8Array<"u"?Uint8Array:Array,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_=0,R=d.length;_0)throw new Error("Invalid string. Length must be a multiple of 4");var w=S.indexOf("=");w===-1&&(w=g);var k=w===g?0:4-w%4;return[w,k]}function c(S){var g=E(S),w=g[0],k=g[1];return(w+k)*3/4-k}function Y(S,g,w){return(g+w)*3/4-w}function Q(S){var g,w=E(S),k=w[0],O=w[1],L=new p(Y(S,k,O)),V=0,ee=O>0?k-4:k,z;for(z=0;z>16&255,L[V++]=g>>8&255,L[V++]=g&255;return O===2&&(g=u[S.charCodeAt(z)]<<2|u[S.charCodeAt(z+1)]>>4,L[V++]=g&255),O===1&&(g=u[S.charCodeAt(z)]<<10|u[S.charCodeAt(z+1)]<<4|u[S.charCodeAt(z+2)]>>2,L[V++]=g>>8&255,L[V++]=g&255),L}function U(S){return B[S>>18&63]+B[S>>12&63]+B[S>>6&63]+B[S&63]}function j(S,g,w){for(var k,O=[],L=g;Lee?ee:V+L));return k===1?(g=S[w-1],O.push(B[g>>2]+B[g<<4&63]+"==")):k===2&&(g=(S[w-2]<<8)+S[w-1],O.push(B[g>>10]+B[g>>4&63]+B[g<<2&63]+"=")),O.join("")}return wt}var ar={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */var Vn;function Fo(){return Vn||(Vn=1,ar.read=function(B,u,p,d,_){var R,E,c=_*8-d-1,Y=(1<>1,U=-7,j=p?_-1:0,G=p?-1:1,S=B[u+j];for(j+=G,R=S&(1<<-U)-1,S>>=-U,U+=c;U>0;R=R*256+B[u+j],j+=G,U-=8);for(E=R&(1<<-U)-1,R>>=-U,U+=d;U>0;E=E*256+B[u+j],j+=G,U-=8);if(R===0)R=1-Q;else{if(R===Y)return E?NaN:(S?-1:1)*(1/0);E=E+Math.pow(2,d),R=R-Q}return(S?-1:1)*E*Math.pow(2,R-d)},ar.write=function(B,u,p,d,_,R){var E,c,Y,Q=R*8-_-1,U=(1<>1,G=_===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=d?0:R-1,g=d?1:-1,w=u<0||u===0&&1/u<0?1:0;for(u=Math.abs(u),isNaN(u)||u===1/0?(c=isNaN(u)?1:0,E=U):(E=Math.floor(Math.log(u)/Math.LN2),u*(Y=Math.pow(2,-E))<1&&(E--,Y*=2),E+j>=1?u+=G/Y:u+=G*Math.pow(2,1-j),u*Y>=2&&(E++,Y/=2),E+j>=U?(c=0,E=U):E+j>=1?(c=(u*Y-1)*Math.pow(2,_),E=E+j):(c=u*Math.pow(2,j-1)*Math.pow(2,_),E=0));_>=8;B[p+S]=c&255,S+=g,c/=256,_-=8);for(E=E<<_|c,Q+=_;Q>0;B[p+S]=E&255,S+=g,E/=256,Q-=8);B[p+S-g]|=w*128}),ar}/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh diff --git a/app.js b/app.js index 194e88c3..6a5ab4b5 100644 --- a/app.js +++ b/app.js @@ -1,4 +1,4 @@ -import{g as Xt,F as V,M as dn,K as mn,a as Ht,I as vn,t as En,O as ie,l as gn,C as ut,b as wn,R as $n,T as yn,D as ft,U as Rn,B as In,c as Tn,A as pt,i as Sn,d as dt,e as Ln,f as mt,h as An,E as Nn,j as vt,k as On,m as xn,W as Et,n as bn}from"./ChartManager-b5a8bd39.js";var qe={exports:{}};const Cn="2.0.0",Bt=256,_n=Number.MAX_SAFE_INTEGER||9007199254740991,Pn=16,Dn=Bt-6,jn=["major","premajor","minor","preminor","patch","prepatch","prerelease"];var Ae={MAX_LENGTH:Bt,MAX_SAFE_COMPONENT_LENGTH:Pn,MAX_SAFE_BUILD_LENGTH:Dn,MAX_SAFE_INTEGER:_n,RELEASE_TYPES:jn,SEMVER_SPEC_VERSION:Cn,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2};const Fn=typeof process=="object"&&process.env&&{}.NODE_DEBUG&&/\bsemver\b/i.test({}.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{};var Ne=Fn;(function(n,e){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:s,MAX_LENGTH:o}=Ae,a=Ne;e=n.exports={};const d=e.re=[],E=e.safeRe=[],c=e.src=[],u=e.t={};let m=0;const $="[a-zA-Z0-9-]",_=[["\\s",1],["\\d",o],[$,s]],y=Y=>{for(const[U,J]of _)Y=Y.split(`${U}*`).join(`${U}{0,${J}}`).split(`${U}+`).join(`${U}{1,${J}}`);return Y},S=(Y,U,J)=>{const G=y(U),Q=m++;a(Y,Q,U),u[Y]=Q,c[Q]=U,d[Q]=new RegExp(U,J?"g":void 0),E[Q]=new RegExp(G,J?"g":void 0)};S("NUMERICIDENTIFIER","0|[1-9]\\d*"),S("NUMERICIDENTIFIERLOOSE","\\d+"),S("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${$}*`),S("MAINVERSION",`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),S("MAINVERSIONLOOSE",`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),S("PRERELEASEIDENTIFIER",`(?:${c[u.NUMERICIDENTIFIER]}|${c[u.NONNUMERICIDENTIFIER]})`),S("PRERELEASEIDENTIFIERLOOSE",`(?:${c[u.NUMERICIDENTIFIERLOOSE]}|${c[u.NONNUMERICIDENTIFIER]})`),S("PRERELEASE",`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),S("PRERELEASELOOSE",`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),S("BUILDIDENTIFIER",`${$}+`),S("BUILD",`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),S("FULLPLAIN",`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),S("FULL",`^${c[u.FULLPLAIN]}$`),S("LOOSEPLAIN",`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),S("LOOSE",`^${c[u.LOOSEPLAIN]}$`),S("GTLT","((?:<|>)?=?)"),S("XRANGEIDENTIFIERLOOSE",`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),S("XRANGEIDENTIFIER",`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),S("XRANGEPLAIN",`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),S("XRANGEPLAINLOOSE",`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),S("XRANGE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),S("XRANGELOOSE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),S("COERCE",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?(?:$|[^\\d])`),S("COERCERTL",c[u.COERCE],!0),S("LONETILDE","(?:~>?)"),S("TILDETRIM",`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",S("TILDE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),S("TILDELOOSE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),S("LONECARET","(?:\\^)"),S("CARETTRIM",`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",S("CARET",`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),S("CARETLOOSE",`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),S("COMPARATORLOOSE",`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),S("COMPARATOR",`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),S("COMPARATORTRIM",`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",S("HYPHENRANGE",`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),S("HYPHENRANGELOOSE",`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),S("STAR","(<|>)?=?\\s*\\*"),S("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),S("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(qe,qe.exports);var Ee=qe.exports;const Gn=Object.freeze({loose:!0}),Mn=Object.freeze({}),Wn=n=>n?typeof n!="object"?Gn:n:Mn;var Ye=Wn;const gt=/^[0-9]+$/,qt=(n,e)=>{const t=gt.test(n),s=gt.test(e);return t&&s&&(n=+n,e=+e),n===e?0:t&&!s?-1:s&&!t?1:nqt(e,n);var Yt={compareIdentifiers:qt,rcompareIdentifiers:Vn};const Re=Ne,{MAX_LENGTH:wt,MAX_SAFE_INTEGER:Ie}=Ae,{safeRe:$t,t:yt}=Ee,Un=Ye,{compareIdentifiers:he}=Yt;let Xn=class ee{constructor(e,t){if(t=Un(t),e instanceof ee){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>wt)throw new TypeError(`version is longer than ${wt} characters`);Re("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const s=e.trim().match(t.loose?$t[yt.LOOSE]:$t[yt.FULL]);if(!s)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>Ie||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Ie||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Ie||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map(o=>{if(/^[0-9]+$/.test(o)){const a=+o;if(a>=0&&a=0;)typeof this.prerelease[a]=="number"&&(this.prerelease[a]++,a=-2);if(a===-1){if(t===this.prerelease.join(".")&&s===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(o)}}if(t){let a=[t,o];s===!1&&(a=[t]),he(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=a):this.prerelease=a}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};var H=Xn;const Rt=H,Hn=(n,e,t=!1)=>{if(n instanceof Rt)return n;try{return new Rt(n,e)}catch(s){if(!t)return null;throw s}};var pe=Hn;const Bn=pe,qn=(n,e)=>{const t=Bn(n,e);return t?t.version:null};var Yn=qn;const zn=pe,kn=(n,e)=>{const t=zn(n.trim().replace(/^[=v]+/,""),e);return t?t.version:null};var Kn=kn;const It=H,Zn=(n,e,t,s,o)=>{typeof t=="string"&&(o=s,s=t,t=void 0);try{return new It(n instanceof It?n.version:n,t).inc(e,s,o).version}catch{return null}};var Jn=Zn;const Tt=pe,Qn=(n,e)=>{const t=Tt(n,null,!0),s=Tt(e,null,!0),o=t.compare(s);if(o===0)return null;const a=o>0,d=a?t:s,E=a?s:t,c=!!d.prerelease.length;if(!!E.prerelease.length&&!c)return!E.patch&&!E.minor?"major":d.patch?"patch":d.minor?"minor":"major";const m=c?"pre":"";return t.major!==s.major?m+"major":t.minor!==s.minor?m+"minor":t.patch!==s.patch?m+"patch":"prerelease"};var er=Qn;const tr=H,nr=(n,e)=>new tr(n,e).major;var rr=nr;const sr=H,ir=(n,e)=>new sr(n,e).minor;var or=ir;const ar=H,lr=(n,e)=>new ar(n,e).patch;var cr=lr;const hr=pe,ur=(n,e)=>{const t=hr(n,e);return t&&t.prerelease.length?t.prerelease:null};var fr=ur;const St=H,pr=(n,e,t)=>new St(n,t).compare(new St(e,t));var K=pr;const dr=K,mr=(n,e,t)=>dr(e,n,t);var vr=mr;const Er=K,gr=(n,e)=>Er(n,e,!0);var wr=gr;const Lt=H,$r=(n,e,t)=>{const s=new Lt(n,t),o=new Lt(e,t);return s.compare(o)||s.compareBuild(o)};var ze=$r;const yr=ze,Rr=(n,e)=>n.sort((t,s)=>yr(t,s,e));var Ir=Rr;const Tr=ze,Sr=(n,e)=>n.sort((t,s)=>Tr(s,t,e));var Lr=Sr;const Ar=K,Nr=(n,e,t)=>Ar(n,e,t)>0;var Oe=Nr;const Or=K,xr=(n,e,t)=>Or(n,e,t)<0;var ke=xr;const br=K,Cr=(n,e,t)=>br(n,e,t)===0;var zt=Cr;const _r=K,Pr=(n,e,t)=>_r(n,e,t)!==0;var kt=Pr;const Dr=K,jr=(n,e,t)=>Dr(n,e,t)>=0;var Ke=jr;const Fr=K,Gr=(n,e,t)=>Fr(n,e,t)<=0;var Ze=Gr;const Mr=zt,Wr=kt,Vr=Oe,Ur=Ke,Xr=ke,Hr=Ze,Br=(n,e,t,s)=>{switch(e){case"===":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n===t;case"!==":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n!==t;case"":case"=":case"==":return Mr(n,t,s);case"!=":return Wr(n,t,s);case">":return Vr(n,t,s);case">=":return Ur(n,t,s);case"<":return Xr(n,t,s);case"<=":return Hr(n,t,s);default:throw new TypeError(`Invalid operator: ${e}`)}};var Kt=Br;const qr=H,Yr=pe,{safeRe:Te,t:Se}=Ee,zr=(n,e)=>{if(n instanceof qr)return n;if(typeof n=="number"&&(n=String(n)),typeof n!="string")return null;e=e||{};let t=null;if(!e.rtl)t=n.match(Te[Se.COERCE]);else{let s;for(;(s=Te[Se.COERCERTL].exec(n))&&(!t||t.index+t[0].length!==n.length);)(!t||s.index+s[0].length!==t.index+t[0].length)&&(t=s),Te[Se.COERCERTL].lastIndex=s.index+s[1].length+s[2].length;Te[Se.COERCERTL].lastIndex=-1}return t===null?null:Yr(`${t[2]}.${t[3]||"0"}.${t[4]||"0"}`,e)};var kr=zr,Ge,At;function Kr(){return At||(At=1,Ge=function(n){n.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}),Ge}var Zr=O;O.Node=le;O.create=O;function O(n){var e=this;if(e instanceof O||(e=new O),e.tail=null,e.head=null,e.length=0,n&&typeof n.forEach=="function")n.forEach(function(o){e.push(o)});else if(arguments.length>0)for(var t=0,s=arguments.length;t1)t=e;else if(this.head)s=this.head.next,t=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var o=0;s!==null;o++)t=n(t,s.value,o),s=s.next;return t};O.prototype.reduceReverse=function(n,e){var t,s=this.tail;if(arguments.length>1)t=e;else if(this.tail)s=this.tail.prev,t=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var o=this.length-1;s!==null;o--)t=n(t,s.value,o),s=s.prev;return t};O.prototype.toArray=function(){for(var n=new Array(this.length),e=0,t=this.head;t!==null;e++)n[e]=t.value,t=t.next;return n};O.prototype.toArrayReverse=function(){for(var n=new Array(this.length),e=0,t=this.tail;t!==null;e++)n[e]=t.value,t=t.prev;return n};O.prototype.slice=function(n,e){e=e||this.length,e<0&&(e+=this.length),n=n||0,n<0&&(n+=this.length);var t=new O;if(ethis.length&&(e=this.length);for(var s=0,o=this.head;o!==null&&sthis.length&&(e=this.length);for(var s=this.length,o=this.tail;o!==null&&s>e;s--)o=o.prev;for(;o!==null&&s>n;s--,o=o.prev)t.push(o.value);return t};O.prototype.splice=function(n,e,...t){n>this.length&&(n=this.length-1),n<0&&(n=this.length+n);for(var s=0,o=this.head;o!==null&&s1;class ns{constructor(e){if(typeof e=="number"&&(e={max:e}),e||(e={}),e.max&&(typeof e.max!="number"||e.max<0))throw new TypeError("max must be a non-negative number");this[oe]=e.max||1/0;const t=e.length||Me;if(this[ue]=typeof t!="function"?Me:t,this[ve]=e.stale||!1,e.maxAge&&typeof e.maxAge!="number")throw new TypeError("maxAge must be a number");this[ae]=e.maxAge||0,this[te]=e.dispose,this[Nt]=e.noDisposeOnSet||!1,this[Zt]=e.updateAgeOnGet||!1,this.reset()}set max(e){if(typeof e!="number"||e<0)throw new TypeError("max must be a non-negative number");this[oe]=e||1/0,de(this)}get max(){return this[oe]}set allowStale(e){this[ve]=!!e}get allowStale(){return this[ve]}set maxAge(e){if(typeof e!="number")throw new TypeError("maxAge must be a non-negative number");this[ae]=e,de(this)}get maxAge(){return this[ae]}set lengthCalculator(e){typeof e!="function"&&(e=Me),e!==this[ue]&&(this[ue]=e,this[ne]=0,this[M].forEach(t=>{t.length=this[ue](t.value,t.key),this[ne]+=t.length})),de(this)}get lengthCalculator(){return this[ue]}get length(){return this[ne]}get itemCount(){return this[M].length}rforEach(e,t){t=t||this;for(let s=this[M].tail;s!==null;){const o=s.prev;Ot(this,e,s,t),s=o}}forEach(e,t){t=t||this;for(let s=this[M].head;s!==null;){const o=s.next;Ot(this,e,s,t),s=o}}keys(){return this[M].toArray().map(e=>e.key)}values(){return this[M].toArray().map(e=>e.value)}reset(){this[te]&&this[M]&&this[M].length&&this[M].forEach(e=>this[te](e.key,e.value)),this[k]=new Map,this[M]=new ts,this[ne]=0}dump(){return this[M].map(e=>Le(this,e)?!1:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[M]}set(e,t,s){if(s=s||this[ae],s&&typeof s!="number")throw new TypeError("maxAge must be a number");const o=s?Date.now():0,a=this[ue](t,e);if(this[k].has(e)){if(a>this[oe])return fe(this,this[k].get(e)),!1;const c=this[k].get(e).value;return this[te]&&(this[Nt]||this[te](e,c.value)),c.now=o,c.maxAge=s,c.value=t,this[ne]+=a-c.length,c.length=a,this.get(e),de(this),!0}const d=new rs(e,t,a,o,s);return d.length>this[oe]?(this[te]&&this[te](e,t),!1):(this[ne]+=d.length,this[M].unshift(d),this[k].set(e,this[M].head),de(this),!0)}has(e){if(!this[k].has(e))return!1;const t=this[k].get(e).value;return!Le(this,t)}get(e){return We(this,e,!0)}peek(e){return We(this,e,!1)}pop(){const e=this[M].tail;return e?(fe(this,e),e.value):null}del(e){fe(this,this[k].get(e))}load(e){this.reset();const t=Date.now();for(let s=e.length-1;s>=0;s--){const o=e[s],a=o.e||0;if(a===0)this.set(o.k,o.v);else{const d=a-t;d>0&&this.set(o.k,o.v,d)}}}prune(){this[k].forEach((e,t)=>We(this,t,!1))}}const We=(n,e,t)=>{const s=n[k].get(e);if(s){const o=s.value;if(Le(n,o)){if(fe(n,s),!n[ve])return}else t&&(n[Zt]&&(s.value.now=Date.now()),n[M].unshiftNode(s));return o.value}},Le=(n,e)=>{if(!e||!e.maxAge&&!n[ae])return!1;const t=Date.now()-e.now;return e.maxAge?t>e.maxAge:n[ae]&&t>n[ae]},de=n=>{if(n[ne]>n[oe])for(let e=n[M].tail;n[ne]>n[oe]&&e!==null;){const t=e.prev;fe(n,e),e=t}},fe=(n,e)=>{if(e){const t=e.value;n[te]&&n[te](t.key,t.value),n[ne]-=t.length,n[k].delete(t.key),n[M].removeNode(e)}};class rs{constructor(e,t,s,o,a){this.key=e,this.value=t,this.length=s,this.now=o,this.maxAge=a||0}}const Ot=(n,e,t,s)=>{let o=t.value;Le(n,o)&&(fe(n,t),n[ve]||(o=void 0)),o&&e.call(s,o.value,o.key,n)};var ss=ns,Ve,xt;function Z(){if(xt)return Ve;xt=1;class n{constructor(p,L){if(L=s(L),p instanceof n)return p.loose===!!L.loose&&p.includePrerelease===!!L.includePrerelease?p:new n(p.raw,L);if(p instanceof o)return this.raw=p.value,this.set=[[p]],this.format(),this;if(this.options=L,this.loose=!!L.loose,this.includePrerelease=!!L.includePrerelease,this.raw=p.trim().split(/\s+/).join(" "),this.set=this.raw.split("||").map(R=>this.parseRange(R.trim())).filter(R=>R.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const R=this.set[0];if(this.set=this.set.filter(I=>!S(I[0])),this.set.length===0)this.set=[R];else if(this.set.length>1){for(const I of this.set)if(I.length===1&&Y(I[0])){this.set=[I];break}}}this.format()}format(){return this.range=this.set.map(p=>p.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(p){const R=((this.options.includePrerelease&&_)|(this.options.loose&&y))+":"+p,I=t.get(R);if(I)return I;const g=this.options.loose,A=g?E[c.HYPHENRANGELOOSE]:E[c.HYPHENRANGE];p=p.replace(A,De(this.options.includePrerelease)),a("hyphen replace",p),p=p.replace(E[c.COMPARATORTRIM],u),a("comparator trim",p),p=p.replace(E[c.TILDETRIM],m),a("tilde trim",p),p=p.replace(E[c.CARETTRIM],$),a("caret trim",p);let x=p.split(" ").map(D=>J(D,this.options)).join(" ").split(/\s+/).map(D=>Pe(D,this.options));g&&(x=x.filter(D=>(a("loose invalid filter",D,this.options),!!D.match(E[c.COMPARATORLOOSE])))),a("range list",x);const N=new Map,P=x.map(D=>new o(D,this.options));for(const D of P){if(S(D))return[D];N.set(D.value,D)}N.size>1&&N.has("")&&N.delete("");const W=[...N.values()];return t.set(R,W),W}intersects(p,L){if(!(p instanceof n))throw new TypeError("a Range is required");return this.set.some(R=>U(R,L)&&p.set.some(I=>U(I,L)&&R.every(g=>I.every(A=>g.intersects(A,L)))))}test(p){if(!p)return!1;if(typeof p=="string")try{p=new d(p,this.options)}catch{return!1}for(let L=0;Lv.value==="<0.0.0-0",Y=v=>v.value==="",U=(v,p)=>{let L=!0;const R=v.slice();let I=R.pop();for(;L&&R.length;)L=R.every(g=>I.intersects(g,p)),I=R.pop();return L},J=(v,p)=>(a("comp",v,p),v=Ce(v,p),a("caret",v),v=Q(v,p),a("tildes",v),v=B(v,p),a("xrange",v),v=_e(v,p),a("stars",v),v),G=v=>!v||v.toLowerCase()==="x"||v==="*",Q=(v,p)=>v.trim().split(/\s+/).map(L=>q(L,p)).join(" "),q=(v,p)=>{const L=p.loose?E[c.TILDELOOSE]:E[c.TILDE];return v.replace(L,(R,I,g,A,x)=>{a("tilde",v,R,I,g,A,x);let N;return G(I)?N="":G(g)?N=`>=${I}.0.0 <${+I+1}.0.0-0`:G(A)?N=`>=${I}.${g}.0 <${I}.${+g+1}.0-0`:x?(a("replaceTilde pr",x),N=`>=${I}.${g}.${A}-${x} <${I}.${+g+1}.0-0`):N=`>=${I}.${g}.${A} <${I}.${+g+1}.0-0`,a("tilde return",N),N})},Ce=(v,p)=>v.trim().split(/\s+/).map(L=>ge(L,p)).join(" "),ge=(v,p)=>{a("caret",v,p);const L=p.loose?E[c.CARETLOOSE]:E[c.CARET],R=p.includePrerelease?"-0":"";return v.replace(L,(I,g,A,x,N)=>{a("caret",v,I,g,A,x,N);let P;return G(g)?P="":G(A)?P=`>=${g}.0.0${R} <${+g+1}.0.0-0`:G(x)?g==="0"?P=`>=${g}.${A}.0${R} <${g}.${+A+1}.0-0`:P=`>=${g}.${A}.0${R} <${+g+1}.0.0-0`:N?(a("replaceCaret pr",N),g==="0"?A==="0"?P=`>=${g}.${A}.${x}-${N} <${g}.${A}.${+x+1}-0`:P=`>=${g}.${A}.${x}-${N} <${g}.${+A+1}.0-0`:P=`>=${g}.${A}.${x}-${N} <${+g+1}.0.0-0`):(a("no pr"),g==="0"?A==="0"?P=`>=${g}.${A}.${x}${R} <${g}.${A}.${+x+1}-0`:P=`>=${g}.${A}.${x}${R} <${g}.${+A+1}.0-0`:P=`>=${g}.${A}.${x} <${+g+1}.0.0-0`),a("caret return",P),P})},B=(v,p)=>(a("replaceXRanges",v,p),v.split(/\s+/).map(L=>we(L,p)).join(" ")),we=(v,p)=>{v=v.trim();const L=p.loose?E[c.XRANGELOOSE]:E[c.XRANGE];return v.replace(L,(R,I,g,A,x,N)=>{a("xRange",v,R,I,g,A,x,N);const P=G(g),W=P||G(A),D=W||G(x),re=D;return I==="="&&re&&(I=""),N=p.includePrerelease?"-0":"",P?I===">"||I==="<"?R="<0.0.0-0":R="*":I&&re?(W&&(A=0),x=0,I===">"?(I=">=",W?(g=+g+1,A=0,x=0):(A=+A+1,x=0)):I==="<="&&(I="<",W?g=+g+1:A=+A+1),I==="<"&&(N="-0"),R=`${I+g}.${A}.${x}${N}`):W?R=`>=${g}.0.0${N} <${+g+1}.0.0-0`:D&&(R=`>=${g}.${A}.0${N} <${g}.${+A+1}.0-0`),a("xRange return",R),R})},_e=(v,p)=>(a("replaceStars",v,p),v.trim().replace(E[c.STAR],"")),Pe=(v,p)=>(a("replaceGTE0",v,p),v.trim().replace(E[p.includePrerelease?c.GTE0PRE:c.GTE0],"")),De=v=>(p,L,R,I,g,A,x,N,P,W,D,re,tt)=>(G(R)?L="":G(I)?L=`>=${R}.0.0${v?"-0":""}`:G(g)?L=`>=${R}.${I}.0${v?"-0":""}`:A?L=`>=${L}`:L=`>=${L}${v?"-0":""}`,G(P)?N="":G(W)?N=`<${+P+1}.0.0-0`:G(D)?N=`<${P}.${+W+1}.0-0`:re?N=`<=${P}.${W}.${D}-${re}`:v?N=`<${P}.${W}.${+D+1}-0`:N=`<=${N}`,`${L} ${N}`.trim()),$e=(v,p,L)=>{for(let R=0;R0){const I=v[R].semver;if(I.major===p.major&&I.minor===p.minor&&I.patch===p.patch)return!0}return!1}return!0};return Ve}var Ue,bt;function xe(){if(bt)return Ue;bt=1;const n=Symbol("SemVer ANY");class e{static get ANY(){return n}constructor(m,$){if($=t($),m instanceof e){if(m.loose===!!$.loose)return m;m=m.value}m=m.trim().split(/\s+/).join(" "),d("comparator",m,$),this.options=$,this.loose=!!$.loose,this.parse(m),this.semver===n?this.value="":this.value=this.operator+this.semver.version,d("comp",this)}parse(m){const $=this.options.loose?s[o.COMPARATORLOOSE]:s[o.COMPARATOR],_=m.match($);if(!_)throw new TypeError(`Invalid comparator: ${m}`);this.operator=_[1]!==void 0?_[1]:"",this.operator==="="&&(this.operator=""),_[2]?this.semver=new E(_[2],this.options.loose):this.semver=n}toString(){return this.value}test(m){if(d("Comparator.test",m,this.options.loose),this.semver===n||m===n)return!0;if(typeof m=="string")try{m=new E(m,this.options)}catch{return!1}return a(m,this.operator,this.semver,this.options)}intersects(m,$){if(!(m instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new c(m.value,$).test(this.value):m.operator===""?m.value===""?!0:new c(this.value,$).test(m.semver):($=t($),$.includePrerelease&&(this.value==="<0.0.0-0"||m.value==="<0.0.0-0")||!$.includePrerelease&&(this.value.startsWith("<0.0.0")||m.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&m.operator.startsWith(">")||this.operator.startsWith("<")&&m.operator.startsWith("<")||this.semver.version===m.semver.version&&this.operator.includes("=")&&m.operator.includes("=")||a(this.semver,"<",m.semver,$)&&this.operator.startsWith(">")&&m.operator.startsWith("<")||a(this.semver,">",m.semver,$)&&this.operator.startsWith("<")&&m.operator.startsWith(">")))}}Ue=e;const t=Ye,{safeRe:s,t:o}=Ee,a=Kt,d=Ne,E=H,c=Z();return Ue}const is=Z(),os=(n,e,t)=>{try{e=new is(e,t)}catch{return!1}return e.test(n)};var be=os;const as=Z(),ls=(n,e)=>new as(n,e).set.map(t=>t.map(s=>s.value).join(" ").trim().split(" "));var cs=ls;const hs=H,us=Z(),fs=(n,e,t)=>{let s=null,o=null,a=null;try{a=new us(e,t)}catch{return null}return n.forEach(d=>{a.test(d)&&(!s||o.compare(d)===-1)&&(s=d,o=new hs(s,t))}),s};var ps=fs;const ds=H,ms=Z(),vs=(n,e,t)=>{let s=null,o=null,a=null;try{a=new ms(e,t)}catch{return null}return n.forEach(d=>{a.test(d)&&(!s||o.compare(d)===1)&&(s=d,o=new ds(s,t))}),s};var Es=vs;const Xe=H,gs=Z(),Ct=Oe,ws=(n,e)=>{n=new gs(n,e);let t=new Xe("0.0.0");if(n.test(t)||(t=new Xe("0.0.0-0"),n.test(t)))return t;t=null;for(let s=0;s{const E=new Xe(d.semver.version);switch(d.operator){case">":E.prerelease.length===0?E.patch++:E.prerelease.push(0),E.raw=E.format();case"":case">=":(!a||Ct(E,a))&&(a=E);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${d.operator}`)}}),a&&(!t||Ct(t,a))&&(t=a)}return t&&n.test(t)?t:null};var $s=ws;const ys=Z(),Rs=(n,e)=>{try{return new ys(n,e).range||"*"}catch{return null}};var Is=Rs;const Ts=H,Jt=xe(),{ANY:Ss}=Jt,Ls=Z(),As=be,_t=Oe,Pt=ke,Ns=Ze,Os=Ke,xs=(n,e,t,s)=>{n=new Ts(n,s),e=new Ls(e,s);let o,a,d,E,c;switch(t){case">":o=_t,a=Ns,d=Pt,E=">",c=">=";break;case"<":o=Pt,a=Os,d=_t,E="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(As(n,e,s))return!1;for(let u=0;u{y.semver===Ss&&(y=new Jt(">=0.0.0")),$=$||y,_=_||y,o(y.semver,$.semver,s)?$=y:d(y.semver,_.semver,s)&&(_=y)}),$.operator===E||$.operator===c||(!_.operator||_.operator===E)&&a(n,_.semver))return!1;if(_.operator===c&&d(n,_.semver))return!1}return!0};var Je=xs;const bs=Je,Cs=(n,e,t)=>bs(n,e,">",t);var _s=Cs;const Ps=Je,Ds=(n,e,t)=>Ps(n,e,"<",t);var js=Ds;const Dt=Z(),Fs=(n,e,t)=>(n=new Dt(n,t),e=new Dt(e,t),n.intersects(e,t));var Gs=Fs;const Ms=be,Ws=K;var Vs=(n,e,t)=>{const s=[];let o=null,a=null;const d=n.sort((m,$)=>Ws(m,$,t));for(const m of d)Ms(m,e,t)?(a=m,o||(o=m)):(a&&s.push([o,a]),a=null,o=null);o&&s.push([o,null]);const E=[];for(const[m,$]of s)m===$?E.push(m):!$&&m===d[0]?E.push("*"):$?m===d[0]?E.push(`<=${$}`):E.push(`${m} - ${$}`):E.push(`>=${m}`);const c=E.join(" || "),u=typeof e.raw=="string"?e.raw:String(e);return c.length{if(n===e)return!0;n=new jt(n,t),e=new jt(e,t);let s=!1;e:for(const o of n.set){for(const a of e.set){const d=Hs(o,a,t);if(s=s||d!==null,d)continue e}if(s)return!1}return!0},Xs=[new Qe(">=0.0.0-0")],Ft=[new Qe(">=0.0.0")],Hs=(n,e,t)=>{if(n===e)return!0;if(n.length===1&&n[0].semver===He){if(e.length===1&&e[0].semver===He)return!0;t.includePrerelease?n=Xs:n=Ft}if(e.length===1&&e[0].semver===He){if(t.includePrerelease)return!0;e=Ft}const s=new Set;let o,a;for(const y of n)y.operator===">"||y.operator===">="?o=Gt(o,y,t):y.operator==="<"||y.operator==="<="?a=Mt(a,y,t):s.add(y.semver);if(s.size>1)return null;let d;if(o&&a){if(d=et(o.semver,a.semver,t),d>0)return null;if(d===0&&(o.operator!==">="||a.operator!=="<="))return null}for(const y of s){if(o&&!me(y,String(o),t)||a&&!me(y,String(a),t))return null;for(const S of e)if(!me(y,String(S),t))return!1;return!0}let E,c,u,m,$=a&&!t.includePrerelease&&a.semver.prerelease.length?a.semver:!1,_=o&&!t.includePrerelease&&o.semver.prerelease.length?o.semver:!1;$&&$.prerelease.length===1&&a.operator==="<"&&$.prerelease[0]===0&&($=!1);for(const y of e){if(m=m||y.operator===">"||y.operator===">=",u=u||y.operator==="<"||y.operator==="<=",o){if(_&&y.semver.prerelease&&y.semver.prerelease.length&&y.semver.major===_.major&&y.semver.minor===_.minor&&y.semver.patch===_.patch&&(_=!1),y.operator===">"||y.operator===">="){if(E=Gt(o,y,t),E===y&&E!==o)return!1}else if(o.operator===">="&&!me(o.semver,String(y),t))return!1}if(a){if($&&y.semver.prerelease&&y.semver.prerelease.length&&y.semver.major===$.major&&y.semver.minor===$.minor&&y.semver.patch===$.patch&&($=!1),y.operator==="<"||y.operator==="<="){if(c=Mt(a,y,t),c===y&&c!==a)return!1}else if(a.operator==="<="&&!me(a.semver,String(y),t))return!1}if(!y.operator&&(a||o)&&d!==0)return!1}return!(o&&u&&!a&&d!==0||a&&m&&!o&&d!==0||_||$)},Gt=(n,e,t)=>{if(!n)return e;const s=et(n.semver,e.semver,t);return s>0?n:s<0||e.operator===">"&&n.operator===">="?e:n},Mt=(n,e,t)=>{if(!n)return e;const s=et(n.semver,e.semver,t);return s<0?n:s>0||e.operator==="<"&&n.operator==="<="?e:n};var Bs=Us;const Be=Ee,Wt=Ae,qs=H,Vt=Yt,Ys=pe,zs=Yn,ks=Kn,Ks=Jn,Zs=er,Js=rr,Qs=or,ei=cr,ti=fr,ni=K,ri=vr,si=wr,ii=ze,oi=Ir,ai=Lr,li=Oe,ci=ke,hi=zt,ui=kt,fi=Ke,pi=Ze,di=Kt,mi=kr,vi=xe(),Ei=Z(),gi=be,wi=cs,$i=ps,yi=Es,Ri=$s,Ii=Is,Ti=Je,Si=_s,Li=js,Ai=Gs,Ni=Vs,Oi=Bs;var xi={parse:Ys,valid:zs,clean:ks,inc:Ks,diff:Zs,major:Js,minor:Qs,patch:ei,prerelease:ti,compare:ni,rcompare:ri,compareLoose:si,compareBuild:ii,sort:oi,rsort:ai,gt:li,lt:ci,eq:hi,neq:ui,gte:fi,lte:pi,cmp:di,coerce:mi,Comparator:vi,Range:Ei,satisfies:gi,toComparators:wi,maxSatisfying:$i,minSatisfying:yi,minVersion:Ri,validRange:Ii,outside:Ti,gtr:Si,ltr:Li,intersects:Ai,simplifyRange:Ni,subset:Oi,SemVer:qs,re:Be.re,src:Be.src,tokens:Be.t,SEMVER_SPEC_VERSION:Wt.SEMVER_SPEC_VERSION,RELEASE_TYPES:Wt.RELEASE_TYPES,compareIdentifiers:Vt.compareIdentifiers,rcompareIdentifiers:Vt.rcompareIdentifiers};const bi=Xt(xi);var Qt={exports:{}};(function(n){(function(){function e(r,i,h){return r.call.apply(r.bind,arguments)}function t(r,i,h){if(!r)throw Error();if(2=i.f?b():r.fonts.load(Ce(i.a),i.h).then(function(j){1<=j.length?T():setTimeout(C,25)},function(){b()})}C()}),f=null,w=new Promise(function(T,b){f=setTimeout(b,i.f)});Promise.race([w,l]).then(function(){f&&(clearTimeout(f),f=null),i.g(i.a)},function(){i.j(i.a)})};function x(r,i,h,l,f,w,T){this.v=r,this.B=i,this.c=h,this.a=l,this.s=T||"BESbswy",this.f={},this.w=f||3e3,this.u=w||null,this.m=this.j=this.h=this.g=null,this.g=new R(this.c,this.s),this.h=new R(this.c,this.s),this.j=new R(this.c,this.s),this.m=new R(this.c,this.s),r=new q(this.a.c+",serif",B(this.a)),r=g(r),this.g.a.style.cssText=r,r=new q(this.a.c+",sans-serif",B(this.a)),r=g(r),this.h.a.style.cssText=r,r=new q("serif",B(this.a)),r=g(r),this.j.a.style.cssText=r,r=new q("sans-serif",B(this.a)),r=g(r),this.m.a.style.cssText=r,I(this.g),I(this.h),I(this.j),I(this.m)}var N={D:"serif",C:"sans-serif"},P=null;function W(){if(P===null){var r=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);P=!!r&&(536>parseInt(r[1],10)||parseInt(r[1],10)===536&&11>=parseInt(r[2],10))}return P}x.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f["sans-serif"]=this.m.a.offsetWidth,this.A=o(),re(this)};function D(r,i,h){for(var l in N)if(N.hasOwnProperty(l)&&i===r.f[N[l]]&&h===r.f[N[l]])return!0;return!1}function re(r){var i=r.g.a.offsetWidth,h=r.h.a.offsetWidth,l;(l=i===r.f.serif&&h===r.f["sans-serif"])||(l=W()&&D(r,i,h)),l?o()-r.A>=r.w?W()&&D(r,i,h)&&(r.u===null||r.u.hasOwnProperty(r.a.c))?je(r,r.v):je(r,r.B):tt(r):je(r,r.v)}function tt(r){setTimeout(s(function(){re(this)},r),50)}function je(r,i){setTimeout(s(function(){u(this.g.a),u(this.h.a),u(this.j.a),u(this.m.a),i(this.a)},r),0)}function Fe(r,i,h){this.c=r,this.a=i,this.f=0,this.m=this.j=!1,this.s=h}var ye=null;Fe.prototype.g=function(r){var i=this.a;i.g&&m(i.f,[i.a.c("wf",r.c,B(r).toString(),"active")],[i.a.c("wf",r.c,B(r).toString(),"loading"),i.a.c("wf",r.c,B(r).toString(),"inactive")]),v(i,"fontactive",r),this.m=!0,nt(this)},Fe.prototype.h=function(r){var i=this.a;if(i.g){var h=$(i.f,i.a.c("wf",r.c,B(r).toString(),"active")),l=[],f=[i.a.c("wf",r.c,B(r).toString(),"loading")];h||l.push(i.a.c("wf",r.c,B(r).toString(),"inactive")),m(i.f,l,f)}v(i,"fontinactive",r),nt(this)};function nt(r){--r.f==0&&r.j&&(r.m?(r=r.a,r.g&&m(r.f,[r.a.c("wf","active")],[r.a.c("wf","loading"),r.a.c("wf","inactive")]),v(r,"active")):$e(r.a))}function rt(r){this.j=r,this.a=new p,this.h=0,this.f=this.g=!0}rt.prototype.load=function(r){this.c=new a(this.j,r.context||this.j),this.g=r.events!==!1,this.f=r.classes!==!1,tn(this,new Pe(this.c,r),r)};function en(r,i,h,l,f){var w=--r.h==0;(r.f||r.g)&&setTimeout(function(){var T=f||null,b=l||null||{};if(h.length===0&&w)$e(i.a);else{i.f+=h.length,w&&(i.j=w);var C,j=[];for(C=0;Cthis.createElement(o));t.replaceChildren(...s)}createElement(e){if(e.type=="separator"){const t=document.createElement("div");return t.classList.add("separator"),t}if(e.type=="selection"||e.type=="checkbox"||e.type=="dropdown"){const t=document.createElement("div"),s=document.createElement("div"),o=document.createElement("div");let a;if(e.type=="selection"||e.type=="checkbox"){const d=mn[e.id]??{label:e.id,combos:[],callback:()=>{}};a=document.createElement("div"),a.innerText=Ht.getKeybindString(e.id),a.classList.add("keybind","unselectable"),o.innerText=d.label;let E=d.disabled;typeof E=="function"&&(E=E(this.app)),E&&t.classList.add("disabled"),t.addEventListener("click",()=>{if(E)return;d.callback(this.app),t.closest(".menu-main").querySelector(".menubar-dropdown").replaceChildren()})}else a=document.createElement("img"),a.classList.add("icon"),a.src=vn.CHEVRON,a.style.transform="rotate(-90deg)",o.innerText=typeof e.title=="function"?e.title(this.app):e.title;if(s.appendChild(o),s.appendChild(a),t.appendChild(s),t.classList.add("menu-item"),s.classList.add("menu-item-title","menu-hover"),o.classList.add("title","unselectable"),e.type=="dropdown"){const d=document.createElement("div");t.appendChild(d),d.classList.add("menubar-dropdown"),e.options.map(E=>this.createElement(E)).forEach(E=>d.appendChild(E))}if(e.type=="checkbox"){let d=e.checked;typeof d=="function"&&(d=d(this.app)),d&&(o.innerText="✓ "+o.innerText)}return t}if(e.type=="menu"){const t=document.createElement("div"),s=document.createElement("div"),o=document.createElement("div");return t.appendChild(s),s.innerText=e.title,t.appendChild(o),s.classList.add("title","unselectable"),t.classList.add("menu-item","menu-main"),s.classList.add("menu-hover"),o.classList.add("menubar-dropdown","unselectable"),t.onmouseenter=()=>{o.replaceChildren(...e.options.map(a=>this.createElement(a)))},t.onmouseleave=()=>{o.replaceChildren()},t}return document.createElement("div")}}class Di{view;windows=[];app;constructor(e,t){this.app=e,this.view=t}unfocusAll(){for(const e of this.view.querySelectorAll(".focused"))e.classList.remove("focused")}getFocusedWindow(){for(const e of this.windows)if(e.windowElement.classList.contains("focused"))return e;return null}isBlocked(){return!this.windows.every(e=>!e.options.blocking)}openWindow(e){if(e.options.win_id){const t=this.getWindowById(e.options.win_id);if(t){t.focus();return}}e.addToManager(this),this.windows.push(e)}removeWindow(e){this.windows.splice(this.windows.indexOf(e),1)}getWindowById(e){for(const t of this.windows)if(t.options.win_id==e)return t}}class ji{renderer;ticker;stage;view;chartManager;windowManager;menubarManager;actionHistory;lastWidth=window.innerWidth;lastHeight=window.innerHeight;constructor(){if(En.setDefaultProps({duration:[200,100],theme:"sm"}),window.nw){const e=nw.Window.get();window.addEventListener("keydown",t=>{(t.key=="r"&&(t.metaKey||t.ctrlKey)||t.key=="F5")&&(t.preventDefault(),e.reload())}),this.checkAppVersion()}if(ie.loadOptions(),gn(),Ht.load(this),setInterval(()=>ie.saveOptions(),1e4),ie.general.smoothAnimations&&document.body.classList.add("animated"),this.registerFonts(),this.view=document.getElementById("pixi"),document.oncontextmenu=e=>{e.preventDefault(),this.chartManager.loadedChart&&e.target==this.view&&ut.open(this,e)},this.view.onmousedown=()=>{ut.close()},this.stage=new wn,this.stage.sortableChildren=!0,this.renderer=new $n({backgroundColor:1579292,antialias:ie.performance.antialiasing,width:this.view.clientWidth,height:this.view.clientHeight,resolution:ie.performance.resolution,autoDensity:!0,view:this.view,powerPreference:"low-power"}),this.ticker=new yn,this.ticker.maxFPS=120,this.ticker.add(()=>{const e=performance.now();this.renderer.render(this.stage),ft.instance?.addFrameTimeValue(performance.now()-e),performance.memory?.usedJSHeapSize&&ft.instance?.addMemoryTimeValue(performance.memory.usedJSHeapSize),bn()},Rn.LOW),this.ticker.start(),In.init(this.renderer),this.chartManager=new Tn(this),this.menubarManager=new Pi(this,document.getElementById("menubar")),this.windowManager=new Di(this,document.getElementById("windows")),this.actionHistory=new pt(this),this.registerListeners(),!V.hidePoweredByText&&Sn()){const e=document.getElementById("embed");e.appendChild(document.createTextNode("Powered by "));const t=document.createElement("a");if(t.href="https://tillvit.github.io/smeditor/",t.innerText="SMEditor",t.target="_blank",e.appendChild(t),V.url!=null){e.appendChild(document.createTextNode(" | Open this chart in a "));const s=document.createElement("a"),o=new URL(location.origin+"/smeditor/app/");s.innerText="new tab",s.target="_blank",o.searchParams.append("url",V.url),V.chartType!==null&&o.searchParams.append("chartType",V.chartType),V.chartIndex!==null&&o.searchParams.append("chartIndex",V.chartIndex+""),s.href=o.toString(),e.appendChild(s)}}dt.initFileSystem().then(()=>{if(V.url){this.chartManager.loadSM(V.url).then(()=>{const e=this.chartManager.loadedSM;if(!e)return;let t;if(V.chartType!=null&&(t=e.charts[V.chartType],t===void 0)){Et.createFormatted(`Couldn't find chart with type ${V.chartType}`,"warn");return}if(t===void 0){const o=Object.keys(e.charts);if(o.length==0||(t=e.charts[o[0]],t.length==0))return}let s;if(V.chartIndex!=null&&(s=t.at(V.chartIndex),s===void 0)){Et.createFormatted(`Couldn't find chart with index ${V.chartIndex}`,"warn");return}s===void 0&&(s=t.at(-1),!s)||this.chartManager.loadChart(s)});return}this.windowManager.openWindow(new Ln(this))}),window.onbeforeunload=e=>{if(pt.instance.isDirty()&&ie.general.warnBeforeExit)return e.preventDefault(),e.returnValue="Are you sure you want to exit?"},window.onunload=()=>{ie.saveOptions()}}registerFonts(){mt.from("Main",{fontFamily:"Assistant",fontSize:20,fill:"white"},{chars:[["a","z"],["A","Z"],"!@#$%^&*()~{}[]:.-?=,_","0123456789/"," "],resolution:window.devicePixelRatio}),mt.from("Fancy",{fontFamily:"Assistant",fontSize:40,fontWeight:"700",fill:["#dddddd","#ffffff"],fillGradientType:An.LINEAR_VERTICAL,stroke:11184810,strokeThickness:3},{chars:[["a","z"],["A","Z"],"!@#$%^&*()~{}[]:.-?=,_","0123456789/"," "],resolution:window.devicePixelRatio})}registerListeners(){window.addEventListener("keydown",function(e){e.code=="Tab"&&e.preventDefault(),e.code=="Enter"&&e.target instanceof HTMLButtonElement&&e.preventDefault()}),window.addEventListener("dragstart",function(e){e.target instanceof HTMLImageElement&&e.preventDefault()}),setInterval(()=>{const e=window.innerWidth,t=window.innerHeight-document.getElementById("menubar").clientHeight;(this.lastHeight!=t||this.lastWidth!=e)&&(this.lastHeight=t,this.lastWidth=e,this.onResize(e,t),Nn.emit("resize"))},100),window.addEventListener("dragover",e=>{e.preventDefault(),e.dataTransfer.dropEffect="copy"}),window.addEventListener("drop",e=>{if(window.nw){e.stopPropagation(),e.preventDefault();let t="";for(const s of e.dataTransfer.files)if(s.path)if(vt(s.path)==".ssc"){t=s.path;break}else t==""&&vt(s.path)==".sm"&&(t=s.path);t!=""&&(this.chartManager.loadSM(t),this.windowManager.getWindowById("select_sm_initial")?.closeWindow())}else dt.handleDropEvent(e).then(t=>{const s=new On(this,{title:"Select an sm/ssc file...",accepted_file_types:[".sm",".ssc"],disableClose:!0,callback:o=>{this.chartManager.loadSM(o),this.windowManager.getWindowById("select_sm_initial")?.closeWindow()},onload:()=>{s.getAcceptableFile(t??"").then(o=>s.selectPath(o))}});this.windowManager.openWindow(s)})})}onResize(e,t){this.renderer.screen.width=e,this.renderer.screen.height=t,this.view.width=e*this.renderer.resolution,this.view.height=t*this.renderer.resolution,this.view.style.width=`${e}px`,this.view.style.height=`${t}px`}checkAppVersion(){if(!window.nw)return;const e=nw.require("nw.gui"),t={stable:3,beta:2,alpha:1,nightly:0};let s="win";navigator.userAgent.includes("Mac")?s="mac":navigator.userAgent.includes("Linux")&&(s="linux"),fetch("/smeditor/assets/app/versions.json").then(o=>o.json()).then(o=>{o=o.sort((d,E)=>t[d.type]!=t[E.type]?t[E.type]-t[d.type]:E.date-d.date);const a=o[0];bi.lt(e.App.manifest.version,a.version)&&localStorage.getItem("downloadedVersion")!==a.version&&xn.open(a.version,a.downloads[s])})}}document.querySelector("body").innerHTML=`
+import{g as Xt,F as V,M as dn,K as mn,a as Ht,I as vn,t as En,O as ie,l as gn,C as ut,b as wn,R as $n,T as yn,D as ft,U as Rn,B as In,c as Tn,A as pt,i as Sn,d as dt,e as Ln,f as mt,h as An,E as Nn,j as vt,k as On,m as xn,W as Et,n as bn}from"./ChartManager-bba9ffde.js";var qe={exports:{}};const Cn="2.0.0",Bt=256,_n=Number.MAX_SAFE_INTEGER||9007199254740991,Pn=16,Dn=Bt-6,jn=["major","premajor","minor","preminor","patch","prepatch","prerelease"];var Ae={MAX_LENGTH:Bt,MAX_SAFE_COMPONENT_LENGTH:Pn,MAX_SAFE_BUILD_LENGTH:Dn,MAX_SAFE_INTEGER:_n,RELEASE_TYPES:jn,SEMVER_SPEC_VERSION:Cn,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2};const Fn=typeof process=="object"&&process.env&&{}.NODE_DEBUG&&/\bsemver\b/i.test({}.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{};var Ne=Fn;(function(n,e){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:s,MAX_LENGTH:o}=Ae,a=Ne;e=n.exports={};const d=e.re=[],E=e.safeRe=[],c=e.src=[],u=e.t={};let m=0;const $="[a-zA-Z0-9-]",_=[["\\s",1],["\\d",o],[$,s]],y=Y=>{for(const[U,J]of _)Y=Y.split(`${U}*`).join(`${U}{0,${J}}`).split(`${U}+`).join(`${U}{1,${J}}`);return Y},S=(Y,U,J)=>{const G=y(U),Q=m++;a(Y,Q,U),u[Y]=Q,c[Q]=U,d[Q]=new RegExp(U,J?"g":void 0),E[Q]=new RegExp(G,J?"g":void 0)};S("NUMERICIDENTIFIER","0|[1-9]\\d*"),S("NUMERICIDENTIFIERLOOSE","\\d+"),S("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${$}*`),S("MAINVERSION",`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),S("MAINVERSIONLOOSE",`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),S("PRERELEASEIDENTIFIER",`(?:${c[u.NUMERICIDENTIFIER]}|${c[u.NONNUMERICIDENTIFIER]})`),S("PRERELEASEIDENTIFIERLOOSE",`(?:${c[u.NUMERICIDENTIFIERLOOSE]}|${c[u.NONNUMERICIDENTIFIER]})`),S("PRERELEASE",`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),S("PRERELEASELOOSE",`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),S("BUILDIDENTIFIER",`${$}+`),S("BUILD",`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),S("FULLPLAIN",`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),S("FULL",`^${c[u.FULLPLAIN]}$`),S("LOOSEPLAIN",`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),S("LOOSE",`^${c[u.LOOSEPLAIN]}$`),S("GTLT","((?:<|>)?=?)"),S("XRANGEIDENTIFIERLOOSE",`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),S("XRANGEIDENTIFIER",`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),S("XRANGEPLAIN",`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),S("XRANGEPLAINLOOSE",`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),S("XRANGE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),S("XRANGELOOSE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),S("COERCE",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?(?:$|[^\\d])`),S("COERCERTL",c[u.COERCE],!0),S("LONETILDE","(?:~>?)"),S("TILDETRIM",`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",S("TILDE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),S("TILDELOOSE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),S("LONECARET","(?:\\^)"),S("CARETTRIM",`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",S("CARET",`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),S("CARETLOOSE",`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),S("COMPARATORLOOSE",`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),S("COMPARATOR",`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),S("COMPARATORTRIM",`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",S("HYPHENRANGE",`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),S("HYPHENRANGELOOSE",`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),S("STAR","(<|>)?=?\\s*\\*"),S("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),S("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(qe,qe.exports);var Ee=qe.exports;const Gn=Object.freeze({loose:!0}),Mn=Object.freeze({}),Wn=n=>n?typeof n!="object"?Gn:n:Mn;var Ye=Wn;const gt=/^[0-9]+$/,qt=(n,e)=>{const t=gt.test(n),s=gt.test(e);return t&&s&&(n=+n,e=+e),n===e?0:t&&!s?-1:s&&!t?1:nqt(e,n);var Yt={compareIdentifiers:qt,rcompareIdentifiers:Vn};const Re=Ne,{MAX_LENGTH:wt,MAX_SAFE_INTEGER:Ie}=Ae,{safeRe:$t,t:yt}=Ee,Un=Ye,{compareIdentifiers:he}=Yt;let Xn=class ee{constructor(e,t){if(t=Un(t),e instanceof ee){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>wt)throw new TypeError(`version is longer than ${wt} characters`);Re("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const s=e.trim().match(t.loose?$t[yt.LOOSE]:$t[yt.FULL]);if(!s)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>Ie||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Ie||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Ie||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map(o=>{if(/^[0-9]+$/.test(o)){const a=+o;if(a>=0&&a=0;)typeof this.prerelease[a]=="number"&&(this.prerelease[a]++,a=-2);if(a===-1){if(t===this.prerelease.join(".")&&s===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(o)}}if(t){let a=[t,o];s===!1&&(a=[t]),he(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=a):this.prerelease=a}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};var H=Xn;const Rt=H,Hn=(n,e,t=!1)=>{if(n instanceof Rt)return n;try{return new Rt(n,e)}catch(s){if(!t)return null;throw s}};var pe=Hn;const Bn=pe,qn=(n,e)=>{const t=Bn(n,e);return t?t.version:null};var Yn=qn;const zn=pe,kn=(n,e)=>{const t=zn(n.trim().replace(/^[=v]+/,""),e);return t?t.version:null};var Kn=kn;const It=H,Zn=(n,e,t,s,o)=>{typeof t=="string"&&(o=s,s=t,t=void 0);try{return new It(n instanceof It?n.version:n,t).inc(e,s,o).version}catch{return null}};var Jn=Zn;const Tt=pe,Qn=(n,e)=>{const t=Tt(n,null,!0),s=Tt(e,null,!0),o=t.compare(s);if(o===0)return null;const a=o>0,d=a?t:s,E=a?s:t,c=!!d.prerelease.length;if(!!E.prerelease.length&&!c)return!E.patch&&!E.minor?"major":d.patch?"patch":d.minor?"minor":"major";const m=c?"pre":"";return t.major!==s.major?m+"major":t.minor!==s.minor?m+"minor":t.patch!==s.patch?m+"patch":"prerelease"};var er=Qn;const tr=H,nr=(n,e)=>new tr(n,e).major;var rr=nr;const sr=H,ir=(n,e)=>new sr(n,e).minor;var or=ir;const ar=H,lr=(n,e)=>new ar(n,e).patch;var cr=lr;const hr=pe,ur=(n,e)=>{const t=hr(n,e);return t&&t.prerelease.length?t.prerelease:null};var fr=ur;const St=H,pr=(n,e,t)=>new St(n,t).compare(new St(e,t));var K=pr;const dr=K,mr=(n,e,t)=>dr(e,n,t);var vr=mr;const Er=K,gr=(n,e)=>Er(n,e,!0);var wr=gr;const Lt=H,$r=(n,e,t)=>{const s=new Lt(n,t),o=new Lt(e,t);return s.compare(o)||s.compareBuild(o)};var ze=$r;const yr=ze,Rr=(n,e)=>n.sort((t,s)=>yr(t,s,e));var Ir=Rr;const Tr=ze,Sr=(n,e)=>n.sort((t,s)=>Tr(s,t,e));var Lr=Sr;const Ar=K,Nr=(n,e,t)=>Ar(n,e,t)>0;var Oe=Nr;const Or=K,xr=(n,e,t)=>Or(n,e,t)<0;var ke=xr;const br=K,Cr=(n,e,t)=>br(n,e,t)===0;var zt=Cr;const _r=K,Pr=(n,e,t)=>_r(n,e,t)!==0;var kt=Pr;const Dr=K,jr=(n,e,t)=>Dr(n,e,t)>=0;var Ke=jr;const Fr=K,Gr=(n,e,t)=>Fr(n,e,t)<=0;var Ze=Gr;const Mr=zt,Wr=kt,Vr=Oe,Ur=Ke,Xr=ke,Hr=Ze,Br=(n,e,t,s)=>{switch(e){case"===":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n===t;case"!==":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n!==t;case"":case"=":case"==":return Mr(n,t,s);case"!=":return Wr(n,t,s);case">":return Vr(n,t,s);case">=":return Ur(n,t,s);case"<":return Xr(n,t,s);case"<=":return Hr(n,t,s);default:throw new TypeError(`Invalid operator: ${e}`)}};var Kt=Br;const qr=H,Yr=pe,{safeRe:Te,t:Se}=Ee,zr=(n,e)=>{if(n instanceof qr)return n;if(typeof n=="number"&&(n=String(n)),typeof n!="string")return null;e=e||{};let t=null;if(!e.rtl)t=n.match(Te[Se.COERCE]);else{let s;for(;(s=Te[Se.COERCERTL].exec(n))&&(!t||t.index+t[0].length!==n.length);)(!t||s.index+s[0].length!==t.index+t[0].length)&&(t=s),Te[Se.COERCERTL].lastIndex=s.index+s[1].length+s[2].length;Te[Se.COERCERTL].lastIndex=-1}return t===null?null:Yr(`${t[2]}.${t[3]||"0"}.${t[4]||"0"}`,e)};var kr=zr,Ge,At;function Kr(){return At||(At=1,Ge=function(n){n.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}),Ge}var Zr=O;O.Node=le;O.create=O;function O(n){var e=this;if(e instanceof O||(e=new O),e.tail=null,e.head=null,e.length=0,n&&typeof n.forEach=="function")n.forEach(function(o){e.push(o)});else if(arguments.length>0)for(var t=0,s=arguments.length;t1)t=e;else if(this.head)s=this.head.next,t=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var o=0;s!==null;o++)t=n(t,s.value,o),s=s.next;return t};O.prototype.reduceReverse=function(n,e){var t,s=this.tail;if(arguments.length>1)t=e;else if(this.tail)s=this.tail.prev,t=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var o=this.length-1;s!==null;o--)t=n(t,s.value,o),s=s.prev;return t};O.prototype.toArray=function(){for(var n=new Array(this.length),e=0,t=this.head;t!==null;e++)n[e]=t.value,t=t.next;return n};O.prototype.toArrayReverse=function(){for(var n=new Array(this.length),e=0,t=this.tail;t!==null;e++)n[e]=t.value,t=t.prev;return n};O.prototype.slice=function(n,e){e=e||this.length,e<0&&(e+=this.length),n=n||0,n<0&&(n+=this.length);var t=new O;if(ethis.length&&(e=this.length);for(var s=0,o=this.head;o!==null&&sthis.length&&(e=this.length);for(var s=this.length,o=this.tail;o!==null&&s>e;s--)o=o.prev;for(;o!==null&&s>n;s--,o=o.prev)t.push(o.value);return t};O.prototype.splice=function(n,e,...t){n>this.length&&(n=this.length-1),n<0&&(n=this.length+n);for(var s=0,o=this.head;o!==null&&s1;class ns{constructor(e){if(typeof e=="number"&&(e={max:e}),e||(e={}),e.max&&(typeof e.max!="number"||e.max<0))throw new TypeError("max must be a non-negative number");this[oe]=e.max||1/0;const t=e.length||Me;if(this[ue]=typeof t!="function"?Me:t,this[ve]=e.stale||!1,e.maxAge&&typeof e.maxAge!="number")throw new TypeError("maxAge must be a number");this[ae]=e.maxAge||0,this[te]=e.dispose,this[Nt]=e.noDisposeOnSet||!1,this[Zt]=e.updateAgeOnGet||!1,this.reset()}set max(e){if(typeof e!="number"||e<0)throw new TypeError("max must be a non-negative number");this[oe]=e||1/0,de(this)}get max(){return this[oe]}set allowStale(e){this[ve]=!!e}get allowStale(){return this[ve]}set maxAge(e){if(typeof e!="number")throw new TypeError("maxAge must be a non-negative number");this[ae]=e,de(this)}get maxAge(){return this[ae]}set lengthCalculator(e){typeof e!="function"&&(e=Me),e!==this[ue]&&(this[ue]=e,this[ne]=0,this[M].forEach(t=>{t.length=this[ue](t.value,t.key),this[ne]+=t.length})),de(this)}get lengthCalculator(){return this[ue]}get length(){return this[ne]}get itemCount(){return this[M].length}rforEach(e,t){t=t||this;for(let s=this[M].tail;s!==null;){const o=s.prev;Ot(this,e,s,t),s=o}}forEach(e,t){t=t||this;for(let s=this[M].head;s!==null;){const o=s.next;Ot(this,e,s,t),s=o}}keys(){return this[M].toArray().map(e=>e.key)}values(){return this[M].toArray().map(e=>e.value)}reset(){this[te]&&this[M]&&this[M].length&&this[M].forEach(e=>this[te](e.key,e.value)),this[k]=new Map,this[M]=new ts,this[ne]=0}dump(){return this[M].map(e=>Le(this,e)?!1:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[M]}set(e,t,s){if(s=s||this[ae],s&&typeof s!="number")throw new TypeError("maxAge must be a number");const o=s?Date.now():0,a=this[ue](t,e);if(this[k].has(e)){if(a>this[oe])return fe(this,this[k].get(e)),!1;const c=this[k].get(e).value;return this[te]&&(this[Nt]||this[te](e,c.value)),c.now=o,c.maxAge=s,c.value=t,this[ne]+=a-c.length,c.length=a,this.get(e),de(this),!0}const d=new rs(e,t,a,o,s);return d.length>this[oe]?(this[te]&&this[te](e,t),!1):(this[ne]+=d.length,this[M].unshift(d),this[k].set(e,this[M].head),de(this),!0)}has(e){if(!this[k].has(e))return!1;const t=this[k].get(e).value;return!Le(this,t)}get(e){return We(this,e,!0)}peek(e){return We(this,e,!1)}pop(){const e=this[M].tail;return e?(fe(this,e),e.value):null}del(e){fe(this,this[k].get(e))}load(e){this.reset();const t=Date.now();for(let s=e.length-1;s>=0;s--){const o=e[s],a=o.e||0;if(a===0)this.set(o.k,o.v);else{const d=a-t;d>0&&this.set(o.k,o.v,d)}}}prune(){this[k].forEach((e,t)=>We(this,t,!1))}}const We=(n,e,t)=>{const s=n[k].get(e);if(s){const o=s.value;if(Le(n,o)){if(fe(n,s),!n[ve])return}else t&&(n[Zt]&&(s.value.now=Date.now()),n[M].unshiftNode(s));return o.value}},Le=(n,e)=>{if(!e||!e.maxAge&&!n[ae])return!1;const t=Date.now()-e.now;return e.maxAge?t>e.maxAge:n[ae]&&t>n[ae]},de=n=>{if(n[ne]>n[oe])for(let e=n[M].tail;n[ne]>n[oe]&&e!==null;){const t=e.prev;fe(n,e),e=t}},fe=(n,e)=>{if(e){const t=e.value;n[te]&&n[te](t.key,t.value),n[ne]-=t.length,n[k].delete(t.key),n[M].removeNode(e)}};class rs{constructor(e,t,s,o,a){this.key=e,this.value=t,this.length=s,this.now=o,this.maxAge=a||0}}const Ot=(n,e,t,s)=>{let o=t.value;Le(n,o)&&(fe(n,t),n[ve]||(o=void 0)),o&&e.call(s,o.value,o.key,n)};var ss=ns,Ve,xt;function Z(){if(xt)return Ve;xt=1;class n{constructor(p,L){if(L=s(L),p instanceof n)return p.loose===!!L.loose&&p.includePrerelease===!!L.includePrerelease?p:new n(p.raw,L);if(p instanceof o)return this.raw=p.value,this.set=[[p]],this.format(),this;if(this.options=L,this.loose=!!L.loose,this.includePrerelease=!!L.includePrerelease,this.raw=p.trim().split(/\s+/).join(" "),this.set=this.raw.split("||").map(R=>this.parseRange(R.trim())).filter(R=>R.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const R=this.set[0];if(this.set=this.set.filter(I=>!S(I[0])),this.set.length===0)this.set=[R];else if(this.set.length>1){for(const I of this.set)if(I.length===1&&Y(I[0])){this.set=[I];break}}}this.format()}format(){return this.range=this.set.map(p=>p.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(p){const R=((this.options.includePrerelease&&_)|(this.options.loose&&y))+":"+p,I=t.get(R);if(I)return I;const g=this.options.loose,A=g?E[c.HYPHENRANGELOOSE]:E[c.HYPHENRANGE];p=p.replace(A,De(this.options.includePrerelease)),a("hyphen replace",p),p=p.replace(E[c.COMPARATORTRIM],u),a("comparator trim",p),p=p.replace(E[c.TILDETRIM],m),a("tilde trim",p),p=p.replace(E[c.CARETTRIM],$),a("caret trim",p);let x=p.split(" ").map(D=>J(D,this.options)).join(" ").split(/\s+/).map(D=>Pe(D,this.options));g&&(x=x.filter(D=>(a("loose invalid filter",D,this.options),!!D.match(E[c.COMPARATORLOOSE])))),a("range list",x);const N=new Map,P=x.map(D=>new o(D,this.options));for(const D of P){if(S(D))return[D];N.set(D.value,D)}N.size>1&&N.has("")&&N.delete("");const W=[...N.values()];return t.set(R,W),W}intersects(p,L){if(!(p instanceof n))throw new TypeError("a Range is required");return this.set.some(R=>U(R,L)&&p.set.some(I=>U(I,L)&&R.every(g=>I.every(A=>g.intersects(A,L)))))}test(p){if(!p)return!1;if(typeof p=="string")try{p=new d(p,this.options)}catch{return!1}for(let L=0;Lv.value==="<0.0.0-0",Y=v=>v.value==="",U=(v,p)=>{let L=!0;const R=v.slice();let I=R.pop();for(;L&&R.length;)L=R.every(g=>I.intersects(g,p)),I=R.pop();return L},J=(v,p)=>(a("comp",v,p),v=Ce(v,p),a("caret",v),v=Q(v,p),a("tildes",v),v=B(v,p),a("xrange",v),v=_e(v,p),a("stars",v),v),G=v=>!v||v.toLowerCase()==="x"||v==="*",Q=(v,p)=>v.trim().split(/\s+/).map(L=>q(L,p)).join(" "),q=(v,p)=>{const L=p.loose?E[c.TILDELOOSE]:E[c.TILDE];return v.replace(L,(R,I,g,A,x)=>{a("tilde",v,R,I,g,A,x);let N;return G(I)?N="":G(g)?N=`>=${I}.0.0 <${+I+1}.0.0-0`:G(A)?N=`>=${I}.${g}.0 <${I}.${+g+1}.0-0`:x?(a("replaceTilde pr",x),N=`>=${I}.${g}.${A}-${x} <${I}.${+g+1}.0-0`):N=`>=${I}.${g}.${A} <${I}.${+g+1}.0-0`,a("tilde return",N),N})},Ce=(v,p)=>v.trim().split(/\s+/).map(L=>ge(L,p)).join(" "),ge=(v,p)=>{a("caret",v,p);const L=p.loose?E[c.CARETLOOSE]:E[c.CARET],R=p.includePrerelease?"-0":"";return v.replace(L,(I,g,A,x,N)=>{a("caret",v,I,g,A,x,N);let P;return G(g)?P="":G(A)?P=`>=${g}.0.0${R} <${+g+1}.0.0-0`:G(x)?g==="0"?P=`>=${g}.${A}.0${R} <${g}.${+A+1}.0-0`:P=`>=${g}.${A}.0${R} <${+g+1}.0.0-0`:N?(a("replaceCaret pr",N),g==="0"?A==="0"?P=`>=${g}.${A}.${x}-${N} <${g}.${A}.${+x+1}-0`:P=`>=${g}.${A}.${x}-${N} <${g}.${+A+1}.0-0`:P=`>=${g}.${A}.${x}-${N} <${+g+1}.0.0-0`):(a("no pr"),g==="0"?A==="0"?P=`>=${g}.${A}.${x}${R} <${g}.${A}.${+x+1}-0`:P=`>=${g}.${A}.${x}${R} <${g}.${+A+1}.0-0`:P=`>=${g}.${A}.${x} <${+g+1}.0.0-0`),a("caret return",P),P})},B=(v,p)=>(a("replaceXRanges",v,p),v.split(/\s+/).map(L=>we(L,p)).join(" ")),we=(v,p)=>{v=v.trim();const L=p.loose?E[c.XRANGELOOSE]:E[c.XRANGE];return v.replace(L,(R,I,g,A,x,N)=>{a("xRange",v,R,I,g,A,x,N);const P=G(g),W=P||G(A),D=W||G(x),re=D;return I==="="&&re&&(I=""),N=p.includePrerelease?"-0":"",P?I===">"||I==="<"?R="<0.0.0-0":R="*":I&&re?(W&&(A=0),x=0,I===">"?(I=">=",W?(g=+g+1,A=0,x=0):(A=+A+1,x=0)):I==="<="&&(I="<",W?g=+g+1:A=+A+1),I==="<"&&(N="-0"),R=`${I+g}.${A}.${x}${N}`):W?R=`>=${g}.0.0${N} <${+g+1}.0.0-0`:D&&(R=`>=${g}.${A}.0${N} <${g}.${+A+1}.0-0`),a("xRange return",R),R})},_e=(v,p)=>(a("replaceStars",v,p),v.trim().replace(E[c.STAR],"")),Pe=(v,p)=>(a("replaceGTE0",v,p),v.trim().replace(E[p.includePrerelease?c.GTE0PRE:c.GTE0],"")),De=v=>(p,L,R,I,g,A,x,N,P,W,D,re,tt)=>(G(R)?L="":G(I)?L=`>=${R}.0.0${v?"-0":""}`:G(g)?L=`>=${R}.${I}.0${v?"-0":""}`:A?L=`>=${L}`:L=`>=${L}${v?"-0":""}`,G(P)?N="":G(W)?N=`<${+P+1}.0.0-0`:G(D)?N=`<${P}.${+W+1}.0-0`:re?N=`<=${P}.${W}.${D}-${re}`:v?N=`<${P}.${W}.${+D+1}-0`:N=`<=${N}`,`${L} ${N}`.trim()),$e=(v,p,L)=>{for(let R=0;R0){const I=v[R].semver;if(I.major===p.major&&I.minor===p.minor&&I.patch===p.patch)return!0}return!1}return!0};return Ve}var Ue,bt;function xe(){if(bt)return Ue;bt=1;const n=Symbol("SemVer ANY");class e{static get ANY(){return n}constructor(m,$){if($=t($),m instanceof e){if(m.loose===!!$.loose)return m;m=m.value}m=m.trim().split(/\s+/).join(" "),d("comparator",m,$),this.options=$,this.loose=!!$.loose,this.parse(m),this.semver===n?this.value="":this.value=this.operator+this.semver.version,d("comp",this)}parse(m){const $=this.options.loose?s[o.COMPARATORLOOSE]:s[o.COMPARATOR],_=m.match($);if(!_)throw new TypeError(`Invalid comparator: ${m}`);this.operator=_[1]!==void 0?_[1]:"",this.operator==="="&&(this.operator=""),_[2]?this.semver=new E(_[2],this.options.loose):this.semver=n}toString(){return this.value}test(m){if(d("Comparator.test",m,this.options.loose),this.semver===n||m===n)return!0;if(typeof m=="string")try{m=new E(m,this.options)}catch{return!1}return a(m,this.operator,this.semver,this.options)}intersects(m,$){if(!(m instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new c(m.value,$).test(this.value):m.operator===""?m.value===""?!0:new c(this.value,$).test(m.semver):($=t($),$.includePrerelease&&(this.value==="<0.0.0-0"||m.value==="<0.0.0-0")||!$.includePrerelease&&(this.value.startsWith("<0.0.0")||m.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&m.operator.startsWith(">")||this.operator.startsWith("<")&&m.operator.startsWith("<")||this.semver.version===m.semver.version&&this.operator.includes("=")&&m.operator.includes("=")||a(this.semver,"<",m.semver,$)&&this.operator.startsWith(">")&&m.operator.startsWith("<")||a(this.semver,">",m.semver,$)&&this.operator.startsWith("<")&&m.operator.startsWith(">")))}}Ue=e;const t=Ye,{safeRe:s,t:o}=Ee,a=Kt,d=Ne,E=H,c=Z();return Ue}const is=Z(),os=(n,e,t)=>{try{e=new is(e,t)}catch{return!1}return e.test(n)};var be=os;const as=Z(),ls=(n,e)=>new as(n,e).set.map(t=>t.map(s=>s.value).join(" ").trim().split(" "));var cs=ls;const hs=H,us=Z(),fs=(n,e,t)=>{let s=null,o=null,a=null;try{a=new us(e,t)}catch{return null}return n.forEach(d=>{a.test(d)&&(!s||o.compare(d)===-1)&&(s=d,o=new hs(s,t))}),s};var ps=fs;const ds=H,ms=Z(),vs=(n,e,t)=>{let s=null,o=null,a=null;try{a=new ms(e,t)}catch{return null}return n.forEach(d=>{a.test(d)&&(!s||o.compare(d)===1)&&(s=d,o=new ds(s,t))}),s};var Es=vs;const Xe=H,gs=Z(),Ct=Oe,ws=(n,e)=>{n=new gs(n,e);let t=new Xe("0.0.0");if(n.test(t)||(t=new Xe("0.0.0-0"),n.test(t)))return t;t=null;for(let s=0;s{const E=new Xe(d.semver.version);switch(d.operator){case">":E.prerelease.length===0?E.patch++:E.prerelease.push(0),E.raw=E.format();case"":case">=":(!a||Ct(E,a))&&(a=E);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${d.operator}`)}}),a&&(!t||Ct(t,a))&&(t=a)}return t&&n.test(t)?t:null};var $s=ws;const ys=Z(),Rs=(n,e)=>{try{return new ys(n,e).range||"*"}catch{return null}};var Is=Rs;const Ts=H,Jt=xe(),{ANY:Ss}=Jt,Ls=Z(),As=be,_t=Oe,Pt=ke,Ns=Ze,Os=Ke,xs=(n,e,t,s)=>{n=new Ts(n,s),e=new Ls(e,s);let o,a,d,E,c;switch(t){case">":o=_t,a=Ns,d=Pt,E=">",c=">=";break;case"<":o=Pt,a=Os,d=_t,E="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(As(n,e,s))return!1;for(let u=0;u{y.semver===Ss&&(y=new Jt(">=0.0.0")),$=$||y,_=_||y,o(y.semver,$.semver,s)?$=y:d(y.semver,_.semver,s)&&(_=y)}),$.operator===E||$.operator===c||(!_.operator||_.operator===E)&&a(n,_.semver))return!1;if(_.operator===c&&d(n,_.semver))return!1}return!0};var Je=xs;const bs=Je,Cs=(n,e,t)=>bs(n,e,">",t);var _s=Cs;const Ps=Je,Ds=(n,e,t)=>Ps(n,e,"<",t);var js=Ds;const Dt=Z(),Fs=(n,e,t)=>(n=new Dt(n,t),e=new Dt(e,t),n.intersects(e,t));var Gs=Fs;const Ms=be,Ws=K;var Vs=(n,e,t)=>{const s=[];let o=null,a=null;const d=n.sort((m,$)=>Ws(m,$,t));for(const m of d)Ms(m,e,t)?(a=m,o||(o=m)):(a&&s.push([o,a]),a=null,o=null);o&&s.push([o,null]);const E=[];for(const[m,$]of s)m===$?E.push(m):!$&&m===d[0]?E.push("*"):$?m===d[0]?E.push(`<=${$}`):E.push(`${m} - ${$}`):E.push(`>=${m}`);const c=E.join(" || "),u=typeof e.raw=="string"?e.raw:String(e);return c.length{if(n===e)return!0;n=new jt(n,t),e=new jt(e,t);let s=!1;e:for(const o of n.set){for(const a of e.set){const d=Hs(o,a,t);if(s=s||d!==null,d)continue e}if(s)return!1}return!0},Xs=[new Qe(">=0.0.0-0")],Ft=[new Qe(">=0.0.0")],Hs=(n,e,t)=>{if(n===e)return!0;if(n.length===1&&n[0].semver===He){if(e.length===1&&e[0].semver===He)return!0;t.includePrerelease?n=Xs:n=Ft}if(e.length===1&&e[0].semver===He){if(t.includePrerelease)return!0;e=Ft}const s=new Set;let o,a;for(const y of n)y.operator===">"||y.operator===">="?o=Gt(o,y,t):y.operator==="<"||y.operator==="<="?a=Mt(a,y,t):s.add(y.semver);if(s.size>1)return null;let d;if(o&&a){if(d=et(o.semver,a.semver,t),d>0)return null;if(d===0&&(o.operator!==">="||a.operator!=="<="))return null}for(const y of s){if(o&&!me(y,String(o),t)||a&&!me(y,String(a),t))return null;for(const S of e)if(!me(y,String(S),t))return!1;return!0}let E,c,u,m,$=a&&!t.includePrerelease&&a.semver.prerelease.length?a.semver:!1,_=o&&!t.includePrerelease&&o.semver.prerelease.length?o.semver:!1;$&&$.prerelease.length===1&&a.operator==="<"&&$.prerelease[0]===0&&($=!1);for(const y of e){if(m=m||y.operator===">"||y.operator===">=",u=u||y.operator==="<"||y.operator==="<=",o){if(_&&y.semver.prerelease&&y.semver.prerelease.length&&y.semver.major===_.major&&y.semver.minor===_.minor&&y.semver.patch===_.patch&&(_=!1),y.operator===">"||y.operator===">="){if(E=Gt(o,y,t),E===y&&E!==o)return!1}else if(o.operator===">="&&!me(o.semver,String(y),t))return!1}if(a){if($&&y.semver.prerelease&&y.semver.prerelease.length&&y.semver.major===$.major&&y.semver.minor===$.minor&&y.semver.patch===$.patch&&($=!1),y.operator==="<"||y.operator==="<="){if(c=Mt(a,y,t),c===y&&c!==a)return!1}else if(a.operator==="<="&&!me(a.semver,String(y),t))return!1}if(!y.operator&&(a||o)&&d!==0)return!1}return!(o&&u&&!a&&d!==0||a&&m&&!o&&d!==0||_||$)},Gt=(n,e,t)=>{if(!n)return e;const s=et(n.semver,e.semver,t);return s>0?n:s<0||e.operator===">"&&n.operator===">="?e:n},Mt=(n,e,t)=>{if(!n)return e;const s=et(n.semver,e.semver,t);return s<0?n:s>0||e.operator==="<"&&n.operator==="<="?e:n};var Bs=Us;const Be=Ee,Wt=Ae,qs=H,Vt=Yt,Ys=pe,zs=Yn,ks=Kn,Ks=Jn,Zs=er,Js=rr,Qs=or,ei=cr,ti=fr,ni=K,ri=vr,si=wr,ii=ze,oi=Ir,ai=Lr,li=Oe,ci=ke,hi=zt,ui=kt,fi=Ke,pi=Ze,di=Kt,mi=kr,vi=xe(),Ei=Z(),gi=be,wi=cs,$i=ps,yi=Es,Ri=$s,Ii=Is,Ti=Je,Si=_s,Li=js,Ai=Gs,Ni=Vs,Oi=Bs;var xi={parse:Ys,valid:zs,clean:ks,inc:Ks,diff:Zs,major:Js,minor:Qs,patch:ei,prerelease:ti,compare:ni,rcompare:ri,compareLoose:si,compareBuild:ii,sort:oi,rsort:ai,gt:li,lt:ci,eq:hi,neq:ui,gte:fi,lte:pi,cmp:di,coerce:mi,Comparator:vi,Range:Ei,satisfies:gi,toComparators:wi,maxSatisfying:$i,minSatisfying:yi,minVersion:Ri,validRange:Ii,outside:Ti,gtr:Si,ltr:Li,intersects:Ai,simplifyRange:Ni,subset:Oi,SemVer:qs,re:Be.re,src:Be.src,tokens:Be.t,SEMVER_SPEC_VERSION:Wt.SEMVER_SPEC_VERSION,RELEASE_TYPES:Wt.RELEASE_TYPES,compareIdentifiers:Vt.compareIdentifiers,rcompareIdentifiers:Vt.rcompareIdentifiers};const bi=Xt(xi);var Qt={exports:{}};(function(n){(function(){function e(r,i,h){return r.call.apply(r.bind,arguments)}function t(r,i,h){if(!r)throw Error();if(2=i.f?b():r.fonts.load(Ce(i.a),i.h).then(function(j){1<=j.length?T():setTimeout(C,25)},function(){b()})}C()}),f=null,w=new Promise(function(T,b){f=setTimeout(b,i.f)});Promise.race([w,l]).then(function(){f&&(clearTimeout(f),f=null),i.g(i.a)},function(){i.j(i.a)})};function x(r,i,h,l,f,w,T){this.v=r,this.B=i,this.c=h,this.a=l,this.s=T||"BESbswy",this.f={},this.w=f||3e3,this.u=w||null,this.m=this.j=this.h=this.g=null,this.g=new R(this.c,this.s),this.h=new R(this.c,this.s),this.j=new R(this.c,this.s),this.m=new R(this.c,this.s),r=new q(this.a.c+",serif",B(this.a)),r=g(r),this.g.a.style.cssText=r,r=new q(this.a.c+",sans-serif",B(this.a)),r=g(r),this.h.a.style.cssText=r,r=new q("serif",B(this.a)),r=g(r),this.j.a.style.cssText=r,r=new q("sans-serif",B(this.a)),r=g(r),this.m.a.style.cssText=r,I(this.g),I(this.h),I(this.j),I(this.m)}var N={D:"serif",C:"sans-serif"},P=null;function W(){if(P===null){var r=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);P=!!r&&(536>parseInt(r[1],10)||parseInt(r[1],10)===536&&11>=parseInt(r[2],10))}return P}x.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f["sans-serif"]=this.m.a.offsetWidth,this.A=o(),re(this)};function D(r,i,h){for(var l in N)if(N.hasOwnProperty(l)&&i===r.f[N[l]]&&h===r.f[N[l]])return!0;return!1}function re(r){var i=r.g.a.offsetWidth,h=r.h.a.offsetWidth,l;(l=i===r.f.serif&&h===r.f["sans-serif"])||(l=W()&&D(r,i,h)),l?o()-r.A>=r.w?W()&&D(r,i,h)&&(r.u===null||r.u.hasOwnProperty(r.a.c))?je(r,r.v):je(r,r.B):tt(r):je(r,r.v)}function tt(r){setTimeout(s(function(){re(this)},r),50)}function je(r,i){setTimeout(s(function(){u(this.g.a),u(this.h.a),u(this.j.a),u(this.m.a),i(this.a)},r),0)}function Fe(r,i,h){this.c=r,this.a=i,this.f=0,this.m=this.j=!1,this.s=h}var ye=null;Fe.prototype.g=function(r){var i=this.a;i.g&&m(i.f,[i.a.c("wf",r.c,B(r).toString(),"active")],[i.a.c("wf",r.c,B(r).toString(),"loading"),i.a.c("wf",r.c,B(r).toString(),"inactive")]),v(i,"fontactive",r),this.m=!0,nt(this)},Fe.prototype.h=function(r){var i=this.a;if(i.g){var h=$(i.f,i.a.c("wf",r.c,B(r).toString(),"active")),l=[],f=[i.a.c("wf",r.c,B(r).toString(),"loading")];h||l.push(i.a.c("wf",r.c,B(r).toString(),"inactive")),m(i.f,l,f)}v(i,"fontinactive",r),nt(this)};function nt(r){--r.f==0&&r.j&&(r.m?(r=r.a,r.g&&m(r.f,[r.a.c("wf","active")],[r.a.c("wf","loading"),r.a.c("wf","inactive")]),v(r,"active")):$e(r.a))}function rt(r){this.j=r,this.a=new p,this.h=0,this.f=this.g=!0}rt.prototype.load=function(r){this.c=new a(this.j,r.context||this.j),this.g=r.events!==!1,this.f=r.classes!==!1,tn(this,new Pe(this.c,r),r)};function en(r,i,h,l,f){var w=--r.h==0;(r.f||r.g)&&setTimeout(function(){var T=f||null,b=l||null||{};if(h.length===0&&w)$e(i.a);else{i.f+=h.length,w&&(i.j=w);var C,j=[];for(C=0;Cthis.createElement(o));t.replaceChildren(...s)}createElement(e){if(e.type=="separator"){const t=document.createElement("div");return t.classList.add("separator"),t}if(e.type=="selection"||e.type=="checkbox"||e.type=="dropdown"){const t=document.createElement("div"),s=document.createElement("div"),o=document.createElement("div");let a;if(e.type=="selection"||e.type=="checkbox"){const d=mn[e.id]??{label:e.id,combos:[],callback:()=>{}};a=document.createElement("div"),a.innerText=Ht.getKeybindString(e.id),a.classList.add("keybind","unselectable"),o.innerText=d.label;let E=d.disabled;typeof E=="function"&&(E=E(this.app)),E&&t.classList.add("disabled"),t.addEventListener("click",()=>{if(E)return;d.callback(this.app),t.closest(".menu-main").querySelector(".menubar-dropdown").replaceChildren()})}else a=document.createElement("img"),a.classList.add("icon"),a.src=vn.CHEVRON,a.style.transform="rotate(-90deg)",o.innerText=typeof e.title=="function"?e.title(this.app):e.title;if(s.appendChild(o),s.appendChild(a),t.appendChild(s),t.classList.add("menu-item"),s.classList.add("menu-item-title","menu-hover"),o.classList.add("title","unselectable"),e.type=="dropdown"){const d=document.createElement("div");t.appendChild(d),d.classList.add("menubar-dropdown"),e.options.map(E=>this.createElement(E)).forEach(E=>d.appendChild(E))}if(e.type=="checkbox"){let d=e.checked;typeof d=="function"&&(d=d(this.app)),d&&(o.innerText="✓ "+o.innerText)}return t}if(e.type=="menu"){const t=document.createElement("div"),s=document.createElement("div"),o=document.createElement("div");return t.appendChild(s),s.innerText=e.title,t.appendChild(o),s.classList.add("title","unselectable"),t.classList.add("menu-item","menu-main"),s.classList.add("menu-hover"),o.classList.add("menubar-dropdown","unselectable"),t.onmouseenter=()=>{o.replaceChildren(...e.options.map(a=>this.createElement(a)))},t.onmouseleave=()=>{o.replaceChildren()},t}return document.createElement("div")}}class Di{view;windows=[];app;constructor(e,t){this.app=e,this.view=t}unfocusAll(){for(const e of this.view.querySelectorAll(".focused"))e.classList.remove("focused")}getFocusedWindow(){for(const e of this.windows)if(e.windowElement.classList.contains("focused"))return e;return null}isBlocked(){return!this.windows.every(e=>!e.options.blocking)}openWindow(e){if(e.options.win_id){const t=this.getWindowById(e.options.win_id);if(t){t.focus();return}}e.addToManager(this),this.windows.push(e)}removeWindow(e){this.windows.splice(this.windows.indexOf(e),1)}getWindowById(e){for(const t of this.windows)if(t.options.win_id==e)return t}}class ji{renderer;ticker;stage;view;chartManager;windowManager;menubarManager;actionHistory;lastWidth=window.innerWidth;lastHeight=window.innerHeight;constructor(){if(En.setDefaultProps({duration:[200,100],theme:"sm"}),window.nw){const e=nw.Window.get();window.addEventListener("keydown",t=>{(t.key=="r"&&(t.metaKey||t.ctrlKey)||t.key=="F5")&&(t.preventDefault(),e.reload())}),this.checkAppVersion()}if(ie.loadOptions(),gn(),Ht.load(this),setInterval(()=>ie.saveOptions(),1e4),ie.general.smoothAnimations&&document.body.classList.add("animated"),this.registerFonts(),this.view=document.getElementById("pixi"),document.oncontextmenu=e=>{e.preventDefault(),this.chartManager.loadedChart&&e.target==this.view&&ut.open(this,e)},this.view.onmousedown=()=>{ut.close()},this.stage=new wn,this.stage.sortableChildren=!0,this.renderer=new $n({backgroundColor:1579292,antialias:ie.performance.antialiasing,width:this.view.clientWidth,height:this.view.clientHeight,resolution:ie.performance.resolution,autoDensity:!0,view:this.view,powerPreference:"low-power"}),this.ticker=new yn,this.ticker.maxFPS=120,this.ticker.add(()=>{const e=performance.now();this.renderer.render(this.stage),ft.instance?.addFrameTimeValue(performance.now()-e),performance.memory?.usedJSHeapSize&&ft.instance?.addMemoryTimeValue(performance.memory.usedJSHeapSize),bn()},Rn.LOW),this.ticker.start(),In.init(this.renderer),this.chartManager=new Tn(this),this.menubarManager=new Pi(this,document.getElementById("menubar")),this.windowManager=new Di(this,document.getElementById("windows")),this.actionHistory=new pt(this),this.registerListeners(),!V.hidePoweredByText&&Sn()){const e=document.getElementById("embed");e.appendChild(document.createTextNode("Powered by "));const t=document.createElement("a");if(t.href="https://tillvit.github.io/smeditor/",t.innerText="SMEditor",t.target="_blank",e.appendChild(t),V.url!=null){e.appendChild(document.createTextNode(" | Open this chart in a "));const s=document.createElement("a"),o=new URL(location.origin+"/smeditor/app/");s.innerText="new tab",s.target="_blank",o.searchParams.append("url",V.url),V.chartType!==null&&o.searchParams.append("chartType",V.chartType),V.chartIndex!==null&&o.searchParams.append("chartIndex",V.chartIndex+""),s.href=o.toString(),e.appendChild(s)}}dt.initFileSystem().then(()=>{if(V.url){this.chartManager.loadSM(V.url).then(()=>{const e=this.chartManager.loadedSM;if(!e)return;let t;if(V.chartType!=null&&(t=e.charts[V.chartType],t===void 0)){Et.createFormatted(`Couldn't find chart with type ${V.chartType}`,"warn");return}if(t===void 0){const o=Object.keys(e.charts);if(o.length==0||(t=e.charts[o[0]],t.length==0))return}let s;if(V.chartIndex!=null&&(s=t.at(V.chartIndex),s===void 0)){Et.createFormatted(`Couldn't find chart with index ${V.chartIndex}`,"warn");return}s===void 0&&(s=t.at(-1),!s)||this.chartManager.loadChart(s)});return}this.windowManager.openWindow(new Ln(this))}),window.onbeforeunload=e=>{if(pt.instance.isDirty()&&ie.general.warnBeforeExit)return e.preventDefault(),e.returnValue="Are you sure you want to exit?"},window.onunload=()=>{ie.saveOptions()}}registerFonts(){mt.from("Main",{fontFamily:"Assistant",fontSize:20,fill:"white"},{chars:[["a","z"],["A","Z"],"!@#$%^&*()~{}[]:.-?=,_","0123456789/"," "],resolution:window.devicePixelRatio}),mt.from("Fancy",{fontFamily:"Assistant",fontSize:40,fontWeight:"700",fill:["#dddddd","#ffffff"],fillGradientType:An.LINEAR_VERTICAL,stroke:11184810,strokeThickness:3},{chars:[["a","z"],["A","Z"],"!@#$%^&*()~{}[]:.-?=,_","0123456789/"," "],resolution:window.devicePixelRatio})}registerListeners(){window.addEventListener("keydown",function(e){e.code=="Tab"&&e.preventDefault(),e.code=="Enter"&&e.target instanceof HTMLButtonElement&&e.preventDefault()}),window.addEventListener("dragstart",function(e){e.target instanceof HTMLImageElement&&e.preventDefault()}),setInterval(()=>{const e=window.innerWidth,t=window.innerHeight-document.getElementById("menubar").clientHeight;(this.lastHeight!=t||this.lastWidth!=e)&&(this.lastHeight=t,this.lastWidth=e,this.onResize(e,t),Nn.emit("resize"))},100),window.addEventListener("dragover",e=>{e.preventDefault(),e.dataTransfer.dropEffect="copy"}),window.addEventListener("drop",e=>{if(window.nw){e.stopPropagation(),e.preventDefault();let t="";for(const s of e.dataTransfer.files)if(s.path)if(vt(s.path)==".ssc"){t=s.path;break}else t==""&&vt(s.path)==".sm"&&(t=s.path);t!=""&&(this.chartManager.loadSM(t),this.windowManager.getWindowById("select_sm_initial")?.closeWindow())}else dt.handleDropEvent(e).then(t=>{const s=new On(this,{title:"Select an sm/ssc file...",accepted_file_types:[".sm",".ssc"],disableClose:!0,callback:o=>{this.chartManager.loadSM(o),this.windowManager.getWindowById("select_sm_initial")?.closeWindow()},onload:()=>{s.getAcceptableFile(t??"").then(o=>s.selectPath(o))}});this.windowManager.openWindow(s)})})}onResize(e,t){this.renderer.screen.width=e,this.renderer.screen.height=t,this.view.width=e*this.renderer.resolution,this.view.height=t*this.renderer.resolution,this.view.style.width=`${e}px`,this.view.style.height=`${t}px`}checkAppVersion(){if(!window.nw)return;const e=nw.require("nw.gui"),t={stable:3,beta:2,alpha:1,nightly:0};let s="win";navigator.userAgent.includes("Mac")?s="mac":navigator.userAgent.includes("Linux")&&(s="linux"),fetch("/smeditor/assets/app/versions.json").then(o=>o.json()).then(o=>{o=o.sort((d,E)=>t[d.type]!=t[E.type]?t[E.type]-t[d.type]:E.date-d.date);const a=o[0];bi.lt(e.App.manifest.version,a.version)&&localStorage.getItem("downloadedVersion")!==a.version&&xn.open(a.version,a.downloads[s])})}}document.querySelector("body").innerHTML=`
diff --git a/app/index.html b/app/index.html index 65427e81..28393389 100644 --- a/app/index.html +++ b/app/index.html @@ -24,7 +24,7 @@ SMEditor - + diff --git a/assets/analyze-576bdc06.mp4 b/assets/analyze-576bdc06.mp4 deleted file mode 100644 index 1b63bf159a98627260db6733b5c0c0fd7e8f75ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3326754 zcmX`R18`+cv^IQVO+2w}+sVYXW}*|@wkEcdiEZ1qZQC~fy!U?huiAU}(@VWny{oz! z000mgJG$ALIoMbM0HA>X#_yLI=xo4bWy{J0005wk?Tw58%sLoWhCs(}nJP$#udlLo z(UXqD6^W)K+GWBOlFKVsW_DIWIzj^*dm}=oZ)nfL#K=j=!eqq6Wz6->kf8q-V31W1 z6{lk*6jBrZmNYan_+|*(*t%I789Nd(GcvN!F*7o=d=pI_9c{T87+hRj=$*|BjchD| z*7P>^CJg_rLT~D5W%(^*W9w*UW9`6AXaLj)8t^d@+8Y`3u@D*>>08*|{U9sXOy%--mK0&_7kGck44|K{1)8d>X_*w}t^|Cea{t!iQ9_HCPwnT_%PL0u~| z>+dO{gMpE?k%5yVA1mX3ZrTI?%c;GQgXy=ry@BrkAMSsAdjmcLdt*W?{qMy77uNTL zkC~O8k$>0i+wt9lDk&E|DE;D)OM2v`nS+d&WKVBJJ%Kj42e;3+FI z41zEyAgZm=rqg>Ndah)h_a9%>cDkIFyrI*$iBZ1t_BhVr7tHW0Xl6AdkAxRerbmSe z&i0Mwq`_j{-jV&_BlO^t&XJQb(0?0jS`deC?f)f+2`q#1je z4&k~*8s3;Xh5^>v#n(GN=X)nS9VX~5?Q4H!THrVcCF1$xRKh$;H&wqf3qy}{hKg}1 zc(8WsEVf#9RNLIh%f%mgGK{V}5c?i-u7MFFRYjfxfvY+hW7~<-AJ~JY z^?DWrLM-S$)ZU)_ObA5^71Z>@4Z4V;*u)&&ZJ`=fnCGWpEj0tvHv3AN`gxL52ve~k z;!a(bt_C$m((1b5#2Fs3DJTYuLQz)3;e|YTQuJ}o3PPk7-*JR0DA9@E^1$zP1+RbI zN>b!Qu8}kP;sod6$9oUn(D;}JGH6{3N1R{;X zwMNVskWMo)L>j|RI`~R-91H!Q8cQi}W7ln(Do1YROmFJ^;qt~%`=a3rA=D`L?5c`` z$5aFBO4`j!v1R_+{Ki@C@T!V^Vpu*$!E#m$I7q`-@^Q7Dq&zS%m9O%+H?}+ebdCK5 zS()qi?l^+8Jfg{7l-_}>EmA+Z6stb5;nvROn`acOb_6d!j*b+cF~;(=hRM#nUYW^qVkz<%zcgcHjZ!w-7} zvn9T#EwY~B0#2gbEKrF|1fzUmc`L-6$QJCG1Z*^0yjWj8W4M2w$K5E(B{wCKsk|q~ zodTwD`f}Hk%P0kksn*DWA7~GHpA|1;a)_M-ugul{|HSiWRMUQzmJ26}!RR#wJT1vS zrrf8$myf5--Dcamf*Pb{?i~3UbAb*!u75g=vLb!erZ)&^HaA%Fg@bg6|RqUpkBdg zrTfU!G#SpiE4~NCLs$Sz3*4q5!4fSqsfDk(JScZ@?()i9(7o3S`l>efwqs_534aF0 zpbzu=`!4y$xU$0xnrH1d9Ks@j=X0#~K`I&L94@*n+b2|$0b>Rk>&oIogV_}HxCCzgMQ`Yb)B8Ar&Cqpz4OdzoT=K2-Xx2~IGQ;>agSb$5T`|MW1*@8pd4nA zTAtiF^U7cpKC_ZIbo}D8$ltk}y-SGe+sGG2bj{4+AN2SNeCov6lsE90(d@26Owt1d zfV9{|Tw_y%x|t3i2x1Kgy|D^|-h)v%I+pVVh`h_NyEjHuLV=hIJ~g0<4TrYqWDvyV z9Fhj!xMOcsoun-4{#mXny*yqGt?~BN*KQCXsk-jnG_KlR+b^7lK!hpxA6P}Hju9OFriKRAEt9m%n9-YOE&&P!8IpnbX{qUI)`#l3kMBLj+_u}Z&+PO({DvZ7apg)@jJSPiop8toZ{Lfz|Q11g308I>|2_%`(`h4C#a>>XMNX zOK_wj+H_yri*LH>{xoL21-#@Pl!+=}2Z!KQ4xj6H^~8IKYha@+Tc9?LP0&ZY^=*wn zO(vluwnz@rk)Gqpp#(VP1Ct9&@^DJ0qUN0W_9&3xBx!bfk>bJjzGU)TU$1}|sWu+dNTw5ulY9BY5Q`k2 zhg~d$2}L485WVg!d&J_DCvV8qii~c^thwMSuBr+uKx?UCANbj_q;doiBg{gf;UMPK zf0w<~Yj0LQAUD`gaWmE7tL}~*Ef6#&tUzSvoMWTZoa{ohpTFC7ZuRVgmJ%^rZ8j5P z*dUFl^zBpoLp;0GBsT;M`H_jg8Awhc z-)#B({`8EZatj<5rTNI*J*`)9sA)+2an5DpJY4IpwuzqQW_U*IWQ+FB`%27N?jKjf zOv{nBQ=7xmk8rD(B}jTNmX-A_@-y66!tz<)`LU^<9rQotknr2<7fG1Bn|(y@IUR%{ z98JqA9>qTgVpd{J?t2BNOW5+&^Sy%XAi%L8Duk=!{gWlVTr85_^V%>6rk;cB*i_b> zw0GdzH8)jq$XLZE&BkUC1%iua{$ugD zsQNMh6AGoCKZd4<^1+Y^a2whGVh;(?LXnAE>Ek0IAdGIhv=Mw+QHT06HF(7Sthdx3 zQp9fFXnGrrX8C)r`(f_CLW06aQvA?omu0^&`}KZ-k8S4Jx2I{Vwp%AI!R5da;XsBA z8(yd11D&2@_@7r8KXiOQwH5WXhpimY+YYlQ@iWciRac=87bAu5+s3BHGB#<7F!T;=craa(w<`zhjt{nUP zPn(4j@e5;hcW0#8AgXH^t%-~S*?%HUwW^0eDI8^oJ?je};th@Aai*szU-Due$}ogF zgUmM~^>ZEpbQ||HwP+C!ZhfhSyU!<|QocK+P+_@Wgczk8saIYrtl>u1Z=zQ~0J%s2<`S)>K z-TB)~&ftD+P?g@FwOg=endT|m{0p8LA1dsW0W9rFPdw(o0H6YVKJXdN3YL3%oL_o0 zkRwz!R|E2HuZz4fw zDjy4xqRg`%)%6dY@EM=wqGh)xrf?kF<2?*x`Ry_={tJIx?DwPepAuuR{p5v4ZH*wz?;pg9jTk1yCv0{DhYg9cc3%ZKz+r2*cxj;GT@orJ9Dz&Z z%t~1GleDoMU@0}25sV?b!9&x9)@F3q7|PK#>uXfJ+2z)JWNxTrA4df>o3J57MZhy= zZ5A>jybpwC4)XlRGhQ%7|c`#(h?V zv-|w_nSPZwpWeRM4zU3y?U-I>o9!8uX31Vf;f$IyMh97A= zo}&8Vx8=PQb%c?^YqQ>h)#~`Q81CRJgJi1qJN~l970V*4;c{?p&=2Ra$Mwzs{tnYE z%z+!ICr7toT(1cRt2TLj>R^o4A-_YhFMXJD1VPN<{A*hJt;JMh>=9{k&^vctj~VGx z$jY;^HhHB-dnHh}njcYQ0sA?O#gwBC9p987g_ZQ9eakq-vC0=PArIr+&sK!#de$Pr z>2}szkYaKGOMar|Bi*mP++ zz0W+s{Cpy^hV5X5rM|Zo1)sITQtQecT(t-vM+9aiXnVQAHKtqsDQ?b>(B#}1nKnuT z9d67yksmP2F@e1X^|Pw3?7<$t6XN2<_NaY6AP3N^=hwEpI?^4OP9M596`~ev%U&M3 zwHWnGsF-JFQ9I(mM@7vy``ThT=Lp~l`}|@&#BKFf-}Q%kV@+z592MV2EN9`}p>#uWwy6`bdb;K$0@nM)3=1bsov$vI2UoZ> z!71qi+d-JCFS|if!kv3`tfj8J)W;oovoLP1;2avtn0c6&QYM!TYx zADdQHW35Yk5$vv~hF|zta|(r$j=1~4T(vc1RlE`N?XoUh#UK2xoe;>^4TIC0jdDqB zJz|Pp7YqoWarUJbwBP9_nfs*{RZAR`ZN)vpxEKHWsxWWk2g_J=MimAm|ELG^FwgKK z_1XpX{qrnWbcXhK@gyXal|@(Fs4g)*5ByBrC|F{I)OEu&gq7bilST8vzJC)9mHII3 za#5M7S&k6^0Qd25@8qjqU9^M*02Gu)?p-uy6^|9}O$$)W6*hs+D1mvwT@qXksr`ve zQ;HBhpo~4Oru6v5*gD#LTSnl{11>fy64&JF>qqL?+tX;?Q#9N6d-+@cFCUq_uV6l&S(q59+vWMfE z3?Lz0k^Mvm37A&1=SV|0{_j7{=4yZpd$H?%>)eq^leBrwX^0~7%K#Aje5ov4mFGRs zeS=i&TmskQA#2vc966tmcpneuSwH}%uDtaOA1<}Y^*hU=aRsL~C)>>N#GpN^N8PZ5 z&ADz@<^(Io{hv}l2)B}PZ!&W)8=OuF{eLYykT^qmO(j(KyNdS2J8EGNeSJLTVWMm! z&{AyZ?~x6A1qjlm8}0<94aUl3X(Fa-<$n&r-7?^zzmN@_QcsCU$`&)#e&PgMzpg2 zw7SSVz9(cJ<_(=Xg0q0wsfSf$BofD$m$JjNvYF`GDAc!BIl@tAsAns zLcv)47oOg1$PxZF(}M-r<-Fq673F^}(HGS;KVOfEwf_iOXkzwg9&0rTp|Cj@>Sbc*jfn$;lnbn(B}6OhuJ8toQ^|ut)8@sNwwNv zUKzlKHKTqGnS2vJ0kK@ELGHb1#@(yrTy56Epl0s!<6T(}UhQNVKMXjOmo`QEeVkQn z2R#rKVDz?0jvYSX3&5SfI54|r0u%GcqMz5T#Tm9IhqkUGbv_@l)Le*wkWUocNidPK zPV*Yx=UL-ZavF)F;@0#XYNzf?rOf`rZSVw{Ow|j`=%peSpF-YoId?jxE@-b0)N!~V zN$=v}eebE;P3%RDPxTiH?wrj=k#?zCw7ln-5(|S>w!fxOW>~^e{@1!$kEh8C4!~}5 zwYZ^{srW%*_P3n$ps>j6-`!tm>i)D8?QqwygQO4Hfz!wIF2E`Enk<)&cz)%zna|^K zOH{`q2hj^)@?WLtAZosuRWswT40dI1bULY}K*Y!Djvcj6E;VS&C$^*AnBP>U2VTpR zAH^>{i3fSi*v-5LCikYLoNS59CeA_ID0lvy5z%bsdZE z@JWD<(#1E&^IbUy5ZcqbY;dIV?=yJUAIzSKjSH z5Zd@|bIr2-%gRDy%H?NJfVumP&J|~MDz2oDUx#72Ft7?k8P8NxhQ%VSLOvE!rWnxu zl7Ym~mNxXXwIYBlLuvoo9yAMKZtusARF@Rs^783CrI)ZcHFgKtlVqPH+9O90y!%rK z=AGJ@E4sx@LLl<98Ak)~sIwJ`!i) z?~o+66*eJkw0rxwtlopo5Y=?PUfznb(sYPUIHyPy=P&1V2q_FX``Is;Q^Pom@8eQE z&eea?KLsmuv%4VbMrI@AX0X!ipI8?;H3{6$I#ubjhs1s>7umLA1x=&}`2}ocpidOa z(8oeW4&pA$i8>e&3!IPM4UAUYr-uCJ;xn;OXqX#nGt%{p0;;}}(td#ngX z60p;x*-DRMhkt2W)#jB`#R~ZI(=5Ncmh3gqbG+!B!Gz4%UMV`VU9!A$jNGnGlEd)+UP8Kg&pygA~&wH5&fRAa2o=l;>3dA7JX6Dg5)O;7J?xXvw> z@n?8G-CGJ(nki)$>IEp4pW#yHu6}>Hr!Wnv`12~USlf9Dudw-Kg65G=@=RC?d;yRI zOwRp$1-)|K-v_}x7<(d5#uo+S(6);qGYp%#Hmu1?#Y!1!NpuiV9Wp#i`ZZ24?Us#D z?!jRtn8are>y3~`?q|GOmGfc;dFkFtgEM{G<71-gxWQ-Vc@Ea-Wamq0zz76~PjT^N?ePlW1sac8;EAB=| z!Uk5#sO~;zam{g~xM^^I$Su)MMni3~r^Jbxx#>;cTa6r7B4Pf99(0eylqxIPYhRE; zU`sWHW4BR$>-;Bog1kTC=tG3r{>HIqn*F0EITn>76PAwsv?J*y@~oU}a@=&8UY5LEn(*(StF zkvTw6Vx&g5y_bS5F5pRLY=bK^7XyRbF)j8bj@ld!7f%8E2|_;6aAx8V<+Cc8&M)v6 z|Ba%7ksKlU$ny^-Vo@`fp}7yGm7L^bZ&v+@*2}_fR<_)+-0WIH=g-k!ofY!x^au-) zjhhQaJV)H>gO2$G%^gwwGY`M^ws|h>-NgRb$-~P`nE^#{K(d@|k^T+z@XPKEN*t@T zNQWXLd~l9?Xr*?JW`T{{;lr+1p6fbyZRz7axL!B>+tCsTB-71x0-kq5lOrx!MhN7t!gCB5kVHw;Hh?!j!<6Khi$-QPk;c zaC2k~FQsnPq6CXs>wuuF8p13^(y6;jL^mKI8`QN}cY?t^h1VGs-AcgKjGKI`Kq{T+ z{($BHFu5Ogn1ISzdr2Ia(fw%BqS(%71{t0VK2&QoDQGNRA;&FS9NX6E)}eUaD=?M` zyaM?MTKk%*Xc0P6<1$jZ(W|w^eJI(au@{?#X9%P*)BSqGd4k>p+LJLzYgLyV9$G#w7Xn9-~sY928{bdnGDFlJduH4*!O4*l(nM6W-)zfZ`^3RH-o#x{Qnud1JVj;_m6{}ZSqlOGtI(?HFyy%L%! z(#~G4T}1e|66)jUN>Kl>g@}+Jt%@PAWX`Sop4zNe^%egopp~Vm@~Lhn1JU1&*%Be? zisEAXt)MP%nPKPz>LP9f=AOer9;gp?yz@!&Trso}?t2<7*O^d~A5FCQsJSu34E_#L zd|OGKznbj+qa$*EBPHAbO{C{39kMOpU{ zk8%^5>6rO_6XpM^RejQ!eolcNXkiyPXkV~asrTl!YnUkYV6J1x0+g4V&CW$_7Iau!JgCgNd` zDh#j9f35D7NSt+F`aL>_1_#^Q*|9fCfa#3unjNdDZ>mJ`jhR#4(tMEp&))zRVUKMI zLD$5JUrQ-JGS3iK2!O*enDA`F!o-)B+EZ$F!)Aac&%pOC@bGl&d3;2`5m?O1mrOp? z2~7tx^NaB3ITmz)gMCqb!mS%;v8_vH=-DnPmZPA1F%#*gr~E074FD9h=Y1^FwA~cVz`9t|%deU)=O};Wq97$dLL2k?yqBgc%&3nz`^$TOfT(~K8it!RQ zr8tYM3vnM+1xf5MTbxwtaPQOXSFVz>%*G? znVCs(2g3Uty3Xo>zd@20w5WqA;GYFVFNa!)#F5Q!F6ul50raXZAd-fQaU1HqQSI~P zspV_>ImTx<0uT>l<?cCym~?)&r=R10cq$tku9MK zqBoOe6pk9(vOb;u=YZQW2*JFvyI~+<0sGYMDSWEDmhUZKmr27Ms*cB4W$$o70L9s! z-*W|Td}ZmGY@g0QD5U^Pe8TKx6B#mxzY4E>!<>{2*kRGDrjW4!Q33Xw&>BeoYLC&$ zw<8Gqg0WZ^L@SSHA4n46N&<{tl|MH;wHINWM*|Rvf8MP?6JT$U<03>u#hw#Fs)IuO0<5BL_Zw9$g!glvgskaQH30_DN6&Ms`F`tpZ)p5bA@p zkLO~~2jBvoXffC|BTuNZl z;RWx&0dzs22(F5EijkslF*_M1nYa?=12tw8PdyIpp--`2s@xlJm|E!xhgh;iInS2h zP!>qTCGvRp0rG7PYeb*59JggqC-B>v$~p);_-0{J$XV(O?!ocLN|kW4>Yr>!I?t)d z`zP8~*BpN@Sub_Q(NU&aZamwVB~&oTR`a ziO1}*_z<(M18ksX5VA>-H0apAPKJ(3BgSI3yX8 zRu$HIA)t56WM<$9tDN)2Qvf-4(1R_;espnHn_+qyAK$Z89zx&d(OUT81CMQnRyLA1 zSUlE1rYH65*LlJAUt$Ynjz^rq0vvxLT?KRXaFIPTxi^QO<6@PgBI^5$`bKglu8O8O zRSrS>QH(au8MYNZS&D*FWSN#}QblafH|&oLdbNF(GqLgpn^vAd^#i?3@e4&HUhU+b zn(7pq!sMsaapEq1UzZ1+WDKBkky#|w&mR7c+B^*OLbq>F!3|%irA2LbT6bnVVcul7 zs^7>LhDn~rfaJcyPPo}xbUI#)P%q9A`vdnRd$*7cz-8{3hs0KH%|bhTn>mEhLtx6V zmmOZ~h|WGMfVTuG%1>~$k6quGvl$XW(ertQKlQKB$h*?SH>!QWxthOSLnEnm*cr8f z$9ppv2{pWTM*c(D-8MThvN&hMuKva2Tj3O27i;+7@yBHG&Tusox58(_09u4(tolWV zwD zbR~5ss*4$kesIxhOa(~dkxEweyu8Sg4)W6(+3dB-=6o7Yrzae z`+m2Rg8XmY)ECvlo0a8eAmm+bx#}8PXV><ab1drq#-TSDND6*w# zoLbX4SOn`4+hl&zJ!=~3&1Mv{w146`0sN;YTW*Gqz%gQHuUOF^<@8JtdpZ-?!&e+~ zI#OA?dZ4AJJK2fjCpAFEK{3H(Cc~Ev-ig0mnv|je`$V}inkjvOoNLX|1#ZwV6Ego! zofCiQ_sP+Zm+NK+8SHlj@0?~m{D5SU&o&vTL4k_< z)p%pSDKJpCi0;GQ_l|P7<=c{Fy~C)7#BIPmbZszY+GHKlFA5_YSY9{)#HbnQh4wle zo8XtD`_%26tNCw6s3Tb{&udcg&$vX;$U{Lr9!FLqToaOD)R~$q%a%bq{!9 z^D2nKh+jhf`h{*lrm?%hcxx=@zjefa;c_Z~g&_%)lcD_E*Yz)-Ac0*DR}{0fp`A(~ zU+}~lO!RFRW?<)&_3v-9El5R-FngaB_h1Li*P?)}xron&*K*7xoUck~-3{{r>ge#c zx|=pbJ@8#w=4k1;vpY}#SBX-S_19l858Rv9r#${Eli3cf9}&GrQ?X9|LXm71365P( zEU}{v5z9GjN{c+5Jk(4?3++onJ1aMMaw;HRRXDb3YAH@N8h8YAbn9Yyuj&|X7?7))eu2njSjR%_0CgAs9QMgo?fx(7IQ zST(pC4>{NYL%|PWwb#!op?#cYS)o0sd&tXjy-Jq6#l@;EYWbIM#_l_x0wQ2d7>pmOAjidIFpG8FsaM+I5$0j2ONMTsey z3BqtapeOxY^YwrMcY@r!w20hBi}7b9Iu~1R&u**2wmdCq^>#Ik|EqD&PH1IuRyOtNSZjVCifLjQE6; zpm^cJib>ccVh+3y>=XZOiyxNut`K2{Nujqs#S=SD<>({fzH7n1Mgf|B=?(A1z}<|$ zMGjGkcY5xLr`r}4;_jgl{vgA-F4+Sme0pvK?GTCy8*UZ?`XPsb!k#iMNvr^JRYuV) zKk`tFtfmHXWV|&?Io}}fY`0pRUlWHD88$HRAn30s)~Rz{TUnuIAX9aAHccw5nJ$eh z-wD~C$-xrN<&QYkl$%dakKe>3!k(uIH^XCBE6*QgMi?mipEQ8DNNxl(kDCT@SvA}K zC1d?n&LR|2JkXo`LivDMj)93EVh53g?(X%Z0~$yWc;yAJOACaJmQCeP6X9eo&8O7z zH1IrtMkLO=NydrpyyU+kHs z^vSjwi}`|9-+Cm%@nm<3pXsUkCf~GcH zcYIP>7~uFFWx=uE)66@ z9LhZ9JPg_3yrR`g8Tj#2+85jj0N4%pad{G9I)PlIF6Fe1b@vh5Ta##qqzOw2&7nxX z_=7UEYG~rFyMO4YTMR?P==ms>H;<7ti(E^slOH z-;-deaSOeTnlYS44`;oWb)TEE?z9lM?E2!p%ymJGn>c2wbQ&QREOSh<_)WEWN939v zeQyI!!(1SmYCdix28CH%leq6i-+043T}WO_?bZZ}w%!7Bh^6OLQ3F`sj$m8f@#oe|>x`sq(~_3lo(*a_5n{#$^j zCSFgPwU_bJi7S$?AM;;_1ct**A+5&W@khV2-X@(- zFlINa0}-xB=@W_G$&!+;cNNA_Z&oYYa{+Z5NUbTvX`scniC@>yR8&hjEM=%a(iG%W zUo(|J>6dl_0b%{9ECp9^Y}FT%^kp(q{=+(}&Xv-fwEHCsj`^y=0 zOmo!y(a(b#HU+~`8N;Y9}6)c z|9B6E_Rs1|_S@0AAGLw7Z?Y-cp>s%acYHuQi>a@8^i$||e`=sK3+hr!zDeuj%2gzG zGl)?1P^t-f0+oJK$A-@K#+isT&Q5X#glxzCwix{D5d4Qv26tR^oQI4cY$M)y)mThl$VeYGn*bg=DuoepmY67yaJ7d zRbga|k(l>?RqH(rd?sW=?AzO&F^P*Zl_->wUt|T*omFklC$Rn8BjdMlWS4bH0iTue zFR2s+MYj+c3RNL{$s&f9L%CAnIcDoPZT)(r(|BWDRT`4|WFK>C;0X^uCx$w(+s>E) zF=FY*hJIfMj!s`viB06P+c-tV?qdC7cKHhT;M#xpMM-GdUeL5s&3t0>DwPM&2R{y( zxdxqJ?}P#_jWP{<0lPkV*HNeYkJ2?)yhyjDV@-5SD=+|KYdmM>H(Lu8*J<~U`Pye- zyLx=fgcg|@;#l^6XBG9H!Xd=-%SjFW;WKfTxHq1@GBJnFT;79XZE{lD!$3K{+VN}x zWjx0G+V4)3ztb!+m_t&=o;BcMKnlcG0Z)O#(GT9gDQ#UY_-29U?x+R<6Q=azi2j%i zRgqph+e|;7_$ogA!3(x58MmBFp#?lyg%8A-ka3-XSrqO%xMktMx1Gd&P7o0{qt!S( zNwpiPL+KBMRtV>&+ivej^de|Sv`iBz4_)f*RtcLUPrBPm+DVCuUk-*LaVNhx*B0J6 zd{!h6DMtcHijPSd3yC8n%0fb=RC+@el>7c{g0-@g(6$DTLGr||#pYicnaS6JKIv*% zDf*e0faaW;gDr1x_t^(R^!cHDVh4M7L$Ij42GCuE2Y~>KO~IL&E35^Mc${R!O{&Vt z<{v(hb*<2Z$k@8oH=tvltOAp(MG997e{ZNrdWC=rqhr`>a37t}K5eb|5K4oCD(>W&TdKm&ZJ z+G{A;D}GozQg!>U7zsuw6#h^-fe3Mfpw{ae?99(PKqUWDSNY;P%CF?A^TXNA@0PwX zZjn+Ad##i8XOY~|=8E1Hihwr2G43u?jM_N($pcN&@%j7@SzMX0VP4{n+hAY)y}%{-CIq)2$f?Tii@dVf{Ljncp8&Y!^POXy-okl+w?0cL$x`SxD75eud%0CEx%_)3dWQFD8hhZXHrfTn3_5^moRTCp_6pAn4`9XEe|7p@|K5_i=RMCHzd< zN622o;&~SgMjD z43{oQI9Gx`50bOFi8l~gku><;knN*JG*S#iaHUg1dns5uUj%vY5)*cednT7ulk#W& zM+3@sK3JXyWq7^=3j>Hg4mATcVG%ihT(j{|-7nN%#O*3+f2ynyWwvS1F+@llWvSkp z|npTaxv-DxOlt!u8ZK_fwWvO9N4 znkmSpHwfRZBa`j)yYA54knZf8mgu04s5ttyGL1poC1`5zoXF?av2OU>Llg^Ia$e|N z@JT;~)t%TCJSDJNX!&NHsMYyTd0<_7fUD!UBI1T2+;TI{1`I)LS* zR~;M=`c_n(^2C@Z*53GsePQ~K*lf3W&mMI`%PU8ld^IJ3w*0NTS^#SDEGmP?ot3ZI z=lp%UGnn?A3b~U{{vGR2^p4j1cyHW5?xfS}TEz8ZX*A}>jjlX^GeZpIC=R*O&NxR3 za$kh?2R|=r!bqn)YxathNYI5|R>pl_slQSJ(#wR$S6(PwiQt_0Te*kVy{uI9pA)se z8lGm!tXSdv`?F)m1n7s$1lHxUvaie*$Gj{B^MKqnfhW zy-)-}XTv_4PEvP{kTxn#wDR?*QwO*RK`@4IgNIIPT~Iqo%*PAy`D+P=kJmL;+3LLy z6zrtNG&HsxzQ9E#<*EErHZ%GOu2ehEq%&sqfioQPZMTI~N(I+eRu+Nmm|c0~Ui@cm zd;vEI7=7{AJ$f$fr9RIlkmy#3eXQy(C+hRkG(GHwbO7PL>Qy5xvV+tBYr)8c!H^+j z((t#hJZPJO1GiisXe`^7W>AjA|CrJ#dwvZ*{F*3S^ zDm|lJCTYZ7_sUM%lovqVJ$^;u%wTVI7q1~NLobRZ#9h2Np0*JInWRCG0&|#GMQOUS zP|yL1Ix-?z$YpkJn>_InmT~H}Xu?`0x%AM?YN0via@)NT!hqaqHD@<%D`2aNs!cUa z%9RfQQ|~H$8EGU5Or!z8Mu#c74}|yuwFW)g6Qpt8o!O`dentF^^Yt{r^&75gJDxaP zgW+UwNbkP9%%&_)REA^za}N8=BZ~$Pl;&U3^k5Y&8@iU6$_U-Mh*gtn^S53p9BW5q+6EMY5$k*sK`wYe*uKvG||=Ri|XuB&9$;HT@i z+F%jyACa`6L5E`SYvC`s{3yLrmas({^;l8DBrlEyy4!vXye8bMwqJJ|4eC!yQt23- zcgBztCGLfA-TOnAHlcBDJ6b+HXS*rGK4L>=-Ro9x&K45qU4&J+Fwz|4Wne8g$RvwS z7Ywf_OUFpgJgwV%Ng1e~@$+sU;wJjy@DF2DEh|IGuuI-UqteEr1R1#-k5RpRcJUABqU2$FnCe85O9W$-vyW?@NY2r5tJrNp*Qp<=sis(=5@3#>v+eKcJ; znS-jYrUtwZ_iQH2hyiMwma-1uzTncese##sWwi2s)OqYKwW&0fl5WW9fa z|C1hfqX(?Hv(Tj0wvHQx(;Ly9)T*OnH`IZSB<}{f+81{(+F={{z-tq%2WC$$-?s&;9xBBC6Vt$(FpSfU z(Jen4AUs)szgThkcBka!6@8S`0fho{Mqlg1q&Z1_0+AtMybQ=S=a?bMGZl&MSNLJ_ zWVq=7&~hPydZyUtakV@UYiJdS&`z0kzREQebDC}=UXS(4f@PIC4NyMm30#bhn zk%}+!Xpv0=J1Lg8PeXsH)cmC%aPvU>N72uV_)!=Fqy#9%DE%3;k#haIDgL0>q(rIj zrwq!6;R1CU`W1@igm@RuS{ze2S^KU;P@HmOGF>ZNV&y}|7+xO(#5XidjC8F6$j^70 zcDNnCukA|a5t-tR(b+=~nhG3Qbc9T}1nEzBN9MiVe3^7+Lq$CwtB0*bHbR>`UGx}R zPnWS!OeMxQN|LIfH=k;J>TFcRaJ!nAb&Cf?72HChrqe32A?9J)3Bm6#Y6%<|l!X>F zRYQaPJ7#~-R^^F{Rzc@(U) zj|vCRS4+Q1x$A2c1Q19v25tQ)TS=08bk+!ap!ob{8=u*vfU}WasKDBn2H_MG&n^#`XfvpC2&ohSYNa23C*=HEpu3FYiSZQ;I&S_22${@Qy&MX_Z$YMh* z0|}Bd_OOfzKr421>c78$sa4;)2ni1Y9z}rsf9$cAMOvYg6!G=|PVt_cF9G2AiS>cgOkQwPOWk&C2r9IQL5) zOxDEK0!#HIM|0p_4-MwwhfHAeY&Z@@XI9;VHxW-yX|8wzQvSAMd}d=}YzbMKFpBYh zaUxs|=`cT<5Dk{9>;(ON;L2tcg!=(q@a6U#2 zl(w0b3mOxDD@}MIiOY0wE-7^dcF&m(S@r~V)ncP}ZGxn*nXuN7oa6((IA)-R)8|5U zRFt)(ZnLEkVuM})y?gkco2?R&Cxq+w)df$fz=4M6&l=tuBgg0Ta5U=%unJ~!x9{f1ro3uUUdUy|jnb;iSzp@_ARAjbs$D6qJa3Hr@o?B_+ei;P(s1 z>9r3MPvjndjcg}$dMlX&wUmu%vtt9s&7-k*Hv*_=!&e02WwUF*Xv=&bnt1~tzJMz7 zF7Y^n7?oF?&F^?^+4R3v<+4J?^_p9dTX$f?k#})<2fufFet}H}XkttbM1ByY0i^?k zNCCyu@>B`0(JK2bJ7>Dtz@daS+7C8O%pvB{AMRQfJ_0;mG@@bJJsp@s@0=&->zPLR z?68E*KfZ+c?z14R4w*Eo_9*Y6)9-Ld-824B&j$ea%6FNMaVs@Ju@jPH4Wcrl zfqpN?@5Y4Ec23^{)@(5-Z(`F2pH*#1fw3YVyv626apIHY5EO1#o;`TlnYDY!|FE7N zp#1I-_q+oqu8wa4Z1BQwO>{j!Pl>Xxd#n~7(-m~c^Zj@JEw=0|jPHT1spT4l96DtQ zb~vps{Q7xZ4XaD`;4{<$xn*CWQEjND1yr%#kBU0Pwa?|D`||_aYLPRZ zuDr=0chF*vKM?0%AhQR0jrNa`>qJ-gx~_U)0(o-$9vf#xCP@Z<9FHF=Ro$>j{)3Jo{$-NW26>r;Wj14a!5Q8%M{ zeC~eoot;`c+g-hqlJNE`2~ZZNnLgo0nxIMH>T$=S@mmi>er>D?1%Rd%0B_DIrRIlFGL3`dz3_XW$U4V~Q@(7Pi z*@UWcezJx6D22XA?`r{3c?s=yhmI6_bNE=|F)ki=XgXPB;$5F2 zteG)xj33j`7jFg6vjJwd0tfMn*};Rgx@ zYsG1m?C-tKP1>{Gnx|Hg1%&%MrQ~BDGXwRBXCrL6XpJqU2UX)YzUFeVlVJ;OlG|!o zaX5ou;XRk}Fxam0BkI9i=DZcMw(hP#SZNA#XiM~jfvn)UD0su5aPp4L8eu)1PthvV zU&AYUG1guFjv;h2J>Uaxvi3I#rXwAVc=ZD;E~SAVnD+ZVAjdjxtk$Mq4Hg&QXY4e- zlM$ilmdD0x5|w_rL2~_(r}*RSbTg@Q5dpa=J*bNvD(edw2i zggAc3H+&2wadmKE*4K$BP8PvtHW*qQ8+Udu1R#b(a z{4KsS6p`g;S^R63bBs=lsRk^)5Ot6g{Idkhc^URG5?ucoovg9DPuX6mhZ`_ z4cUN}p~|trG^uLXRSv&EKawVc^0;LJk95=%BfykP^D!WwJ{Qu|k6{7R7|yr}LHXj? zUt@zk16SD@XCAYo7}BJ4XT+donP+Uf`If*U12p~H&Bt(xTc)=+BTXNi2&mXN*P3c( z-M^fw(RHJ@XjMA3UO>r61Vc57TaaKqRQdi0ro!3ny_Ab!0{Ctba}ntn#uo%YMs_Wf zEh__W6ki$>+$2FDM^k6fNL3+gApADP4T3z7K;i?UyVnnku5zsO+B*ub z>}Z$XoCy#N$Z%8m=TL1CS;djtj9_%$tH2MlUkmWgu}VotaHNUgT9C|lH)J9SrEw$o zeXp-prgHM^aK-DL{2p-C+7gx@W3Wp;Uk_Pq17pOb@yRYN?$Z)8pJ(?BQ)UQ1%1aWE zk=fX?lj4Wz8u`XPHovtSk6g_DCFuM%_P{P+tB=;n8CF`BTeJS^+vm{Wz%OTpbD?3VIqIYMj8qY&UwSl2Fct# zP7rI!B0AoRrMXo85Nljaqg#V9j3@J?PY~s^{FA^cyj4pVbr827(DA|ak4pv-|2Y~` z-qG)tnjn*%8*l3!%4;m`tT{J$({B;VLpt*!P5b~Rv&uf=10ZgTn)m<+W_Yht$4_7J zpNxzWSv6QnnnM=s1$i05rBsNL6KYXn<5V>5#arKN(()Y2Sjzin#Sh$#sMnfa56*G< zKx>?ug`W6BtaN7)soxNp2fmAde%Ml`*R6+GeNlgh=nNlTPMfOt4igk+r|;c*C9m`R zVK>#@=}9(I!*k|-E&KEotv*j$O{PudI5ecrA?ae4?I-sH?FQ^XtWHJ^OIoaq1ATy zFyh8biau`&_RBA{q;GY)qJZ4by6Uc?kN3f?6itraEzqk+f|jZQCmI+WRvx+?_lXLA z;IKgrS>jsKoU<091W$c{H0XAL2Mi)|pal1! z(_mU=y3lP<#<7`CmR~W(asQqlA2hAVQ!vB1>qhaPj|eXR=JC;w42{zti3W3Dz$?kT zEj=qxOe#={a3qhyb9RG{D{6PCQ|iKo5q7RUZZyhiJ^_M; z5!sMMthnuQ4>Dz_6`gRTdG+Ybb>uGo)uKol?8kyQSNFMe(`39#VHiOs1+zeCY3JY+YPzPD(%3#DZR;m+#DTM?o?5u8Y(>&_-Fw8!XRE-D;vHA$+1CLBa%tfx1DE4Dy_!1>dIYP=1@RXLuQDunk?{(xVYBUDk8kc1d8clp$^Z$$D!w8e%t zhIP;cG$7`IqpUJ2X zZ{aKCL<#WZN#Ax^h|CE^hl+yW73#~vTY3AA)Mz3BREdN8ZVv%_44;}h zs(JeUZ3<7)mY&6ee=C|q-Rmx4DgHyc_!$wHz=d~FC6;!xY@k2~)N-P2qJNAdM5viJ z*LlJbsf`cN9GZ=G|q} zrDF~3breBx&2i5$^;elxE(el!cjOY9sHpB{gGTHW*z0$*fvQRJjs#p9n%0E^AH5?! z6-mUzK4X?#V0TwB+VO16ky=KTJ1RL2e4RFc!*ftN;V=GhNV6u9HoDwy7>=Z~ug%%w z2Sfd(sFdaSY!S8Pq$ZN~3I(Y=jC|j?wDv7#W{c)g{1-|sT&HM#UKY&R+zAXah`o3I z1{mM2rpV%)J%Sv30ZsTjxkV?YAQ{BT3EWi7)g2MM5fbmh6t+@(i`(wMt%JxPw>TL@J0?=K9)vY{8nCg%hq?N3 zO56Wv$A->&dpUaJOW|Y(dE|(pe%&SmK^yxQPjRiWya!Cml_hBOi0{tw!+A#4(us|> z>PY%7`+|=$i(38YlPvN19}1kYB)dO$b%Hs(FXOx$(r*C^&=5JiD;Rb)fzcP-3}QG^ zOZXTN)}b^BrG|wrNvCvPI3!`cq?CDgzK25qq!C<;TlBOSyVD;qqSBsJCPGqj)CqQ6 zJkpCEhIqWw|0H7=%^6rFgFf(N+8QKjHm!hL6?q4KONl?M=lP6y&a+)z2BsossH5isqCcs9|9YoZ{(~ZZJ+hZ( z?Z@(6LIa|sc2{8pNfH5{F-fFdAhoc+Q44zHcdrPS=MPpN*7V7|!9tvnKtI7VC|s;T zA$M)Z*#meIF+IV+qTm@3a+`1y`d5Fc9F?5|h)*Aqa!n41)~(w@85`X_JVsq$K0kg| zV+m4SlUwKOWX`%|m#^0rAgtX>y2_W+Bj=4(b)_yR?;3H0CvU5$J`9{->14oPDLg+ z!tr(!3si04@cKPHl=oh&-l1M4w8K03mx9&`0zob51@yYX9j#;uURzJ$#&RAEI3lG| z`&JViL;a%^y;^z(#N$jJSCELP6X_a|Pd~iZPi9|FrQ~J2By*FJ^@SKZ(tow#(t37W zcODkkV$FPr>3uL?rIFro(KRGAjSzP5Jjxc$c}Gxo+RY1jX|hKNX*senbCT>yM*C&K zUyKC#0Fv>HpTP5oB^X(AARI!~!~EsTwxnm#>Qa+zP$J1QStT!=S}o2}3!&Gzg?-gt z<-|7hwsKRa(>P3=870YCu*gewKyFas?b@XP^L#!s#o2gDBMbS8WBe%c;>%g52g+Bl zEAT zbakNc3|ez9@R54D-dVAN>jm9gr)1f|G(YH3uF{v#di>*A-t@;9zB!J(0&>u?$V#I| z!el@Kc!}*$9g5RIKUm~`8z$Q3LtULkOQdBK#r$wey|M3Fqs?YR_{E~>h=`X4BQvl8 z6^|^Avt--0l3y};-bnO(jEVF-WKQVQcBMU)6b)fOS z*>@e?{ZMHDpu1(WU}G`Aj%h_(ZzRFGG@D3|=U|)l3xs!U8$BK`EC~vO5my{ae*@`h zYN6X0pa~pJ$_kZON$N!jwl{!Ai5p+^lN?gjm)*cGR-7?W-7k-FW#!9T$qwc4*w1MY z#Xsk4q6<=etr}cATNsKQ%`#^g@_*CTKGrKdju)MQD8=Fgu7MX8jms?^`7RdP*92a< zF|}X+;}ZtUgwIu;S#)4VXiKNvS1xSh<6u;e4=oMK9~Kp7+ppWdn5vLXcRq;$z~CMI zoZ)AQXZ_xU1ev2-w_&Wit>lL?m;+gs^OzLutTGy`K^FXUZS+3;<7c-rsH_p*pa&-A z8Y2G4S389!{A}4NVI$ZE7_4M*<=IOuu`Nrl{f#rLP}2$>YVag74J00#hqua4lrj^_ z@R1i^Ieou2FVR%U2c?8Wd)$0xc)YMd(*;;#r6qT;!D;*%h@W}Q3fnJ;IN8k!gsO#> z(w*3FL;|aB$9t+uKNZi)oR&zzPNaW^LRm+CPj5l^v~%Q#8MXWavT?I@IFO@B>q{tV zloYx#4m)#;#p3*>Oz&+eWmCv{jxHx^&V_>_T{=C6@zIY#bF+MBJCg?dW z%Y7lk$PZ)hYF3x6j8xJb4oyrdP^-4%5Kqa>q z>ToHD-LW*B;bf_fb(4^K8w$d2H$zxkqLWx*Dc5+vNo%BHh_kl4(MelF@Y5s(3Wnd> zbv`!~w`j&tD^z6J=;{nvEc-{4jecv?O^$H<56(xncy0IvpPS*L+QFl8X@kpqa0>DE zy48#^#tF4C$UQ%)0X$|YNB$ujXGsU9A#wGJ&*LZ5E6^;qApFop0}$!?J3b8t68T&V zF+47{+*O9^7i-od1Bq&fNRek~yt*>LU?sYGS}*H2_{Y7W_Bz5v!evX1x9GFd47wQKm(qA-aH6+k znl_mWdInhU#k1og=I$S?bB2LG8KWbQNy*(fZfgI;#h)m7YRcZ@w|wI_Mp`pUZPE~s zOn63k{od|FTL~Dh2gY09%)lp(+$qK*GM!8K^`FRc3h8hq(+H>5l%{@u+M^gPZAu@J zblc9EO1_jaiL+x-I}ES-WF|NneJNQ~Qv6gh{7#hOY>2f)%X#PSjM|g2E8)#jg~?JZ z5+$6Pm^x3v2Rp4%Sr!@!qAT(Ca<)(DZ$K$cn@2z;RlWt&Wgo!R;%sj0yop=sJI~rg zF$bpwRR;0Qd7s=Ae))-oA@!nb&oV#zQAZIx zo8wa%<9Vm8ftINBhdOyY#9E`hg9&rCG4P{}jL+NZ8xcQQCT1C^8FS05R;J%DpyV5i zz=Oc;Dr*7LfnOL7xZX`#TW}nz5?#F799=3rVY-n$@AS^FpU5C&!swh9R{)`BEWRqd z?=|Z)*cRLGKSDLx!W~*22S|k;R8&-e4$3jca zjHo$5x`?d%@VPc-Xhr~qBJrJ!BlcRlg?<-H#9~yg7YNefJo5)k{1jZ%+Al1*M0a!b zs5dL;Ec{z&L1OLOlZa#{=1O{07d}J{?E4!kV{kq|b0*E{9HG;inj?=V|5OFUEKY8& z@8_i^TcI1)2@te(Yj37XkAb0`$w;J*lB3hAoHbgK$j|QN+WYfQtHZ?WrPsXr76;OL`v9fj}_`pa>(geEHYKZPu6Z67i(eNU>N3*oprg*1^ z72}qPS6w!DHYR=)rQsOtnd`}Yw!DuMCin&}O{>XGT^|ESE}-stQxSHxeyIsR@Qpo~ z+;jBglQS&o2S2$T!H}t_*M_D|>O~a^75qMnTm2ir^6{JDeYvCg?1P#?!P>+~5Uumgw zJC_4m>b=1h^KO$lBA>NqV>551oT4f>b^@!Ksz{NR zk(}((1zA&W?L~0sMO;#QR5uE@iupsmnQodWjT~RT8y7sNV&9qAhb!UPA@cLFRmv4Z zwTvXK3aD%pb7=fwVYiz5xn}OY_79d!B<9ViqVFn;A~YyAA=PqS zJKJz)j@x9sDDRh-ofCKf`vQhUA_?QGIgh%s_(39Hc@^K_&wyY^R3Y_JaN9(;mkY23 z)Si5e+M`Rg##u&h5q0V|sBn zqKvGpNceAmZVW%FXfwgY3ETK~0#AMR2% zY3LHU_%f>^4}EO5$ako^^3C|6>FoBSD7U%7;lKW5_uf$&~^Otxg%%5Wu$XFSGT z0lPYU??Q3K$AZSeseW>vc1-r{hV`lw&g!rSItTAd8bkWDHhTD;?e`G#)k@qafsXCz zFY*#ZEa}#)93ErAycTcB^CcM75nx~u%A|(O7DL6C_&9KL7dlpyP=c&K;2 z(Lvq%&-$`u6-5{i&I82zp|6Xp8sCiz+6$T0Uj#4DyoS9yBTa(qH!1zjP(;3d9@Q?* zcE~;5K&T)gjGWq*ih~Fb$Yt^@z=32BA|alI-ofbjV_CDpmjnP4G{t*){pDCEJvf2vq^pQ3&uePe)UB`xQkl@eTpDI3 zhjfDM1QJRTMoIp>82!sb(#^e(^beV9G~I5+?!}PAw{eb=a~ALdlLYvvbkyeP1C*(v z1~m!n7WNf8wmX8u zu7B>NU5$=SO+diJ*SOrCx$q3t;x(I}@QKHk^k3SOCI`7kM+^kqeI!20LGlc_oSOC% zoSc;h;Sg5phj*eqREwOG_qM}%|7HksLteVv(AtqAGhGqlx?KTO_uKm+!j)^p_uA}_ zEX_Fba;>Yrh}Y=3=pdkh5QvrTcrY!WD_jtCKCuChGXJ%gp>XJhI)zBq z4*8QF=V8Hj8buJ`zr*eC5%p_@8{jIGDeMv`0D%2afrCm$P)n~pOsm?N5T#OxzKSpi z;|aaTfIV4aKHm|*O%^WmD5P6TD0bG8*@&)cQLY7!{cjRPEb>aF+d=P;ZS7Szl)mfl z*@>JzR71>td=3^dxk}I2s4kzt=pSHo(}V_tr?(m8FdE@xy#tMV9eOK}Og%>tA^_Y} z(+dFl&j-&C)KZujnt>E%TVOYGQeWX)Dy4|(E8y@c)2W@H~!1#zAz0;={N1aJngC= znFi*szyTJS{6by>rnr0cc3){eTRQ@f^|px}a1yz@_#l3uD@?ekZ^dV|TCnmg>yrWK9UAno1Q5nWo6V2>hXC zS#L@O$-Q-p>*+d_&V$3+?KP?sDi3UI$47_LbUTBHD6-WX($D;m#IMf{a$M5!$K#_g{bu@?XIfn-Ge``Dmg-fE z8zPf{f&vUeP%z&=FaQqkh67!J6If=AMT;Q%69B2W4W| zIfVyz5Q|op3+zu`)Dj|x458lw*hBpa0J7cd(29U$7W`5B0dwCT(+wSMKW1+LHbl@a zWM6Tn7+|ggk*uUz5Ta$0QXysN6z@Pp@BLgK(1Gag!?9xe2cZBMn8j~Ke|bjJK{AW} ztmxKXlA)o61i@IA0PK&xUHATP1cw2<009BtEh?-h%9n@W8zCcK#LS75UenBB3f&3}+53<>KH94ZB4-%i&?Ni{k z&39JO-w3dIE0g=6JHOE5wz!Bd-3HEg z9BaF!DeR6=&=PB4V%@eL*4=NX4D%;KPj|Gi9Bc5)9~TIvz74v)3nqHcl}0* z0}%%9yh$S7zL~T@vglymH?5b?O`sOZyRA5SQ_k53c~nAV=#)DygqdQytiD+W&lpFn ze>_m4?;qbmN`5o@%QIUplsP1Z@n_vPAn$v{0<5y23IIzrR-G=how#j4BMsaK7&~`U z+AEQY5^M)wr$F>nQ!%8|W883K#9jj2?o+Fuxi`#q z*R5W?XZ`1Aby`ukg0{cU-tFd4een9}>b-=iLC~UUJk7F%`r>4g`0XdoaGzSBC}HFX zD*#pFP@8Mrv8U?Cu2vzRRJIr&j11rc{5}AZ)Nf#ad0?|aG7tXLl2*9Hf8g5q2_*<{ ztq82P?;eiw1dv%h=5D-fiTst^RbGg%PhYN`vhJm$#EC{`@_Gu^=St1=SexUX_@2Ux z?TMJ@TLgAIybKDvC~xNICYyFUJMLEYD6h6F6gJln!6)pSZZomUN~Q&pBoXf*66+Oq zz7R+BGnSSY$mwx|7$?%BHbcH%t9D{GsR3mDky2kLRZ_2SC>$j7=ue^Y$0qx(9b<0R7C^9<4Z|_!TJJsNfH~!PG9pRw7z~y@akt+And$rR66=)Q@UEeLpv{e* zoP^OVQf-V!_KS;UH}V=S58}~7{P6n3#mo6S3w)0Vc&rnCnO!oS0jx>e3S^#S`ioV8 z=%H`=P8`d(697yNumRvk{|=d7K4fZzQqTTRUGgWW001HJoz=ZVtO))(Eh0D-5tT>V z5DT(#4#YpBV<8#dPnx~Mu=hCleO)KBBr7gke(VVn2(WEJAp(s!DJ$lAWMDkmR~>nu zE%||OgsQKFA~?PrwuZ*c4*~;G3t<#?a zMHvMaLeQY|)@)a=4&QVH0P81-y^JPj1Q7b7u!5QZbD`hZ{_@!73S}YwB~AX7M=9*h zyYxzGAXCu{3mv=(uG!h}0W4@j9}-QFA`b{(gX{D1i%7Op$SFdjXgq>c-t*S|ts?0s zRjj`CZyP%`w+u2Od0%uBHg?6e$mBr<|L>h3ICpevnk#g5W z9O?zHiyzNnKM+{dDxhGRSEwuw5+ccIC`ONTHGKeJ({BU-ynpXu{~c1`7u!?|2g#!Q zQ;+_^+3LzN)zp!e?=!%u=Q_zT}2a|e($;O7OGs9-7-A_IC0l}9H z(MAHg)>*BUv#9Klx&aoJ?@pN3*;Zey z$hGneasas}ZS0INpKr=t7jH%H`t1}B9OX{304tRmfM%>C2ykS-zJej4G}iw`aKKS> zULq9E&l7cPcAUwj9y=6*5rat7`NZF|;~#88r_Wb#nh(|wWOwtOZ09`SLJUsQL8N3k zglyET7#w8ijC+68)sxU>M}XrZYeVP~Rp2r{n5~vtDtLoUENKST(i3yA%lQb6rwYc9 zI-7QTH#T?i-2use2VqwK7NcCJ$M5k+~)MJ{RP zD`UA30IZ((59tnq^gE<}^^gLA6UtKhPaV<;S^_a>lcB>+`O~Ur||`EMAHBvz5L6H}-n-1Ro!MN@z_dk0p7= zg3q$ac$y{SEfZqCY2lpwQ4=`N0!`IuHsUSpu_C}nK7h1+mfo>0Ub5JFtt0Yfwq~a_ zILwDz8~{pNdjYIQAM(xL;qa@61E2?zW%u6&Psg-UC=D5epQcO)1aG}()0JTWjVWyv z-RBW{)Serg=RK~-9o{^otJ%RZs0lJ|RK@u>+fntF6i18*K3__pMbz<&e7BCETK~0z z0vh`pvR@uDHIOWa|8Ft|YRWz54SC`r-A@$8{7~vezFC_RZD5p4RrJ|*ML#46$t27# zA5TQ^Pq@f7UPrc7D9z=6Q71?%1=;s`v$`VK7BHZjQk5B8IIsT;2L9v4J%Ib8ZN$#F zbxsH03R0KfL7NXVrxHvW|GAY0g@EG4U}u)8wzx4?7VBUpW^`kXfi6#+&>DEYn#BBB z!2rMDaw+K3%RSEuW&|OVci?6)yrC_m#8;c)ICzy9JT5gFm#FIEn^mbhhIN!I&DC*6 zzo+C9Ja2X`*Oh-o1^_hto^k#?G=8-ir-M*d;{T*aglaL;Q~~5@?uKr{bJu60WtAVx zm%66M4ddW~-v)znZcY;KZpwJ}uB2dmFFrkUKjx#bGDm_FR^V0K*nDZ`j@Yo+0HgsE zAN0%jI$6|YuNSky9I~R?{!Yn%=k6DqS&D*W)&FzdSM&j+$CFTo-x6u7=qb(!iSmgp z&UtDn(fv^)UoSn{q%5CE{AUJ3IseVkFVB%6NLJ%Nmi7fn07Jz{#TI1WA2N&5Tx$R+ z|3>&Dq|;&XMK!uYEA79EAehK+hJJa5GKJDw|7QtT&;#;ixhIjE5F1s|-H`c?a{_=D zF=z)*R5RopYLM39$~@Pl8c5j;#otB?k}hNi0sPfa%M7@Ci{mGY4lFH>R(+R}<}KV< zo4PszzU2?)98T@xK4BY!mI85ES?ekj>Fg1y7Rol=lWX;E^%z{BJk~YGbN+&VsWcpg z*Y~3@l(qCf6=`AR=7t}u04(yGTq(A9nRn)BI2{1m}~_|lyb8GMe@J61tI$l)GrT|Fi6(JKNsiF z06-aU$k~YctO^Jw|nnUe7V3N)GO3?+Y*5r^!#Zl$ZHf6LbGsZU_S?1#Hy1){nN!9gq( z`mzP;Pe3Y+4|iYe%ua&$7xo&6NEm9W<~sNcetw?#E7+dtn^BO=PyKBr3$7328X z9ky?|Icvy%YwZj40oJu@I{<&5-%0cDy#Hb|V@Z%qzJIR5WlDk&@&CCZZpSp;n$UQ# zk?Cww$7#s){_!tB*M76~ca(m$)F}v(DezAP7?UC2an{G+WAGebWsauB5{nGcVl$8F z_Qv|zlFT~QgICp`6d}O;&PRWT=-0|eAUdzM8vmE_``>5BqMz=SSHbe#Iygq!TbANX zhXP9UceyN^S!1d4FU>=dM24E#_HD7H3f}P$_V~jY%8{Sdm-%z$p)$xNV&(#3Vi0xYjrmekN;#R~KFLNaXchVKIuhPdSh!8Tic(Gv$49XR zhd^Doh#9)=x%xb_SL1b^%2G#$a{|vyD#CBa=bWx?+f2HeQiGart zxt`Kz0t)DB*6~JGP%cJ${R5g;7h9~y_J8&rjZ${=D9AoZ4!7M$Mq{ zNg~(hSx`!~LT^Ovy?hs_nIz2kSDFSh{vBe!dWZq9?XtrElaBmvXF|B!55K_ht>T+@virfJP1&)+DppOLCesF zYw6KYm>&XGJDueA)el)!l+DZYV70}BH%RDBIlqETJC=OfL><4k!7}PCI_O-dYKy=k zu4J&&UBEB^v#;kP&Hk(U0-~M2>HOvCl={Q1;$K~>|J54uk4G~9U49**$w$FE^6Y&1 z1%&Qit>^dz_W&&Tgn0h#PVrwS`2YDp+Yq2D(0pkIS8uBYfA%MigfYKa{N-8X z__r&?-^%QNp16NKs+J9arvHf!_{wi|esy#}KmLbd#D5go{jYn=vT64Dbdg(!5K19$ zEt+l5w_(32RRm-?2r=L;N73rJ%UC_T)8#5p+(Vuv}!k|;3pNB*`Ql~W7~0M zGpKgJmJHko4C-9eIKwV5QAI_NDPJ%o$8OTpdT%|$Hv7HRg04wLve4w65F#RN zoPGP4-9uAl4K*NOBqoplXJ6Ctg9Ou$TiD* z#OtTeMki1pQB1FWfxk_ICgdVFNcqe)3MQ3VCX zrsz)Gcdl`UlqtFRKKs5z{0H_?*vNf-6in!{$OvZ+KSBr$vXRNq+*CnzXft)v_|Jay zF^U<{hwYAZ6FoxNB)5EXAxmU6KS;6d2|FmK4-m`EoRp!M*fso?WKIypV&<>BCNW#K z{33lunzD(_Uo(l}P_!|UZh6zQ_AFusqK&j{Bt6*HpOm%rndOZE(nbi=@|8^qSav%O zpPxL~HYz5e*6C$6h{0}likHw7RrIl7Zt&S`QGKW&^u`kl z!PWJI9Xd*FF=)nlhwBa1sAe+~i+<8m_Lt@`hmJZve+eZ}x!(!qS5Gj&%m3@{@qg%~ zx*=#SvZR+3z|_;Ml$KC?=xao^vlMs&O5u0o(s~OxLgKJIFN!WyyWG}+_A7eqyZWz> zRZbJLS1g$dN%xg8^7+MK(h=t|!qixBN> zI(xXi5&t@@Rwg;O2YyB7_ZJ%h9qu{FLM(bND_gbB?267$K@4VmbX6UE$dyos1Q$i6 ziSh;WmnoUcQ-Knz7gFf4^Rg9V(KPcvk5)-rc477r`G|JDJL7M^CFjl5_3W=L_o6sp z=P^?q)w)dV417+f14aY^KqhQ@0wUu$GUay&{PH0n`)|LH|3lrYS|eaGo(5pD0H7An z3AB5Ho5MzQx}Sascv}{t8n$6rIpiA_@zK7cb&`R~ZI@@A_$#N9Z@dm?>_3=$w7!Td z$RFXmOcFZO@&d3j?)qT~sYIFPcAqOVb1IIcYvjx;qhdKFx+nVKuTQTLM6ApNghN3~ z?j$9{nxZoG%tkh9W{)_XF%#dq!ufCMMvVvz`$12Ic6gYM^nuJ^LMKU8w8NfO8@UTR zY!?;K243G`_5Eq(^eP#me(xLpo$_C7-w?#@fA#n%*l((5TO03FGBmmIrxS7R%JrTB z*HE*Jzr&Dk(e`+YgEy~f)@`*2la%1X5e3#p%@;+Zq_`IlR z{UPC?5{wnX{IgKp#9ZJJu0kQ0>OBziVga)k5i<&N*Y+7R8u=_zkY_CjDGQa_dRD8Q zZP{Z*OOG@9)MNG&Kl{YJj}mROQ{9SM_=9!hv>+R8)G#VC38O68yYDpb`H}2SMI(Il zoU<1iI8+4x$_Zq@4?O+y(Fe%?gH=f3MUz1zpTD zc^XJK!Lf^6;*o&KJux{GhNozPf_p�-C@FfTQ}YTmH_}ueFH}ytYaFhp))LS0(?U z-R6oVsl?O4O`*^9q82n%lDi`7x2YM)y*tZLvX_lT!q#u~V6GY}u7)ZtCat|h zFo38gkWM+{ii|qb1kbTLsnp9=#E^m~^(0ZgT=#*itGx>|Cj$~gDq$aOW0lT0Hl zMhNJ`Q#P(&RF;HPe9x>Qn}`46D)xYk@1A`hYN_D|j0U#N#lx5!RrW%g^lI`t@!pSu zS3UB4B3{QJXgJ&7d|cc)N?*8sq8Rz8ceQ@cTVP4XzVlfZO-tT2Y<`#N^Oqn1u&aKj z@4rXiFBW>=|G_k*tH>4kfM}5?K*(H3*{s)R3`$F`A=$xHx`vH2?h4u5768eH{POMW znjl0u6?Xe&tH<@3uQMW@G-HIn?KA$w=RHBMlF!@Kk7-yE-!qZe2@&YTL!96b27LvF zI9)XP*}p*N5DkBi8rUD*)X@x~(%-~-vb$H8fOkXAqDJd*gAU2xPq@hoLf z@bMiNRoKv7u1d_+ZYRp|h9VJ!a$Ky0T*FqPuoPn|Wfl0Sun>w?h5|WhKQTh5F4ZX_ zBOZlE6m+dsQyi8Pn-RUwtz}mJ%(RgCztimB;rqqXtjIt3gtT6ZG`<9Ips{rTP%l`myYJx<>mq#ruTsr znF8J4v&t5+8{e2q3B%lQK4~UEVWkv$E^kj;pRlf6<&2#8`bi^6hn45M*{j+Kh|Pr^ zwB1#;&-96KDr!*8aHfPzGl9MuH^i6N98KT(Ygvk+lkw*6!99tW@uO*^SZw$}g12>r zg1FezdxjSWlY>u=mq)K#1Wl6lxfEt+scj=+Rm@R454Ma5`dD1NG4=9ga_Ld zT#xDCWEnQYUS(~Z#9=TEUn%_w+*{Jeo5+@8Qt(rSfvO4j2hq3ww{`QPF!X`x;Rf8t zqy-YXgq&Q|i9tMN9g0bn!jC13N$F(j1D-GBw_gt0S7Us?Cex3)9GWL&e~QxbxFq5u z^5A6Rt+n1(OAa4UWk|T7hf3yoQZLTE!{^j2SSsFBm?A{$KC3e=il4jq;*V+Kwf~pU z1CjlmfPVP|bp4NJEKNjn+vDWK^EsZh;v2 zc$>SIT6koK<_vO!qHmvcW2}Y~ZQpW`8?GxlzWI@le!9MxtYs*9LN@{@py|kns8U++jqY*?9>p+78ES3yi;*w`Lv@&yB`gcA5X}X zcWhzJRI3_>zkUTCO*#j>i6P8W$|5`pY$o$u3iH>Zlj6u0Jb@U0M?U`Xy?PLkWx`sp` zbismXSy@Ue=2qazwP@8TG>Kc>Ay?(s&7qP5`>Z|~n+Y&(<+h6a48kdDtEyDvsCp{4 zA04;tkEBoF62-b&j8f9kG{U#Vmb!bxdg9n*j-Qc9nDs~_WJYbaY& z`_SrkmS^h2@(^t7gM`D7i{w-U0VCy#Y+hw+HB!7Y0QZ)GkCWhQt&69-`4MS@KHMj) zWbE%#@^XIIx+?{G7sVVzG1tsdD~|sUdvDcMSGskLu7w77cLD@=cL?qTcMa|YcXtWy z?hxD|xH|+VxVyW3*|n?o+p1FM{DFiUCS0rrbN10kAM*5x=1!O4Yuf}`pgz28AgE)4 z))=lCi$Uqu@Wx86!d{Ci{*beVU*v@Ct*`TtcD%*u^E=wvM+vu~6o9o_@fH}idf#_X zXfYuWYd*P*F0_?lD$RyY5&^^2B9rBIX~S3QMz3sT-uprx=g*UD?Jnt*45QcWtKBdl z`+0WEYUg`*E%S1Xylrr^1 zA@G~ni?k0u*6Zs65s>6Y+7H$e!wwbIpc2e?nSh5 z5dW|agE2dL$O^4ma4!feT;_6uZ~$S>@6^FOlStHN&^=ZamVwi%o^=UtYJ&h7^G;QK zJ~h(?Q?UHK;fMAwL8}6erpXX_FBQ|gjuw6!{-NBoIh~xa_fhN<x5rG>NpuKkGhru&%vb|kIXRw09UPM^6e<+aqRf_Q7t2#(@V3Jh_srVj z^$X)C9g3A_lJF_}0gE1()o34pNeQHJi~FEaeB|6|E#0s^JSWrlIxG1(oO4jFydJpn zuUq5OlAH^U`_I9p5Z*Q zJ~QQw)l)jf^~JTC3$@HXn_|;ziY=6OP{)qs20((09%s3s#0)D(5DYRD!GPWU))_xD z|1URIYx>D`sSAWD1$c5^ni8sngOs`?ewMuh0T^**GwvfpMdf_x-wi$WxDJ4e6npYl zzxrFRWXyv_UfMzMdQ`b6h-HZ0X_WKNL-?1mSxoP0uadqh@qj@{Jh{9yXc7fu<9eV~ zlY7z2l7LXS=*Vg4{z(9DoPP_KpW*w9bxe!?#o?(#dlE8LhOWfFvd?{gv7KWjZ2`$S ze#qbD^6CPl8_H~-1e8oC>bpl`IFIP1zLP)mGr^0?-b*er9b6}(+rE=mF`y+vCp^ccPW{3^hrhIXcA*t2d>k>A_qD zwnGwU!lZR^LA>`)5)zcG$DEj$;BgK%#LVTV_JVEI^&)`rBr((IN5euC@QsarO`TC> zu@%NtWB0W^l4jnS$ewz2)!DPFv;mhIu8rRJQ9^I)34rH6G2@ZF3BW?d!J01ysgCNK zdu0l2>IF9lFPm+TD?zYTH+GUAl(*w-ipj(XGr2ZE#trlfJD0Oy!jwvuK*w&}>eh-d z$cRHgizaM5;ILKN3j73Byb%Pa&V+Jg*)r%qCW;djmSk)SN%`V~e8lgIAY{Opy>1yuK6L z)#f>G8>FmS#m4!TGTo!$%c3%^4-(gxk0;FzL@}hCB0OJwWbN|WlT*As`N2K&AE;bA zi{MF&m-A&gU_g^QD|`jL?GU7`A$?se^-q8YX5fXpV`&cB@8jxDs*Q>DB@bFh3s69u z!N{AA%+=$@``{>5Fg+q4qP40R$m8DomnPi!TdLG$*^ZrlsQ@Wc%0M3El8lt*y*{fx z_(IGJB4NyLu#}C0RUw3ru`-2X4f8UX#R1BkXL>Qqx@HtE2Vt-y5d2{-R4q`GMX_!UD z0Yz-5l&DBNAza4v{1WZ2qp4)OqqRN0V%cc+KnoCcxcNVmHGp{iNBm#@i(lD))(G}Y zfKg&F;tqYmEb+RqL=RWa))_;v+aT_Yqq&ij%fSIw&N`CTfY>L+I2pLwUuSa);)wInQql(524xX8gd3JS!%uJ(IX1Qppdwgt&cOY_mR3VA4c8+i)> zNpiDLpg|Jvn(CjlR^<;8FUsz>*CB0gLH&yH~;X0yEc6pv_i6b8N zqmdWvs|mOa1akc*{$HK=0ZISjsHO@)=({+px&YOF$qk{!?yn7v`jmV~BOpQkd)^y->o+!k zd2A;9i$hz7h&{pk4YlN|?Cp$PU8It3_nF&AQi2ya^ro$3W^4X2@bO93k8=1d4GC`&VQr`aL`vxpshTgX* zpf--lEn^L3p>ps5pDrYRW2YdtrqL2Wx}S7eWoEuL{&{OQQ9taVRl?UBG}$dVq&|{W zEx^zBs}dYElEo=7yQI^iw?gSA{*%U3M~W_$QkP|B;j_YAMZBXoh@P$wV(a`AB(9IN zq+A%R;paiH#(KJn1i3_D9TY(V@6Z4V(ABeHY}c}gh;KP%yg(Ok(eIvxw&_U`gHzo0 z*gaQnv|Iqx%h$RoN$^Yv=0E%O3ijUMwynYRv`-)6uF?@ww_KkOcE zS$(M!W1Kiwfs)gZc!ctWltAOuk+aT`<+{>?NRSH9k!x16EhGOTqxbEEO5c~QTySoA zcN5Ang7+lLaaz3(3n#9snfl$~9Nw-^2H3AhDj z+yUxpDKtb;pVSU8b-j*0$S9@8?=RchJsW;CQz@sKHd^5c`&Ow#1Dx<@ZzNVsF*Mym zFxk*zA%(~+%1AiWPkXvNsE08K0-;#8p6Y;^8eWHA3SBj-A&8S#&A2v{oJpJ8e-(#N|9xJZl7}!#U@_Uo9K)yr=fSlezBSexIZ)ta#y?B!rh$NcNql)Ei57 z#|@M8V{v1uOkPdQg4lOhU?Z6d1f5qd(&s(^D9&^1Q*VYdS@NQ1^1)^SgESi86n!(I zBU6HAP@&GH;wxRCYgLs3Z6YgyyB;~~70VpXdhNl%HKG37+6mD{0cuh(YO?b^${&pUcq=d6l^E$%Q3Xk5;$qr?(MrY0mLYD zHK%aTLXFIR#JQPUZLw~`x{^qq`o!0;d0vQ57+7-cjFK+K?%2_;lxrJVq5h&HWrpkZp zRn41ndCv4Z;F@LZ5Imu^f;X0Aif*rIqG1zY%bsM(MBsoLuEtqx*!1X z;Xign@xToIzdOK!juC`eZ+Ndq*Tht4+)PUvN@3C{%D6VFN6&b@BDr!}Wchl%7Cm<~ zh;7<9bGunQkF^!Y%LW;u(jc-#D!krppS5G5&mSw0ig@#3(O>J~yNvRlx7{=~DWNbj z4QELCCZ9%A?&zVxt3cTcMa}s_Dc=`qOMQ-Gm23q7Ff2ei0Ky%=!|+!RL(p=86yu-d z1pspXwHUu0hud3YLF3~*piB;!6O!yl36-IJ*UmGhNkq5%u%1D=OEVQPQ#&njL&+ZnQPqR%iPheq^?9; zU}-S&{*dm*r~v%J2w9U+kZ8mjIZC%$Zd<`jp+((5vX*&2W{^oK`manPMGsG1G@ZK& z_p`AM>r&Vda~x7@BJga2A8fxm0-~p(&rJA(a;x9In&^0{SKFOwBN}Kih;i>MSf4wK zYj4=24tH>XEtOUudXamzSrXsvT+-R%-(_yNT*t{+i_tc$W^KEKuy>Qif9MM2S(huq zllcnr%9|j^!)wpVt`k6-=@js>%dA~1<_cKM|iLtY}gJ}r15 z_6DkfB1h;zX!yzc3NNu+qUx!PnymqXJyjxY4=K>bU;GoEvidEA)G^|hO*RIJLourC zN)g%*wwF>%{(WAQlMmQ_RNPuiCBwq$J_0ce3oiu>2tG1W;g2^YNt`60 zYm+r_tUwd4_bJkeQ9e8#70Hz?6kLOmB=B#qE8NaTdSpAM!XDd(UQp+6vu4q7!At6y z9Uxi}2+f8paKt4pAVSXgZVZ`CGg#k;L7YvJeC3R8L z-QCr$9qWi5LH`TzP1t&*i{thd4Kad}pkbuhRH&)6YNDA%EJi%G*u2_QdZ}X_sY2LTSe}9oz7Ew(5>w`@&-fkH}4 za)KYpvX$m`OnJIo(?9m%tva=mLb+WaKfkgJVyDHK-0vHy>An(RUGm_qAyD7B+s-N* zdi0-#LJ~Au8}O2klI`GKs)>b7%zO+tM%DZhQG78fpFyezp@>lC(g2|m>I@O_b&Dgg ziSaX-9T_HKt9C~JD;eK)G;87QEgm*bCu`THR!e=0>5N|yD6lw*OaRH!2Z$NgEs~L0cyw(h zqf|WcnU!@j%>59kBfEIBZ)jSB%CjU)S_o&^JR`)wTk}Y+64DQe=5M(7@r=fPbD~+> zWy?!ua13eRGb3Q?v<}RG{ZE31%>VIVe1RDSf0z0|^bTYS6xxrh>PBYuh4{9vmUs^z zKJy<2!aE5JF%Iaan@BUcWWL7ty>i#ii=EKdF<)#kYEuApnV0KmWnY~&UF(%P512AP z6X;^9T+g*#+NshFajLy@Ni*=Khdb-~NHKfk)`RJdkoCvk@!P!Q=kWN|)|r6T0x8A+ z)%B=SnSberA8uLTqPt9c=2wXHP}uDQYkb4d_|nc?C%BJ7155=$s}BWlrw0cLcC5VY zadziy^3f57-jtWues162TbLPu@B?DvME4EGmiKBibx&=8NLt>mE&4p^EQ#HJ3YSXR z?pBx1jwP(f=7gXL^yejy-K@zA+Gn{Nb7B8hNRC50wbSX{F(Y z3RNbXW~pxqZMLQn{cxYP=V~V6ORjb6U0%gK>1tmcNi8}5-Rbig>`?8Q6Wq9x@;71u z@?t+v=Li7j4=!gkgSWOIxShJ6izH<#(NYao*uBN!O zzJUNhKW(&sjS_78Kz7Zw<55(OFLTl)8v86(gN=05@B{!F2>vldqRIN5lYS1mUo0nC z0W${vN&M|)mSyN}#P$)BfvO;%ck-*lUWr^Zq&NKU)^M?bfpktgAtSO(hA~!*Nm+Q% z;*Q{#F3}!g=H1yl{T5s;rWi4+7pX$CzWf@`0mrI(GXDu=ut(^EHvsV8R>MC7?iVWs zKr97PM#a~mKYXMo`Cl9LFOD~LUt->g+ zwY=+zF<~!$H$_#|K5GApWBaK8(OM>~@7B`E^)+Iz?#6pEyk+Rw;aYstL z<#tjxk{bld!C(Rf2o}dnwdZPHRR{h)I5~F^d;0LGmx*I~>nE)v+Ne*wcd{hlA#*+U z>eTf-a{_H+%+?;aSdZ>w+VfD4_<-A?+@}7Csn-PpFO&ll4)>K|c`wDduwVS8> zTt-i?6nQgpq2BlUPw&5MT5e9)wWGqkG?i}p)Dvhw0`eapxE*yU&e46a6Yo6z^eUDaX&N8FP7qJ1TqeV znWZTH$2MekW}OfXZxth=UKi{Q0r}0T7%EDu3^rT!5L-f3Ft1nn}Af9w8Xey4kHnxa)QT z3Wdjr^#=f)17T^9Ocr{gJH_Axez!_pX%wd#Pvsk?dfM$eth@74w1Tzg(6v7RCfWI$ zl7Gh6uSLlq!~&^EKMH-5WGN`VKWXPjk?`L--{_i!orTYzKQV=bPd3I%TFPV5y||Mm z!=Bg3duLlUCzd*YGrmj4SNZJ2`87&25p)fzjCHQzbGJ>3n49R~A*Sh{ugqQwqZMBTvzFKl`&K}9=+&V}B)k`} z+8iOE#s&F9FWga^^ooNhUaaM-6^Dsz=~lz<(Qz9w9fE5Vv^yt;i(3w5Cg(5d7LQT% z(l%1^lOz=hKnNr7JIf2k>slL5`}eMChOrpQDWixKtS_!H90l2T&!~HINylr?+Xa*%e61v_-XZ1oe#?W1WIOIEYG3NXt|Eo?z@S@-c=Munq$0Jgn9l} z6e;30c>mPRDF@?_o;*+syIXh5>j=WH32eGR)OCLvTQ|~@oMg=$+>#2c6`_l6x6oWRM?PLOYnGa$o?UnGr$3_#JhzaPomu+1&wMI6u4Pm=#HFbw^+bNiVjezhc2C6Gxcj70r6;nwYX;k@XiB_;#3 zkCDZ?@~|Vb_u3b9(iB%t|2k(vE@v?l7aUrAZ3|MRkXKHpn2Q0wj7miRzEm=MTx8k> z#zz`5vBq1IH+hu4W;<`gg>d>i-Q{8A&H_-gIL%f1_MI%(YUekJ*(9NypmEMDC=>%@ zr1!GfyBy4tvTQs`7kOOe6O6(;>pgPKHiJ0_E(;^BS`a@#3z7gQ2LO%wo!Wjz?XQ*E z0Pes{nZL{Sj&I7Y{CiYu<*f`l3!7-DMPJiHa+BFV=kCnh-1}H;CPIz8gjJ@ zcHr(NX9RWckkneK<{rG0%tNM^qU@)x=kX$PHeM)70p-g)HD&9#q1}VeemaK(s_Ej# zk#v8uCa~_u-4_RD%KfC=Tsqz`2vU^10P)t{H1hV$NwM=h^G>}pQODm{FS#Jy`SX>% z=Wn17kl0PJ0&D!^C z2t6}Yc7&#@W5|ZrmpNjd)}8irVgm$mdgo+$j2dI8Z)H`igeS=9u2Ga04J+g~U0wJ{ z2_Jo8^7-EwkEMZ6WIUy9zHX*z)=oVSp2r6U`S#8_`{MJ~686X6#UNvwN$`wB9|3}h z%?CbXVHJi5TZl0su%ee!;jD}{KS^&&HX;QFNBNQtJj*hpqu!q1fiS6pO}j8$U+X0r zWzDIz&*DfU2cD5YJLPCZ5@fmUD1X^IfQ~gS%$9Mu=H|r+ z?LIwy8Dh8wcdYsTtxq3m0P71p!8%gn;TpoHgznSC5}Si}p#fVx#WW;}7X&A05paYE z94su-p|?6N}vLu*|e7;wz%Wzola}+WnNGO zp4cXYmjgoHfVhSvp9;QIdZm&jY>bckA_Q1N5<^$Ak{2g@&ZD)DdwixK`f|K?aO;{B zPibeoz8^zt#&bR~sZOPX1KR_><`>#UrN)O4f69fhw@}p8m&pN>uMiR3Wb+|gntmIT z!Jz_dB>5KOoiyTI9Si^^!3grG0h_!nGF9vc7pXAVP3iip4*;6@n*e@w0syoLWZM68 zZ>JNYe#u~E-dla%pd~5peg&P#LA;`sk5jS|GI5%amU_>v&<2WPoMCyb7IgAqIxd!; zSq|JlU{ZhI6OJ$orKLg^(`^O`ThUE1`jbj5B61gpC|qbsoEo5*gtopHrKY?<`)Q{y zNkPp(;9%Z=l_~hd+~ree`{r(E`*lP=1Nc`fB7}jNF+b@si@m)l_DnoxtEM;?qJtLpgI<~W z3TWz)J{blg{$hzQK^TB7%J!y4^tC^<5HsPA`&ll!KF{)s$#Vz%HpJhAtD@X|GX@f z^@$$@NrY)olj3WLZ=nven*mqb2>?Hp$RMtij!xWPp398kyM-Yw7Ur%a2HbFHDN?uE z3WuwF#V*($0NE?01Hks%a`2bOIS8phYVyBGHQ1BJ37l+v_HTR(>Agg-+g2QBu0~~M z?#CKI0C_H|F!pMKd#9DEwiluHfW$cL#8BipuV(yvtB(uaD&?6~g1| zKiXhKubaQ3t0c|CJFhzVHBm3vg2Zf|>@$xU_Jh!l17tBT9PG zRN~^B;#M{!eu&dC?ZJfx{s9#k_6m1TB^&e!D$s*7BF0Q_vhjl+->|*fH-ACZ1KJ0~ zAk)(ZYeiD@yjvH$U==}Z`n4e8QBM;!mR9&!w{ME({axqBDeNB~y~gW?XfX>78t>-R ziv_K+noAHJ6Z}y8?c+=Q*JNa*fI1k{!|4l)s}Y3xpnS~s=OlKuUb&^Nfi2OU zSdO!}J65ex{t-Ppj;uONd+YqSpYTQnRB4SA6Z?nu4TJ8)*~+#VNBoHInyLpZL{VE! zrvkbUYUh&YQz?7KuVY5^#)YaJYjWrHSqti6-XCh8hz%w|CwbDKW!b0RiXGi{KFau{|ZL+=3Yaf~|C`hKIsW=4*h z+0d1(aYq1<40Ox6JhSrzNR*t*%Z9T+Ummr%KkGxl*WU^8mnRB9sz7GLzeqX@Nh)tW zdu?@!k`Wj6Of?H`6?NTnFXa(uT@s|G_}VR8BpeC#s~yW$%PNZll?`1zJ|)~5+)*jV z#h%+dRFhV1oUXcdMXi|ZY%Pwmgj}$7JIW`&*QlAB_h5CKY`d)bgY?mOp#9(AMY%T! zlr=VL#p|rC;9uZ!-UWFd13-%DCjlU*zblTP@%fAO&wli;X8)T!#{KSjf9YDc>pCi*Rv9{a`!EoN6>wXU^m8=^5p*cAH{&v=;7Vh1^E3 z(@b;IsgyR$P-{LH3IRH+P%5tBLVMq0(cT-y zn5lO}d|GXJ+HnQ#Qg|YYd1~qE*`Vl^%hVE=^E{CqTjhmfNh`S7@xj|WV=mGj@{6lJ zY6U96{;m&C_>#?I4S}P8u%i6${6XE?&!G)P9|XIiG%<4n&n$+JL`l8$MPRGL=;QR> zFH+b5V2srwC1xej{3}$N->03{@IpQDqmcZih0=dd7=NaRU#&S{3e0@?nIG2P4?DQm zR0;@|h>{$gHb)gL%5ob3gw=@b)8ZL=bt=#Rc`z5ud{+sOGBAq~d*W?dnG7 zbRvGFp268tU~1YUxRp-NKQfWw4*tyuy=1_a8lQHwBzVz}9rs&C#{Xo8@Ruk6o14<}N zUxJo0BLeM^_)It*tmz>>X`$o?o2_&SpG(iQ%lqk!WzdZubH6Lnb`7+0L^*V$y2T{j z1V7(y-Q84|Gt;u3qhaYC*m|Nk7xvoJO;-vq<5(RR@@&|TwDDvcVC9o8JiFT5WtC!{ z%&yIOUs-+Gwwp5)o=NG2(?yRnv+p2|N6M6o_Uho&Yp#qF(`)0Mzr9}2ty~lqNU4x7 zAfu5Al{#NqVQqmrQdBSH!GJA8vGq3Pu?f|gUnKeLUfdXyS}uK^ZYgtO2!+a{Ww)3i z+kjGt-GGdSZPV=`CmoNU5m$_NDLHa*H$M;F9vgxq(XP@5l}hFyE7&@99aVH++OIhw zfUY&FP15*eFI&bEDBHdCXhF5&E0|VGE|d$YR&T)J&bmqe-m&;gvyBH3SwJ4 zJB}gzCgGiM3it`tn0XntV-C@E)zuP-Wcr(3pua3p&Mk)S5qS2KE*E4;qp(KIlIPtE zsSX-6K@%O@aHRU(T3MxXgekVXsW=EK0x4Pe2|UX4=^E1|I*VOm?PKWm`Dl{I-90m$`mXZ?I`I;94L9?;m^2<~?>u3H?e3EWLg1w+wc^#kiavHN&d% zN}AT=Hz>La$c78AP2P>|Q05QHJ_=RRwm6(=yEE^e*G``VSU1H}o8B(#YAI>;WE*l) zgQ0odU2C^Rf|K+FMMl=>U_maI)kqHke;75zR~p{>A>NCRnbPE+vwyW=BLWtFf0;TB8flT