@pinkpixel/haku 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +151 -2
- package/dist/LICENSE +202 -0
- package/dist/cli.mjs +168 -0
- package/dist/fonts/Figtree-Regular.ttf +0 -0
- package/dist/fonts/Figtree-SemiBold.ttf +0 -0
- package/dist/fonts/OFL.txt +93 -0
- package/dist/mcp-DG9U-P0N.mjs +72 -0
- package/dist/node-CVxAljK8.mjs +24 -0
- package/dist/samples/ambience/rain_roof.ogg +0 -0
- package/dist/samples/ambience/rain_window.ogg +0 -0
- package/dist/samples/drums/brush_v0_r1.ogg +0 -0
- package/dist/samples/drums/brush_v0_r2.ogg +0 -0
- package/dist/samples/drums/brush_v1_r1.ogg +0 -0
- package/dist/samples/drums/brush_v1_r2.ogg +0 -0
- package/dist/samples/drums/brushhat_v0_r1.ogg +0 -0
- package/dist/samples/drums/brushhat_v0_r2.ogg +0 -0
- package/dist/samples/drums/brushhat_v1_r1.ogg +0 -0
- package/dist/samples/drums/brushhat_v1_r2.ogg +0 -0
- package/dist/samples/drums/hat_v0_r1.ogg +0 -0
- package/dist/samples/drums/hat_v0_r2.ogg +0 -0
- package/dist/samples/drums/hat_v1_r1.ogg +0 -0
- package/dist/samples/drums/hat_v1_r2.ogg +0 -0
- package/dist/samples/drums/kick_v0_r1.ogg +0 -0
- package/dist/samples/drums/kick_v0_r2.ogg +0 -0
- package/dist/samples/drums/kick_v1_r1.ogg +0 -0
- package/dist/samples/drums/kick_v1_r2.ogg +0 -0
- package/dist/samples/drums/openhat_v0_r1.ogg +0 -0
- package/dist/samples/drums/openhat_v0_r2.ogg +0 -0
- package/dist/samples/drums/openhat_v1_r1.ogg +0 -0
- package/dist/samples/drums/openhat_v1_r2.ogg +0 -0
- package/dist/samples/drums/ride_v0_r1.ogg +0 -0
- package/dist/samples/drums/ride_v0_r2.ogg +0 -0
- package/dist/samples/drums/ride_v1_r1.ogg +0 -0
- package/dist/samples/drums/ride_v1_r2.ogg +0 -0
- package/dist/samples/drums/rim_v0_r1.ogg +0 -0
- package/dist/samples/drums/rim_v0_r2.ogg +0 -0
- package/dist/samples/drums/rim_v1_r1.ogg +0 -0
- package/dist/samples/drums/rim_v1_r2.ogg +0 -0
- package/dist/samples/drums/snare_v0_r1.ogg +0 -0
- package/dist/samples/drums/snare_v0_r2.ogg +0 -0
- package/dist/samples/drums/snare_v1_r1.ogg +0 -0
- package/dist/samples/drums/snare_v1_r2.ogg +0 -0
- package/dist/samples/drums/tom_v0_r1.ogg +0 -0
- package/dist/samples/drums/tom_v0_r2.ogg +0 -0
- package/dist/samples/drums/tom_v1_r1.ogg +0 -0
- package/dist/samples/drums/tom_v1_r2.ogg +0 -0
- package/dist/samples/glock/v0_103.ogg +0 -0
- package/dist/samples/glock/v0_108.ogg +0 -0
- package/dist/samples/glock/v0_79.ogg +0 -0
- package/dist/samples/glock/v0_84.ogg +0 -0
- package/dist/samples/glock/v0_91.ogg +0 -0
- package/dist/samples/glock/v0_96.ogg +0 -0
- package/dist/samples/harp/v0_101.ogg +0 -0
- package/dist/samples/harp/v0_28.ogg +0 -0
- package/dist/samples/harp/v0_31.ogg +0 -0
- package/dist/samples/harp/v0_35.ogg +0 -0
- package/dist/samples/harp/v0_38.ogg +0 -0
- package/dist/samples/harp/v0_41.ogg +0 -0
- package/dist/samples/harp/v0_45.ogg +0 -0
- package/dist/samples/harp/v0_48.ogg +0 -0
- package/dist/samples/harp/v0_52.ogg +0 -0
- package/dist/samples/harp/v0_55.ogg +0 -0
- package/dist/samples/harp/v0_59.ogg +0 -0
- package/dist/samples/harp/v0_62.ogg +0 -0
- package/dist/samples/harp/v0_65.ogg +0 -0
- package/dist/samples/harp/v0_69.ogg +0 -0
- package/dist/samples/harp/v0_72.ogg +0 -0
- package/dist/samples/harp/v0_76.ogg +0 -0
- package/dist/samples/harp/v0_79.ogg +0 -0
- package/dist/samples/harp/v0_83.ogg +0 -0
- package/dist/samples/harp/v0_86.ogg +0 -0
- package/dist/samples/harp/v0_89.ogg +0 -0
- package/dist/samples/harp/v0_93.ogg +0 -0
- package/dist/samples/harp/v0_95.ogg +0 -0
- package/dist/samples/harp/v0_98.ogg +0 -0
- package/dist/samples/manifest.json +368 -0
- package/dist/samples/marimba/v0_41.ogg +0 -0
- package/dist/samples/marimba/v0_48.ogg +0 -0
- package/dist/samples/marimba/v0_55.ogg +0 -0
- package/dist/samples/marimba/v0_59.ogg +0 -0
- package/dist/samples/marimba/v0_65.ogg +0 -0
- package/dist/samples/marimba/v0_72.ogg +0 -0
- package/dist/samples/marimba/v0_79.ogg +0 -0
- package/dist/samples/marimba/v0_83.ogg +0 -0
- package/dist/samples/marimba/v0_89.ogg +0 -0
- package/dist/samples/marimba/v0_96.ogg +0 -0
- package/dist/samples/piano/v0_29.ogg +0 -0
- package/dist/samples/piano/v0_33.ogg +0 -0
- package/dist/samples/piano/v0_37.ogg +0 -0
- package/dist/samples/piano/v0_41.ogg +0 -0
- package/dist/samples/piano/v0_45.ogg +0 -0
- package/dist/samples/piano/v0_49.ogg +0 -0
- package/dist/samples/piano/v0_53.ogg +0 -0
- package/dist/samples/piano/v0_57.ogg +0 -0
- package/dist/samples/piano/v0_61.ogg +0 -0
- package/dist/samples/piano/v0_65.ogg +0 -0
- package/dist/samples/piano/v0_69.ogg +0 -0
- package/dist/samples/piano/v0_73.ogg +0 -0
- package/dist/samples/piano/v0_77.ogg +0 -0
- package/dist/samples/piano/v0_81.ogg +0 -0
- package/dist/samples/piano/v0_85.ogg +0 -0
- package/dist/samples/piano/v0_89.ogg +0 -0
- package/dist/samples/piano/v0_93.ogg +0 -0
- package/dist/samples/piano/v0_97.ogg +0 -0
- package/dist/samples/piano/v1_29.ogg +0 -0
- package/dist/samples/piano/v1_33.ogg +0 -0
- package/dist/samples/piano/v1_37.ogg +0 -0
- package/dist/samples/piano/v1_41.ogg +0 -0
- package/dist/samples/piano/v1_45.ogg +0 -0
- package/dist/samples/piano/v1_49.ogg +0 -0
- package/dist/samples/piano/v1_53.ogg +0 -0
- package/dist/samples/piano/v1_57.ogg +0 -0
- package/dist/samples/piano/v1_61.ogg +0 -0
- package/dist/samples/piano/v1_65.ogg +0 -0
- package/dist/samples/piano/v1_69.ogg +0 -0
- package/dist/samples/piano/v1_73.ogg +0 -0
- package/dist/samples/piano/v1_77.ogg +0 -0
- package/dist/samples/piano/v1_81.ogg +0 -0
- package/dist/samples/piano/v1_85.ogg +0 -0
- package/dist/samples/piano/v1_89.ogg +0 -0
- package/dist/samples/piano/v1_93.ogg +0 -0
- package/dist/samples/piano/v1_97.ogg +0 -0
- package/dist/samples/wurli/v0_33.ogg +0 -0
- package/dist/samples/wurli/v0_40.ogg +0 -0
- package/dist/samples/wurli/v0_45.ogg +0 -0
- package/dist/samples/wurli/v0_51.ogg +0 -0
- package/dist/samples/wurli/v0_56.ogg +0 -0
- package/dist/samples/wurli/v0_61.ogg +0 -0
- package/dist/samples/wurli/v0_66.ogg +0 -0
- package/dist/samples/wurli/v0_71.ogg +0 -0
- package/dist/samples/wurli/v0_73.ogg +0 -0
- package/dist/samples/wurli/v0_79.ogg +0 -0
- package/dist/samples/wurli/v0_85.ogg +0 -0
- package/dist/samples/wurli/v0_92.ogg +0 -0
- package/dist/samples/wurli/v1_33.ogg +0 -0
- package/dist/samples/wurli/v1_36.ogg +0 -0
- package/dist/samples/wurli/v1_41.ogg +0 -0
- package/dist/samples/wurli/v1_47.ogg +0 -0
- package/dist/samples/wurli/v1_52.ogg +0 -0
- package/dist/samples/wurli/v1_56.ogg +0 -0
- package/dist/samples/wurli/v1_61.ogg +0 -0
- package/dist/samples/wurli/v1_68.ogg +0 -0
- package/dist/samples/wurli/v1_73.ogg +0 -0
- package/dist/samples/wurli/v1_79.ogg +0 -0
- package/dist/samples/wurli/v1_85.ogg +0 -0
- package/dist/samples/wurli/v1_92.ogg +0 -0
- package/dist/src-CgZeiBJc.mjs +711 -0
- package/dist/src-dP0jXhPP.mjs +2322 -0
- package/dist/tools-_xkF2Yfv.mjs +1891 -0
- package/dist/web/assets/figtree-latin-ext-wght-normal-DCwSJGxG.woff2 +0 -0
- package/dist/web/assets/figtree-latin-wght-normal-D_ZTVpCC.woff2 +0 -0
- package/dist/web/assets/fraunces-latin-ext-wght-normal-Ca2vKHc0.woff2 +0 -0
- package/dist/web/assets/fraunces-latin-wght-normal-ukD16Tqj.woff2 +0 -0
- package/dist/web/assets/fraunces-vietnamese-wght-normal-CnvboYUG.woff2 +0 -0
- package/dist/web/assets/index-BmW6jd5Q.js +272 -0
- package/dist/web/assets/index-C7U7z4um.css +1 -0
- package/dist/web/icon-192.png +0 -0
- package/dist/web/icon-512.png +0 -0
- package/dist/web/index.html +18 -0
- package/dist/web/manifest.webmanifest +24 -0
- package/dist/web/sw.js +37 -0
- package/package.json +59 -3
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)),u=e=>a.call(e,`module.exports`)?e[`module.exports`]:c(t({},`__esModule`,{value:!0}),e);(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var d=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function ee(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function te(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ne=/\/+/g;function re(e,t){return typeof e==`object`&&e&&e.key!=null?te(``+e.key):t.toString(36)}function ie(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ae(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ae(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+re(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(ne,`$&/`)+`/`),ae(o,r,i,``,function(e){return e})):o!=null&&(ee(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ne,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+re(a,u),c+=ae(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+re(a,u++),c+=ae(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ae(ie(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function oe(e,t,n){if(e==null)return e;var r=[],i=0;return ae(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function se(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var ce=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function le(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,ce)}catch(e){ce(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ue(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else le(ue.bind(null,e))}var de={map:oe,forEach:function(e,t,n){oe(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return oe(e,function(){t++}),t},toArray:function(e){return oe(e,function(e){return e})||[]},only:function(e){if(!ee(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=de,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=ue,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=ee,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:se}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=le,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&ne(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ne(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,te=ee.port2;ee.port1.onmessage=D,O=function(){te.postMessage(null)}}else O=function(){_(D,0)};function ne(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ne(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),m=o(((e,t)=>{t.exports=p()})),h=o((e=>{var t=f();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),g=o(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()})),_=o((e=>{var t=m(),n=f(),r=g();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function p(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&p(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function h(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=h(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),ee=Symbol.for(`react.transitional.element`),te=Symbol.for(`react.portal`),ne=Symbol.for(`react.fragment`),re=Symbol.for(`react.strict_mode`),ie=Symbol.for(`react.profiler`),ae=Symbol.for(`react.consumer`),oe=Symbol.for(`react.context`),se=Symbol.for(`react.forward_ref`),ce=Symbol.for(`react.suspense`),le=Symbol.for(`react.suspense_list`),ue=Symbol.for(`react.memo`),de=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),fe=Symbol.for(`react.legacy_hidden`),pe=Symbol.for(`react.memo_cache_sentinel`),me=Symbol.for(`react.view_transition`),he=Symbol.for(`react.recoverable`),ge=Symbol.iterator;function _e(e){return typeof e!=`object`||!e?null:(e=ge&&e[ge]||e[`@@iterator`],typeof e==`function`?e:null)}var ve=Symbol.for(`react.client.reference`);function ye(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ve?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case ne:return`Fragment`;case ie:return`Profiler`;case re:return`StrictMode`;case ce:return`Suspense`;case le:return`SuspenseList`;case k:return`Activity`;case me:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case te:return`Portal`;case oe:return e.displayName||`Context`;case ae:return(e._context.displayName||`Context`)+`.Consumer`;case se:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ue:return t=e.displayName||null,t===null?ye(e.type)||`Memo`:t;case de:t=e._payload,e=e._init;try{return ye(e(t))}catch{}}return null}var be=Array.isArray,A=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,xe={pending:!1,data:null,method:null,action:null},Se=[],Ce=-1;function we(e){return{current:e}}function Te(e){0>Ce||(e.current=Se[Ce],Se[Ce]=null,Ce--)}function Ee(e,t){Ce++,Se[Ce]=e.current,e.current=t}var De=we(null),Oe=we(null),ke=we(null),Ae=we(null);function je(e,t){switch(Ee(ke,t),Ee(Oe,e),Ee(De,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?yp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=yp(t),e=bp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Te(De),Ee(De,e)}function Me(){Te(De),Te(Oe),Te(ke)}function Ne(e){var t=e.memoizedState;t!==null&&(gh._currentValue=t.memoizedState,Ee(Ae,e)),t=De.current;var n=bp(t,e.type);t!==n&&(Ee(Oe,e),Ee(De,n))}function Pe(e){Oe.current===e&&(Te(De),Te(Oe)),Ae.current===e&&(Te(Ae),gh._currentValue=xe)}var Fe,Ie;function Le(e){if(Fe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Fe=t&&t[1]||``,Ie=-1<e.stack.indexOf(`
|
|
2
|
+
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
3
|
+
`+Fe+e+Ie}var Re=!1;function ze(e,t){if(!e||Re)return``;Re=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
4
|
+
`),l=s.split(`
|
|
5
|
+
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
6
|
+
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Re=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Le(n):``}function Be(e,t){switch(e.tag){case 26:case 27:case 5:return Le(e.type);case 16:return Le(`Lazy`);case 13:return e.child!==t&&t!==null?Le(`Suspense Fallback`):Le(`Suspense`);case 19:return Le(`SuspenseList`);case 0:case 15:return ze(e.type,!1);case 11:return ze(e.type.render,!1);case 1:return ze(e.type,!0);case 31:return Le(`Activity`);case 30:return Le(`ViewTransition`);default:return``}}function Ve(e){try{var t=``,n=null;do t+=Be(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
7
|
+
Error generating stack: `+e.message+`
|
|
8
|
+
`+e.stack}}var He=Object.prototype.hasOwnProperty,Ue=t.unstable_scheduleCallback,We=t.unstable_cancelCallback,Ge=t.unstable_shouldYield,Ke=t.unstable_requestPaint,qe=t.unstable_now,Je=t.unstable_getCurrentPriorityLevel,Ye=t.unstable_ImmediatePriority,Xe=t.unstable_UserBlockingPriority,Ze=t.unstable_NormalPriority,Qe=t.unstable_LowPriority,$e=t.unstable_IdlePriority,et=t.log,tt=t.unstable_setDisableYieldValue,nt=null,rt=null;function it(e){if(typeof et==`function`&&tt(e),rt&&typeof rt.setStrictMode==`function`)try{rt.setStrictMode(nt,e)}catch{}}var at=Math.clz32?Math.clz32:ct,ot=Math.log,st=Math.LN2;function ct(e){return e>>>=0,e===0?32:31-(ot(e)/st|0)|0}var lt=256,ut=262144,dt=4194304;function M(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ft(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=M(n))):i=M(o):i=M(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=M(n))):i=M(o)):i=M(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function pt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function mt(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-at(n),i=1<<r;t|=e[r],n&=~i}return t}function ht(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function gt(){var e=dt;return dt<<=1,!(dt&62914560)&&(dt=4194304),e}function _t(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function vt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function yt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-at(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&bt(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function bt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-at(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function xt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-at(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function St(e,t){var n=t&-t;return n=n&42?1:Ct(n),(n&(e.suspendedLanes|t))===0?n:0}function Ct(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function wt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Tt(){var e=j.p;return e===0?(e=window.event,e===void 0?32:Mh(e.type)):e}function Et(e,t){var n=j.p;try{return j.p=e,t()}finally{j.p=n}}var Dt=Math.random().toString(36).slice(2),Ot=`__reactFiber$`+Dt,kt=`__reactProps$`+Dt,At=`__reactContainer$`+Dt,jt=`__reactEvents$`+Dt,Mt=`__reactListeners$`+Dt,Nt=`__reactHandles$`+Dt,Pt=`__reactResources$`+Dt,Ft=`__reactMarker$`+Dt,It=`__reactLoad$`+Dt;function Lt(e){delete e[Ot],delete e[kt],delete e[Mt],delete e[Nt]}function Rt(e){var t;if(t=e[Ot])return t;for(var n=e.parentNode;n;){if(t=n[At]||n[Ot]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=xm(e);e!==null;){if(n=e[Ot])return n;e=xm(e)}return t}e=n,n=e.parentNode}return null}function zt(e){if(e=e[Ot]||e[At]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Bt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Vt(e){var t=e[Pt];return t||=e[Pt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Ht(e){e[Ft]=!0}function Ut(e){e[It]=void 0}var Wt=new Set,Gt={};function N(e,t){Kt(e,t),Kt(e+`Capture`,t)}function Kt(e,t){for(Gt[e]=t,e=0;e<t.length;e++)Wt.add(t[e])}var qt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Jt={},Yt={};function Xt(e){return He.call(Yt,e)?!0:He.call(Jt,e)?!1:qt.test(e)?Yt[e]=!0:(Jt[e]=!0,!1)}var P=!1;function Zt(){var e=P;return P=!1,e}function F(e,t,n){if(Xt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,n)}}}function Qt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,n)}}function $t(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,r)}}function en(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function tn(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function nn(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function rn(e){if(!e._valueTracker){var t=tn(e)?`checked`:`value`;e._valueTracker=nn(e,t,``+e[t])}}function an(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=tn(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var on=/[\n"\\]/g;function sn(e){return e.replace(on,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function cn(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+en(t)):e.value!==``+en(t)&&(e.value=``+en(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):un(e,en(n)):o===`number`&&e.value==t?un(e,en(e.value)):un(e,en(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+en(s):e.removeAttribute(`name`)}function ln(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){rn(e);return}n=n==null?``:``+en(n),t=t==null?n:``+en(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),rn(e)}function un(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function dn(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+en(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function fn(e,t,n){t!=null&&(t=``+en(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+en(n)}function pn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(be(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=en(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),rn(e)}function mn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var hn=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function gn(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||hn.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function _n(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``,P=!0);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&(gn(e,a,r),P=!0)}else for(var o in t)t.hasOwnProperty(o)&&gn(e,o,t[o])}function vn(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var yn=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`maskType`,`mask-type`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),bn=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function xn(e){return bn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Sn(){}var Cn=null;function wn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Tn=null,En=null;function Dn(e){var t=zt(e);if(t&&(e=t.stateNode)){var n=e[kt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(cn(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+sn(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[kt]||null;if(!a)throw Error(i(90));cn(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&an(r)}break a;case`textarea`:fn(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&dn(e,!!n.multiple,t,!1)}}}var On=!1;function kn(e,t,n){if(On)return e(t,n);On=!0;try{return e(t)}finally{if(On=!1,(Tn!==null||En!==null)&&(Kd(),Tn&&(t=Tn,e=En,En=Tn=null,Dn(t),e)))for(t=0;t<e.length;t++)Dn(e[t])}}function An(e,t){var n=e.stateNode;if(n===null)return null;var r=n[kt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var jn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Mn=!1;if(jn)try{var Nn={};Object.defineProperty(Nn,"passive",{get:function(){Mn=!0}}),window.addEventListener(`test`,Nn,Nn),window.removeEventListener(`test`,Nn,Nn)}catch{Mn=!1}var Pn=null,Fn=null,In=null;function Ln(){if(In)return In;var e,t=Fn,n=t.length,r,i=`value`in Pn?Pn.value:Pn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return In=i.slice(e,1<r?1-r:void 0)}function Rn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function zn(){return!0}function Bn(){return!1}function Vn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?zn:Bn,this.isPropagationStopped=Bn,this}return D(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=zn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=zn)},persist:function(){},isPersistent:zn}),t}var Hn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Un=Vn(Hn),Wn=D({},Hn,{view:0,detail:0}),Gn=Vn(Wn),Kn,qn,Jn,Yn=D({},Wn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:or,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==Jn&&(Jn&&e.type===`mousemove`?(Kn=e.screenX-Jn.screenX,qn=e.screenY-Jn.screenY):qn=Kn=0,Jn=e),Kn)},movementY:function(e){return`movementY`in e?e.movementY:qn}}),Xn=Vn(Yn),Zn=Vn(D({},Yn,{dataTransfer:0})),Qn=Vn(D({},Wn,{relatedTarget:0})),$n=Vn(D({},Hn,{animationName:0,elapsedTime:0,pseudoElement:0})),er=Vn(D({},Hn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),tr=Vn(D({},Hn,{data:0})),nr={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},rr={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},ir={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function ar(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=ir[e])?!!t[e]:!1}function or(){return ar}var sr=Vn(D({},Wn,{key:function(e){if(e.key){var t=nr[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Rn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?rr[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:or,charCode:function(e){return e.type===`keypress`?Rn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Rn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),cr=Vn(D({},Yn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),lr=Vn(D({},Hn,{submitter:0})),ur=Vn(D({},Wn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:or})),dr=Vn(D({},Hn,{propertyName:0,elapsedTime:0,pseudoElement:0})),fr=Vn(D({},Yn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),pr=Vn(D({},Hn,{newState:0,oldState:0,source:0})),mr=[9,13,27,32],hr=jn&&`CompositionEvent`in window,gr=null;jn&&`documentMode`in document&&(gr=document.documentMode);var _r=jn&&`TextEvent`in window&&!gr,vr=jn&&(!hr||gr&&8<gr&&11>=gr),yr=` `,br=!1;function xr(e,t){switch(e){case`keyup`:return mr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Sr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Cr=!1;function wr(e,t){switch(e){case`compositionend`:return Sr(t);case`keypress`:return t.which===32?(br=!0,yr):null;case`textInput`:return e=t.data,e===yr&&br?null:e;default:return null}}function Tr(e,t){if(Cr)return e===`compositionend`||!hr&&xr(e,t)?(e=Ln(),In=Fn=Pn=null,Cr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return vr&&t.locale!==`ko`?null:t.data;default:return null}}var Er={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Dr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Er[e.type]:t===`textarea`}function Or(e,t,n,r){Tn?En?En.push(r):En=[r]:Tn=r,t=np(t,`onChange`),0<t.length&&(n=new Un(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var kr=null,Ar=null;function jr(e){Yf(e,0)}function Mr(e){if(an(Bt(e)))return e}function Nr(e,t){if(e===`change`)return t}var Pr=!1;if(jn){var Fr;if(jn){var Ir=`oninput`in document;if(!Ir){var Lr=document.createElement(`div`);Lr.setAttribute(`oninput`,`return;`),Ir=typeof Lr.oninput==`function`}Fr=Ir}else Fr=!1;Pr=Fr&&(!document.documentMode||9<document.documentMode)}function Rr(){kr&&(kr.detachEvent(`onpropertychange`,zr),Ar=kr=null)}function zr(e){if(e.propertyName===`value`&&Mr(Ar)){var t=[];Or(t,Ar,e,wn(e)),kn(jr,t)}}function Br(e,t,n){e===`focusin`?(Rr(),kr=t,Ar=n,kr.attachEvent(`onpropertychange`,zr)):e===`focusout`&&Rr()}function Vr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Mr(Ar)}function Hr(e,t){if(e===`click`)return Mr(t)}function Ur(e,t){if(e===`input`||e===`change`)return Mr(t)}function Wr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Gr=typeof Object.is==`function`?Object.is:Wr;function Kr(e,t){if(Gr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!He.call(t,i)||!Gr(e[i],t[i]))return!1}return!0}function qr(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Jr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Yr(e,t){var n=Jr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Jr(n)}}function Xr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Xr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Zr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=qr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=qr(e.document)}return t}function Qr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var $r=jn&&`documentMode`in document&&11>=document.documentMode,ei=null,ti=null,ni=null,ri=!1;function ii(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ri||ei==null||ei!==qr(r)||(r=ei,`selectionStart`in r&&Qr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ni&&Kr(ni,r)||(ni=r,r=np(ti,`onSelect`),0<r.length&&(t=new Un(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=ei)))}function ai(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var oi={animationend:ai(`Animation`,`AnimationEnd`),animationiteration:ai(`Animation`,`AnimationIteration`),animationstart:ai(`Animation`,`AnimationStart`),transitionrun:ai(`Transition`,`TransitionRun`),transitionstart:ai(`Transition`,`TransitionStart`),transitioncancel:ai(`Transition`,`TransitionCancel`),transitionend:ai(`Transition`,`TransitionEnd`)},si={},ci={};jn&&(ci=document.createElement(`div`).style,`AnimationEvent`in window||(delete oi.animationend.animation,delete oi.animationiteration.animation,delete oi.animationstart.animation),`TransitionEvent`in window||delete oi.transitionend.transition);function li(e){if(si[e])return si[e];if(!oi[e])return e;var t=oi[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in ci)return si[e]=t[n];return e}var ui=li(`animationend`),di=li(`animationiteration`),fi=li(`animationstart`),pi=li(`transitionrun`),mi=li(`transitionstart`),hi=li(`transitioncancel`),gi=li(`transitionend`),_i=new Map,vi=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);vi.push(`scrollEnd`);function yi(e,t){_i.set(e,t),N(t,[e])}var bi=0;function xi(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=Dd.identifierPrefix;var n=bi++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function Si(e){if(e==null||typeof e==`string`)return e;var t=null,n=Fd;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function Ci(e,t){return e=Si(e),t=Si(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var wi=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Ti=[],Ei=0,Di=0;function Oi(){for(var e=Ei,t=Di=Ei=0;t<e;){var n=Ti[t];Ti[t++]=null;var r=Ti[t];Ti[t++]=null;var i=Ti[t];Ti[t++]=null;var a=Ti[t];if(Ti[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Mi(n,i,a)}}function ki(e,t,n,r){Ti[Ei++]=e,Ti[Ei++]=t,Ti[Ei++]=n,Ti[Ei++]=r,Di|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Ai(e,t,n,r){return ki(e,t,n,r),Ni(e)}function ji(e,t){return ki(e,null,null,t),Ni(e)}function Mi(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-at(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Ni(e){if(50<Id)throw Id=0,Ld=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Pi={};function Fi(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ii(e,t,n,r){return new Fi(e,t,n,r)}function Li(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ri(e,t){var n=e.alternate;return n===null?(n=Ii(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&1206910976,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function zi(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Bi(e,t,n,r,a,o){var s=0;if(r=e,typeof r==`function`)Li(r)&&(s=1);else if(typeof r==`string`)s=nh(e,n,De.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case k:return e=Ii(31,n,t,a),e.elementType=k,e.lanes=o,e;case ne:return Vi(n.children,a,o,t);case re:s=8,a|=24;break;case ie:return e=Ii(12,n,t,a|2),e.elementType=ie,e.lanes=o,e;case ce:return e=Ii(13,n,t,a),e.elementType=ce,e.lanes=o,e;case le:return e=Ii(19,n,t,a),e.elementType=le,e.lanes=o,e;case fe:case me:return e=a|32,e=Ii(30,n,t,e),e.elementType=me,e.lanes=o,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case oe:s=10;break a;case ae:s=9;break a;case se:s=11;break a;case ue:s=14;break a;case de:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Ii(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Vi(e,t,n,r){return e=Ii(7,e,r,t),e.lanes=n,e}function Hi(e,t,n){return e=Ii(6,e,null,t),e.lanes=n,e}function Ui(e){var t=Ii(18,null,null,0);return t.stateNode=e,t}function Wi(e,t,n){return t=Ii(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Gi=new WeakMap;function Ki(e,t){if(typeof e==`object`&&e){var n=Gi.get(e);return n===void 0?(t={value:e,source:t,stack:Ve(t)},Gi.set(e,t),t):n}return{value:e,source:t,stack:Ve(t)}}var qi=[],Ji=0,Yi=null,Xi=0,Zi=[],Qi=0,$i=null,ea=1,ta=``;function na(e,t){qi[Ji++]=Xi,qi[Ji++]=Yi,Yi=e,Xi=t}function ra(e,t,n){Zi[Qi++]=ea,Zi[Qi++]=ta,Zi[Qi++]=$i,$i=e;var r=ea;e=ta;var i=32-at(r)-1;r&=~(1<<i),n+=1;var a=32-at(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,ea=1<<32-at(t)+i|n<<i|r,ta=a+e}else ea=1<<a|n<<i|r,ta=e}function ia(e){e.return!==null&&(na(e,1),ra(e,1,0))}function aa(e){for(;e===Yi;)Yi=qi[--Ji],qi[Ji]=null,Xi=qi[--Ji],qi[Ji]=null;for(;e===$i;)$i=Zi[--Qi],Zi[Qi]=null,ta=Zi[--Qi],Zi[Qi]=null,ea=Zi[--Qi],Zi[Qi]=null}function oa(e,t){Zi[Qi++]=ea,Zi[Qi++]=ta,Zi[Qi++]=$i,ea=t.id,ta=t.overflow,$i=e}var sa=null,ca=null,I=!1,la=null,ua=!1,da=Error(i(519));function fa(e){throw va(Ki(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),da}function pa(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Ot]=e,t[kt]=r,n){case`dialog`:W(`cancel`,t),W(`close`,t);break;case`iframe`:case`object`:case`embed`:W(`load`,t);break;case`video`:case`audio`:for(n=0;n<qf.length;n++)W(qf[n],t);break;case`source`:W(`error`,t);break;case`img`:case`image`:case`link`:W(`error`,t),W(`load`,t);break;case`details`:W(`toggle`,t);break;case`input`:W(`invalid`,t),ln(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:W(`invalid`,t);break;case`textarea`:W(`invalid`,t),pn(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||cp(t.textContent,n)?(r.popover!=null&&(W(`beforetoggle`,t),W(`toggle`,t)),r.onScroll!=null&&W(`scroll`,t),r.onScrollEnd!=null&&W(`scrollend`,t),r.onClick!=null&&(t.onclick=Sn),t=!0):t=!1,t||fa(e,!0)}function ma(e){for(sa=e.return;sa;)switch(sa.tag){case 5:case 31:case 13:ua=!1;return;case 27:case 3:ua=!0;return;default:sa=sa.return}}function ha(e){if(e!==sa)return!1;if(!I)return ma(e),I=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||Sp(e.type,e.memoizedProps)),n=!n),n&&ca&&fa(e),ma(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));ca=bm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));ca=bm(e)}else t===27?(t=ca,jp(e.type)?(e=ym,ym=null,ca=e):ca=t):ca=sa?vm(e.stateNode.nextSibling):null;return!0}function ga(){ca=sa=null,I=!1}function _a(){var e=la;return e!==null&&(yd===null?yd=e:yd.push.apply(yd,e),la=null),e}function va(e){la===null?la=[e]:la.push(e)}var ya=we(null),ba=null,xa=null;function Sa(e,t,n){Ee(ya,t._currentValue),t._currentValue=n}function Ca(e){e._currentValue=ya.current,Te(ya)}function wa(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ta(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),wa(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),wa(s,n,e),s=null}else a.tag===13&&a.memoizedState!==null&&a.memoizedState.dehydrated===null?(a.lanes|=n,s=a.alternate,s!==null&&(s.lanes|=n),wa(a.return,n,e),s=a.child,s=s===null?null:s.sibling):s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Ea(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Gr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===Ae.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[gh]:e.push(gh))}a=a.return}return e!==null&&Ta(t,e,n,r),t.flags|=262144,e!==null}function Da(e){for(e=e.firstContext;e!==null;){if(!Gr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Oa(e){ba=e,xa=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ka(e){return ja(ba,e)}function Aa(e,t){return ba===null&&Oa(e),ja(e,t)}function ja(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},xa===null){if(e===null)throw Error(i(308));xa=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else xa=xa.next=t;return n}var Ma=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Na=t.unstable_scheduleCallback,Pa=t.unstable_NormalPriority,Fa={$$typeof:oe,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ia(){return{controller:new Ma,data:new Map,refCount:0}}function La(e){e.refCount--,e.refCount===0&&Na(Pa,function(){e.controller.abort()})}function Ra(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var za=null;function Ba(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var Va=null,Ha=0,Ua=0,Wa=null;function Ga(e,t){if(Va===null){var n=Va=[];Ha=0,Ua=Hf(),Wa={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Ha++,t.then(Ka,Ka),t}function Ka(){if(--Ha===0&&(za=null,Va!==null)){Wa!==null&&(Wa.status=`fulfilled`);var e=Va;Va=null,Ua=0,Wa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function qa(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var Ja=A.S;A.S=function(e,t){if(Sd=qe(),typeof t==`object`&&t&&typeof t.then==`function`&&Ga(e,t),za!==null)for(var n=Of;n!==null;)Ra(n,za),n=n.next;if(n=e.types,n!==null){for(var r=Of;r!==null;)Ra(r,n),r=r.next;if(Ua!==0){r=za,r===null&&(r=za=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}Ja!==null&&Ja(e,t)};var Ya=we(null);function Xa(){var e=Ya.current;return e===null?ad.pooledCache:e}function Za(e,t){t===null?Ee(Ya,Ya.current):Ee(Ya,t.pool)}function Qa(){var e=Xa();return e===null?null:{parent:Fa._currentValue,pool:e}}var $a=Error(i(460)),eo=Error(i(474)),to=Error(i(542)),no={then:function(){}};function ro(e){return e=e.status,e===`fulfilled`||e===`rejected`}function io(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Sn,Sn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,co(e),e===void 0&&!(`reason`in t)?Error(i(600)):e;default:if(typeof t.status==`string`)t.then(Sn,Sn);else{if(e=ad,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,co(e),e}throw oo=t,$a}}function ao(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(oo=e,$a):e}}var oo=null;function so(){if(oo===null)throw Error(i(459));var e=oo;return oo=null,e}function co(e){if(e===$a||e===to)throw Error(i(483))}var lo=null,uo=0;function fo(e){var t=uo;return uo+=1,lo===null&&(lo=[]),io(lo,e,t)}function po(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function mo(e,t){throw t.$$typeof===O?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function ho(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Ri(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Hi(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===ne?(e=d(e,t,n.props.children,r,n.key),po(e,n),e):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===de&&ao(i)===t.type)?(t=a(t,n.props),po(t,n),t.return=e,t):(t=Bi(n.type,n.key,n.props,null,e.mode,r),po(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Wi(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=Vi(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=Hi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case ee:return n=Bi(t.type,t.key,t.props,null,e.mode,n),po(n,t),n.return=e,n;case te:return t=Wi(t,e.mode,n),t.return=e,t;case de:return t=ao(t),f(e,t,n)}if(be(t)||_e(t))return t=Vi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,fo(t),n);if(t.$$typeof===oe)return f(e,Aa(e,t),n);mo(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case ee:return n.key===i?l(e,t,n,r):null;case te:return n.key===i?u(e,t,n,r):null;case de:return n=ao(n),p(e,t,n,r)}if(be(n)||_e(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,fo(n),r);if(n.$$typeof===oe)return p(e,t,Aa(e,n),r);mo(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case ee:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case te:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case de:return r=ao(r),m(e,t,n,r,i)}if(be(r)||_e(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,fo(r),i);if(r.$$typeof===oe)return m(e,t,n,Aa(t,r),i);mo(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),I&&na(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return I&&na(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&(_=g.alternate,_!==null&&d.delete(_.key===null?h:_.key)),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),I&&na(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),I&&na(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return I&&na(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),I&&na(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===ne&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case ee:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===ne){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),po(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===de&&ao(l)===r.type){n(e,r.sibling),c=a(r,o.props),po(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===ne?(c=Vi(o.props.children,e.mode,c,o.key),po(c,o),c.return=e,e=c):(c=Bi(o.type,o.key,o.props,null,e.mode,c),po(c,o),c.return=e,e=c)}return s(e);case te:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Wi(o,e.mode,c),c.return=e,e=c}return s(e);case de:return o=ao(o),_(e,r,o,c)}if(be(o))return h(e,r,o,c);if(_e(o)){if(l=_e(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,fo(o),c);if(o.$$typeof===oe)return _(e,r,Aa(e,o),c);mo(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Hi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{uo=0;var i=_(e,t,n,r);return lo=null,i}catch(t){if(t===$a||t===to)throw t;var a=Ii(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var go=ho(!0),_o=ho(!1),vo=!1;function yo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function bo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function xo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function So(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,V&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Ni(e),Mi(e,null,n),t}return ki(e,r,t,n),Ni(e)}function Co(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xt(e,n)}}function wo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var To=!1;function Eo(){if(To){var e=Wa;if(e!==null)throw e}}function Do(e,t,n,r){To=!1;var i=e.updateQueue;vo=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(U&f)===f:(r&f)===f){f!==0&&f===Ua&&(To=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=D({},d,f);break a;case 2:vo=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),pd|=o,e.lanes=o,e.memoizedState=d}}function Oo(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function ko(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Oo(n[e],t)}var Ao=we(null),jo=we(0);function Mo(e,t){e=dd,Ee(jo,e),Ee(Ao,t),dd=e|t.baseLanes}function No(){Ee(jo,dd),Ee(Ao,Ao.current)}function Po(){dd=jo.current,Te(Ao),Te(jo)}var Fo=we(null),Io=null;function Lo(e){var t=e.alternate;Ee(Ho,Ho.current&1),Ee(Fo,e),Io===null&&(t===null||Ao.current!==null||t.memoizedState!==null)&&(Io=e)}function Ro(e){Ee(Ho,Ho.current),Ee(Fo,e),Io===null&&(Io=e)}function zo(e){e.tag===22?(Ee(Ho,Ho.current),Ee(Fo,e),Io===null&&(Io=e)):Bo()}function Bo(){Ee(Ho,Ho.current),Ee(Fo,Fo.current)}function Vo(e){Te(Fo),Io===e&&(Io=null),Te(Ho)}var Ho=we(0);function Uo(e,t){Ee(Fo,Fo.current),Ee(Ho,t)}function Wo(e){Te(Ho),Te(Fo),Io===e&&(Io=null)}function Go(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||hm(n)||gm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ko=0,L=null,qo=null,Jo=null,Yo=!1,Xo=!1,Zo=!1,Qo=0,$o=0,es=null,ts=0;function ns(){throw Error(i(321))}function rs(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Gr(e[n],t[n]))return!1;return!0}function is(e,t,n,r,i,a){return Ko=a,L=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,A.H=e===null||e.memoizedState===null?bc:xc,Zo=!1,a=n(r,i),Zo=!1,Xo&&(a=os(t,n,r,i)),as(e),a}function as(e){A.H=yc;var t=qo!==null&&qo.next!==null;if(Ko=0,Jo=qo=L=null,Yo=!1,$o=0,es=null,t)throw Error(i(300));e===null||Lc||(e=e.dependencies,e!==null&&Da(e)&&(Lc=!0))}function os(e,t,n,r){L=e;var a=0;do{if(Xo&&(es=null),$o=0,Xo=!1,25<=a)throw Error(i(301));if(a+=1,Jo=qo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}A.H=Sc,o=t(n,r)}while(Xo);return o}function ss(){var e=A.H,t=e.useState()[0];return t=typeof t.then==`function`?ms(t):t,e=e.useState()[0],(qo===null?null:qo.memoizedState)!==e&&(L.flags|=1024),t}function cs(){var e=Qo!==0;return Qo=0,e}function ls(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function us(e){if(Yo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Yo=!1}Ko=0,Jo=qo=L=null,Xo=!1,$o=Qo=0,es=null}function ds(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Jo===null?L.memoizedState=Jo=e:Jo=Jo.next=e,Jo}function fs(){if(qo===null){var e=L.alternate;e=e===null?null:e.memoizedState}else e=qo.next;var t=Jo===null?L.memoizedState:Jo.next;if(t!==null)Jo=t,qo=e;else{if(e===null)throw L.alternate===null?Error(i(467)):Error(i(310));qo=e,e={memoizedState:qo.memoizedState,baseState:qo.baseState,baseQueue:qo.baseQueue,queue:qo.queue,next:null},Jo===null?L.memoizedState=Jo=e:Jo=Jo.next=e}return Jo}function ps(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ms(e){var t=$o;return $o+=1,es===null&&(es=[]),e=io(es,e,t),t=L,(Jo===null?t.memoizedState:Jo.next)===null&&(t=t.alternate,A.H=t===null||t.memoizedState===null?bc:xc),e}function hs(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return ms(e);if(e.$$typeof===he)return;if(e.$$typeof===oe)return ka(e)}throw Error(i(438,String(e)))}function gs(e){var t=null,n=L.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=L.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=ps(),L.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=pe;return t.index++,n}function _s(e,t){return typeof t==`function`?t(e):t}function vs(e){return ys(fs(),qo,e)}function ys(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Ko&f)===f:(U&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===Ua&&(d=!0);else if((Ko&p)===p){u=u.next,p===Ua&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,L.lanes|=p,pd|=p;f=u.action,Zo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,L.lanes|=f,pd|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Gr(o,e.memoizedState)&&(Lc=!0,d&&(n=Wa,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function bs(e){var t=fs(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Gr(o,t.memoizedState)||(Lc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function xs(e,t,n){var r=L,a=fs(),o=I;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Gr((qo||a).memoizedState,n);if(s&&(a.memoizedState=n,Lc=!0),a=a.queue,Ks(ws.bind(null,r,a,e),[e]),e=a.getSnapshot!==t||s||Jo!==null&&!!(Jo.memoizedState.tag&1),Vs(e?9:8,{destroy:void 0},Cs.bind(null,r,a,n,t),null),e){if(r.flags|=2048,ad===null)throw Error(i(349));o||Ko&127||Ss(r,t,n)}return n}function Ss(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=L.updateQueue,t===null?(t=ps(),L.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Cs(e,t,n,r){t.value=n,t.getSnapshot=r,Ts(t)&&Es(e)}function ws(e,t,n){return n(function(){Ts(t)&&Es(e)})}function Ts(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Gr(e,n)}catch{return!0}}function Es(e){var t=ji(e,2);t!==null&&Vd(t,e,2)}function Ds(e){var t=ds();if(typeof e==`function`){var n=e;if(e=n(),Zo){it(!0);try{n()}finally{it(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:_s,lastRenderedState:e},t}function Os(e,t,n,r){return e.baseState=n,ys(e,qo,typeof r==`function`?r:_s)}function ks(e,t,n,r,a){if(gc(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};A.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,As(t,o)):(o.next=n.next,t.pending=n.next=o)}}function As(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=A.T,o={};o.types=a===null?null:a.types,A.T=o;try{var s=n(i,r),c=A.S;c!==null&&c(o,s),js(e,t,s)}catch(n){Ns(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),A.T=a}}else try{a=n(i,r),js(e,t,a)}catch(n){Ns(e,t,n)}}function js(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Ms(e,t,n)},function(n){return Ns(e,t,n)}):Ms(e,t,n)}function Ms(e,t,n){t.status=`fulfilled`,t.value=n,Ps(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,As(e,n)))}function Ns(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Ps(t),t=t.next;while(t!==r)}e.action=null}function Ps(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Fs(e,t){return t}function Is(e,t){if(I){var n=ad.formState;if(n!==null){a:{var r=L;if(I){if(ca){b:{for(var i=ca,a=ua;i.nodeType!==8;)if(!a||(i=vm(i.nextSibling),i===null)){i=null;break b}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){ca=vm(i.nextSibling),r=i.data===`F!`;break a}}fa(r)}r=!1}r&&(t=n[0])}}return n=ds(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fs,lastRenderedState:t},n.queue=r,n=pc.bind(null,L,r),r.dispatch=n,r=Ds(!1),a=hc.bind(null,L,!1,r.queue),r=ds(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=ks.bind(null,L,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Ls(e){return Rs(fs(),qo,e)}function Rs(e,t,n){if(t=ys(e,t,Fs)[0],e=vs(_s)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=ms(t)}catch(e){throw e===$a?to:e}else r=t;t=fs();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(L.flags|=2048,Vs(9,{destroy:void 0},zs.bind(null,i,n),null)),[r,a,e]}function zs(e,t){e.action=t}function Bs(e){var t=fs(),n=qo;if(n!==null)return Rs(t,n,e);fs(),t=t.memoizedState,n=fs();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Vs(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=L.updateQueue,t===null&&(t=ps(),L.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Hs(){return fs().memoizedState}function Us(e,t,n,r){var i=ds();L.flags|=e,i.memoizedState=Vs(1|t,{destroy:void 0},n,r===void 0?null:r)}function Ws(e,t,n,r){var i=fs();r=r===void 0?null:r;var a=i.memoizedState.inst;qo!==null&&r!==null&&rs(r,qo.memoizedState.deps)?i.memoizedState=Vs(t,a,n,r):(L.flags|=e,i.memoizedState=Vs(1|t,a,n,r))}function Gs(e,t){Us(8390656,8,e,t)}function Ks(e,t){Ws(2048,8,e,t)}function qs(e){L.flags|=4;var t=L.updateQueue;if(t===null)t=ps(),L.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Js(e){var t=fs().memoizedState;return qs({ref:t,nextImpl:e}),function(){if(V&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Ys(e,t){return Ws(4,2,e,t)}function Xs(e,t){return Ws(4,4,e,t)}function Zs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function R(e,t,n){n=n==null?null:n.concat([e]),Ws(4,4,Zs.bind(null,t,e),n)}function Qs(){}function $s(e,t){var n=fs();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&rs(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ec(e,t){var n=fs();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&rs(t,r[1]))return r[0];if(r=e(),Zo){it(!0);try{e()}finally{it(!1)}}return n.memoizedState=[r,t],r}function tc(e,t,n){return n===void 0||Ko&1073741824&&!(U&261930)?e.memoizedState=t:(e.memoizedState=n,e=zd(),L.lanes|=e,pd|=e,n)}function nc(e,t,n,r){return Gr(n,t)?n:Ao.current===null?!(Ko&106)||Ko&1073741824&&!(U&261930)?(Lc=!0,e.memoizedState=n):(e=zd(),L.lanes|=e,pd|=e,t):(e=tc(e,n,r),Gr(e,t)||(Lc=!0),e)}function rc(e,t,n,r,i){var a=j.p;j.p=a!==0&&8>a?a:8;var o=A.T,s={};s.types=o===null?null:o.types,A.T=s,hc(e,!1,t,n);try{var c=i(),l=A.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?mc(e,t,qa(c,r),Rd(e)):mc(e,t,r,Rd(e))}catch(n){mc(e,t,{then:function(){},status:`rejected`,reason:n},Rd())}finally{j.p=a,o!==null&&s.types!==null&&(o.types=s.types),A.T=o}}function ic(){}function ac(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=oc(e).queue;rc(e,a,t,xe,n===null?ic:function(){return sc(e),n(r)})}function oc(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:xe,baseState:xe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_s,lastRenderedState:xe},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_s,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function sc(e){var t=oc(e);t.next===null&&(t=e.alternate.memoizedState),mc(e,t.next.queue,{},Rd())}function cc(){return ka(gh)}function lc(){return fs().memoizedState}function uc(){return fs().memoizedState}function dc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Rd();e=xo(n);var r=So(t,e,n);r!==null&&(Vd(r,t,n),Co(r,t,n)),t={cache:Ia()},e.payload=t;return}t=t.return}}function fc(e,t,n){var r=Rd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},gc(e)?_c(t,n):(n=Ai(e,t,n,r),n!==null&&(Vd(n,e,r),vc(n,t,r)))}function pc(e,t,n){mc(e,t,n,Rd())}function mc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(gc(e))_c(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Gr(s,o))return ki(e,t,i,0),ad===null&&Oi(),!1}catch{}if(n=Ai(e,t,i,r),n!==null)return Vd(n,e,r),vc(n,t,r),!0}return!1}function hc(e,t,n,r){if(r={lane:2,revertLane:Hf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},gc(e)){if(t)throw Error(i(479))}else t=Ai(e,n,r,2),t!==null&&Vd(t,e,2)}function gc(e){var t=e.alternate;return e===L||t!==null&&t===L}function _c(e,t){Xo=Yo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function vc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xt(e,n)}}var yc={readContext:ka,use:hs,useCallback:ns,useContext:ns,useEffect:ns,useImperativeHandle:ns,useLayoutEffect:ns,useInsertionEffect:ns,useMemo:ns,useReducer:ns,useRef:ns,useState:ns,useDebugValue:ns,useDeferredValue:ns,useTransition:ns,useSyncExternalStore:ns,useId:ns,useHostTransitionStatus:ns,useFormState:ns,useActionState:ns,useOptimistic:ns,useMemoCache:ns,useCacheRefresh:ns,useEffectEvent:ns},bc={readContext:ka,use:hs,useCallback:function(e,t){return ds().memoizedState=[e,t===void 0?null:t],e},useContext:ka,useEffect:Gs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Us(4194308,4,Zs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Us(4194308,4,e,t)},useInsertionEffect:function(e,t){Us(4,2,e,t)},useMemo:function(e,t){var n=ds();t=t===void 0?null:t;var r=e();if(Zo){it(!0);try{e()}finally{it(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=ds();if(n!==void 0){var i=n(t);if(Zo){it(!0);try{n(t)}finally{it(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=fc.bind(null,L,e),[r.memoizedState,e]},useRef:function(e){var t=ds();return e={current:e},t.memoizedState=e},useState:function(e){e=Ds(e);var t=e.queue,n=pc.bind(null,L,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Qs,useDeferredValue:function(e,t){return tc(ds(),e,t)},useTransition:function(){var e=Ds(!1);return e=rc.bind(null,L,e.queue,!0,!1),ds().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=L,a=ds();if(I){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),ad===null)throw Error(i(349));U&127||Ss(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Gs(ws.bind(null,r,o,e),[e]),r.flags|=2048,Vs(9,{destroy:void 0},Cs.bind(null,r,o,n,t),null),n},useId:function(){var e=ds(),t=ad.identifierPrefix;if(I){var n=ta,r=ea;n=(r&~(1<<32-at(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Qo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=ts++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:cc,useFormState:Is,useActionState:Is,useOptimistic:function(e){var t=ds();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=hc.bind(null,L,!0,n),n.dispatch=t,[e,t]},useMemoCache:gs,useCacheRefresh:function(){return ds().memoizedState=dc.bind(null,L)},useEffectEvent:function(e){var t=ds(),n={impl:e};return t.memoizedState=n,function(){if(V&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},xc={readContext:ka,use:hs,useCallback:$s,useContext:ka,useEffect:Ks,useImperativeHandle:R,useInsertionEffect:Ys,useLayoutEffect:Xs,useMemo:ec,useReducer:vs,useRef:Hs,useState:function(){return vs(_s)},useDebugValue:Qs,useDeferredValue:function(e,t){return nc(fs(),qo.memoizedState,e,t)},useTransition:function(){var e=vs(_s)[0],t=fs().memoizedState;return[typeof e==`boolean`?e:ms(e),t]},useSyncExternalStore:xs,useId:lc,useHostTransitionStatus:cc,useFormState:Ls,useActionState:Ls,useOptimistic:function(e,t){return Os(fs(),qo,e,t)},useMemoCache:gs,useCacheRefresh:uc,useEffectEvent:Js},Sc={readContext:ka,use:hs,useCallback:$s,useContext:ka,useEffect:Ks,useImperativeHandle:R,useInsertionEffect:Ys,useLayoutEffect:Xs,useMemo:ec,useReducer:bs,useRef:Hs,useState:function(){return bs(_s)},useDebugValue:Qs,useDeferredValue:function(e,t){var n=fs();return qo===null?tc(n,e,t):nc(n,qo.memoizedState,e,t)},useTransition:function(){var e=bs(_s)[0],t=fs().memoizedState;return[typeof e==`boolean`?e:ms(e),t]},useSyncExternalStore:xs,useId:lc,useHostTransitionStatus:cc,useFormState:Bs,useActionState:Bs,useOptimistic:function(e,t){var n=fs();return qo===null?(n.baseState=e,[e,n.queue.dispatch]):Os(n,qo,e,t)},useMemoCache:gs,useCacheRefresh:uc,useEffectEvent:Js};function Cc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:D({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var wc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Rd(),i=xo(r);i.payload=t,n!=null&&(i.callback=n),t=So(e,i,r),t!==null&&(Vd(t,e,r),Co(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Rd(),i=xo(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=So(e,i,r),t!==null&&(Vd(t,e,r),Co(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Rd(),r=xo(n);r.tag=2,t!=null&&(r.callback=t),t=So(e,r,n),t!==null&&(Vd(t,e,n),Co(t,e,n))}};function Tc(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Kr(n,r)||!Kr(i,a):!0}function Ec(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&wc.enqueueReplaceState(t,t.state,null)}function Dc(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=D({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Oc(e){wi(e)}function kc(e){console.error(e)}function Ac(e){wi(e)}function jc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Mc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Nc(e,t,n){return n=xo(n),n.tag=3,n.payload={element:null},n.callback=function(){jc(e,t)},n}function Pc(e){return e=xo(e),e.tag=3,e}function z(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Mc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Mc(t,n,r),typeof i!=`function`&&(Td===null?Td=new Set([this]):Td.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Fc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Ea(t,n,a,!0),n=Fo.current,n!==null){switch(n.tag){case 31:case 13:case 19:return Io===null?$d():n.alternate===null&&fd===0&&(fd=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===no?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Sf(e,r,a)),!1;case 22:return n.flags|=65536,r===no?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Sf(e,r,a)),!1}throw Error(i(435,n.tag))}return Sf(e,r,a),$d(),!1}if(I)return t=Fo.current,t===null?(r!==da&&(t=Error(i(423),{cause:r}),va(Ki(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Ki(r,n),a=Nc(e.stateNode,r,a),wo(e,a),fd!==4&&(fd=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==da&&(e=Error(i(422),{cause:r}),va(Ki(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Ki(o,n),vd===null?vd=[o]:vd.push(o),fd!==4&&(fd=2),t===null)return!0;r=Ki(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Nc(n.stateNode,r,e),wo(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(Td===null||!Td.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Pc(a),z(a,e,n,r),wo(n,a),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Ic=Error(i(461)),Lc=!1;function Rc(e,t,n,r){t.child=e===null?_o(t,null,n,r):go(t,e.child,n,r)}function zc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Oa(t),r=is(e,t,n,o,a,i),s=cs(),e!==null&&!Lc?(ls(e,t,i),fl(e,t,i)):(I&&s&&ia(t),t.flags|=1,Rc(e,t,r,i),t.child)}function Bc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Li(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Vc(e,t,a,r,i)):(e=Bi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!pl(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Kr:n,n(o,r)&&e.ref===t.ref)return fl(e,t,i)}return t.flags|=1,e=Ri(a,r),e.ref=t.ref,e.return=t,t.child=e}function Vc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Kr(a,r)&&e.ref===t.ref){if(Lc=!1,t.pendingProps=r=a,pl(e,i))e.flags&131072&&(Lc=!0);else return t.lanes=e.lanes,fl(e,t,i)}}return Jc(e,t,n,r,i)}function Hc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return B(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Za(t,a===null?null:a.cachePool),a===null?No():Mo(t,a),zo(t);else return r=t.lanes=536870912,B(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Za(t,null),No(),Bo()):(Za(t,a.cachePool),Mo(t,a),Bo(),t.memoizedState=null);return Rc(e,t,i,n),t.child}function Uc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function B(e,t,n,r,i){var a=Xa();return a=a===null?null:{parent:Fa._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Za(t,null),No(),zo(t),e!==null&&Ea(e,t,r,!0),t.childLanes=i,null}function Wc(e,t){return t=rl({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Gc(e,t,n){return go(t,e.child,null,n),e=Wc(t,t.pendingProps),e.flags|=2,Vo(t),t.memoizedState=null,e}function Kc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(I){if(r.mode===`hidden`)return e=Wc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Uc(null,e);if(Ro(t),(e=ca)?(e=mm(e,ua),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:$i===null?null:{id:ea,overflow:ta},retryLane:536870912,hydrationErrors:null},n=Ui(e),n.return=t,t.child=n,sa=t,ca=null)):e=null,e===null)throw fa(t);return t.lanes=536870912,null}return Wc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Ro(t),a){if(t.flags&256)t.flags&=-257,t=Gc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(Lc||Ea(e,t,n,!1),a=(n&e.childLanes)!==0,Lc||a){if(Ao.current===null){if(r=ad,r!==null&&(s=St(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,ji(e,s),Vd(r,e,s),Ic;$d()}t=Gc(e,t,n)}else e=o.treeContext,ca=vm(s.nextSibling),sa=t,I=!0,la=null,ua=!1,e!==null&&oa(t,e),t=Wc(t,r),t.flags|=134221824;return t}return e=Ri(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function qc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Jc(e,t,n,r,i){return Oa(t),n=is(e,t,n,r,void 0,i),r=cs(),e!==null&&!Lc?(ls(e,t,i),fl(e,t,i)):(I&&r&&ia(t),t.flags|=1,Rc(e,t,n,i),t.child)}function Yc(e,t,n,r,i,a){return Oa(t),t.updateQueue=null,n=os(t,r,n,i),as(e),r=cs(),e!==null&&!Lc?(ls(e,t,a),fl(e,t,a)):(I&&r&&ia(t),t.flags|=1,Rc(e,t,n,a),t.child)}function Xc(e,t,n,r,i){if(Oa(t),t.stateNode===null){var a=Pi,o=n.contextType;typeof o==`object`&&o&&(a=ka(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=wc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},yo(t),o=n.contextType,a.context=typeof o==`object`&&o?ka(o):Pi,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Cc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&wc.enqueueReplaceState(a,a.state,null),Do(t,r,a,i),Eo(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Dc(n,s);a.props=c;var l=a.context,u=n.contextType;o=Pi,typeof u==`object`&&u&&(o=ka(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Ec(t,a,r,o),vo=!1;var f=t.memoizedState;a.state=f,Do(t,r,a,i),Eo(),l=t.memoizedState,s||f!==l||vo?(typeof d==`function`&&(Cc(t,n,d,r),l=t.memoizedState),(c=vo||Tc(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,bo(e,t),o=t.memoizedProps,u=Dc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Pi,typeof l==`object`&&l&&(c=ka(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Ec(t,a,r,c),vo=!1,f=t.memoizedState,a.state=f,Do(t,r,a,i),Eo();var p=t.memoizedState;o!==d||f!==p||vo||e!==null&&e.dependencies!==null&&Da(e.dependencies)?(typeof s==`function`&&(Cc(t,n,s,r),p=t.memoizedState),(u=vo||Tc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Da(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,qc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=go(t,e.child,null,i),t.child=go(t,null,n,i)):Rc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=fl(e,t,i),e}function Zc(e,t,n,r){return ga(),t.flags|=256,Rc(e,t,n,r),t.child}var Qc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function $c(e){return{baseLanes:e,cachePool:Qa()}}function el(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=gd),e}function tl(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(Ho.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(I){if(i?Lo(t):Bo(),(e=ca)?(e=mm(e,ua),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:$i===null?null:{id:ea,overflow:ta},retryLane:536870912,hydrationErrors:null},n=Ui(e),n.return=t,t.child=n,sa=t,ca=null)):e=null,e===null)throw fa(t);return t.lanes=gm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(Bo(),i=t.mode,a=rl({mode:`hidden`,children:a},i),r=Vi(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=$c(n),r.childLanes=el(e,o,n),t.memoizedState=Qc,Uc(null,r)):(Lo(t),nl(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return al(e,t,a,o,r,c,s,n)}return i?(Bo(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Ri(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=Vi(i,a,n,null),i.flags|=2):i=Ri(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Uc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=$c(n):(a=i.cachePool,a===null?a=Qa():(s=Fa._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=el(e,o,n),t.memoizedState=Qc,Uc(e.child,r)):(Lo(t),n=e.child,e=n.sibling,n=Ri(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function nl(e,t){return t=rl({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function rl(e,t){return e=Ii(22,e,null,t),e.lanes=0,e}function il(e,t,n){return go(t,e.child,null,n),e=nl(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function al(e,t,n,r,a,o,s,c){if(n)return t.flags&256?(Lo(t),t.flags&=-257,il(e,t,c)):t.memoizedState===null?(Bo(),o=a.fallback,s=t.mode,a=rl({mode:`visible`,children:a.children},s),o=Vi(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,go(t,e.child,null,c),a=t.child,a.memoizedState=$c(c),a.childLanes=el(e,r,c),t.memoizedState=Qc,Uc(null,a)):(Bo(),t.child=e.child,t.flags|=128,null);if(Lo(t),gm(o)){if(r=o.nextSibling&&o.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(a=Error(i(419)),a.stack=``,a.digest=r,va({value:a,source:null,stack:null})),il(e,t,c)}if(Lc||Ea(e,t,c,!1),r=(c&e.childLanes)!==0,Lc||r){if(Ao.current!==null)return il(e,t,c);if(r=ad,r!==null&&(a=St(r,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,ji(e,a),Vd(r,e,a),Ic;return hm(o)||$d(),il(e,t,c)}return hm(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,ca=vm(o.nextSibling),sa=t,I=!0,la=null,ua=!1,e!==null&&oa(t,e),t=nl(t,a.children),t.flags|=134221824,t)}function ol(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),wa(e.return,t,n)}function sl(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Go(n)===null&&(t=e),e=e.sibling}return t}function cl(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function ll(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function ul(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Ho.current;if(t.flags&128)return Uo(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Uo(t,o),i===`backwards`&&e!==null?(ll(e),Rc(e,t,r,n),ll(e)):Rc(e,t,r,n),r=I?Xi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ol(e,n,t);else if(e.tag===19)ol(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=sl(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,ll(t)),cl(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Go(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}cl(t,!0,n,null,a,r);break;case`together`:cl(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=sl(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),cl(t,!1,i,n,a,r)}return t.child}function dl(e,t,n){var r=t.pendingProps;return Sa(t,t.type,r.value),Rc(e,t,r.children,n),t.child}function fl(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),pd|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(Ea(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Ri(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Ri(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function pl(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&Da(e)))}function ml(e,t,n){switch(t.tag){case 3:je(t,t.stateNode.containerInfo),Sa(t,Fa,e.memoizedState.cache),ga();break;case 27:case 5:Ne(t);break;case 4:je(t,t.stateNode.containerInfo);break;case 10:Sa(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ro(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return Lo(t),t.flags|=128,null;r=Ea(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?tl(e,t,n):(Lo(t),e=fl(e,t,n),e===null?null:e.sibling)}Lo(t);break;case 19:if(t.flags&128)return ul(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(Ea(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return ul(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Uo(t,Ho.current),r)break;return null;case 22:return t.lanes=0,Hc(e,t,n,t.pendingProps);case 24:Sa(t,Fa,e.memoizedState.cache)}return fl(e,t,n)}function hl(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Lc=!0;else{if(!pl(e,n)&&!(t.flags&128))return Lc=!1,ml(e,t,n);Lc=!!(e.flags&131072)}}else Lc=!1,I&&t.flags&1048576&&ra(t,Xi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=ao(t.elementType),t.type=e,typeof e==`function`)Li(e)?(r=Dc(e,r),t.tag=1,t=Xc(null,t,e,r,n)):(t.tag=0,t=Jc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===se){t.tag=11,t=zc(null,t,e,r,n);break a}if(a===ue){t.tag=14,t=Bc(null,t,e,r,n);break a}if(a===oe){t.tag=10,t.type=e,t=dl(null,t,n);break a}}throw t=ye(e)||e,Error(i(306,t,``))}}return t;case 0:return Jc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Dc(r,t.pendingProps),Xc(e,t,r,a,n);case 3:a:{if(je(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,bo(e,t),Do(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Sa(t,Fa,r),r!==o.cache&&Ta(t,[Fa],n,!0),Eo(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=Zc(e,t,r,n);break a}if(r!==a){a=Ki(Error(i(424)),t),va(a),t=Zc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(ca=vm(e.firstChild),sa=t,I=!0,la=null,ua=!0,n=_o(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(ga(),r===a){t=fl(e,t,n);break a}Rc(e,t,r,n)}t=t.child}return t;case 26:return qc(e,t),e===null?(n=Hm(t.type,null,t.pendingProps,null))?t.memoizedState=n:I||(t.stateNode=xp(t.type,t.pendingProps,ke.current,t)):t.memoizedState=Hm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Ne(t),e===null&&I&&(r=t.stateNode=wm(t.type,t.pendingProps,ke.current),sa=t,ua=!0,a=ca,jp(t.type)?(ym=a,ca=vm(r.firstChild)):ca=a),Rc(e,t,t.pendingProps.children,n),qc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&I&&((a=r=ca)&&(r=fm(r,t.type,t.pendingProps,ua),r===null?a=!1:(t.stateNode=r,sa=t,ca=vm(r.firstChild),ua=!1,a=!0)),a||fa(t)),Ne(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Sp(a,o)?r=null:s!==null&&Sp(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=is(e,t,ss,null,null,n),gh._currentValue=a),qc(e,t),Rc(e,t,r,n),t.child;case 6:return e===null&&I&&((e=n=ca)&&(n=pm(n,t.pendingProps,ua),n===null?e=!1:(t.stateNode=n,sa=t,ca=null,e=!0)),e||fa(t)),null;case 13:return tl(e,t,n);case 4:return je(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=go(t,null,r,n):Rc(e,t,r,n),t.child;case 11:return zc(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,qc(e,t),Rc(e,t,r,n),t.child;case 8:return Rc(e,t,t.pendingProps.children,n),t.child;case 12:return Rc(e,t,t.pendingProps.children,n),t.child;case 10:return dl(e,t,n);case 9:return a=t.type._context,r=t.pendingProps.children,Oa(t),a=ka(a),r=r(a),t.flags|=1,Rc(e,t,r,n),t.child;case 14:return Bc(e,t,t.type,t.pendingProps,n);case 15:return Vc(e,t,t.type,t.pendingProps,n);case 19:return ul(e,t,n);case 31:return Kc(e,t,n);case 22:return Hc(e,t,n,t.pendingProps);case 24:return Oa(t),r=ka(Fa),e===null?(a=Xa(),a===null&&(a=ad,o=Ia(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},yo(t),Sa(t,Fa,a)):((e.lanes&n)!==0&&(bo(e,t),Do(t,null,null,n),Eo()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Sa(t,Fa,r),r!==a.cache&&Ta(t,[Fa],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Sa(t,Fa,r))),Rc(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:I&&ia(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:qc(e,t),Rc(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function gl(e){e.flags|=4}function _l(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?rh(t,r):rh(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Xd())e.flags|=8192;else throw oo=no,eo}}else e.flags&=-16777217}function vl(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!ih(t)){if(Xd())e.flags|=8192;else throw oo=no,eo}}function yl(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:gt(),e.lanes|=t,_d|=t)}function bl(e,t){if(!I)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function xl(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Sl(e,t,n){var r=t.pendingProps;switch(aa(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return xl(t),null;case 1:return xl(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Ca(Fa),Me(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ha(t)?gl(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,_a())),xl(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(gl(t),o===null?(xl(t),_l(t,a,null,r,n)):(xl(t),vl(t,o))):o?o===e.memoizedState?(xl(t),t.flags&=-16777217):(gl(t),xl(t),vl(t,o)):(e=e.memoizedProps,e!==r&&gl(t),xl(t),_l(t,a,e,r,n)),null;case 27:if(Pe(t),n=ke.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&gl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return xl(t),t.subtreeFlags&=-33554433,null}e=De.current,ha(t)?pa(t,e):(e=wm(a,r,n),t.stateNode=e,gl(t))}return xl(t),t.subtreeFlags&=-33554433,null;case 5:if(Pe(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&gl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return xl(t),t.subtreeFlags&=-33554433,null}if(o=De.current,ha(t))pa(t,o);else{var s=vp(ke.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[Ot]=t,o[kt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(dp(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&gl(t)}}return xl(t),t.subtreeFlags&=-33554433,_l(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&gl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ke.current,ha(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=sa,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Ot]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||cp(e.nodeValue,n)),e||fa(t,!0)}else e=vp(e).createTextNode(r),e[Ot]=t,t.stateNode=e}return xl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ha(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[Ot]=t}else ga(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;xl(t),e=!1}else n=_a(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Vo(t),t):(Vo(t),null);if(t.flags&128)throw Error(i(558))}return xl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ha(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[Ot]=t}else ga(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;xl(t),a=!1}else a=_a(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Vo(t),t):(Vo(t),null)}return Vo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),yl(t,t.updateQueue),xl(t),null);case 4:return Me(),e===null&&Qf(t.stateNode.containerInfo),t.flags|=67108864,xl(t),null;case 10:return Ca(t.type),xl(t),null;case 19:if(Wo(t),r=t.memoizedState,r===null)return xl(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)bl(r,!1);else{if(fd!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Go(e),o!==null){for(t.flags|=128,bl(r,!1),e=o.updateQueue,t.updateQueue=e,yl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)zi(n,e),n=n.sibling;return Uo(t,Ho.current&1|2),I&&na(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&qe()>Cd&&(t.flags|=128,a=!0,bl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=Go(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,yl(t,e),bl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!I)return xl(t),null}else 2*qe()-r.renderingStartTime>Cd&&n!==536870912&&(t.flags|=128,a=!0,bl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=qe(),e.sibling=null,o=Ho.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||I?Uo(t,o):(n=o,Ee(Fo,t),Ee(Ho,n),Io===null&&(Io=t)),I&&na(t,r.treeForkCount),e}return xl(t),null;case 22:case 23:return Vo(t),Po(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(xl(t),t.subtreeFlags&6&&(t.flags|=8192)):xl(t),n=t.updateQueue,n!==null&&yl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&Te(Ya),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ca(Fa),xl(t),null;case 25:return null;case 30:return t.flags|=33554432,xl(t),null}throw Error(i(156,t.tag))}function Cl(e,t){switch(aa(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ca(Fa),Me(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Pe(t),null;case 31:if(t.memoizedState!==null){if(Vo(t),t.alternate===null)throw Error(i(340));ga()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Vo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));ga()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Wo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Me(),null;case 10:return Ca(t.type),null;case 22:case 23:return Vo(t),Po(),e!==null&&Te(Ya),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ca(Fa),null;case 25:return null;default:return null}}function wl(e,t){switch(aa(t),t.tag){case 3:Ca(Fa),Me();break;case 26:case 27:case 5:Pe(t);break;case 4:Me();break;case 31:t.memoizedState!==null&&Vo(t);break;case 13:Vo(t);break;case 19:Wo(t);break;case 10:Ca(t.type);break;case 22:case 23:Vo(t),Po(),e!==null&&Te(Ya);break;case 24:Ca(Fa)}}function Tl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){xf(t,t.return,e)}}function El(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){xf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){xf(t,t.return,e)}}function Dl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{ko(t,n)}catch(t){xf(e,e.return,t)}}}function Ol(e,t,n){n.props=Dc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){xf(e,t,n)}}function kl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=xi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Up(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Wp(e);p(e.child,!1,sm,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){xf(e,t,n)}}function Al(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){xf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){xf(e,t,n)}else n.current=null}}function jl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)lm(e.stateNode,t[n])}function Ml(e){for(var t=e.return;t!==null&&(Fl(t)&&lm(e.stateNode,t.stateNode),!Pl(t));)t=t.return}function Nl(e){for(var t=e.return;t!==null&&(Fl(t)&&um(e.stateNode,t.stateNode),!Pl(t));)t=t.return}function Pl(e){return e.tag===5||e.tag===3||e.tag===27}function Fl(e){return e&&e.tag===7&&e.stateNode!==null}function Il(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){xf(e,e.return,t)}}function Ll(e,t,n){try{var r=e.stateNode;pp(r,e.type,n,t),r[kt]=t}catch(t){xf(e,e.return,t)}}function Rl(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&jp(e.type)||e.tag===4}function zl(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Rl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&jp(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Bl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Sn)),jl(e,r),P=!0;else if(i!==4&&(i===27&&(jl(e,r),r=null,jp(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(Bl(e,t,n,r),e=e.sibling;e!==null;)Bl(e,t,n,r),e=e.sibling}function Vl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),jl(e,r),P=!0;else if(i!==4&&(i===27&&(jl(e,r),r=null,jp(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(Vl(e,t,n,r),e=e.sibling;e!==null;)Vl(e,t,n,r),e=e.sibling}function Hl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);dp(t,r,n),t[Ot]=e,t[kt]=n}catch(t){xf(e,e.return,t)}}var Ul=!1,Wl=null;function Gl(e){(e.tag===30||e.subtreeFlags&33554432)&&(Ul=!0)}var Kl=null;function ql(){var e=Kl;return Kl=null,e}var Jl=0;function Yl(e,t,n,r,i){return Jl=0,Xl(e.child,t,n,r,i)}function Xl(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=Lp(o);r.push(s),s.view&&(a=!0)}else a||Lp(o).view&&(a=!0);Ul=!0,Pp(o,Jl===0?t:t+`_`+Jl,n),Jl++}else e.tag===22&&e.memoizedState!==null||e.tag===30&&i||Xl(e.child,t,n,r,i)&&(a=!0);e=e.sibling}return a}function Zl(e,t){for(;e!==null;)e.tag===5?Fp(e.stateNode,e.memoizedProps):e.tag===22&&e.memoizedState!==null||e.tag===30&&t||Zl(e.child,t),e=e.sibling}function Ql(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Ql(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(i(544));var n=t.name;t=Ci(t.default,t.share),t!==`none`&&(Yl(e,n,t,null,!1)||Zl(e.child,!1))}e=e.sibling}}function $l(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=xi(r,n),a=Ci(r.default,n.paired?r.share:r.enter);a===`none`?Ql(e):Yl(e,i,a,null,!1)?(Ql(e),n.paired||t||Bd(e,r.onEnter)):Zl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)$l(e,t),e=e.sibling;else Ql(e)}function eu(e){if(Wl!==null&&Wl.size!==0){var t=Wl;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=Ci(n.default,n.share);if(a!==`none`&&(Yl(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,Bd(e,n.onShare)):Zl(e.child,!1)),t.delete(r),t.size===0)break}}}eu(e)}e=e.sibling}}}function tu(e){if(e.tag===30){var t=e.memoizedProps,n=xi(t,e.stateNode),r=Wl===null?void 0:Wl.get(n),i=Ci(t.default,r===void 0?t.exit:t.share);i!==`none`&&(Yl(e,n,i,null,!1)?r===void 0?Bd(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Wl.delete(n),Bd(e,t.onShare)):Zl(e.child,!1)),Wl!==null&&eu(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)tu(e),e=e.sibling;else Wl!==null&&eu(e)}function nu(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=xi(t,e.stateNode);t=Ci(t.default,t.update),e.flags&=-5,t!==`none`&&Yl(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&nu(e);e=e.sibling}}function ru(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,Zl(e.child,!1))}ru(e)}e=e.sibling}}function iu(e){if(e.tag===30)e.stateNode.paired=null,Zl(e.child,!1),ru(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)iu(e),e=e.sibling;else ru(e)}function au(e){for(e=e.child;e!==null;)e.tag===30?Zl(e.child,!1):e.subtreeFlags&33554432&&au(e),e=e.sibling}function ou(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&Jl<a.length){var l=a[Jl],u=Lp(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&Pp(c,Jl===0?n:n+`_`+Jl,i),s&&e.flags&4||(Kl===null&&(Kl=[]),Kl.push(c,Jl===0?r:r+`_`+Jl,t.memoizedProps)),Jl++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:ou(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function su(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=xi(n,r),a=Ci(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(Rp)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;Jl=0,i=ou(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||Bd(e,n.onUpdate))}else e.subtreeFlags&33554432&&su(e,t);e=e.sibling}}var cu=!1,lu=!1,uu=!1,du=!1,fu=typeof WeakSet==`function`?WeakSet:Set,pu=null,mu=!1,hu=!1,gu=!1,_u=!1;function vu(e,t,n){if(e=e.containerInfo,gp=Th,e=Zr(e),Qr(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(_p={focusedElem:e,selectionRange:r},Th=!1,n=(n&335544064)===n,pu=t,t=n?9270:1024;pu!==null;){if(e=pu,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&tu(r[a]);if(e.alternate===null&&e.flags&2)n&&Gl(e),yu(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&tu(r),yu(n);continue}if(r!==null&&r.memoizedState!==null){n&&Gl(e),yu(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,pu=r):(n&&nu(e),yu(n))}}Wl=null}function yu(e){for(;pu!==null;){var t=pu,n=e,r=t.alternate,a=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(a&1024&&r!==null){n=void 0,a=r.memoizedProps,r=r.memoizedState;var o=t.stateNode;try{var s=Dc(t.type,a);n=o.getSnapshotBeforeUpdate(s,r),o.__reactInternalSnapshotBeforeUpdate=n}catch(e){xf(t,t.return,e)}}break;case 3:if(a&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)dm(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:dm(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=xi(r.memoizedProps,r.stateNode),a=t.memoizedProps,a=Ci(a.default,a.update),a!==`none`&&Yl(r,n,a,r.memoizedState=[],!0));break;default:if(a&1024)throw Error(i(163))}if(r=t.sibling,r!==null){r.return=t.return,pu=r;break}pu=t.return}}function bu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Bu(e,n),r&4&&Tl(5,n);break;case 1:if(Bu(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){xf(n,n.return,e)}else{var i=Dc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){xf(n,n.return,e)}}}r&64&&Dl(n),r&512&&kl(n,n.return);break;case 3:if(Bu(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{ko(e,t)}catch(e){xf(n,n.return,e)}}break;case 27:t===null&&r&4&&Hl(n);case 26:case 5:Bu(e,n),t===null&&r&4&&Il(n),r&512&&kl(n,n.return);break;case 12:Bu(e,n);break;case 31:Bu(e,n),r&4&&ku(e,n);break;case 13:Bu(e,n),r&4&&Au(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Tf.bind(null,n),_m(e,n))));break;case 22:if(r=n.memoizedState!==null||cu,!r){var a=t!==null&&t.memoizedState!==null||lu;t=cu,i=lu,cu=r,(lu=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),Hu(e,n,r)):Bu(e,n),cu=t,lu=i}break;case 30:Bu(e,n),r&512&&kl(n,n.return);break;case 7:r&512&&kl(n,n.return);default:Bu(e,n)}}function xu(e,t){for(e=e.child;e!==null;)Su(e,t),e=e.sibling}function Su(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){xf(e,e.return,t)}Cu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,P=!0}catch(t){xf(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?Np(s,!0):Np(e.stateNode,!1)}catch(t){xf(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&xu(e,t);break;default:xu(e,t)}}function Cu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:Su(n,r);break a;case 22:n.memoizedState===null&&Cu(n,r);break a;default:Cu(n,r)}}e=e.sibling}}function wu(e){var t=e.alternate;t!==null&&(e.alternate=null,wu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Lt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Tu=null,Eu=!1;function Du(e,t,n){for(n=n.child;n!==null;)Ou(e,t,n),n=n.sibling}function Ou(e,t,n){if(rt&&typeof rt.onCommitFiberUnmount==`function`)try{rt.onCommitFiberUnmount(nt,n)}catch{}switch(n.tag){case 26:lu||Al(n,t),Du(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!lu&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:lu||Al(n,t),Nl(n);var r=Tu,i=Eu;jp(n.type)&&(Tu=n.stateNode,Eu=!1),Du(e,t,n),Tm(n.stateNode,n.type,n.memoizedProps),Tu=r,Eu=i;break;case 5:lu||Al(n,t),Nl(n);case 6:if(n.tag===6&&Nl(n),r=Tu,i=Eu,Tu=null,Du(e,t,n),Tu=r,Eu=i,Tu!==null){if(Eu)try{(Tu.nodeType===9?Tu.body:Tu.nodeName===`HTML`?Tu.ownerDocument.body:Tu).removeChild(n.stateNode),P=!0}catch(e){xf(n,t,e)}else try{Tu.removeChild(n.stateNode),P=!0}catch(e){xf(n,t,e)}}break;case 18:Tu!==null&&(Eu?(e=Tu,Mp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Zh(e)):Mp(Tu,n.stateNode));break;case 4:r=Tu,i=Eu,Tu=n.stateNode.containerInfo,Eu=!0,Du(e,t,n),Tu=r,Eu=i;break;case 0:case 11:case 14:case 15:El(2,n,t),lu||El(4,n,t),Du(e,t,n);break;case 1:lu||(Al(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Ol(n,t,r)),Du(e,t,n);break;case 21:Du(e,t,n);break;case 22:lu=(r=lu)||n.memoizedState!==null,Du(e,t,n),lu=r;break;case 30:Al(n,t),Du(e,t,n);break;case 7:lu||Al(n,t),Du(e,t,n);break;default:Du(e,t,n)}}function ku(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Zh(e)}catch(e){xf(t,t.return,e)}}}function Au(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Zh(e)}catch(e){xf(t,t.return,e)}}function ju(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new fu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new fu),t;default:throw Error(i(435,e.tag))}}function Mu(e,t){var n=ju(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Ef.bind(null,e,t);t.then(r,r)}})}function Nu(e,t,n){var r=t.deletions;if(r!==null)for(var a=0;a<r.length;a++){var o=r[a],s=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(jp(l.type)){Tu=l.stateNode,Eu=!1;break a}break;case 5:Tu=l.stateNode,Eu=!1;break a;case 3:case 4:Tu=l.stateNode.containerInfo,Eu=!0;break a}l=l.return}if(Tu===null)throw Error(i(160));Ou(s,c,o),Tu=null,Eu=!1,s=o.alternate,s!==null&&(s.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Fu(t,e,n),t=t.sibling}var Pu=null;function Fu(e,t,n){var r=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(a&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var o=0;o<r.length;o++){var s=r[o];s.ref.impl=s.nextImpl}Nu(t,e,n),Iu(e),a&4&&(El(3,e,e.return),Tl(3,e),El(5,e,e.return));break;case 1:Nu(t,e,n),Iu(e),a&512&&(lu||r===null||Al(r,r.return)),a&64&&cu&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(o=Pu,Nu(t,e,n),Iu(e),a&512&&(lu||r===null||Al(r,r.return)),a&4){if(a=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if(cu)e.stateNode=xp(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,a=o.ownerDocument||o;b:switch(t){case`title`:r=a.getElementsByTagName(`title`)[0],(!r||r[Ft]||r[Ot]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=a.createElement(t),a.head.insertBefore(r,a.querySelector(`head > title`))),dp(r,t,n),r[Ot]=e,Ht(r),t=r;break a;case`link`:if(o=eh(`link`,`href`,a).get(t+(n.href||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){o.splice(s,1);break b}}r=a.createElement(t),dp(r,t,n),a.head.appendChild(r);break;case`meta`:if(o=eh(`meta`,`content`,a).get(t+(n.content||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){o.splice(s,1);break b}}r=a.createElement(t),dp(r,t,n),a.head.appendChild(r);break;default:throw Error(i(468,t))}r[Ot]=e,Ht(r),t=r}e.stateNode=t}}else cu||th(o,e.type,e.stateNode)}else e.stateNode=Ym(o,n,e.memoizedProps)}else a===n?n===null&&e.stateNode!==null&&Ll(e,e.memoizedProps,r.memoizedProps):(a===null?(t=r.stateNode,t===null||lu||t.parentNode.removeChild(t)):a.count--,n===null?cu||th(o,e.type,e.stateNode):Ym(o,n,e.memoizedProps))}break;case 27:Nu(t,e,n),Iu(e),a&512&&(lu||r===null||Al(r,r.return)),r!==null&&a&4&&Ll(e,e.memoizedProps,r.memoizedProps);break;case 5:if(o=uu,uu=!1,Nu(t,e,n),uu=o,Iu(e),a&512&&(lu||r===null||Al(r,r.return)),e.flags&32){t=e.stateNode;try{mn(t,``),P=!0}catch(t){xf(e,e.return,t)}}a&4&&e.stateNode!=null&&(t=e.memoizedProps,Ll(e,t,r===null?t:r.memoizedProps)),a&1024&&(du=!0);break;case 6:if(Nu(t,e,n),Iu(e),a&4){if(e.stateNode===null)throw Error(i(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,P=!0}catch(t){xf(e,e.return,t)}}break;case 3:if(P=!1,$m=null,o=Pu,Pu=km(t.containerInfo),Nu(t,e,n),Pu=o,Iu(e),a&4&&r!==null&&r.memoizedState.isDehydrated)try{Zh(t.containerInfo)}catch(t){xf(e,e.return,t)}du&&(du=!1,Lu(e)),P=!1;break;case 4:a=uu,uu=cu,r=Zt(),o=Pu,Pu=km(e.stateNode.containerInfo),Nu(t,e,n),Iu(e),Pu=o,P&&hu&&(gu=!0),P=r,uu=a;break;case 12:Nu(t,e,n),Iu(e);break;case 31:Nu(t,e,n),Iu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Mu(e,t)));break;case 13:Nu(t,e,n),Iu(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(xd=qe()),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Mu(e,t)));break;case 22:o=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=cu,l=lu,u=uu;cu=c||o,uu=u||o,lu=l||s,Nu(t,e,n),lu=l,uu=u,cu=c,Iu(e),a&8192&&(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,!o||r===null||s||cu||lu||(t=s||lu,n=cu,r=lu,cu=o||cu,lu=t,Vu(e,2),cu=n,lu=r),!o&&uu||xu(e,o)),a&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,Mu(e,n))));break;case 19:Nu(t,e,n),Iu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Mu(e,t)));break;case 30:a&512&&(lu||r===null||Al(r,r.return)),a=Zt(),o=hu,s=(n&335544064)===n,c=e.memoizedProps,hu=s&&Ci(c.default,c.update)!==`none`,Nu(t,e,n),Iu(e),s&&r!==null&&P&&(e.flags|=4),hu=o,P=a;break;case 21:break;case 7:a&512&&(lu||r===null||Al(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:Nu(t,e,n),Iu(e)}}function Iu(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Rl(r)){n=r;break}r=r.return}r=null;for(var a=e.return;a!==null;){if(Fl(a)){var o=a.stateNode;r===null?r=[o]:r.push(o)}if(Pl(a))break;a=a.return}var s=r;if(n==null)throw Error(i(160));switch(n.tag){case 27:var c=n.stateNode;Vl(e,zl(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(mn(l,``),n.flags&=-33),Vl(e,zl(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;Bl(e,zl(e),u,s);break;default:throw Error(i(161))}}catch(t){xf(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Lu(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Lu(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,Th=!0,t.reset(),Th=!1),e=e.sibling}}function Ru(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)zu(t,e),t=t.sibling;else su(t,!1)}function zu(e,t){var n=e.alternate;if(n===null)$l(e,!1);else switch(e.tag){case 3:if(_u=mu=!1,ql(),Ru(t,e),!mu&&!gu){if(e=Kl,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Fp(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),_u=!0}Kl=null;break;case 5:Ru(t,e);break;case 4:r=mu,mu=!1,Ru(t,e),mu&&(gu=!0),mu=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?Ru(t,e):$l(e,!1));break;case 30:r=mu,i=ql(),mu=!1,Ru(t,e),mu&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=xi(a,o),o=xi(n.memoizedProps,o);var s=Ci(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,Jl=0,t=ou(e,n,t,o,s,a,!0),Jl!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(Bd(e,e.memoizedProps.onUpdate),Kl=i):i!==null&&(i.push.apply(i,Kl),Kl=i),mu=e.flags&32?!0:r;break;default:Ru(t,e)}}function Bu(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)bu(e,t.alternate,t),t=t.sibling}function Vu(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:El(4,n,n.return),Vu(n,r);break;case 1:Al(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&Ol(n,n.return,i),Vu(n,r);break;case 27:r&2&&Tm(n.stateNode,n.type,n.memoizedProps);case 5:Al(n,n.return),n.tag!==5&&n.tag!==27||Nl(n),Vu(n,r);break;case 6:Nl(n);break;case 26:Al(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||lu||i.parentNode.removeChild(i),Vu(n,r);break;case 22:n.memoizedState===null&&Vu(n,r);break;case 30:Al(n,n.return),Vu(n,r);break;case 7:Al(n,n.return);default:Vu(n,r)}e=e.sibling}}function Hu(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:Hu(i,a,n),Tl(4,a);break;case 1:if(Hu(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){xf(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)Oo(l[i],c)}catch(e){xf(r,r.return,e)}}s&&o&64&&Dl(a),kl(a,a.return);break;case 27:n&2&&Hl(a);case 5:a.tag!==5&&a.tag!==27||Ml(a),Hu(i,a,n),s&&r===null&&o&4&&Il(a),kl(a,a.return);break;case 6:Ml(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||cu||th(km(c.ownerDocument),a.type,c),Hu(i,a,n),s&&r===null&&o&4&&Il(a),kl(a,a.return);break;case 12:Hu(i,a,n);break;case 31:Hu(i,a,n),s&&o&4&&ku(i,a);break;case 13:Hu(i,a,n),s&&o&4&&Au(i,a);break;case 22:a.memoizedState===null&&Hu(i,a,n),kl(a,a.return);break;case 30:Hu(i,a,n),kl(a,a.return);break;case 7:kl(a,a.return);default:Hu(i,a,n)}t=t.sibling}}function Uu(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&La(n))}function Wu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&La(e))}function Gu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Ku(e,t,n,r),t=t.sibling;else i&&au(t)}function Ku(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&iu(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Gu(e,t,n,r),a&2048&&Tl(9,t);break;case 1:Gu(e,t,n,r);break;case 3:Gu(e,t,n,r),i&&_u&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&La(a)));break;case 12:if(a&2048){Gu(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){xf(t,t.return,e)}}else Gu(e,t,n,r);break;case 31:Gu(e,t,n,r);break;case 13:Gu(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&iu(t),o._visibility&2?Gu(e,t,n,r):(o._visibility|=2,qu(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&iu(s),o._visibility&2?Gu(e,t,n,r):Ju(e,t)),a&2048&&Uu(s,t);break;case 24:Gu(e,t,n,r),a&2048&&Wu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Zl(a.child,!0),Zl(t.child,!0))),Gu(e,t,n,r);break;default:Gu(e,t,n,r)}}function qu(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:qu(a,o,s,c,i),Tl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,qu(a,o,s,c,i)):u._visibility&2?qu(a,o,s,c,i):Ju(a,o),i&&l&2048&&Uu(o.alternate,o);break;case 24:qu(a,o,s,c,i),i&&l&2048&&Wu(o.alternate,o);break;default:qu(a,o,s,c,i)}t=t.sibling}}function Ju(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Ju(n,r),i&2048&&Uu(r.alternate,r);break;case 24:Ju(n,r),i&2048&&Wu(r.alternate,r);break;default:Ju(n,r)}t=t.sibling}}var Yu=8192;function Xu(e,t,n){if(e.subtreeFlags&Yu)for(e=e.child;e!==null;)Zu(e,t,n),e=e.sibling}function Zu(e,t,n){switch(e.tag){case 26:Xu(e,t,n),e.flags&Yu&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&oh(n,e)):sh(n,Pu,e.memoizedState,e.memoizedProps));break;case 5:Xu(e,t,n),e.flags&Yu&&(e=e.stateNode,(t&335544128)===t&&oh(n,e));break;case 3:case 4:var r=Pu;Pu=km(e.stateNode.containerInfo),Xu(e,t,n),Pu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Yu,Yu=16777216,Xu(e,t,n),Yu=r):Xu(e,t,n));break;case 30:if((e.flags&Yu)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,Wl===null&&(Wl=new Map),Wl.set(r,i)}Xu(e,t,n);break;default:Xu(e,t,n)}}function Qu(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function $u(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];pu=r,nd(r,e)}Qu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)ed(e),e=e.sibling}function ed(e){switch(e.tag){case 0:case 11:case 15:$u(e),e.flags&2048&&El(9,e,e.return);break;case 3:$u(e);break;case 12:$u(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,td(e)):$u(e);break;default:$u(e)}}function td(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];pu=r,nd(r,e)}Qu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:El(8,t,t.return),td(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,td(t));break;default:td(t)}e=e.sibling}}function nd(e,t){for(;pu!==null;){var n=pu;switch(n.tag){case 0:case 11:case 15:El(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:La(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,pu=r;else a:for(n=e;pu!==null;){r=pu;var i=r.sibling,a=r.return;if(wu(r),r===n){pu=null;break a}if(i!==null){i.return=a,pu=i;break a}pu=a}}}var rd={getCacheForType:function(e){var t=ka(Fa),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return ka(Fa).controller.signal}},id=typeof WeakMap==`function`?WeakMap:Map,V=0,ad=null,H=null,U=0,od=0,sd=null,cd=!1,ld=!1,ud=!1,dd=0,fd=0,pd=0,md=0,hd=0,gd=0,_d=0,vd=null,yd=null,bd=!1,xd=0,Sd=0,Cd=1/0,wd=null,Td=null,Ed=0,Dd=null,Od=null,kd=0,Ad=0,jd=null,Md=null,Nd=null,Pd=null,Fd=null,Id=0,Ld=null;function Rd(){return V&2&&U!==0?U&-U:A.T===null?Tt():Hf()}function zd(){if(gd===0){if(!(U&536870912)||I){var e=ut;ut<<=1,!(ut&3932160)&&(ut=262144),gd=e}else gd=536870912}return e=Fo.current,e!==null&&(e.flags|=32),gd}function Bd(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Up(xi(e.memoizedProps,n))),Pd===null&&(Pd=[]),Pd.push(t.bind(null,r))}}function Vd(e,t,n){(e===ad&&(od===2||od===9)||e.cancelPendingCommit!==null)&&(Jd(e,0),Gd(e,U,gd,!1)),vt(e,n),V&2&&e===ad||(e===ad&&(!(V&2)&&(md|=n),fd===4&&Gd(e,U,gd,!1)),Pf(e))}function Hd(e,t,n){if(V&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||pt(e,t),a=r?nf(e,t):ef(e,t,!0),o=r;do{if(a===0){ld&&!r&&Gd(e,t,0,!1);break}if(n=e.current.alternate,o&&!Wd(n))a=ef(e,t,!1),o=!1;else{if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=vd;var l=c.current.memoizedState.isDehydrated;if(l&&(Jd(c,s).flags|=256),s=ef(c,s,!1),s!==2&&s!==6){if(ud&&!l){c.errorRecoveryDisabledLanes|=o,md|=o,a=4;break a}o=yd,yd=a,o!==null&&(yd===null?yd=o:yd.push.apply(yd,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Jd(e,0),Gd(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t&&(t&62914560)!==t)break;case 6:Gd(r,t,gd,!cd);break a;case 2:yd=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=xd+300-qe(),10<a)){if(Gd(r,t,gd,!cd),ft(r,0,!0)!==0)break a;kd=t,r.timeoutHandle=Tp(Ud.bind(null,r,n,yd,wd,bd,t,gd,md,_d,cd,o,`Throttled`,-0,0),a);break a}Ud(r,n,yd,wd,bd,t,gd,md,_d,cd,o,null,-0,0)}break}}while(1);Pf(e)}function Ud(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Sn},Wl=null,Zu(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=dh.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?xd-qe():(a&4194048)===a?Sd-qe():0,m=lh(d,m),m!==null)?(kd=a,e.cancelPendingCommit=m(uf.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),Gd(e,a,o,!l)):uf(e,t,a,n,r,i,o,s,c,l,u,d)}function Wd(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Gr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Gd(e,t,n,r){t=mt(e,t),t&=~hd,t&=~md,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-at(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&bt(e,n,t)}function Kd(){return V&6?!0:(Ff(0,!1),!1)}function qd(){if(H!==null){if(od===0)var e=H.return;else e=H,xa=ba=null,us(e),lo=null,uo=0,e=H;for(;e!==null;)wl(e.alternate,e),e=e.return;H=null}}function Jd(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,Ep(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),kd=0,qd(),ad=e,H=n=Ri(e.current,null),U=t,od=0,sd=null,cd=!1,ld=pt(e,t),ud=!1,_d=gd=hd=md=pd=fd=0,yd=vd=null,bd=!1,dd=mt(e,t),Oi(),n}function Yd(e,t){L=null,A.H=yc,t===$a||t===to?(t=so(),od=3):t===eo?(t=so(),od=4):od=t===Ic?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,sd=t,H===null&&(fd=1,jc(e,Ki(t,e.current)))}function Xd(){var e=Fo.current;return e===null?!0:(U&4194048)===U?Io===null:(U&62914560)===U||U&536870912?e===Io:!1}function Zd(){var e=A.H;return A.H=yc,e===null?yc:e}function Qd(){var e=A.A;return A.A=rd,e}function $d(){fd=4,cd||(U&4194048)!==U&&Fo.current!==null||(ld=!0),!(pd&134217727)&&!(md&134217727)||ad===null||Gd(ad,U,gd,!1)}function ef(e,t,n){var r=V;V|=2;var i=Zd(),a=Qd();(ad!==e||U!==t)&&(wd=null,Jd(e,t)),t=!1;var o=fd;a:do try{if(od!==0&&H!==null){var s=H,c=sd;switch(od){case 8:qd(),o=6;break a;case 3:case 2:case 9:case 6:Fo.current===null&&(t=!0);var l=od;if(od=0,sd=null,sf(e,s,c,l),n&&ld){o=0;break a}break;default:l=od,od=0,sd=null,sf(e,s,c,l)}}tf(),o=fd;break}catch(t){Yd(e,t)}while(1);return t&&e.shellSuspendCounter++,xa=ba=null,V=r,A.H=i,A.A=a,H===null&&(ad=null,U=0,Oi()),o}function tf(){for(;H!==null;)af(H)}function nf(e,t){var n=V;V|=2;var r=Zd(),a=Qd();ad!==e||U!==t?(wd=null,Cd=qe()+500,Jd(e,t)):ld=pt(e,t);a:do try{if(od!==0&&H!==null){t=H;var o=sd;b:switch(od){case 1:od=0,sd=null,sf(e,t,o,1);break;case 2:case 9:if(ro(o)){od=0,sd=null,of(t);break}t=function(){od!==2&&od!==9||ad!==e||(od=7),Pf(e)},o.then(t,t);break a;case 3:od=7;break a;case 4:od=5;break a;case 7:ro(o)?(od=0,sd=null,of(t)):(od=0,sd=null,sf(e,t,o,7));break;case 5:var s=null;switch(H.tag){case 26:s=H.memoizedState;case 5:case 27:var c=H;if(s?ih(s):c.stateNode.complete){od=0,sd=null;var l=c.sibling;if(l!==null)H=l;else{var u=c.return;u===null?H=null:(H=u,cf(u))}break b}}od=0,sd=null,sf(e,t,o,5);break;case 6:od=0,sd=null,sf(e,t,o,6);break;case 8:qd(),fd=6;break a;default:throw Error(i(462))}}rf();break}catch(t){Yd(e,t)}while(1);return xa=ba=null,A.H=r,A.A=a,V=n,H===null?(ad=null,U=0,Oi(),fd):0}function rf(){for(;H!==null&&!Ge();)af(H)}function af(e){var t=hl(e.alternate,e,dd);e.memoizedProps=e.pendingProps,t===null?cf(e):H=t}function of(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Yc(n,t,t.pendingProps,t.type,void 0,U);break;case 11:t=Yc(n,t,t.pendingProps,t.type.render,t.ref,U);break;case 5:us(t);var r=t;r===sa&&(I?(ma(r),r.tag===5&&r.stateNode!=null&&(ca=r.stateNode)):(ma(r),I=!0));default:wl(n,t),t=H=zi(t,dd),t=hl(n,t,dd)}e.memoizedProps=e.pendingProps,t===null?cf(e):H=t}function sf(e,t,n,r){xa=ba=null,us(t),lo=null,uo=0;var i=t.return;try{if(Fc(e,i,t,n,U)){fd=1,jc(e,Ki(n,e.current)),H=null;return}}catch(t){if(i!==null)throw H=i,t;fd=1,jc(e,Ki(n,e.current)),H=null;return}t.flags&32768?(I||r===1?e=!0:ld||U&536870912?e=!1:(cd=e=!0,(r===2||r===9||r===3||r===6)&&(r=Fo.current,r!==null&&r.tag===13&&(r.flags|=16384))),lf(t,e)):cf(t)}function cf(e){var t=e;do{if(t.flags&32768){lf(t,cd);return}e=t.return;var n=Sl(t.alternate,t,dd);if(n!==null){H=n;return}if(t=t.sibling,t!==null){H=t;return}H=t=e}while(t!==null);fd===0&&(fd=5)}function lf(e,t){do{var n=Cl(e.alternate,e);if(n!==null){n.flags&=32767,H=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){H=e;return}H=e=n}while(e!==null);fd=6,H=null}function uf(e,t,n,r,a,o,s,c,l,u,d,f){e.cancelPendingCommit=null;do vf();while(Ed!==0);if(V&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));e===ad&&(H=ad=null,U=0),Od=t,Dd=e,kd=n,jd=a,Md=r,df(e,t,n,s,c,l,f)}}function df(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(Ad=s,s|=Di,yt(e,n,s,r,i,a),Pd=null,(n&335544064)===n?(Fd=Ba(e),r=10262):(Fd=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,Df(Ze,function(){return yf(),null})):(e.callbackNode=null,e.callbackPriority=0),Ul=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=A.T,A.T=null,i=j.p,j.p=2,a=V,V|=4;try{vu(e,t,n)}finally{V=a,j.p=i,A.T=r}}Ed=1,Ul?Nd=Vp(o,e.containerInfo,Fd,mf,hf,pf,gf,yf,ff,null,null):(mf(),hf(),gf())}function ff(e){if(Ed!==0){var t=Dd.onRecoverableError;t(e,{componentStack:null})}}function pf(){Ed===3&&(Ed=0,zu(Od,Dd),Ed=4)}function mf(){if(Ed===1){Ed=0;var e=Dd,t=Od,n=kd,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=A.T,A.T=null;var i=j.p;j.p=2;var a=V;V|=4;try{hu=gu=!1,Fu(t,e,n),n=_p;var o=Zr(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&Xr(s.ownerDocument.documentElement,s)){if(c!==null&&Qr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Yr(s,h),v=Yr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}Th=!!gp,_p=gp=null}finally{V=a,j.p=i,A.T=r}}e.current=t,Ed=2}}function hf(){if(Ed===2){Ed=0;var e=Dd,t=Od,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=A.T,A.T=null;var r=j.p;j.p=2;var i=V;V|=4;try{bu(e,t.alternate,t)}finally{V=i,j.p=r,A.T=n}}Ed=3}}function gf(){if(Ed===4||Ed===3){Ed=0;var e=Nd;Nd=null,Ke();var t=Dd,n=Od,r=kd,i=Md,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?Ed=5:(Ed=0,Od=Dd=null,_f(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(Td=null),wt(r),n=n.stateNode,rt&&typeof rt.onCommitFiberRoot==`function`)try{rt.onCommitFiberRoot(nt,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=A.T,a=j.p,j.p=2,A.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{A.T=n,j.p=a}}if(i=Pd,o=Fd,Fd=null,i!==null&&(Pd=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);kd&3&&vf(),Pf(t),a=t.pendingLanes,r&261930&&a&42?t===Ld?Id++:(Id=0,Ld=t):(Id=0,Ld=null),Ff(0,!1)}}function _f(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,La(t)))}function vf(){return Nd!==null&&(Nd.skipTransition(),Nd=null),mf(),hf(),gf(),yf()}function yf(){if(Ed!==5)return!1;var e=Dd,t=Ad;Ad=0;var n=wt(kd),r=A.T,a=j.p;try{j.p=32>n?32:n,A.T=null,n=jd,jd=null;var o=Dd,s=kd;if(Ed=0,Od=Dd=null,kd=0,V&6)throw Error(i(331));var c=V;if(V|=4,ed(o.current),Ku(o,o.current,s,n),V=c,Ff(0,!1),rt&&typeof rt.onPostCommitFiberRoot==`function`)try{rt.onPostCommitFiberRoot(nt,o)}catch{}return!0}finally{j.p=a,A.T=r,_f(e,t)}}function bf(e,t,n){t=Ki(n,t),t=Nc(e.stateNode,t,2),e=So(e,t,2),e!==null&&(vt(e,2),Pf(e))}function xf(e,t,n){if(e.tag===3)bf(e,e,n);else for(;t!==null;){if(t.tag===3){bf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(Td===null||!Td.has(r))){e=Ki(n,e),n=Pc(2),r=So(t,n,2),r!==null&&(z(n,r,t,e),vt(r,2),Pf(r));break}}t=t.return}}function Sf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new id;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(ud=!0,i.add(n),e=Cf.bind(null,e,t,n),t.then(e,e))}function Cf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,ad===e&&(U&n)===n&&(fd===4||fd===3&&(U&62914560)===U&&300>qe()-xd?V&2?hd|=n:Jd(e,0):hd|=n,_d===U&&(_d=0)),Pf(e)}function wf(e,t){t===0&&(t=gt()),e=ji(e,t),e!==null&&(vt(e,t),Pf(e))}function Tf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),wf(e,n)}function Ef(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),wf(e,n)}function Df(e,t){return Ue(e,t)}var Of=null,kf=null,Af=!1,jf=!1,Mf=!1,Nf=0;function Pf(e){e!==kf&&e.next===null&&(kf===null?Of=kf=e:kf=kf.next=e),jf=!0,Af||(Af=!0,Vf())}function Ff(e,t){if(!Mf&&jf){Mf=!0;do for(var n=!1,r=Of;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-at(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Bf(r,a))}else a=U,a=ft(r,r===ad?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||pt(r,a)||(n=!0,Bf(r,a))}r=r.next}while(n);Mf=!1}}function If(){Lf()}function Lf(){jf=Af=!1;var e=0;Nf!==0&&wp()&&(e=Nf);for(var t=qe(),n=null,r=Of;r!==null;){var i=r.next,a=Rf(r,t);a===0?(r.next=null,n===null?Of=i:n.next=i,i===null&&(kf=n)):(n=r,(e!==0||a&3)&&(jf=!0)),r=i}Ed!==0&&Ed!==5||Ff(e,!1),Nf!==0&&(Nf=0)}function Rf(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-at(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=ht(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=ad,n=U,n=ft(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(od===2||od===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&We(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||pt(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&We(r),wt(n)){case 2:case 8:n=Xe;break;case 32:n=Ze;break;case 268435456:n=$e;break;default:n=Ze}return r=zf.bind(null,e),n=Ue(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&We(r),e.callbackPriority=2,e.callbackNode=null,2}function zf(e,t){if(Ed!==0&&Ed!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(vf()&&e.callbackNode!==n)return null;var r=U;return r=ft(e,e===ad?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Hd(e,r,t),Rf(e,qe()),e.callbackNode!=null&&e.callbackNode===n?zf.bind(null,e):null)}function Bf(e,t){if(vf())return null;Hd(e,t,!0)}function Vf(){kp(function(){V&6?Ue(Ye,If):Lf()})}function Hf(){if(Nf===0){var e=Ua;e===0&&(e=lt,lt<<=1,!(lt&261888)&&(lt=256)),Nf=e}return Nf}function Uf(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:xn(e)}function Wf(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Uf((i[kt]||null).action),o=r.submitter;o&&(t=(t=o[kt]||null)?Uf(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Un(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Nf!==0){var e=new FormData(i,o);ac(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),ac(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Gf=0;Gf<vi.length;Gf++){var Kf=vi[Gf];yi(Kf.toLowerCase(),`on`+(Kf[0].toUpperCase()+Kf.slice(1)))}yi(ui,`onAnimationEnd`),yi(di,`onAnimationIteration`),yi(fi,`onAnimationStart`),yi(`dblclick`,`onDoubleClick`),yi(`focusin`,`onFocus`),yi(`focusout`,`onBlur`),yi(pi,`onTransitionRun`),yi(mi,`onTransitionStart`),yi(hi,`onTransitionCancel`),yi(gi,`onTransitionEnd`),Kt(`onMouseEnter`,[`mouseout`,`mouseover`]),Kt(`onMouseLeave`,[`mouseout`,`mouseover`]),Kt(`onPointerEnter`,[`pointerout`,`pointerover`]),Kt(`onPointerLeave`,[`pointerout`,`pointerover`]),N(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),N(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),N(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),N(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),N(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),N(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var qf=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Jf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(qf));function Yf(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){wi(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){wi(e)}i.currentTarget=null,a=c}}}}function W(e,t){var n=t[jt];n===void 0&&(n=t[jt]=new Set);var r=e+`__bubble`;n.has(r)||($f(t,e,2,!1),n.add(r))}function Xf(e,t,n){var r=0;t&&(r|=4),$f(n,e,r,t)}var Zf=`_reactListening`+Math.random().toString(36).slice(2);function Qf(e){if(!e[Zf]){e[Zf]=!0,Wt.forEach(function(t){t!==`selectionchange`&&(Jf.has(t)||Xf(t,!1,e),Xf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Zf]||(t[Zf]=!0,Xf(`selectionchange`,!1,t))}}function $f(e,t,n,r){switch(Mh(t)){case 2:var i=Eh;break;case 8:i=Dh;break;default:i=Oh}n=i.bind(null,t,n,e),i=void 0,!Mn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function ep(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=Rt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}kn(function(){var r=a,i=wn(n),s=[];a:{var c=_i.get(e);if(c!==void 0){var l=Un,u=e;switch(e){case`keypress`:if(Rn(n)===0)break a;case`keydown`:case`keyup`:l=sr;break;case`focusin`:u=`focus`,l=Qn;break;case`focusout`:u=`blur`,l=Qn;break;case`beforeblur`:case`afterblur`:l=Qn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=Xn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Zn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=ur;break;case ui:case di:case fi:l=$n;break;case gi:l=dr;break;case`scroll`:case`scrollend`:l=Gn;break;case`wheel`:l=fr;break;case`copy`:case`cut`:case`paste`:l=er;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=cr;break;case`submit`:l=lr;break;case`toggle`:case`beforetoggle`:l=pr}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=An(m,p),g!=null&&d.push(tp(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(l=e===`mouseover`||e===`pointerover`,c=e===`mouseout`||e===`pointerout`,l&&n!==Cn&&(u=n.relatedTarget||n.fromElement)&&(Rt(u)||u[At]))break a;(c||l)&&(u=i.window===i?i:(l=i.ownerDocument)?l.defaultView||l.parentWindow:window,c?(l=n.relatedTarget||n.toElement,c=r,l=l?Rt(l):null,l!==null&&(f=o(l),d=l.tag,l!==f||d!==5&&d!==27&&d!==6)&&(l=null)):(c=null,l=r),c!==l&&(d=Xn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=cr,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=c==null?u:Bt(c),h=l==null?u:Bt(l),u=new d(g,m+`leave`,c,n,i),u.target=f,u.relatedTarget=h,g=null,Rt(i)===r&&(d=new d(p,m+`enter`,l,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=c&&l?E(c,l,rp):null,c!==null&&ip(s,u,c,d,!1),l!==null&&f!==null&&ip(s,f,l,d,!0)))}a:{if(c=r?Bt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var _=Nr;else if(Dr(c)){if(Pr)_=Ur;else{_=Vr;var v=Br}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&vn(r.elementType)&&(_=Nr):_=Hr;if(_&&=_(e,r)){Or(s,_,n,i);break a}v&&v(e,c,r)}switch(v=r?Bt(r):window,e){case`focusin`:(Dr(v)||v.contentEditable===`true`)&&(ei=v,ti=r,ni=null);break;case`focusout`:ni=ti=ei=null;break;case`mousedown`:ri=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:ri=!1,ii(s,n,i);break;case`selectionchange`:if($r)break;case`keydown`:case`keyup`:ii(s,n,i)}var y;if(hr)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else Cr?xr(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(vr&&n.locale!==`ko`&&(Cr||b!==`onCompositionStart`?b===`onCompositionEnd`&&Cr&&(y=Ln()):(Pn=i,Fn=`value`in Pn?Pn.value:Pn.textContent,Cr=!0)),v=np(r,b),0<v.length&&(b=new tr(b,e,null,n,i),s.push({event:b,listeners:v}),y?b.data=y:(y=Sr(n),y!==null&&(b.data=y)))),(y=_r?wr(e,n):Tr(e,n))&&(b=np(r,`onBeforeInput`),0<b.length&&(v=new tr(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:v,listeners:b}),v.data=y)),Wf(s,e,r,n,i)}Yf(s,t)})}function tp(e,t,n){return{instance:e,listener:t,currentTarget:n}}function np(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=An(e,n),i!=null&&r.unshift(tp(e,i,a)),i=An(e,t),i!=null&&r.push(tp(e,i,a))),e.tag===3)return r;e=e.return}return[]}function rp(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function ip(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=An(n,a),l!=null&&o.unshift(tp(n,l,c))):i||(l=An(n,a),l!=null&&o.push(tp(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var ap=/\r\n?/g,op=/\u0000|\uFFFD/g;function sp(e){return(typeof e==`string`?e:``+e).replace(ap,`
|
|
9
|
+
`).replace(op,``)}function cp(e,t){return t=sp(t),sp(e)===t}function lp(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||mn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&mn(e,``+r);else return;break;case`className`:Qt(e,`class`,r);break;case`tabIndex`:Qt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Qt(e,n,r);break;case`style`:_n(e,r,o);return;case`data`:if(t!==`object`){Qt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=xn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&lp(e,t,`name`,a.name,a,null),lp(e,t,`formEncType`,a.formEncType,a,null),lp(e,t,`formMethod`,a.formMethod,a,null),lp(e,t,`formTarget`,a.formTarget,a,null)):(lp(e,t,`encType`,a.encType,a,null),lp(e,t,`method`,a.method,a,null),lp(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=xn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Sn);return;case`onScroll`:r!=null&&W(`scroll`,e);return;case`onScrollEnd`:r!=null&&W(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=xn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:W(`beforetoggle`,e),W(`toggle`,e),F(e,`popover`,r);break;case`xlinkActuate`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:$t(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:$t(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:$t(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:F(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=yn.get(n)||n,F(e,n,r);else return}P=!0}function up(e,t,n,r,a,o){switch(n){case`style`:_n(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)mn(e,r);else if(typeof r==`number`||typeof r==`bigint`)mn(e,``+r);else return;break;case`onScroll`:r!=null&&W(`scroll`,e);return;case`onScrollEnd`:r!=null&&W(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=Sn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Gt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[kt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}P=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):F(e,n,r)}return}P=!0}function dp(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:W(`error`,e),W(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:lp(e,t,o,s,n,null)}}a&&lp(e,t,`srcSet`,n.srcSet,n,null),r&&lp(e,t,`src`,n.src,n,null);return;case`input`:W(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:lp(e,t,r,d,n,null)}}ln(e,o,c,l,u,s,a,!1);return;case`select`:for(a in W(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:lp(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&dn(e,!!r,n,!0):dn(e,!!r,t,!1);return;case`textarea`:for(s in W(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:lp(e,t,s,c,n,null)}pn(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:lp(e,t,l,r,n,null)}return;case`dialog`:W(`beforetoggle`,e),W(`toggle`,e),W(`cancel`,e),W(`close`,e);break;case`iframe`:case`object`:W(`load`,e);break;case`video`:case`audio`:for(r=0;r<qf.length;r++)W(qf[r],e);break;case`image`:W(`error`,e),W(`load`,e);break;case`details`:W(`toggle`,e);break;case`embed`:case`source`:case`link`:W(`error`,e),W(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:lp(e,t,u,r,n,null)}return;default:if(vn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&up(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&lp(e,t,c,r,n,null))}var fp={};function pp(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||lp(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(P=!0),o=m;break;case`name`:m!==f&&(P=!0),a=m;break;case`checked`:m!==f&&(P=!0),u=m;break;case`defaultChecked`:m!==f&&(P=!0),d=m;break;case`value`:m!==f&&(P=!0),s=m;break;case`defaultValue`:m!==f&&(P=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&lp(e,t,p,m,r,f)}}cn(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||lp(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:o!==l&&(P=!0),p=o;break;case`defaultValue`:o!==l&&(P=!0),c=o;break;case`multiple`:o!==l&&(P=!0),s=o;default:o!==l&&lp(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?dn(e,!!n,n?[]:``,!1):dn(e,!!n,t,!0)):dn(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:lp(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:a!==o&&(P=!0),p=a;break;case`defaultValue`:a!==o&&(P=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&lp(e,t,s,a,r,o)}fn(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:lp(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(P=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:lp(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&lp(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:lp(e,t,u,p,r,m)}return;default:if(vn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&up(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||up(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&lp(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||lp(e,t,f,p,r,m)}function mp(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function hp(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&mp(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&mp(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var gp=null,_p=null;function vp(e){return e.nodeType===9?e:e.ownerDocument}function yp(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function bp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function xp(e,t,n,r){return n=vp(n).createElement(e),n[Ot]=r,n[kt]=t,dp(n,e,t),Ht(n),n}function Sp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Cp=null;function wp(){var e=window.event;return e&&e.type===`popstate`?e!==Cp&&(Cp=e,!0):(Cp=null,!1)}var Tp=typeof setTimeout==`function`?setTimeout:void 0,Ep=typeof clearTimeout==`function`?clearTimeout:void 0,Dp=typeof Promise==`function`?Promise:void 0,Op=typeof requestAnimationFrame==`function`?requestAnimationFrame:Tp,kp=typeof queueMicrotask==`function`?queueMicrotask:Dp===void 0?Tp:function(e){return Dp.resolve(null).then(e).catch(Ap)};function Ap(e){setTimeout(function(){throw e})}function jp(e){return e===`head`}function Mp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Zh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)Em(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Em(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[Ft]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&Em(e.ownerDocument.body)}n=i}while(n);Zh(t)}function Np(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Pp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Fp(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Ip(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Lp(e){return Ip(e.getBoundingClientRect(),getComputedStyle(e),e)}function Rp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Ip(t,n,e)}function zp(e){return e.documentElement.clientHeight}function Bp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Vp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(zp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=ah(f),u>ch){s.length=o;break}f=new Promise(Bp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Hp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Hp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:D({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Hp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Hp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Up(e){return{name:e,group:new Hp(`group`,e),imagePair:new Hp(`image-pair`,e),old:new Hp(`old`,e),new:new Hp(`new`,e)}}function Wp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Wp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Yp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=qp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),p(this._fragmentFiber.child,!1,Gp,e,s,r)}this._eventListeners=a}};function Gp(e,t,n,r){return b(e).addEventListener(t,n,r),!1}Wp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Yp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=qp(i.optionsOrUseCapture),p(this._fragmentFiber.child,!1,Kp,e,n,i),r.splice(t,1),a!==null&&a()}};function Kp(e,t,n,r){return b(e).removeEventListener(t,n,r),!1}function qp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function Jp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Yp(e,t,n,r){if(e.length===0)return-1;r=Jp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&Jp(a.optionsOrUseCapture)===r)return i}return-1}Wp.prototype.dispatchEvent=function(e){var t=h(this._fragmentFiber);if(t===null)return!0;t=b(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,qp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,qp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Wp.prototype.focus=function(e){p(this._fragmentFiber.child,!0,Xp,e,void 0,void 0)};function Xp(e,t){return e.tag!==6&&(e=b(e),Sm(e,t))}Wp.prototype.focusLast=function(e){var t=[];p(this._fragmentFiber.child,!0,Zp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Xp(t[n],e);n--);};function Zp(e,t){return t.push(e),!1}Wp.prototype.blur=function(){var e=h(this._fragmentFiber);e!==null&&(e=b(e),e=vp(e).activeElement,e!==null&&p(this._fragmentFiber.child,!1,Qp,e,void 0,void 0))};function Qp(e,t){return e.tag!==6&&(e=b(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Wp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),p(this._fragmentFiber.child,!1,$p,e,void 0,void 0)};function $p(e,t){return e.tag===6||(e=b(e),t.observe(e)),!1}Wp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),p(this._fragmentFiber.child,!1,em,e,void 0,void 0);for(var n=t=0;n<tm.length;n++){var r=tm[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):tm[t++]=r}tm.length=t}};function em(e,t){return e.tag===6||(e=b(e),t.unobserve(e)),!1}var tm=[],nm=!1;function rm(e,t,n){tm.push({fragmentInstance:e,observer:t,instance:n}),nm||(nm=!0,Cm(function(){nm=!1;var e=tm;tm=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Wp.prototype.getClientRects=function(){var e=[];return p(this._fragmentFiber.child,!1,im,e,void 0,void 0),e};function im(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=b(e),t.push.apply(t,e.getClientRects());return!1}Wp.prototype.getRootNode=function(e){var t=h(this._fragmentFiber);return t===null?this:b(t).getRootNode(e)},Wp.prototype.compareDocumentPosition=function(e){var t=h(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];p(this._fragmentFiber.child,!1,Zp,n,void 0,void 0);var r=b(t);if(n.length===0){if(n=r,_(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=v(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=b(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=b(n[0]),i=b(n[n.length-1]);var a=_(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||am(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function am(e,t,n,r,i){var a=Rt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=h(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=E(n,a,T),t===null?t=!1:(p(t,!0,C,a,n),a=x,x=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=E(r,a,T),t===null?t=!1:(p(t,!0,w,a,r),a=x,S=x=null,t=a!==null)),t):!1}function om(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Wp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];p(this._fragmentFiber.child,!1,Zp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=v(this._fragmentFiber);if(r=n?r[1]||r[0]||h(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=b(r),om(e,n);return}if(r=b(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=b(a),om(a,n)):b(a).scrollIntoView(e),r+=n?-1:1}};function sm(e,t){return e=b(e),cm(e,t),!1}function cm(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function lm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,qp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<tm.length;i++){var a=tm[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(tm[r++]=a)}tm.length=r,n.observe(e)}),cm(e,t))}function um(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,qp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?rm(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function dm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:dm(n),Lt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function fm(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[Ft])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=vm(e.nextSibling),e===null)break}return null}function pm(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=vm(e.nextSibling),e===null))return null;return e}function mm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=vm(e.nextSibling),e===null))return null;return e}function hm(e){return e.data===`$?`||e.data===`$~`}function gm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function _m(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function vm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var ym=null;function bm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return vm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function xm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function Sm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function Cm(e){Op(function(){Op(function(t){return e(t)})})}function wm(e,t,n){switch(t=vp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Tm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&lp(e,t,r,null,fp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===Sn&&(e.onclick=null),Lt(e)}function Em(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Lt(e)}var Dm=new Map,Om=new Set;function km(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Am=j.d;j.d={f:jm,r:Mm,D:Fm,C:Im,L:Lm,m:Rm,X:Bm,S:zm,M:Vm};function jm(){var e=Am.f(),t=Kd();return e||t}function Mm(e){var t=zt(e);t!==null&&t.tag===5&&t.type===`form`?sc(t):Am.r(e)}var Nm=typeof document>`u`?null:document;function Pm(e,t,n){var r=Nm;if(r&&typeof t==`string`&&t){var i=sn(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Om.has(i)||(Om.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),dp(t,`link`,e),Ht(t),r.head.appendChild(t)))}}function Fm(e){Am.D(e),Pm(`dns-prefetch`,e,null)}function Im(e,t){Am.C(e,t),Pm(`preconnect`,e,t)}function Lm(e,t,n){Am.L(e,t,n);var r=Nm;if(r&&e&&t){var i=`link[rel="preload"][as="`+sn(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+sn(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+sn(n.imageSizes)+`"]`)):i+=`[href="`+sn(e)+`"]`;var a=i;switch(t){case`style`:a=Um(e);break;case`script`:a=qm(e)}if(!(Dm.has(a)||(e=D({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Dm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Wm(a))||t===`script`&&r.querySelector(Jm(a))))){var o=r.createElement(`link`);dp(o,`link`,e),t===`style`&&(o[It]=!0,o.onload=o.onerror=function(){Ut(o)}),Ht(o),r.head.appendChild(o)}}}function Rm(e,t){Am.m(e,t);var n=Nm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+sn(r)+`"][href="`+sn(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=qm(e)}if(!Dm.has(a)&&(e=D({rel:`modulepreload`,href:e},t),Dm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Jm(a)))return}r=n.createElement(`link`),dp(r,`link`,e),Ht(r),n.head.appendChild(r)}}}function zm(e,t,n){Am.S(e,t,n);var r=Nm;if(r&&e){var i=Vt(r).hoistableStyles,a=Um(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Wm(a)))s.loading=5;else{e=D({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Dm.get(a))&&Zm(e,n);var c=o=r.createElement(`link`);Ht(c),dp(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Xm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Bm(e,t){Am.X(e,t);var n=Nm;if(n&&e){var r=Vt(n).hoistableScripts,i=qm(e),a=r.get(i);a||(a=n.querySelector(Jm(i)),a||(e=D({src:e,async:!0},t),(t=Dm.get(i))&&Qm(e,t),a=n.createElement(`script`),Ht(a),dp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Vm(e,t){Am.M(e,t);var n=Nm;if(n&&e){var r=Vt(n).hoistableScripts,i=qm(e),a=r.get(i);a||(a=n.querySelector(Jm(i)),a||(e=D({src:e,async:!0,type:`module`},t),(t=Dm.get(i))&&Qm(e,t),a=n.createElement(`script`),Ht(a),dp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Hm(e,t,n,r){var a=(a=ke.current)?km(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Um(n.href),t=Vt(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Um(n.href);var o=Vt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Wm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=Dm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Dm.set(e,o)),Km(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=qm(n),t=Vt(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Um(e){return`href="`+sn(e)+`"`}function Wm(e){return`link[rel="stylesheet"][`+e+`]`}function Gm(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function Km(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[It]){r.loading=1;return}}else t=e.createElement(`link`),t[It]=!0,t.onload=t.onerror=Ut.bind(null,t),dp(t,`link`,n),Ht(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function qm(e){return`[src="`+sn(e)+`"]`}function Jm(e){return`script[async]`+e}function Ym(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+sn(n.href)+`"]`);if(r)return t.instance=r,Ht(r),r;var a=D({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Ht(r),dp(r,`style`,a),Xm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Um(n.href);var o=e.querySelector(Wm(a));if(o)return t.state.loading|=4,t.instance=o,Ht(o),o;r=Gm(n),(a=Dm.get(a))&&Zm(r,a),o=(e.ownerDocument||e).createElement(`link`),Ht(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),dp(o,`link`,r),t.state.loading|=4,Xm(o,n.precedence,e),t.instance=o;case`script`:return o=qm(n.src),(a=e.querySelector(Jm(o)))?(t.instance=a,Ht(a),a):(r=n,(a=Dm.get(o))&&(r=D({},n),Qm(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Ht(a),dp(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Xm(r,n.precedence,e));return t.instance}function Xm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Zm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Qm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var $m=null;function eh(e,t,n){if($m===null){var r=new Map,i=$m=new Map;i.set(n,r)}else i=$m,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[Ft]||a[Ot]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function th(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function nh(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function rh(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function ih(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function ah(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function oh(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=ah(t),e.suspenseyImages.push(t)),e=fh.bind(e),t.decode().then(e,e))}function sh(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Um(r.href),a=t.querySelector(Wm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=dh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Ht(a);return}a=t.ownerDocument||t,r=Gm(r),(i=Dm.get(i))&&Zm(r,i),a=a.createElement(`link`),Ht(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),dp(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=dh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var ch=0;function lh(e,t){return e.stylesheets&&e.count===0&&mh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&mh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&ch===0&&(ch=62500*hp());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&mh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>ch?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function uh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)mh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function dh(){this.count--,uh(this)}function fh(){this.imgCount--,uh(this)}var ph=null;function mh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ph=new Map,t.forEach(hh,e),ph=null,dh.call(e))}function hh(e,t){if(!(t.state.loading&4)){var n=ph.get(e);if(n)var r=n.get(null);else{n=new Map,ph.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=dh.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var gh={$$typeof:oe,Provider:null,Consumer:null,_currentValue:xe,_currentValue2:xe,_threadCount:0};function _h(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=_t(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_t(0),this.hiddenUpdates=_t(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function vh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new _h(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Ii(3,null,null,t),e.current=a,a.stateNode=e,t=Ia(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},yo(a),e}function yh(e){return e?(e=Pi,e):Pi}function bh(e,t,n,r,i,a){i=yh(i),r.context===null?r.context=i:r.pendingContext=i,r=xo(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=So(e,r,t),n!==null&&(Vd(n,e,t),Co(n,e,t))}function xh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Sh(e,t){xh(e,t),(e=e.alternate)&&xh(e,t)}function Ch(e){if(e.tag===13||e.tag===31){var t=ji(e,67108864);t!==null&&Vd(t,e,67108864),Sh(e,67108864)}}function wh(e){if(e.tag===13||e.tag===31){var t=Rd();t=Ct(t);var n=ji(e,t);n!==null&&Vd(n,e,t),Sh(e,t)}}var Th=!0;function Eh(e,t,n,r){var i=A.T;A.T=null;var a=j.p;try{j.p=2,Oh(e,t,n,r)}finally{j.p=a,A.T=i}}function Dh(e,t,n,r){var i=A.T;A.T=null;var a=j.p;try{j.p=8,Oh(e,t,n,r)}finally{j.p=a,A.T=i}}function Oh(e,t,n,r){if(Th){var i=kh(r);if(i===null)ep(e,t,r,Ah,n),Vh(e,r);else if(Uh(i,e,t,n,r))r.stopPropagation();else if(Vh(e,r),t&4&&-1<Bh.indexOf(e)){for(;i!==null;){var a=zt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=M(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-at(o);s.entanglements[1]|=c,o&=~c}Pf(a),!(V&6)&&(Cd=qe()+500,Ff(0,!1))}}break;case 31:case 13:s=ji(a,2),s!==null&&Vd(s,a,2),Kd(),Sh(a,2)}if(a=kh(r),a===null&&ep(e,t,r,Ah,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else ep(e,t,r,null,n)}}function kh(e){return e=wn(e),jh(e)}var Ah=null;function jh(e){if(Ah=null,e=Rt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ah=e,null}function Mh(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Je()){case Ye:return 2;case Xe:return 8;case Ze:case Qe:return 32;case $e:return 268435456;default:return 32}default:return 32}}var Nh=!1,Ph=null,Fh=null,Ih=null,Lh=new Map,Rh=new Map,zh=[],Bh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Vh(e,t){switch(e){case`focusin`:case`focusout`:Ph=null;break;case`dragenter`:case`dragleave`:Fh=null;break;case`mouseover`:case`mouseout`:Ih=null;break;case`pointerover`:case`pointerout`:Lh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Rh.delete(t.pointerId)}}function Hh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=zt(t),t!==null&&Ch(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Uh(e,t,n,r,i){switch(t){case`focusin`:return Ph=Hh(Ph,e,t,n,r,i),!0;case`dragenter`:return Fh=Hh(Fh,e,t,n,r,i),!0;case`mouseover`:return Ih=Hh(Ih,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Lh.set(a,Hh(Lh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Rh.set(a,Hh(Rh.get(a)||null,e,t,n,r,i)),!0}return!1}function Wh(e){var t=Rt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,Et(e.priority,function(){wh(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,Et(e.priority,function(){wh(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Gh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=kh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Cn=r,n.target.dispatchEvent(r),Cn=null}else return t=zt(n),t!==null&&Ch(t),e.blockedOn=n,!1;t.shift()}return!0}function Kh(e,t,n){Gh(e)&&n.delete(t)}function qh(){Nh=!1,Ph!==null&&Gh(Ph)&&(Ph=null),Fh!==null&&Gh(Fh)&&(Fh=null),Ih!==null&&Gh(Ih)&&(Ih=null),Lh.forEach(Kh),Rh.forEach(Kh)}function Jh(e,n){e.blockedOn===n&&(e.blockedOn=null,Nh||(Nh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,qh)))}var Yh=null;function Xh(e){Yh!==e&&(Yh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Yh===e&&(Yh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(jh(r||n)===null)continue;break}var a=zt(n);a!==null&&(e.splice(t,3),t-=3,ac(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Zh(e){function t(t){return Jh(t,e)}Ph!==null&&Jh(Ph,e),Fh!==null&&Jh(Fh,e),Ih!==null&&Jh(Ih,e),Lh.forEach(t),Rh.forEach(t);for(var n=0;n<zh.length;n++){var r=zh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<zh.length&&(n=zh[0],n.blockedOn===null);)Wh(n),n.blockedOn===null&&zh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[kt]||null;if(typeof a==`function`)o||Xh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[kt]||null)s=o.formAction;else if(jh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Xh(n)}}}function Qh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function $h(e){this._internalRoot=e}eg.prototype.render=$h.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;bh(n,Rd(),e,t,null,null)},eg.prototype.unmount=$h.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;bh(e.current,2,null,e,null,null),Kd(),t[At]=null}};function eg(e){this._internalRoot=e}eg.prototype.unstable_scheduleHydration=function(e){if(e){var t=Tt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<zh.length&&t!==0&&t<zh[n].priority;n++);zh.splice(n,0,e),n===0&&Wh(e)}};var tg=n.version;if(tg!==`19.3.1`)throw Error(i(527,tg,`19.3.1`));j.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var ng={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:A,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var rg=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!rg.isDisabled&&rg.supportsFiber)try{nt=rg.inject(ng),rt=rg}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Oc,s=kc,c=Ac;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=vh(e,1,!1,null,null,n,r,null,o,s,c,Qh),e[At]=t.current,Qf(e),new $h(t)}})),v=o(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=_()})),y=f(),b=v(),x=[`C`,`C#`,`D`,`D#`,`E`,`F`,`F#`,`G`,`G#`,`A`,`A#`,`B`],S=[`C`,`Db`,`D`,`Eb`,`E`,`F`,`Gb`,`G`,`Ab`,`A`,`Bb`,`B`],C={C:0,D:2,E:4,F:5,G:7,A:9,B:11},w=e=>(e%12+12)%12;function T(e){let t=/^([A-Ga-g])([#b]*)$/.exec(e.trim());if(!t)return null;let n=C[t[1].toUpperCase()],r=0;for(let e of t[2])r+=e===`#`?1:-1;return w(n+r)}function E(e){let t=e.trim();if(/^\d+$/.test(t)){let e=Number(t);return e>=0&&e<=127?e:null}let n=/^([A-Ga-g][#b]*)(-?\d)$/.exec(t);if(!n)return null;let r=T(n[1]);if(r===null)return null;let i=C[n[1][0].toUpperCase()],a=r-i>6?r-i-12:r-i<-6?r-i+12:r-i,o=(Number(n[2])+1)*12+i+a;return o>=0&&o<=127?o:null}function D(e,t=!1){return(t?S:x)[w(e)]}function O(e,t=!1){return`${D(e,t)}${Math.floor(e/12)-1}`}var ee=[`major`,`minor`,`dorian`,`mixolydian`,`lydian`,`phrygian`],te={major:[0,2,4,5,7,9,11],minor:[0,2,3,5,7,8,10],dorian:[0,2,3,5,7,9,10],mixolydian:[0,2,4,5,7,9,10],lydian:[0,2,4,6,7,9,11],phrygian:[0,1,3,5,7,8,10]};function ne(e){return te[e][2]===3}function re(e){let t=T(e.tonic);if(t===null)throw Error(`Unknown tonic "${e.tonic}"`);return t}function ie(e){let t=re(e);return te[e.mode].map(e=>w(t+e))}function ae(e){let t=re(e);return(ne(e.mode)?[0,3,5,7,10]:[0,2,4,7,9]).map(e=>w(t+e))}function oe(e){if(e.tonic.includes(`b`))return!0;if(e.tonic.includes(`#`))return!1;let t=w(re(e)+{major:0,minor:3,dorian:-2,mixolydian:5,lydian:-5,phrygian:-4}[e.mode]);return[5,10,3,8,1,6].includes(t)}function se(e){let t=re(e);return`${e.tonic.length>1?e.tonic[0].toUpperCase()+e.tonic.slice(1):S[t]} ${e.mode}`}var ce={maj:{tones:[0,4,7],voicing:[0,4,7],minor:!1},m:{tones:[0,3,7],voicing:[0,3,7],minor:!0},dim:{tones:[0,3,6],voicing:[0,3,6],minor:!0},aug:{tones:[0,4,8],voicing:[0,4,8],minor:!1},sus2:{tones:[0,2,7],voicing:[0,2,7],minor:!1},sus4:{tones:[0,5,7],voicing:[0,5,7],minor:!1},add9:{tones:[0,4,7,14],voicing:[4,14,7,0],minor:!1},6:{tones:[0,4,7,9],voicing:[4,9,7,0],minor:!1},m6:{tones:[0,3,7,9],voicing:[3,9,7,0],minor:!0},69:{tones:[0,4,7,9,14],voicing:[4,9,14,7],minor:!1},maj7:{tones:[0,4,7,11],voicing:[4,11,7,0],minor:!1},maj9:{tones:[0,4,7,11,14],voicing:[4,11,14,7],minor:!1},m7:{tones:[0,3,7,10],voicing:[3,10,7,0],minor:!0},m9:{tones:[0,3,7,10,14],voicing:[3,10,14,7],minor:!0},m11:{tones:[0,3,7,10,14,17],voicing:[3,10,14,17],minor:!0},7:{tones:[0,4,7,10],voicing:[4,10,7,0],minor:!1},9:{tones:[0,4,7,10,14],voicing:[4,10,14,7],minor:!1},13:{tones:[0,4,7,10,14,21],voicing:[4,10,14,21],minor:!1},"7b9":{tones:[0,4,7,10,13],voicing:[4,10,13,7],minor:!1},"7sus4":{tones:[0,5,7,10],voicing:[5,10,7,0],minor:!1},"9sus4":{tones:[0,5,7,10,14],voicing:[5,10,14,7],minor:!1},m7b5:{tones:[0,3,6,10],voicing:[3,10,6,0],minor:!0},dim7:{tones:[0,3,6,9],voicing:[3,9,6,0],minor:!0}},le=Object.keys(ce),ue={"":`maj`,M:`maj`,major:`maj`,min:`m`,minor:`m`,"-":`m`,mi:`m`,M7:`maj7`,Δ:`maj7`,Δ7:`maj7`,ma7:`maj7`,M9:`maj9`,Δ9:`maj9`,ma9:`maj9`,min7:`m7`,"-7":`m7`,mi7:`m7`,min9:`m9`,"-9":`m9`,min11:`m11`,"-11":`m11`,dom7:`7`,ø:`m7b5`,ø7:`m7b5`,"m7-5":`m7b5`,"°":`dim`,"°7":`dim7`,o:`dim`,o7:`dim7`,sus:`sus4`,"7sus":`7sus4`,"9sus":`9sus4`,"6/9":`69`,add2:`add9`,"+":`aug`};function de(e){return e in ce?e:ue[e]??null}function k(e,t){return[...new Set(ce[t].tones.map(t=>w(e+t)))]}function fe(e,t){return w(re(t)+e.root)}function pe(e,t,n){let r=D(fe(e,t),n);return e.quality===`maj`?r:`${r}${e.quality}`}function me(e){let t=/^([A-Ga-g][#b]?)(.*)$/.exec(e.trim());if(!t)return null;let n=T(t[1]),r=de(t[2]);return n===null||r===null?null:{rootPc:n,quality:r}}var he=[`i`,`ii`,`iii`,`iv`,`v`,`vi`,`vii`],ge=[0,2,4,5,7,9,11];function _e(e,t){if(t){let t={"":`m`,6:`m6`,7:`m7`,9:`m9`,11:`m11`};if(e in t)return de(t[e])}return de(e)}function ve(e){let t=/^([b#]?)(vii|iii|iv|vi|ii|v|i|VII|III|IV|VI|II|V|I)(.*)$/.exec(e.trim());if(!t)return null;let n=he.indexOf(t[2].toLowerCase()),r=t[2]===t[2].toLowerCase(),i=_e(t[3],r);if(i===null)return null;let a=t[1]===`b`?-1:+(t[1]===`#`);return{root:w(ge[n]+a),quality:i}}function ye(e,t){let n=e.split(/[\s|,]+/).filter(Boolean);if(n.length===0)throw Error(`Progression is empty`);return n.map(e=>{let[n,r]=e.split(`:`),i=r===void 0?4:Number(r);if(!Number.isFinite(i)||i<=0||i>32)throw Error(`Bad chord length in "${e}"`);let a=ve(n);if(a)return{...a,beats:i};let o=me(n);if(o)return{root:w(o.rootPc-re(t)),quality:o.quality,beats:i};throw Error(`Can't read chord "${n}". Try a roman numeral like ii9 or a symbol like Em9.`)})}function be(e){return e.reduce((e,t)=>e+t.beats,0)}function A(e,t){let n=be(e),r=Math.floor(t/n)*n,i=t-r,a=r;for(let t of e){if(i<t.beats)return{chord:t,start:a};i-=t.beats,a+=t.beats}return{chord:e[e.length-1],start:r+n-e[e.length-1].beats}}function j(e,t){let n=oe(t);return e.map(e=>pe(e,t,n)+(e.beats===4?``:`:${e.beats}`)).join(` `)}var xe={"jazzy-251":{label:`Jazzy 2-5-1`,text:`ii9 V13 Imaj9 vi9`},"soft-turnaround":{label:`Soft turnaround`,text:`Imaj9 vi9 ii9 V9sus4`},"rainy-minor":{label:`Rainy minor`,text:`i9 iv9 bVIImaj7 bIIImaj7`},"neo-soul":{label:`Neo soul`,text:`IVmaj9 iii7 vi9 Imaj9`},"late-night":{label:`Late night`,text:`i9 bVImaj7 iv9 V7b9`},"dreamy-two":{label:`Dreamy two-chord`,text:`Imaj9 IVmaj9`},"dorian-float":{label:`Dorian float`,text:`i9 IV9 i9 IV9`},"sunday-walk":{label:`Sunday walk`,text:`Imaj7 iii7 IVmaj7 iv6`},"city-lights":{label:`City lights`,text:`vi9 ii9 V13 Imaj9`},snowfall:{label:`Snowfall`,text:`Imaj9 bVIImaj9 IVmaj9 iv6`}},Se=Object.keys(xe);function Ce(e,t){let n=xe[e];return ye(n?n.text:e,t)}var we={piano:{label:`Upright piano`,range:[55,84],kind:`tonal`,gm:0},wurli:{label:`Wurlitzer`,range:[55,81],kind:`tonal`,gm:4},"fm-ep":{label:`FM keys`,range:[55,81],kind:`tonal`,gm:5},glock:{label:`Glockenspiel`,range:[72,96],kind:`tonal`,gm:9},marimba:{label:`Marimba`,range:[55,84],kind:`tonal`,gm:12},harp:{label:`Harp`,range:[48,84],kind:`tonal`,gm:46},pad:{label:`Warm pad`,range:[55,79],kind:`tonal`,gm:89},pluck:{label:`Soft pluck`,range:[60,84],kind:`tonal`,gm:24},bass:{label:`Round bass`,range:[31,55],kind:`tonal`,gm:33},drums:{label:`Drums`,range:[0,0],kind:`drums`,gm:0}},Te=Object.keys(we),Ee={pencil:{label:`Pencil`,stepsPerBeat:2,velocity:.7,note:`Melodies in eighth notes, held notes merge`},brush:{label:`Brush`,stepsPerBeat:1,velocity:.55,note:`Long soft notes on the beat`},chalk:{label:`Chalk`,stepsPerBeat:2,velocity:.6,note:`Two-note harmonies under the line`},spray:{label:`Spray`,stepsPerBeat:4,velocity:.45,note:`Scattered sparkly sixteenths`},stamp:{label:`Stamp`,stepsPerBeat:4,velocity:.75,note:`One hit per step, great for drums`}},De=Object.keys(Ee),Oe=[`smart`,`scale`,`pentatonic`,`chord`,`chromatic`],ke={kick:{label:`Kick`,gm:36},snare:{label:`Snare`,gm:38},brush:{label:`Brush snare`,gm:40},rim:{label:`Side stick`,gm:37},hat:{label:`Hi-hat`,gm:42},brushhat:{label:`Brush hat`,gm:44},openhat:{label:`Open hat`,gm:46},ride:{label:`Ride`,gm:51},tom:{label:`Tom`,gm:45}},Ae=Object.keys(ke),je=[`sticks`,`brushes`];function Me(e){return e===`brushes`?[`kick`,`tom`,`brush`,`rim`,`brushhat`,`openhat`,`ride`]:[`kick`,`tom`,`snare`,`rim`,`hat`,`openhat`,`ride`]}var Ne=[`sustain`,`lazy`,`stabs`,`arp`],Pe=[`roots`,`walking`,`dub`],Fe=[`piano`,`wurli`,`fm-ep`,`pad`,`harp`],Ie=[`dusty`,`brushes`,`halftime`,`bossa`,`sparse`],Le=[`rain`,`dusk`,`night-city`,`sunny`,`snow`],Re=[`roof`,`window`],ze=[`#e8897a`,`#8fae8b`,`#f2c48d`,`#a39bd1`,`#7fb7c9`,`#d98fb0`,`#c9a27e`];function Be(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Ve(e,t=`|`){return e.map(e=>ft(e)).join(t)}function He(e,t){return typeof t==`bigint`?t.toString():t}var Ue=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function We(e){return new Ue(e)}function Ge(e){return e==null}function Ke(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function qe(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Je(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ye(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Xe(e){return Ye(e._zod.def)??e._zod.def.shape}function Ze(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Je(this,t,e),e},enumerable:!0,configurable:!0})}function Qe(e,t,n){t in e?Je(e,t,n):e[t]=n}function $e(e,t,n,r){let i=Xe(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Ze(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Qe(e,a,r?r(n.value,a):n.value))}}function et(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Ze(e,n,()=>t[n]):Qe(e,n,r.value))}}function tt(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function nt(e){return JSON.stringify(e)}function rt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var it=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function at(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ot=We(()=>{if(en.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function st(e){if(at(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return at(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function ct(e){return st(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var lt=new Set([`string`,`number`,`symbol`]);function ut(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function dt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function M(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ft(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function pt(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var mt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ht={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function gt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return $e(i,e,_t(e,t)),dt(e,tt(n,{shape:i,checks:[]}))}function _t(e,t){let n=Xe(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function vt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(_t(e,t)),a={};return $e(a,e,Reflect.ownKeys(Xe(e)).filter(e=>!i.has(e))),dt(e,tt(n,{shape:a,checks:[]}))}function yt(e,t){if(!st(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Xe(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return dt(e,tt(e._zod.def,{shape:bt(e,t)}))}function bt(e,t){let n={};return $e(n,e,Reflect.ownKeys(Xe(e))),et(n,t),n}function xt(e,t){if(!st(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return dt(e,tt(e._zod.def,{shape:bt(e,t)}))}function St(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return $e(n,e,Reflect.ownKeys(Xe(e))),$e(n,t,Reflect.ownKeys(Xe(t))),dt(e,tt(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ct(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(_t(t,n)):void 0,o={};return $e(o,t,Reflect.ownKeys(Xe(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),dt(t,tt(t._zod.def,{shape:o,checks:[]}))}function wt(e,t,n){let r=n?new Set(_t(t,n)):void 0,i={};return $e(i,t,Reflect.ownKeys(Xe(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),dt(t,tt(t._zod.def,{shape:i}))}function Tt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Et(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Dt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Ot(e){return typeof e==`string`?e:e?.message}function kt(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function At(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function jt(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Ot(e.inst?._zod.def?.error?.(e))??Ot(a?.(e))??Ot(t?.error?.(e))??Ot(n.customError?.(e))??Ot(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var Mt=/[\uD800-\uDBFF]/;function Nt(e){let t=e.length;if(!Mt.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Pt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Ft(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function It(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Lt(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Vt(e,n,r.value)}}function Rt(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function zt(e,t,n){return Rt(e,t,n,!1)}function Bt(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Rt(this,n,r(this))},set(e){Rt(this,n,e)}})}return t}function Vt(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Rt(this,t,n.bind(this))},set(e){Rt(this,t,e)}})}function Ht(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Ut,Wt=!1,Gt={configurable:!0,get(){Wt=!0}};function N(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&Ut!==e._zod?Ut=void 0:(Ut=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Gt);let e=Wt;Wt=!1;try{let r=n(this);return Wt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Wt||=e,r}catch(n){throw delete this[t],Wt||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Kt(e,t,n,r){let i=Ht(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var qt=`~constantCatch`;function Jt(e){let t=()=>e;return t[qt]=!0,t}var Yt,Xt={value:void 0,enumerable:!1},P=`captureStackTrace`in Error?Error:null;function Zt(e){let t=P;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return P=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function F(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){Xt.value=new a(r);try{Object.defineProperty(n,"_zod",Xt)}finally{Xt.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Lt(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Zt(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Qt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},$t=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Yt=globalThis).__zod_globalConfig??(Yt.__zod_globalConfig={});var en=globalThis.__zod_globalConfig;function tn(e){return e&&Object.assign(en,e),en}function nn(){let e=this._zod;return e.message??=JSON.stringify(e.def,He,2),e.message}function rn(e){this._zod.message=e}var an={get:nn,set:rn,enumerable:!0,configurable:!0},on={value:void 0,enumerable:!1},sn=new WeakSet([Object.prototype,Error.prototype]),cn=F(`$ZodError`,(e,t)=>{e.name=`$ZodError`,on.value=t,Object.defineProperty(e,"issues",on),on.value=void 0,Object.defineProperty(e,"message",an);let n=Object.getPrototypeOf(e);sn.has(n)||(sn.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function ln(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function un(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?ln(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function dn(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function fn(e,t){return{callee:t?.callee??e,Err:t?.Err}}var pn=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Qt;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>jt(e,o,tn())));throw it(n,a?.callee??t),n}return s.value};return t},mn=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>jt(e,o,tn())));throw it(n,a?.callee??t),n}return s.value};return t},hn=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Qt;return a.issues.length?gn(e,a.issues,i):{success:!0,data:a.value}};function gn(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>jt(e,n,tn()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var _n=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?gn(e,a.issues,i):{success:!0,data:a.value}},vn=Symbol.for(`zod.compile.invalid`),yn=Symbol.for(`zod.compile.fallback`),bn=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==vn)return!0;if(r.definite===!0&&n===void 0)return!1}return xn(e,t,n)});function xn(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[yn]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Qt;return a.issues.length===0}var Sn=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Cn=e=>{let t=pn(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,fn(n,a))};return n},wn=e=>{let t=pn(e),n=(e,r,i,a)=>t(e,r,i,fn(n,a));return n},Tn=e=>{let t=mn(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,fn(n,a))};return n},En=e=>{let t=mn(e),n=async(e,r,i,a)=>await t(e,r,i,fn(n,a));return n},Dn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return hn(e)(t,n,i)},On=e=>(t,n,r)=>hn(e)(t,n,r),kn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return _n(e)(t,n,i)},An=e=>async(t,n,r)=>_n(e)(t,n,r),jn=/^[cC][0-9a-z]{6,}$/,Mn=/^[0-9a-z]+$/,Nn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Pn=/^[0-9a-vA-V]{20}$/,Fn=/^[A-Za-z0-9]{27}$/,In=/^[a-zA-Z0-9_-]{21}$/;function Ln(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Rn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,zn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Bn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Vn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Hn=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Un(){return new RegExp(Hn,`u`)}var Wn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Gn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Kn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,qn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Jn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Yn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Xn=/^https?$/,Zn=/^\+[1-9]\d{6,14}$/,Qn=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function $n(e){return RegExp(`^${e}$`)}var er=$n(Qn);function tr(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function nr(e){return RegExp(`^${tr(e)}$`)}function rr(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${tr({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${tr({precision:e.precision})}`:n;return RegExp(`^${Qn}T(?:${r})$`)}var ir=/^[\s\S]{0,}$/,ar=/^-?\d+(?:\.\d+)?$/,or=/^(?:true|false)$/i,sr=/^[^A-Z]*$/,cr=/^[^a-z]*$/,lr=F(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ur=e=>{let t=e.value;return!Ge(t)&&t.length!==void 0},dr={number:`number`,bigint:`bigint`,object:`date`},fr=F(`$ZodCheckLessThan`,(e,t)=>{lr.init(e,t);let n=dr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:dr[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),pr=F(`$ZodCheckGreaterThan`,(e,t)=>{lr.init(e,t);let n=dr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:dr[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mr=F(`$ZodCheckMultipleOf`,(e,t)=>{lr.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):qe(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),hr=F(`$ZodCheckNumberFormat`,(e,t)=>{lr.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=mt[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),gr=F(`$ZodCheckMaxLength`,(e,t)=>{var n;lr.init(e,t),(n=e._zod.def).when??(n.when=ur),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Nt(r):i)<=t.maximum)return;let a=Pt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),_r=F(`$ZodCheckMinLength`,(e,t)=>{var n;lr.init(e,t),(n=e._zod.def).when??(n.when=ur),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Nt(r):i)>=t.minimum)return;let a=Pt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),vr=F(`$ZodCheckLengthEquals`,(e,t)=>{var n;lr.init(e,t),(n=e._zod.def).when??(n.when=ur),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Nt(r):i;if(a===t.length)return;let o=Pt(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),yr=F(`$ZodCheckStringFormat`,(e,t)=>{var n,r;lr.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),br=F(`$ZodCheckRegex`,(e,t)=>{yr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),xr=F(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=sr,yr.init(e,t)}),Sr=F(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=cr,yr.init(e,t)}),Cr=F(`$ZodCheckIncludes`,(e,t)=>{lr.init(e,t);let n=ut(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),wr=F(`$ZodCheckStartsWith`,(e,t)=>{lr.init(e,t);let n=RegExp(`^${ut(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Tr=F(`$ZodCheckEndsWith`,(e,t)=>{lr.init(e,t);let n=RegExp(`.*${ut(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Er=F(`$ZodCheckOverwrite`,(e,t)=>{lr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Dr=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
10
|
+
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
11
|
+
`)}\n};`)(...Object.values(this.closed))}},Or={major:4,minor:6,patch:7},kr=F(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Or;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=Tt(t),a;for(let o of n){if(o._zod.def.when){if(Et(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Qt;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(At(t.issues,n,e),i||=Tt(t,n))});else{if(t.issues.length===n)continue;At(t.issues,n,e),i||=Tt(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(Tt(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Qt;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Qt;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return zt(this,`~standard`,Mr(this))},set"~standard"(e){Rt(this,`~standard`,e)}}),Ar=(e,t)=>e.issues.length?{issues:e.issues.map(e=>jt(e,t,tn()))}:{value:e.value};async function jr(e,t){let n={async:!0};return Ar(await e._zod.run({value:t,issues:[]},n),n)}function Mr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Ar(r,n)}catch{}return jr(e,t)},vendor:`zod`,version:1}}var Nr=F(`$ZodString`,(e,t)=>{kr.init(e,t),e._zod.pattern=t.pattern??ir,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Pr=F(`$ZodStringFormat`,(e,t)=>{yr.init(e,t),Nr.init(e,t)}),Fr=F(`$ZodGUID`,(e,t)=>{t.pattern??=zn,Pr.init(e,t)}),Ir=F(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Bn(e)}else t.pattern??=Bn();Pr.init(e,t)}),Lr=F(`$ZodEmail`,(e,t)=>{t.pattern??=Vn,Pr.init(e,t)});function Rr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function zr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Rr(e)||2:Br(e,t)}function Br(e,t){if(!t.normalize&&t.protocol?.source===Xn.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var Vr=/[\t\n\r]/g;function Hr(e){return e.replace(Vr,``)}function Ur(e,t){return t.lastIndex=0,t.test(e.hostname)}function Wr(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var Gr=F(`$ZodURL`,(e,t)=>{Pr.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=zr(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Hr(r);return}t.hostname&&!Ur(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Wr(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Hr(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Kr=F(`$ZodEmoji`,(e,t)=>{t.pattern??=Un(),Pr.init(e,t)}),qr=F(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?In:Ln(t.length),Pr.init(e,t)}),Jr=F(`$ZodCUID`,(e,t)=>{t.pattern??=jn,Pr.init(e,t)}),Yr=F(`$ZodCUID2`,(e,t)=>{t.pattern??=Mn,Pr.init(e,t)}),Xr=F(`$ZodULID`,(e,t)=>{t.pattern??=Nn,Pr.init(e,t)}),Zr=F(`$ZodXID`,(e,t)=>{t.pattern??=Pn,Pr.init(e,t)}),Qr=F(`$ZodKSUID`,(e,t)=>{t.pattern??=Fn,Pr.init(e,t)}),$r=F(`$ZodISODateTime`,(e,t)=>{t.pattern??=rr(t),Pr.init(e,t)}),ei=F(`$ZodISODate`,(e,t)=>{t.pattern??=er,Pr.init(e,t)}),ti=F(`$ZodISOTime`,(e,t)=>{t.pattern??=nr(t),Pr.init(e,t)}),ni=F(`$ZodISODuration`,(e,t)=>{t.pattern??=Rn,Pr.init(e,t)}),ri=F(`$ZodIPv4`,(e,t)=>{t.pattern??=Wn,Pr.init(e,t)}),ii=/^[0-9a-fA-F:.]+$/;function ai(e){return ii.test(e)?Rr(`http://[${e}]`):!1}var oi=F(`$ZodIPv6`,(e,t)=>{t.pattern??=Gn,Pr.init(e,t),e._zod.check=n=>{ai(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),si=F(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Kn,Pr.init(e,t)});function ci(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:ai(n)}var li=F(`$ZodCIDRv6`,(e,t)=>{t.pattern??=qn,Pr.init(e,t),e._zod.check=n=>{ci(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function ui(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var di=/^[0-9a-zA-Z+/]*={0,2}$/,fi=F(`$ZodBase64`,(e,t)=>{t.pattern??=di,Pr.init(e,t),e._zod.check=n=>{ui(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),pi=/^[A-Za-z0-9_-]*$/;function mi(e){if(!pi.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ui(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var hi=F(`$ZodBase64URL`,(e,t)=>{t.pattern??=pi,Pr.init(e,t),e._zod.check=n=>{mi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),gi=F(`$ZodE164`,(e,t)=>{t.pattern??=Zn,Pr.init(e,t)});function _i(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var vi=F(`$ZodJWT`,(e,t)=>{Pr.init(e,t),e._zod.check=n=>{_i(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),yi=F(`$ZodNumber`,(e,t)=>{kr.init(e,t),e._zod.pattern=ar,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),bi=F(`$ZodNumberFormat`,(e,t)=>{hr.init(e,t),yi.init(e,t)}),xi=F(`$ZodBoolean`,(e,t)=>{kr.init(e,t),e._zod.pattern=or,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Si=F(`$ZodUnknown`,(e,t)=>{kr.init(e,t),e._zod.parse=e=>e}),Ci=F(`$ZodNever`,(e,t)=>{kr.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function wi(e,t){let n=kt(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of kt(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,At(n.issues,t,e),n}}return i(n,a)}}var Ti=e=>Array.isArray(e)?e.length:-1;function Ei(e,t,n){e.issues.length&&t.issues.push(...Dt(n,e.issues)),t.value[n]=e.value}var Di=F(`$ZodArray`,(e,t)=>{kr.init(e,t);let n=en.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Ei(t,r,e)));else if(Ei(c,r,e),s&&c.issues.length!==0&&Tt(c))break}return o.length?Promise.all(o).then(()=>r):r},wi(e,Ti)});function Oi(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Dt(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var ki=[];function Ai(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ki,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=pt(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function ji(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(Tt(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Oi(e,n,i,t,d,f))):Oi(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Mi=F(`$ZodObject`,(e,t)=>{kr.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=We(()=>Ai(t));N(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Je(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=at,o=t.catchall,s,c=en.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(Tt(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Oi(n,t,e,r,a,o))):Oi(s,t,e,r,a,o)}return o?ji(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Ni=F(`$ZodObjectJIT`,(e,t)=>{Mi.init(e,t);let n=e._zod.parse,r=We(()=>Ai(t)),i=en.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Dr([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
12
|
+
let ${e}_ab = false;
|
|
13
|
+
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
14
|
+
const iss = ${e}.issues[i];
|
|
15
|
+
iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
|
|
16
|
+
payload.issues.push(iss);
|
|
17
|
+
if (iss.continue !== true) ${e}_ab = true;
|
|
18
|
+
}
|
|
19
|
+
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
20
|
+
payload.value = newResult;
|
|
21
|
+
return payload;
|
|
22
|
+
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:nt(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
23
|
+
const ${n}_present = ${i};
|
|
24
|
+
if (!${n}.issues.length || ${n}_present) {
|
|
25
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (${e}) {
|
|
29
|
+
newResult[${r}] = ${n}.value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
`)}else f?(o.write(`
|
|
34
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
35
|
+
}
|
|
36
|
+
`),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
|
|
37
|
+
if (${n}.value !== undefined || ${i}) {
|
|
38
|
+
newResult[${r}] = ${n}.value;
|
|
39
|
+
}
|
|
40
|
+
`)):o.write(`
|
|
41
|
+
const ${n}_present = ${i};
|
|
42
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
43
|
+
}
|
|
44
|
+
if (!${n}_present && !${n}.issues.length) {
|
|
45
|
+
payload.issues.push({
|
|
46
|
+
code: "invalid_type",
|
|
47
|
+
expected: "nonoptional",
|
|
48
|
+
input: undefined,
|
|
49
|
+
path: [${r}]
|
|
50
|
+
});
|
|
51
|
+
if (ctx && ctx.abortEarly) {
|
|
52
|
+
payload.value = newResult;
|
|
53
|
+
return payload;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (${n}_present) {
|
|
58
|
+
newResult[${r}] = ${n}.value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=at,c=!en.jitless,l=c&&ot.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?ji([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Pi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Tt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>jt(e,r,tn())))}),t)}var Fi=F(`$ZodUnion`,(e,t)=>{kr.init(e,t),N(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),N(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),N(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),N(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Ke(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Pi(t,r,e,i)):Pi(o,r,e,i)}});function Ii(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var Li=F(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Fi.init(e,t);let n=e._zod.parse;N(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||Je(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=Ye(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=We(()=>Ii(t));e._zod.parse=(i,a)=>{let o=i.value;if(!at(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),Ri=F(`$ZodIntersection`,(e,t)=>{kr.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Bi(e,t,n)):Bi(e,i,a)}});function zi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(st(e)&&st(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=zi(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=zi(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Bi(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=zi(t.value,n.value);if(!c.valid){if(Tt(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Vi=F(`$ZodEnum`,(e,t)=>{kr.init(e,t);let n=Be(t.entries),r=new Set(n);e._zod.values=r,N(e,`pattern`,e=>{let t=Be(e.def.entries).filter(e=>lt.has(typeof e));return RegExp(t.length?`^(${t.map(e=>ut(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Hi=F(`$ZodLiteral`,(e,t)=>{kr.init(e,t);let n=new Set(t.values);e._zod.values=n,N(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?ut(e):e?ut(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Ui=F(`$ZodTransform`,(e,t)=>{kr.init(e,t),e._zod.optin=`optional`,en.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $t(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Qt;return n.value=i,n}});function Wi(e,t){return e.value=t.issues.length?void 0:t.value,e}var Gi=F(`$ZodOptional`,(e,t)=>{kr.init(e,t),N(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,N(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),N(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Ke(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Wi(e,t)):Wi(e,r)}return t.innerType._zod.run(e,n)}}),Ki=F(`$ZodExactOptional`,(e,t)=>{Gi.init(e,t),N(e,`values`,e=>e.def.innerType._zod.values),N(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),qi=F(`$ZodNullable`,(e,t)=>{kr.init(e,t),N(e,`optin`,e=>e.def.innerType._zod.optin),N(e,`optout`,e=>e.def.innerType._zod.optout),N(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Ke(t.source)}|null)$`):void 0}),N(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ji=F(`$ZodDefault`,(e,t)=>{kr.init(e,t),e._zod.optin=`defaulted`,N(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Yi(e,t)):Yi(r,t)}});function Yi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Xi=F(`$ZodPrefault`,(e,t)=>{kr.init(e,t),e._zod.optin=`defaulted`,N(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Zi=F(`$ZodNonOptional`,(e,t)=>{kr.init(e,t),N(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Qi(t,e)):Qi(i,e)}});function Qi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function $i(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>jt(e,r,tn()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var ea=F(`$ZodCatch`,(e,t)=>{kr.init(e,t),N(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),N(e,`optout`,e=>e.def.innerType._zod.optout),N(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>$i(e,r,t,n)):$i(e,r,t,n)}}),ta=F(`$ZodPipe`,(e,t)=>{kr.init(e,t),N(e,`values`,e=>e.def.in._zod.values),N(e,`optin`,e=>e.def.in._zod.optin),N(e,`optout`,e=>e.def.out._zod.optout),N(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>na(e,t.in,n)):na(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>na(e,t.out,n)):na(r,t.out,n)}});function na(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var ra=F(`$ZodReadonly`,(e,t)=>{kr.init(e,t),N(e,`propValues`,e=>e.def.innerType._zod.propValues),N(e,`values`,e=>e.def.innerType._zod.values),N(e,`optin`,e=>e.def.innerType?._zod?.optin),N(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ia):ia(r)}});function ia(e){return e.memo||(e.value=Object.freeze(e.value)),e}var aa=F(`$ZodCustom`,(e,t)=>{lr.init(e,t),kr.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>oa(t,n,r,e));oa(i,n,r,e)}});function oa(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(It(e))}}var sa=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},ca=`~memo`,I=[];function la(e){return typeof e==`object`&&!!e}function ua(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var da=new WeakMap,fa=0,pa=1,ma=2;function ha(e,t,n){let r=da.get(e);if(r!==void 0)return r?ma:fa;if(t.has(e))return ma;t.add(e);let i=fa,a=e=>{if(i!==ma&&e?._zod){let r=ha(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=fa;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?pa:o.value?._zod?ha(o.value,t,n):fa;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Ye(c);s(e?o(e,!0):pa),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?ha(r,t,!1):pa);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),ga(e,i)}function ga(e,t){return t!==pa&&da.set(e,t===ma),t}function _a(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var va,ya=[],ba={alloc(e,t,n){let r=va;if(!r)return n;va=void 0;let i={value:n,issues:null};return r.set(t.value,i),ya.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Sa(n,e.value))throw new sa;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=ha(e,new Set,!1);if(i===fa)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===ma||r?n=!0:r=!0}let l=s.value;if(!la(l))return t(s,c);let u=c[ca];u||(u={buckets:new WeakMap,backEdges:void 0},c[ca]=u);let d;i===c?d=a:(d=_a(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...ua(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;va=d;let p=ya.length,m=t(s,c);va=void 0;let h=ya.length>p?ya.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?ua(e.issues):I),e)):(h&&(h.issues=m.issues.length?ua(m.issues):I),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function xa(){return ba}function Sa(e,t){let n=e[ca]?.backEdges;return n!==void 0&&la(t)&&n.has(t)}var Ca=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Ft(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${ft(e.values[0])}`:`Invalid option: expected one of ${Ve(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Ve(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function wa(){return{localeError:Ca()}}var Ta,Ea=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Da(){return new Ea}(Ta=globalThis).__zod_globalRegistry??(Ta.__zod_globalRegistry=Da());var Oa=globalThis.__zod_globalRegistry;function ka(e){return e.checks&&=[...e.checks],e}function Aa(e,t){return new e(ka({type:`string`,...M(t)}))}function ja(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...M(t)})}function Ma(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...M(t)})}function Na(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...M(t)})}function Pa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...M(t)})}function Fa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...M(t)})}function Ia(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...M(t)})}function La(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...M(t)})}function Ra(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...M(t)})}function za(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...M(t)})}function Ba(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...M(t)})}function Va(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...M(t)})}function Ha(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...M(t)})}function Ua(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...M(t)})}function Wa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...M(t)})}function Ga(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...M(t)})}function Ka(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...M(t)})}function qa(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...M(t)})}function Ja(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...M(t)})}function Ya(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...M(t)})}function Xa(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...M(t)})}function Za(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...M(t)})}function Qa(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...M(t)})}function $a(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...M(t)})}function eo(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...M(t)})}function to(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...M(t)})}function no(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...M(t)})}function ro(e,t){return new e(ka({type:`number`,checks:[],...M(t)}))}function io(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...M(t)})}function ao(e,t){return new e({type:`boolean`,...M(t)})}function oo(e){return new e({type:`unknown`})}function so(e,t){return new e({type:`never`,...M(t)})}function co(e,t){return new fr({check:`less_than`,...M(t),value:e,inclusive:!1})}function lo(e,t){return new fr({check:`less_than`,...M(t),value:e,inclusive:!0})}function uo(e,t){return new pr({check:`greater_than`,...M(t),value:e,inclusive:!1})}function fo(e,t){return new pr({check:`greater_than`,...M(t),value:e,inclusive:!0})}function po(e,t){return new mr({check:`multiple_of`,...M(t),value:e})}function mo(e,t){return new gr({check:`max_length`,...M(t),maximum:e})}function ho(e,t){return new _r({check:`min_length`,...M(t),minimum:e})}function go(e,t){return new vr({check:`length_equals`,...M(t),length:e})}function _o(e,t){return new br({check:`string_format`,format:`regex`,...M(t),pattern:e})}function vo(e){return new xr({check:`string_format`,format:`lowercase`,...M(e)})}function yo(e){return new Sr({check:`string_format`,format:`uppercase`,...M(e)})}function bo(e,t){return new Cr({check:`string_format`,format:`includes`,...M(t),includes:e})}function xo(e,t){return new wr({check:`string_format`,format:`starts_with`,...M(t),prefix:e})}function So(e,t){return new Tr({check:`string_format`,format:`ends_with`,...M(t),suffix:e})}function Co(e){return new Er({check:`overwrite`,tx:e})}function wo(e){return Co(t=>t.normalize(e))}function To(){return Co(e=>e.trim())}function Eo(){return Co(e=>e.toLowerCase())}function Do(){return Co(e=>e.toUpperCase())}function Oo(){return Co(e=>rt(e))}function ko(e,t,n){return new e({type:`array`,element:t,...M(n)})}function Ao(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...M(n)})}function jo(e,t){let n=Mo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(It(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(It(r))}},e(t.value,t)),t);return n}function Mo(e,t){let n=new lr({check:`custom`,...M(t)});return n._zod.check=e,n}function No(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Je(e,t,n[t]);return e}function Po(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Oa,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Fo(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function Io(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Io(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&No(o.schema,c),t.io===`input`&&Ko(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Lo(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Ro(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Lo(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Lo(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
62
|
+
|
|
63
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function zo(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;zo(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Bo=new Set([`type`,`properties`,`required`,`additionalProperties`]),Vo=[`oneOf`,`anyOf`];function Ho(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Uo(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Bo.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Ho(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Je(n,r,e.length===1?e[0]:Uo(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Ho(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Wo(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Bo)if(t in e)return;let n=t.filter(e=>Vo.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Uo(t);else{let e=n[0],i=Vo.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Uo([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,No(e,r))}function Go(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):No(i,s),No(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())zo(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Wo(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}No(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Je(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:qo(t,`input`,e.processors),output:qo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ko(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ko(r.element,n);if(r.type===`set`)return Ko(r.valueType,n);if(r.type===`lazy`)return Ko(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Ko(r.innerType,n);if(r.type===`intersection`)return Ko(r.left,n)||Ko(r.right,n);if(r.type===`record`||r.type===`map`)return Ko(r.keyType,n)||Ko(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ko(r.in,n)||Ko(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ko(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ko(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ko(e,n))return!0;return!!(r.rest&&Ko(r.rest,n))}return!1}var L=(e,t={})=>n=>{let r=Po({...n,processors:t});return Io(e,r),Ro(r,e),Go(r,e)},qo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Po({...i??{},target:a,io:t,processors:n});return Io(e,o),Ro(o,e),Go(o,e)},Jo=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Yo=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Xo=(e,t)=>{Jo(e,`minimum`,t),Yo(e,`maximum`,t)},Zo=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Qo=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},$o=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},es=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},ts=(e,t)=>Jo(e,`minimum`,t.minimum),ns=(e,t)=>Yo(e,`maximum`,t.maximum),rs=e=>(t,n)=>{es(t,n.format);let[r,i]=e[n.format];Jo(t,`minimum`,r),Yo(t,`maximum`,i)},is={greater_than:(e,t)=>Jo(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Yo(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Zo(e,t.value),number_format:rs(mt),bigint_format:rs(ht),min_length:ts,max_length:ns,length_equals:(e,t)=>Xo(e,t.length),min_size:ts,max_size:ns,size_equals:(e,t)=>Xo(e,t.size),string_format:(e,t)=>{es(e,t.format),t.pattern&&Qo(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>$o(e,t.mime)};function as(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)is[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Jo(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Jo(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Yo(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Yo(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Zo(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&$o(t,i.mime);for(let e of i.patterns??[])Qo(t,e);return t}var os={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ss=new Map([[di,Jn],[pi,Yn]]),cs=e=>ss.get(e)??e,ls=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=as(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=os[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(cs);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},us=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=as(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Fo(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},ds=(e,t,n,r)=>{n.type=`boolean`},fs=(e,t,n,r)=>{n.not={}},ps=(e,t,n,r)=>{let i=e._zod.def,a=Be(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},ms=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Fo(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Fo(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},hs=(e,t,n,r)=>{Fo(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},gs=(e,t,n,r)=>{Fo(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},_s=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=as(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Io(a.element,t,{...r,path:[...r.path,`items`]})};function vs(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?vs(t.out):t.type===`catch`?vs(t.innerType):e._zod.optin}var ys=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Fo(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Je(i.properties,e,Io(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?vs(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Io(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},bs=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Io(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},xs=(e,t,n,r)=>{let i=e._zod.def,a=Io(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Io(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Ss=(e,t,n,r)=>{let i=e._zod.def,a=Io(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Cs=(e,t,n,r)=>{let i=e._zod.def;Io(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ws=Symbol();function Ts(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Fo(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),ws):JSON.parse(o)}var Es=(e,t,n,r)=>{let i=e._zod.def;Io(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Ts(i.defaultValue,e,t,n,r);o!==ws&&(n.default=o)},Ds=(e,t,n,r)=>{let i=e._zod.def;Io(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Ts(i.defaultValue,e,t,n,r);o!==ws&&(n._prefault=o)},Os=(e,t,n,r)=>{let i=e._zod.def;Io(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Fo(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},ks=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Io(o,t,r);let s=t.seen.get(e);s.ref=o},As=(e,t,n,r)=>{let i=e._zod.def;Io(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},js=(e,t,n,r)=>{let i=e._zod.def;Io(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ms=new WeakSet([Object.prototype,Error.prototype]);function Ns(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var Ps=F(`ZodError`,(e,t)=>{cn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Ms.has(n)||(Ms.add(n),Ns(n,`format`,e=>t=>dn(e,t)),Ns(n,`flatten`,e=>t=>un(e,t)),Ns(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,He,2)}),Ns(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,He,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Fs=pn(Ps),Is=mn(Ps),Ls=hn(Ps),Rs=_n(Ps),zs=Cn(Ps),Bs=wn(Ps),Vs=Tn(Ps),Hs=En(Ps),Us=Dn(Ps),Ws=On(Ps),Gs=kn(Ps),Ks=An(Ps);function qs(){en.localeError||tn(wa())}function Js(){en.memoizer||tn({memoizer:xa()})}var Ys=F(`ZodType`,(e,t)=>(qs(),kr.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(tt(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return dt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(dl(e,t))},superRefine(e,t){return this.check(fl(e,t))},overwrite(e){return this.check(Co(e))},optional(){return qc(this)},exactOptional(){return Yc(this)},nullable(){return Zc(this)},nullish(){return qc(Zc(this))},nonoptional(e){return rl(this,e)},array(){return Nc(this)},or(e){return Ic([this,e])},and(e){return Bc(this,e)},transform(e){return sl(this,Gc(e))},default(e){return $c(this,e)},prefault(e){return tl(this,e)},catch(e){return al(this,e)},pipe(e){return sl(this,e)},readonly(){return ll(this)},describe(e){let t=this.clone();return Oa.add(t,{description:e}),t},meta(...e){if(e.length===0)return Oa.get(this);let t=this.clone();return Oa.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return zt(this,`~standard`,{...Mr(this),jsonSchema:{input:qo(this,`input`),output:qo(this,`output`)}})},set"~standard"(e){Rt(this,`~standard`,e)},parse:function e(t,n){return Fs(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Is(this,t,n,{callee:e})},safeParse(e,t){return Ls(this,e,t)},async safeParseAsync(e,t){return Rs(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Rt(this,`spa`,e)},validate(e,t){return bn(this,e,t)},validateAsync(e,t){return Sn(this,e,t)},encode:function e(t,n){return zs(this,t,n,{callee:e})},decode:function e(t,n){return Bs(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Vs(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Hs(this,t,n,{callee:e})},safeEncode(e,t){return Us(this,e,t)},safeDecode(e,t){return Ws(this,e,t)},async safeEncodeAsync(e,t){return Gs(this,e,t)},async safeDecodeAsync(e,t){return Ks(this,e,t)},toJSONSchema(e){return L(this,{})(e)},get description(){return Oa.get(this)?.description},get _def(){return this._zod.def}}),Xs=F(`_ZodString`,(e,t)=>{Nr.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r)},Bt({format:e=>as(e).format??null,minLength:e=>as(e).minimum??null,maxLength:e=>as(e).maximum??null},{regex(...e){return this.check(_o(...e))},includes(...e){return this.check(bo(...e))},startsWith(...e){return this.check(xo(...e))},endsWith(...e){return this.check(So(...e))},min(...e){return this.check(ho(...e))},max(...e){return this.check(mo(...e))},length(...e){return this.check(go(...e))},nonempty(...e){return this.check(ho(1,...e))},lowercase(e){return this.check(vo(e))},uppercase(e){return this.check(yo(e))},trim(){return this.check(To())},normalize(...e){return this.check(wo(...e))},toLowerCase(){return this.check(Eo())},toUpperCase(){return this.check(Do())},slugify(){return this.check(Oo())}})),Zs=F(`ZodString`,(e,t)=>{Nr.init(e,t),Xs.init(e,t)},{email(e){return this.check(ja(rc,e))},url(e){return this.check(La(oc,e))},jwt(e){return this.check(Qa(xc,e))},emoji(e){return this.check(Ra(sc,e))},guid(e){return this.check(Ma(ic,e))},uuid(e){return this.check(Na(ac,e))},uuidv4(e){return this.check(Pa(ac,e))},uuidv6(e){return this.check(Fa(ac,e))},uuidv7(e){return this.check(Ia(ac,e))},nanoid(e){return this.check(za(cc,e))},cuid(e){return this.check(Ba(lc,e))},cuid2(e){return this.check(Va(uc,e))},ulid(e){return this.check(Ha(dc,e))},base64(e){return this.check(Ya(vc,e))},base64url(e){return this.check(Xa(yc,e))},xid(e){return this.check(Ua(fc,e))},ksuid(e){return this.check(Wa(pc,e))},ipv4(e){return this.check(Ga(mc,e))},ipv6(e){return this.check(Ka(hc,e))},cidrv4(e){return this.check(qa(gc,e))},cidrv6(e){return this.check(Ja(_c,e))},e164(e){return this.check(Za(bc,e))},datetime(e){return this.check($a($s,e))},date(e){return this.check(eo(ec,e))},time(e){return this.check(to(tc,e))},duration(e){return this.check(no(nc,e))}});function R(e){return Aa(Zs,e)}var Qs=F(`ZodStringFormat`,(e,t)=>{Pr.init(e,t),Xs.init(e,t)}),$s=F(`ZodISODateTime`,(e,t)=>{$r.init(e,t),Qs.init(e,t)}),ec=F(`ZodISODate`,(e,t)=>{ei.init(e,t),Qs.init(e,t)}),tc=F(`ZodISOTime`,(e,t)=>{ti.init(e,t),Qs.init(e,t)}),nc=F(`ZodISODuration`,(e,t)=>{ni.init(e,t),Qs.init(e,t)}),rc=F(`ZodEmail`,(e,t)=>{Lr.init(e,t),Qs.init(e,t)}),ic=F(`ZodGUID`,(e,t)=>{Fr.init(e,t),Qs.init(e,t)}),ac=F(`ZodUUID`,(e,t)=>{Ir.init(e,t),Qs.init(e,t)}),oc=F(`ZodURL`,(e,t)=>{Gr.init(e,t),Qs.init(e,t)}),sc=F(`ZodEmoji`,(e,t)=>{Kr.init(e,t),Qs.init(e,t)}),cc=F(`ZodNanoID`,(e,t)=>{qr.init(e,t),Qs.init(e,t)}),lc=F(`ZodCUID`,(e,t)=>{Jr.init(e,t),Qs.init(e,t)}),uc=F(`ZodCUID2`,(e,t)=>{Yr.init(e,t),Qs.init(e,t)}),dc=F(`ZodULID`,(e,t)=>{Xr.init(e,t),Qs.init(e,t)}),fc=F(`ZodXID`,(e,t)=>{Zr.init(e,t),Qs.init(e,t)}),pc=F(`ZodKSUID`,(e,t)=>{Qr.init(e,t),Qs.init(e,t)}),mc=F(`ZodIPv4`,(e,t)=>{ri.init(e,t),Qs.init(e,t)}),hc=F(`ZodIPv6`,(e,t)=>{oi.init(e,t),Qs.init(e,t)}),gc=F(`ZodCIDRv4`,(e,t)=>{si.init(e,t),Qs.init(e,t)}),_c=F(`ZodCIDRv6`,(e,t)=>{li.init(e,t),Qs.init(e,t)}),vc=F(`ZodBase64`,(e,t)=>{fi.init(e,t),Qs.init(e,t)}),yc=F(`ZodBase64URL`,(e,t)=>{hi.init(e,t),Qs.init(e,t)}),bc=F(`ZodE164`,(e,t)=>{gi.init(e,t),Qs.init(e,t)}),xc=F(`ZodJWT`,(e,t)=>{vi.init(e,t),Qs.init(e,t)}),Sc=F(`ZodNumber`,(e,t)=>{yi.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.isFinite=!0},Bt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=as(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=as(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=as(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>as(e).format??null},{gt(e,t){return this.check(uo(e,t))},gte(e,t){return this.check(fo(e,t))},min(e,t){return this.check(fo(e,t))},lt(e,t){return this.check(co(e,t))},lte(e,t){return this.check(lo(e,t))},max(e,t){return this.check(lo(e,t))},int(e){return this.check(Tc(e))},safe(e){return this.check(Tc(e))},positive(e){return this.check(uo(0,e))},nonnegative(e){return this.check(fo(0,e))},negative(e){return this.check(co(0,e))},nonpositive(e){return this.check(lo(0,e))},multipleOf(e,t){return this.check(po(e,t))},step(e,t){return this.check(po(e,t))},finite(){return this}}));function Cc(e){return ro(Sc,e)}var wc=F(`ZodNumberFormat`,(e,t)=>{bi.init(e,t),Sc.init(e,t)});function Tc(e){return io(wc,e)}var Ec=F(`ZodBoolean`,(e,t)=>{xi.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r)});function Dc(e){return ao(Ec,e)}var Oc=F(`ZodUnknown`,(e,t)=>{Si.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function kc(){return oo(Oc)}var Ac=F(`ZodNever`,(e,t)=>{Ci.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r)});function jc(e){return so(Ac,e)}var Mc=F(`ZodArray`,(e,t)=>{Js(),Di.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.element=t.element},{min(e,t){return this.check(ho(e,t))},nonempty(e){return this.check(ho(1,e))},max(e,t){return this.check(mo(e,t))},length(e,t){return this.check(go(e,t))},unwrap(){return this.element}});function Nc(e,t){return ko(Mc,e,t)}var Pc=F(`ZodObject`,(e,t)=>{Js(),Ni.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),Kt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Hc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(tt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(tt(this._zod.def,{catchall:kc()}))},loose(){return this.clone(tt(this._zod.def,{catchall:kc()}))},strict(){return this.clone(tt(this._zod.def,{catchall:jc()}))},strip(){return this.clone(tt(this._zod.def,{catchall:void 0}))},extend(e){return yt(this,e)},safeExtend(e){return xt(this,e)},merge(e){return St(this,e)},pick(e){return gt(this,e)},omit(e){return vt(this,e)},partial(...e){return Ct(Kc,this,e[0])},exactPartial(...e){return Ct(Jc,this,e[0],`exactPartial`)},required(...e){return wt(nl,this,e[0])}});function z(e,t){return new Pc({type:`object`,shape:e??{},...M(t)})}var Fc=F(`ZodUnion`,(e,t)=>{Fi.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.options=t.options});function Ic(e,t){return new Fc({type:`union`,options:e,...M(t)})}var Lc=F(`ZodDiscriminatedUnion`,(e,t)=>{Fc.init(e,t),Li.init(e,t)});function Rc(e,t,n){return new Lc({type:`union`,options:t,discriminator:e,...M(n)})}var zc=F(`ZodIntersection`,(e,t)=>{Ri.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r)});function Bc(e,t){return new zc({type:`intersection`,left:e,right:t})}var Vc=F(`ZodEnum`,(e,t)=>{Vi.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Vc({...t,checks:[],...M(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Vc({...t,checks:[],...M(r),entries:i})}});function Hc(e,t){return new Vc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...M(t)})}var Uc=F(`ZodLiteral`,(e,t)=>{Hi.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function B(e,t){return new Uc({type:`literal`,values:Array.isArray(e)?e:[e],...M(t)})}var Wc=F(`ZodTransform`,(e,t)=>{Js(),Ui.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $t(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(It(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(It(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Gc(e){return new Wc({type:`transform`,transform:e})}var Kc=F(`ZodOptional`,(e,t)=>{Gi.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>js(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qc(e){return new Kc({type:`optional`,innerType:e})}var Jc=F(`ZodExactOptional`,(e,t)=>{Ki.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>js(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yc(e){return new Jc({type:`optional`,innerType:e})}var Xc=F(`ZodNullable`,(e,t)=>{qi.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zc(e){return new Xc({type:`nullable`,innerType:e})}var Qc=F(`ZodDefault`,(e,t)=>{Ji.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function $c(e,t){return new Qc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ct(t)}})}var el=F(`ZodPrefault`,(e,t)=>{Xi.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function tl(e,t){return new el({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ct(t)}})}var nl=F(`ZodNonOptional`,(e,t)=>{Zi.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rl(e,t){return new nl({type:`nonoptional`,innerType:e,...M(t)})}var il=F(`ZodCatch`,(e,t)=>{ea.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function al(e,t){return new il({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Jt(t)})}var ol=F(`ZodPipe`,(e,t)=>{ta.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.in=t.in,e.out=t.out});function sl(e,t){return new ol({type:`pipe`,in:e,out:t})}var cl=F(`ZodReadonly`,(e,t)=>{ra.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ll(e){return new cl({type:`readonly`,innerType:e})}var ul=F(`ZodCustom`,(e,t)=>{aa.init(e,t),Ys.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r)});function dl(e,t={}){return Ao(ul,e,t)}function fl(e,t){return jo(e,t)}var pl=Cc().min(0).max(1),ml=z({tonic:R().regex(/^[A-Ga-g][#b]?$/,`Tonic should look like C, F#, or Bb`),mode:Hc(ee)}),hl=z({root:Cc().int().min(0).max(11),quality:Hc(le),beats:Cc().positive().max(32)}),gl=z({x:pl,y:pl,t:Cc().min(0),p:pl.optional()}),_l=z({id:R(),brush:Hc(De),size:pl,points:Nc(gl).min(1),exact:Dc().optional()}),vl=z({id:R(),name:R().min(1).max(40),instrument:Hc(Te),color:R(),volume:pl,pan:Cc().min(-1).max(1),muted:Dc(),solo:Dc(),harmony:Hc(Oe),octave:Cc().int().min(-2).max(2),kit:Hc(je),strokes:Nc(_l)}),yl=z({chords:z({enabled:Dc(),instrument:Hc(Fe),style:Hc(Ne),volume:pl}),bass:z({enabled:Dc(),style:Hc(Pe),volume:pl}),drums:z({enabled:Dc(),groove:Hc(Ie),volume:pl})}),bl=z({id:R(),name:R().min(1).max(40),bars:Cc().int().min(1).max(16),progression:Nc(hl).min(1),layers:Nc(vl),backing:yl}),xl=z({master:pl,warmth:pl,crackle:pl,reverb:pl,wobble:pl,rain:z({enabled:Dc(),kind:Hc(Re),level:pl})}),Sl=z({format:B(`haku`),version:B(1),id:R(),name:R().min(1).max(80),createdAt:R(),updatedAt:R(),seed:Cc().int(),mood:R().nullable(),window:Hc(Le),key:ml,bpm:Cc().min(50).max(140),swing:pl,humanize:pl,mix:xl,scenes:Nc(bl).min(1),arrangement:Nc(z({sceneId:R(),repeat:Cc().int().min(1).max(16)})).min(1),activeSceneId:R()}),Cl={"rainy-study":{label:`Rainy study`,bpm:72,key:{tonic:`F`,mode:`major`},progression:`jazzy-251`,lead:`piano`,swing:.35,window:`rain`,backing:{chords:{enabled:!0,instrument:`wurli`,style:`lazy`,volume:.6},bass:{enabled:!0,style:`roots`,volume:.7},drums:{enabled:!0,groove:`brushes`,volume:.65}},mix:{master:.8,warmth:.55,crackle:.35,reverb:.4,wobble:.25,rain:{enabled:!0,kind:`roof`,level:.45}}},"late-night-train":{label:`Late-night train`,bpm:68,key:{tonic:`A`,mode:`minor`},progression:`late-night`,lead:`wurli`,swing:.4,window:`night-city`,backing:{chords:{enabled:!0,instrument:`piano`,style:`sustain`,volume:.55},bass:{enabled:!0,style:`dub`,volume:.75},drums:{enabled:!0,groove:`dusty`,volume:.7}},mix:{master:.8,warmth:.65,crackle:.45,reverb:.45,wobble:.4,rain:{enabled:!0,kind:`window`,level:.2}}},"sunny-cafe":{label:`Sunny café`,bpm:86,key:{tonic:`G`,mode:`major`},progression:`sunday-walk`,lead:`marimba`,swing:.2,window:`sunny`,backing:{chords:{enabled:!0,instrument:`piano`,style:`stabs`,volume:.55},bass:{enabled:!0,style:`walking`,volume:.65},drums:{enabled:!0,groove:`bossa`,volume:.6}},mix:{master:.8,warmth:.35,crackle:.2,reverb:.3,wobble:.15,rain:{enabled:!1,kind:`roof`,level:.3}}},"dusk-walk":{label:`Dusk walk`,bpm:78,key:{tonic:`D`,mode:`dorian`},progression:`dorian-float`,lead:`harp`,swing:.3,window:`dusk`,backing:{chords:{enabled:!0,instrument:`wurli`,style:`lazy`,volume:.55},bass:{enabled:!0,style:`roots`,volume:.7},drums:{enabled:!0,groove:`halftime`,volume:.65}},mix:{master:.8,warmth:.5,crackle:.3,reverb:.45,wobble:.3,rain:{enabled:!1,kind:`roof`,level:.3}}},"snowy-window":{label:`Snowy window`,bpm:64,key:{tonic:`Eb`,mode:`major`},progression:`snowfall`,lead:`glock`,swing:.25,window:`snow`,backing:{chords:{enabled:!0,instrument:`pad`,style:`sustain`,volume:.5},bass:{enabled:!0,style:`roots`,volume:.6},drums:{enabled:!0,groove:`sparse`,volume:.5}},mix:{master:.8,warmth:.6,crackle:.3,reverb:.6,wobble:.2,rain:{enabled:!1,kind:`window`,level:.3}}}},wl=Object.keys(Cl);function Tl(e){let t=Cl[e];if(!t)throw Error(`Unknown mood "${e}". Try one of: ${wl.join(`, `)}`);return t}function El(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function Dl(...e){let t=2166136261;for(let n of e){for(let e of String(n))t^=e.charCodeAt(0),t=Math.imul(t,16777619);t^=255,t=Math.imul(t,16777619)}return t>>>0}function Ol(e){return e()+e()-1}var kl=`0123456789abcdefghijklmnopqrstuvwxyz`;function Al(e){let t=crypto.getRandomValues(new Uint8Array(6)),n=``;for(let e of t)n+=kl[e%36];return`${e}_${n}`}function jl({name:e,instrument:t,color:n,index:r=0}){return{id:Al(`l`),name:e??we[t].label,instrument:t,color:n??ze[r%ze.length],volume:.8,pan:0,muted:!1,solo:!1,harmony:`smart`,octave:0,kit:`sticks`,strokes:[]}}function Ml(e,t,n=4){let r=Tl(e.mood??`rainy-study`);return{id:Al(`s`),name:t,bars:n,progression:Ce(r.progression,e.key),layers:[jl({instrument:r.lead,name:`Melody`})],backing:structuredClone(r.backing)}}function Nl({name:e=`Untitled loop`,mood:t=`rainy-study`,seed:n,bars:r=4}={}){let i=Tl(t),a=new Date().toISOString(),o={key:{...i.key},mood:t},s=Ml(o,`A`,r);return{format:`haku`,version:1,id:Al(`p`),name:e,createdAt:a,updatedAt:a,seed:n??Math.floor(El(Date.now())()*2**31),mood:t,window:i.window,key:o.key,bpm:i.bpm,swing:i.swing,humanize:.5,mix:structuredClone(i.mix),scenes:[s],arrangement:[{sceneId:s.id,repeat:1}],activeSceneId:s.id}}function Pl(e){let t=Sl.safeParse(e);if(!t.success){let e=t.error.issues[0];throw Error(`Not a valid Haku project: ${e.path.join(`.`)||`root`}: ${e.message}`)}return t.data}function Fl(e,t){let n=t??e.activeSceneId,r=e.scenes.find(e=>e.id===n||e.name===n);if(!r)throw Error(`No scene "${n}"`);return r}function Il(e,t,n){let r=Fl(e,n),i=t?r.layers.find(e=>e.id===t||e.name.toLowerCase()===t.toLowerCase()):r.layers.find(e=>we[e.instrument].kind===`tonal`)??r.layers[0];if(!i)throw Error(t?`No layer "${t}" in scene ${r.name}`:`Scene ${r.name} has no layers`);return{scene:r,layer:i}}function Ll(e,t){return e*60/t}function Rl(e){let t=(e%4+4)%4;return Math.abs(t-Math.round(t))>1e-6?`weak`:Math.round(t)%2==0?`strong`:`medium`}function zl(e,t){let n=t.filter(t=>!e.includes(t));return e.filter(e=>t.includes(e)||!n.some(t=>w(e-t)===1||w(t-e)===1))}function Bl(e){let t=k(w(re(e.key)+e.chord.root),e.chord.quality),n=e.mode===`smart`?zl(ie(e.key),t):ie(e.key);switch(e.mode){case`chromatic`:return[0,1,2,3,4,5,6,7,8,9,10,11];case`scale`:return n;case`pentatonic`:return ae(e.key);case`chord`:return t;case`smart`:{if(e.strength===`strong`||e.long)return t;if(e.strength===`weak`)return[...new Set([...n,...t])];let r=n.filter(e=>t.includes(e)||!t.includes(w(e-1)));return[...new Set([...r,...t])]}}}function Vl(e,t){let n=new Set(Bl(t)),[r,i]=t.range,a=Math.round(Math.min(i,Math.max(r,e))),o=1/0;for(let s=r-2;s<=i+2;s++){if(!n.has(w(s)))continue;let c=s<r?r-s:s>i?s-i:0,l=Math.abs(s-e)+(t.prev===void 0?0:.08*Math.abs(s-t.prev))+c*2;l<o&&(o=l,a=s)}return a}function Hl(e,t,n){let r=new Set(ie(n)),i=e,a=Math.abs(t),o=Math.sign(t);for(;a>0;)i+=o,r.has(w(i))&&a--;return i}function Ul(e){let t=e.points,n=1,r=0,i=1,a=0,o=0;for(let e of t)n=Math.min(n,e.x),r=Math.max(r,e.x),i=Math.min(i,e.y),a=Math.max(a,e.y);for(let e=1;e<t.length;e++)o+=Math.hypot(t[e].x-t[e-1].x,t[e].y-t[e-1].y);let s=0,c=0,l=t[0].y;for(let e of t){let t=e.y-l;if(Math.abs(t)<.012)continue;let n=Math.sign(t);c!==0&&n!==c&&s++,c=n,l=e.y}return{minX:n,maxX:r,minY:i,maxY:a,width:r-n,height:a-i,length:o,durationMs:t[t.length-1].t-t[0].t,reversals:s}}function Wl(e){let t=Ul(e);return e.points.length===1||t.width<.012&&t.height<.02?`dot`:e.exact||e.brush===`stamp`||e.brush===`spray`?`line`:t.height>.06&&t.width<Math.max(.015,t.height*.15)?`strum`:t.reversals>=4&&t.width/t.reversals<.04&&t.height<.15?`trill`:t.durationMs>0&&t.durationMs<180&&t.length>.03&&t.length<.12?`flick`:`line`}var Gl=(e,t,n)=>Math.min(n,Math.max(t,e));function Kl(e,t){let n=(t.t-e.t)/1e3;return n>0?Math.hypot(t.x-e.x,t.y-e.y)/n:null}function ql(e,t){let n=e=>Gl(Math.floor(e*t),0,t-1),r=[],i=e=>{(r.length===0||r[r.length-1].col!==e.col)&&r.push(e)},a=e[0];i({col:n(a.x),y:a.y,speed:e[1]?Kl(a,e[1]):null,pressure:a.p});for(let r=1;r<e.length;r++){let a=e[r-1],o=e[r],s=o.x-a.x;if(Math.abs(s)<1e-9)continue;let c=Kl(a,o),l=n(a.x),u=n(o.x),d=u>=l?1:-1;for(let e=l;e!==u+d;e+=d){let n=((e+.5)/t-a.x)/s;if(n<0||n>1)continue;let r=a.p===void 0||o.p===void 0?void 0:a.p+(o.p-a.p)*n;i({col:e,y:a.y+(o.y-a.y)*n,speed:c,pressure:r})}}let o=e[e.length-1];return e.length>1&&i({col:n(o.x),y:o.y,speed:null,pressure:o.p}),r}function Jl(e,t,n){let r;return r=e.pressure===void 0?e.speed===null?t:t*(.75+.5*Gl(e.speed/1.2,0,1)):.25+.7*e.pressure,Gl(r*(1-.25*n),.15,1)}function Yl(e){let[t,n]=we[e.instrument].range;return[t+e.octave*12,n+e.octave*12]}function Xl(e,t){return t[1]-Gl(e,0,1)*(t[1]-t[0])}function Zl(e,t){return Gl((t[1]-e)/(t[1]-t[0]),0,1)}function Ql(e,t){if(we[t.layer.instrument].kind===`drums`)return eu(e,t);let n=Ee[e.brush],r=e.exact?4:n.stepsPerBeat,i=t.bars*4,a=i*r,o=1/r,s=Yl(t.layer),c=Gl(1-e.size*.7,0,1),l=El(Dl(t.seed,e.id)),u={track:t.layer.id,instrument:t.layer.instrument,source:`stroke`,brightness:c,strokeId:e.id},d=(e,t,n,r)=>({...u,time:e,duration:t,midi:n,velocity:r}),f=(n,r,i,a=!1)=>e.exact?Gl(Math.round(r),0,127):Vl(r,{key:t.key,chord:A(t.progression,n).chord,mode:t.layer.harmony,strength:Rl(n),long:a,range:s,prev:i}),p=Wl(e),m=Ul(e),h=Jl({speed:null,pressure:e.points[0].p},n.velocity,e.size);if(p===`dot`){let t=e.points[0],n=Math.floor(Gl(t.x,0,.9999)*a)/r,i=e.brush===`brush`?1:o;return[d(n,i,f(n,Xl(t.y,s),void 0,i>=1),h)]}if(p===`strum`){let n=Math.floor(Gl((m.minX+m.maxX)/2,0,.9999)*a)/r,{chord:i,start:c}=A(t.progression,n),l=new Set(k(w(re(t.key)+i.root),i.quality)),u=Math.round(Xl(m.minY,s)),f=Math.round(Xl(m.maxY,s)),p=[];for(let e=f;e<=u;e++)l.has(w(e))&&p.push(e);e.points[e.points.length-1].y<e.points[0].y||p.reverse();let g=Math.max(o,Math.min(2,c+i.beats-n));return p.slice(0,6).map((e,t)=>d(n+t*.04,g-t*.04,e,h*(1-t*.04)))}if(p===`trill`){let e=Math.floor(Gl(m.minX,0,.9999)*i*4),n=Math.max(e+1,Math.ceil(Gl(m.maxX,0,1)*i*4)),r=f(e/4,Xl((m.minY+m.maxY)/2,s)),a=Hl(r,1,t.key),o=[];for(let t=e;t<n;t++)o.push(d(t/4,.25,(t-e)%2==0?r:a,h*.85));return o}if(p===`flick`){let n=e.points[e.points.length-1],i=Math.floor(Gl(n.x,0,.9999)*a)/r,c=f(i,Xl(n.y,s),void 0,!0),l=Hl(c,n.y<e.points[0].y?-1:1,t.key),u=Gl(h*1.15,0,1),p=Math.max(0,i-.125);return[d(p,i-p||.125,l,u*.7),d(i,o*2,c,u)]}let g=ql(e.points,a),_=[],v,y=-2,b,x;for(let i of g){let a=i.col/r,c=Jl(i,n.velocity,e.size);if(e.brush===`spray`){if(l()>.6)continue;let e=Xl(i.y,s)+Ol(l)*4;_.push(d(a,o,f(a,e),c*(.7+l()*.4)));continue}let u=f(a,Xl(i.y,s),v,e.brush===`brush`);if(b&&e.brush!==`stamp`&&i.col===y+1&&b.midi===u)b.duration+=o,x&&(x.duration=b.duration);else if(b=d(a,o,u,c),_.push(b),x=void 0,e.brush===`chalk`){let e=$l(u,a,t);e!==null&&_.push(x=d(a,o,e,c*.8))}v=u,y=i.col}return _}function $l(e,t,n){let{chord:r}=A(n.progression,t),i=new Set(k(w(re(n.key)+r.root),r.quality));for(let t=e-3;t>=e-9;t--)if(i.has(w(t)))return t;return null}function eu(e,t){let n=Ee[e.brush],r=t.bars*4*n.stepsPerBeat,i=Me(t.layer.kit),a=El(Dl(t.seed,e.id)),o=Gl(1-e.size*.7,0,1),s=Wl(e)===`dot`?ql(e.points.slice(0,1),r):ql(e.points,r),c=[];for(let r of s){if(e.brush===`spray`&&a()>.55)continue;let s=i[Gl(Math.floor((1-r.y)*i.length),0,i.length-1)],l=Jl(r,n.velocity,e.size)*(e.brush===`spray`?.55:1);c.push({time:r.col/n.stepsPerBeat,duration:.25,midi:ke[s].gm,velocity:l,track:t.layer.id,instrument:`drums`,source:`stroke`,drum:s,brightness:o,strokeId:e.id})}return c}var tu=[50,76];function nu(e,t){let n=[t];for(let t=1;t<e.length;t++){let r=n[t-1]+1;for(;w(r)!==e[t];)r++;n.push(r)}return n}function ru(e,t,n=tu){let r=[...new Set(ce[t].voicing.map(t=>w(e+t)))],i=[];for(let e=0;e<r.length;e++){let t=[...r.slice(e),...r.slice(0,e)],a=n[0];for(;w(a)!==t[0];)a++;for(let e=a;e<=n[1];e+=12){let n=nu(t,e);if(i.push(n),n.length>=4){let e=[...n];e[e.length-2]-=12,i.push(e.sort((e,t)=>e-t))}}}return i.filter(e=>e[0]>=n[0]-2&&e[e.length-1]<=n[1])}function iu(e,t){let n=(e,t)=>Math.min(...t.map(t=>Math.abs(t-e)));return(e.reduce((e,r)=>e+n(r,t),0)+t.reduce((t,r)=>t+n(r,e),0))/2}function au(e){let t=0;for(let n=1;n<e.length;n++)e[n-1]<53&&e[n]-e[n-1]<5&&(t+=3);return e[e.length-1]>74&&(t+=1.5),t}function ou(e,t,n,r=tu){let i=ru(e,t,r),a=i[0]??[],o=1/0;for(let e of i){let t=e.reduce((e,t)=>e+t,0)/e.length,r=(n?iu(e,n):Math.abs(t-62))+au(e);r<o&&(o=r,a=e)}return a}var su={dusty:{label:`Dusty boom bap`,kit:`sticks`,bar:{kick:`X......x..X.....`,snare:`....X.......X...`,hat:`x.o.x.o.x.ogx.o.`},turnaround:{kick:`X......x..X..x..`,snare:`....X.......X.g.`,hat:`x.o.x.o.x.ogx...`,openhat:`..............o.`}},brushes:{label:`Brushes`,kit:`brushes`,bar:{kick:`o.......o.......`,brush:`g...X..g....X.g.`,brushhat:`x...x.o.x...x.o.`}},halftime:{label:`Half-time`,kit:`sticks`,bar:{kick:`X.........x.....`,snare:`........X.......`,hat:`x.o.x.o.x.o.x.o.`},turnaround:{kick:`X.........x..o..`,snare:`........X.....g.`,hat:`x.o.x.o.x.o.x...`,openhat:`..............o.`}},bossa:{label:`Lazy bossa`,kit:`sticks`,bar:{kick:`x..ox..ox..ox..o`,rim:`x..x..x...x..x..`,hat:`o.g.o.g.o.g.o.g.`}},sparse:{label:`Sparse`,kit:`sticks`,bar:{kick:`x.......o.......`,rim:`........o.......`,ride:`o...o...o...o...`}}},cu={X:.95,x:.72,o:.5,g:.28};function lu(e,t){let n=su[e],r=t&&n.turnaround?n.turnaround:n.bar,i=[];for(let[e,t]of Object.entries(r))for(let n=0;n<t.length;n++){let r=cu[t[n]];r!==void 0&&i.push({beat:n/4,piece:e,velocity:r})}return i.sort((e,t)=>e.beat-t.beat)}function uu(e,t,n){let r=[],i=re(t),a=0;for(let t=0;a<n;t=(t+1)%e.length){let o=e[t],s=Math.min(o.beats,n-a);r.push({chord:o,start:a,beats:s,rootPc:w(i+o.root)}),a+=o.beats}return r}function du(e,t){switch(e){case`sustain`:return[{at:0,len:t,strum:.01}];case`lazy`:return[{at:.06,len:t-.3,strum:.035}];case`stabs`:{let e=[];for(let n=0;n<t;n+=4)for(let[r,i]of[[0,.9],[1.5,.4],[3,.4]])n+r<t&&e.push({at:n+r,len:Math.min(i,t-n-r),strum:.01});return e}case`arp`:return[]}}function fu(e,t,n){let r=[],i={track:`backing:chords`,instrument:t.instrument,source:`chords`,brightness:.6};for(let a of e){let e=ou(a.rootPc,a.chord.quality,n.voicing);if(n.voicing=e,t.style===`arp`){let t=[...e,...e.slice(1,-1).reverse()];for(let e=0;e*.5<a.beats;e++)r.push({...i,time:a.start+e*.5,duration:Math.min(.9,a.beats-e*.5),midi:t[e%t.length],velocity:e%4==0?.55:.42})}else for(let n of du(t.style,a.beats))e.forEach((e,t)=>{let o=n.at+t*n.strum;r.push({...i,time:a.start+o,duration:Math.max(.1,n.len-t*n.strum),midi:e,velocity:.5-t*.03})})}return r}var pu=[33,52];function mu(e,t,n=pu){let r=-1;for(let i=n[0];i<=n[1];i++)w(i)===e&&(r<0||Math.abs(i-t)<Math.abs(r-t))&&(r=i);return r}function hu(e,t){let n=ce[e.chord.quality].tones.map(e=>e%12),r=(e,t)=>e.find(e=>n.includes(e))??t,i=t===`third`?r([4,3,5,2],4):t===`fifth`?r([7,6,8],7):r([10,11,9],10);return w(e.rootPc+i)}function gu(e,t,n){let r=[],i={track:`backing:bass`,instrument:`bass`,source:`bass`,brightness:.5},a=(e,t,a,o)=>{r.push({...i,time:e,duration:t,midi:a,velocity:o}),n.last=a};return e.forEach((r,i)=>{let o=mu(r.rootPc,n.last),s=mu(hu(r,`fifth`),o+5),c=e[i+1]??e[0];if(t===`walking`){let e=[o,mu(hu(r,`third`),o+4),s,mu(hu(r,`seventh`),o+9)];for(let t=0;t<r.beats;t++){let i=t===Math.ceil(r.beats)-1&&r.beats>1,s=mu(c.rootPc,n.last),l=t===0?o:i?s+(s>n.last?-1:1):e[t%e.length];a(r.start+t,.9,l,t===0?.78:.62)}}else for(let e=0;e<r.beats;e+=4){let n=r.beats-e;t===`roots`?(a(r.start+e,Math.min(2.75,n-.1),o,.75),n>3&&a(r.start+e+3,.75,e%8==0?s:o+12<=pu[1]?o+12:o,.6)):(a(r.start+e,Math.min(1.5,n-.1),o,.8),n>2.5&&a(r.start+e+2.5,.4,o,.55),n>3.5&&a(r.start+e+3.5,.4,s,.5))}}),r}function _u(e,t){let n=[],r=Math.ceil(t/4);for(let i=0;i<r;i++){let a=i===r-1||i%4==3;for(let r of lu(e,a)){let e=i*4+r.beat;e>=t||n.push({time:e,duration:.25,midi:ke[r.piece].gm,velocity:r.velocity,track:`backing:drums`,instrument:`drums`,source:`drums`,drum:r.piece,brightness:.6})}}return n}var vu=.25;function yu(e,t){let n=e%(vu*2);return Math.abs(n-vu)>.01?e:e+t*(1/3-vu)}function bu(e,t){if(!(t<=0))for(let n of e){let e=yu(n.time,t);n.duration=Math.max(.05,n.duration-(e-n.time)),n.time=e}}var xu={snare:.012,brush:.016,rim:.01};function Su(e,t,n,r=0){if(t<=0)return;let i=new Map;for(let a of e){let e=i.get(a.track);e||i.set(a.track,e=El(Dl(n,a.track,r)));let o=a.drum===`kick`?.5:1,s=a.drum?(xu[a.drum]??0)*t:0;a.time=Math.max(0,a.time+Ol(e)*.022*t*o+s),a.velocity=Math.min(1,Math.max(.05,a.velocity*(1+Ol(e)*.14*t)))}}var Cu=()=>({voicing:null,bassLast:40});function wu(e){let t=e.layers.some(e=>e.solo);return{layers:e.layers.filter(e=>t?e.solo:!e.muted),backing:!t}}function Tu(e,t,{offset:n=0,pass:r=0,carry:i=Cu()}={}){let a=t.bars*4,o=[],{layers:s,backing:c}=wu(t);for(let n of s)for(let r of n.strokes)o.push(...Ql(r,{key:e.key,progression:t.progression,bars:t.bars,layer:n,seed:e.seed}));let l=uu(t.progression,e.key,a);if(c){let e=t.backing;if(e.chords.enabled){let t={voicing:i.voicing};o.push(...fu(l,e.chords,t)),i.voicing=t.voicing}if(e.bass.enabled){let t={last:i.bassLast};o.push(...gu(l,e.bass.style,t)),i.bassLast=t.last}e.drums.enabled&&o.push(..._u(e.drums.groove,a))}let u=o.filter(e=>e.time<a);for(let e of u)e.duration=Math.min(e.duration,a-e.time);bu(u,e.swing),Su(u,e.humanize,Dl(e.seed,t.id),r);for(let e of u)e.time+=n;let d=oe(e.key),f=l.map(t=>({time:t.start+n,duration:t.beats,symbol:pe(t.chord,e.key,d),rootPc:t.rootPc,pcs:k(t.rootPc,t.chord.quality)}));return{events:u.sort((e,t)=>e.time-t.time||e.midi-t.midi),chords:f}}function Eu(e,t){let n=Fl(e,t),{events:r,chords:i}=Tu(e,n);return{bpm:e.bpm,beats:n.bars*4,events:r,chords:i,sections:[{sceneId:n.id,name:n.name,start:0,beats:n.bars*4}]}}function Du(e){let t=Cu(),n={bpm:e.bpm,beats:0,events:[],chords:[],sections:[]};for(let r of e.arrangement){let i=Fl(e,r.sceneId);for(let a=0;a<r.repeat;a++){let{events:r,chords:o}=Tu(e,i,{offset:n.beats,pass:a,carry:t});n.events.push(...r),n.chords.push(...o),n.sections.push({sceneId:i.id,name:i.name,start:n.beats,beats:i.bars*4}),n.beats+=i.bars*4}}return n}var Ou=[`wave`,`arc`,`zigzag`,`stairs-up`,`stairs-down`],ku=e=>Math.min(1,Math.max(0,e));function Au(e,t,n){let r=[0];for(let t=1;t<e.length;t++)r.push(r[t-1]+Math.hypot(e[t].x-e[t-1].x,e[t].y-e[t-1].y));let i=r[r.length-1]||1;return e.map((e,a)=>({x:ku(e.x),y:ku(e.y),t:Math.round(r[a]/i*t),...n===void 0?{}:{p:ku(n)}}))}function ju(e,t){let n=Math.max(2,Math.ceil(Math.hypot(t.x-e.x,t.y-e.y)*200));return Array.from({length:n+1},(r,i)=>({x:e.x+(t.x-e.x)*i/n,y:e.y+(t.y-e.y)*i/n}))}function Mu(e){if(e.length<3)return e.length===2?ju(e[0],e[1]):[...e];let t=[];for(let n=0;n<e.length-1;n++){let r=e[Math.max(0,n-1)],i=e[n],a=e[n+1],o=e[Math.min(e.length-1,n+2)],s=Math.max(4,Math.ceil(Math.hypot(a.x-i.x,a.y-i.y)*200));for(let e=0;e<s;e++){let n=e/s,c=n*n,l=c*n,u=(e,t,r,i)=>.5*(2*t+(-e+r)*n+(2*e-5*t+4*r-i)*c+(-e+3*t-3*r+i)*l);t.push({x:u(r.x,i.x,a.x,o.x),y:u(r.y,i.y,a.y,o.y)})}}return t.push(e[e.length-1]),t}function Nu(e,{x:t,y:n,width:r,height:i,cycles:a=2}){let o=Math.max(24,Math.ceil(r*240)),s=e=>t+r*e;switch(e){case`wave`:return Array.from({length:o+1},(e,t)=>({x:s(t/o),y:n-i/2*Math.sin(t/o*a*Math.PI*2)}));case`arc`:return Array.from({length:o+1},(e,t)=>({x:s(t/o),y:n+i/2-i*Math.sin(t/o*Math.PI)}));case`zigzag`:{let e=[];for(let t=0;t<=a*2;t++)e.push({x:s(t/(a*2)),y:n+(t%2==0?i/2:-i/2)});return e.flatMap((t,n)=>n===0?[t]:ju(e[n-1],t).slice(1))}case`stairs-up`:case`stairs-down`:{let t=Math.max(2,Math.round(a*2)),r=e===`stairs-up`?-1:1,o=[];for(let e=0;e<t;e++){let a=n-r*i/2+r*i*e/(t-1);o.push(...ju({x:s(e/t),y:a},{x:s((e+1)/t)-.001,y:a}))}return o}}}var Pu=e=>`${Math.round(e*100)}%`;function Fu(e,t,n,r=14){if(e.length===0)return[`(empty)`];let i=Math.ceil(t*2),a=[...new Set(e.map(e=>e.midi))].sort((e,t)=>t-e),o=a.length>r?a.filter((e,t)=>t%Math.ceil(a.length/r)===0):a,s=Math.max(...o.map(e=>O(e,n).length));return o.map(t=>{let r=Array.from({length:i},()=>`.`);for(let n of e){if(n.midi!==t)continue;let e=Math.min(i-1,Math.round(n.time*2)),a=Math.min(i,Math.max(e+1,Math.round((n.time+n.duration)*2)));r[e]=`o`;for(let t=e+1;t<a;t++)r[t]===`.`&&(r[t]=`-`)}let a=``;for(let e=0;e<i;e++)a+=(e%8==0?`|`:``)+r[e];return`${O(t,n).padStart(s)} ${a}|`})}function Iu(e,t){let n=oe(e.key),r=Fl(e,t),i=Eu(e,r.id),a=[];a.push(`${e.name} · ${se(e.key)} · ${e.bpm} BPM · swing ${Pu(e.swing)} · humanize ${Pu(e.humanize)}`),a.push(`Mood: ${e.mood??`custom`} · window: ${e.window}`);let o=e.arrangement.map(t=>`${e.scenes.find(e=>e.id===t.sceneId)?.name??t.sceneId}${t.repeat>1?`×${t.repeat}`:``}`).join(` → `);a.push(`Scenes: ${e.scenes.map(e=>`${e.name} [${e.id}] ${e.bars} bars`).join(`, `)}`),a.push(`Arrangement: ${o}`);let s=e.mix;a.push(`Mix: master ${Pu(s.master)}, warmth ${Pu(s.warmth)}, crackle ${Pu(s.crackle)}, reverb ${Pu(s.reverb)}, wobble ${Pu(s.wobble)}, rain ${s.rain.enabled?`${s.rain.kind} ${Pu(s.rain.level)}`:`off`}`),a.push(``),a.push(`Scene ${r.name} (${r.bars} bars, ${r.bars*4} beats). Canvas x 0→1 spans the whole scene, y 0 is the top (high notes).`),a.push(`Chords: ${j(r.progression,e.key)}`);let c=r.backing;a.push(`Backing: chords ${c.chords.enabled?`${c.chords.instrument} ${c.chords.style}`:`off`} · bass ${c.bass.enabled?c.bass.style:`off`} · drums ${c.drums.enabled?c.drums.groove:`off`}`);for(let e of r.layers){let t=i.events.filter(t=>t.track===e.id),o=[e.muted&&`muted`,e.solo&&`solo`].filter(Boolean).join(`, `),s=[...new Set(e.strokes.map(e=>Ee[e.brush].label.toLowerCase()))].join(`/`);if(a.push(``),a.push(`Layer "${e.name}" [${e.id}] ${we[e.instrument].label}, harmony ${e.harmony}, octave ${e.octave>=0?`+`:``}${e.octave}, volume ${Pu(e.volume)}${o?` (${o})`:``}`),e.strokes.length===0){a.push(` No strokes yet.`);continue}let c=t.length?`${O(Math.min(...t.map(e=>e.midi)),n)} to ${O(Math.max(...t.map(e=>e.midi)),n)}`:`none`;if(a.push(` ${e.strokes.length} strokes (${s}), ${t.length} notes, range ${c}`),we[e.instrument].kind===`drums`){let e=new Map;for(let n of t)e.set(n.drum??`?`,(e.get(n.drum??`?`)??0)+1);a.push(` Hits: ${[...e].map(([e,t])=>`${e} ${t}`).join(`, `)}`)}else{let e=t.map(e=>({...e,time:Math.round(e.time*4)/4}));for(let t of Fu(e,r.bars*4,n))a.push(` ${t}`)}}return a.join(`
|
|
64
|
+
`)}var Lu=o(((e,t)=>{function n(e){var t=new a(e),n=t.readChunk();if(n.id!=`MThd`)throw`Bad MIDI file. Expected 'MHdr', got: '`+n.id+`'`;for(var o=r(n.data),s=[],c=0;!t.eof()&&c<o.numTracks;c++){var l=t.readChunk();if(l.id!=`MTrk`)throw`Bad MIDI file. Expected 'MTrk', got: '`+l.id+`'`;var u=i(l.data);s.push(u)}return{header:o,tracks:s}}function r(e){var t=new a(e),n={format:t.readUInt16(),numTracks:t.readUInt16()},r=t.readUInt16();return r&32768?(n.framesPerSecond=256-(r>>8),n.ticksPerFrame=r&255):n.ticksPerBeat=r,n}function i(e){for(var t=new a(e),n=[];!t.eof();){var r=i();n.push(r)}return n;function i(){var e={};e.deltaTime=t.readVarInt();var n=t.readUInt8();if((n&240)==240){if(n===255){e.meta=!0;var r=t.readUInt8(),i=t.readVarInt();switch(r){case 0:if(e.type=`sequenceNumber`,i!==2)throw`Expected length for sequenceNumber event is 2, got `+i;return e.number=t.readUInt16(),e;case 1:return e.type=`text`,e.text=t.readString(i),e;case 2:return e.type=`copyrightNotice`,e.text=t.readString(i),e;case 3:return e.type=`trackName`,e.text=t.readString(i),e;case 4:return e.type=`instrumentName`,e.text=t.readString(i),e;case 5:return e.type=`lyrics`,e.text=t.readString(i),e;case 6:return e.type=`marker`,e.text=t.readString(i),e;case 7:return e.type=`cuePoint`,e.text=t.readString(i),e;case 32:if(e.type=`channelPrefix`,i!=1)throw`Expected length for channelPrefix event is 1, got `+i;return e.channel=t.readUInt8(),e;case 33:if(e.type=`portPrefix`,i!=1)throw`Expected length for portPrefix event is 1, got `+i;return e.port=t.readUInt8(),e;case 47:if(e.type=`endOfTrack`,i!=0)throw`Expected length for endOfTrack event is 0, got `+i;return e;case 81:if(e.type=`setTempo`,i!=3)throw`Expected length for setTempo event is 3, got `+i;return e.microsecondsPerBeat=t.readUInt24(),e;case 84:if(e.type=`smpteOffset`,i!=5)throw`Expected length for smpteOffset event is 5, got `+i;var a=t.readUInt8();return e.frameRate={0:24,32:25,64:29,96:30}[a&96],e.hour=a&31,e.min=t.readUInt8(),e.sec=t.readUInt8(),e.frame=t.readUInt8(),e.subFrame=t.readUInt8(),e;case 88:if(e.type=`timeSignature`,i!=2&&i!=4)throw`Expected length for timeSignature event is 4 or 2, got `+i;return e.numerator=t.readUInt8(),e.denominator=1<<t.readUInt8(),i===4?(e.metronome=t.readUInt8(),e.thirtyseconds=t.readUInt8()):(e.metronome=36,e.thirtyseconds=8),e;case 89:if(e.type=`keySignature`,i!=2)throw`Expected length for keySignature event is 2, got `+i;return e.key=t.readInt8(),e.scale=t.readUInt8(),e;case 127:return e.type=`sequencerSpecific`,e.data=t.readBytes(i),e;default:return e.type=`unknownMeta`,e.data=t.readBytes(i),e.metatypeByte=r,e}}else if(n==240){e.type=`sysEx`;var i=t.readVarInt();return e.data=t.readBytes(i),e}else if(n==247){e.type=`endSysEx`;var i=t.readVarInt();return e.data=t.readBytes(i),e}else throw`Unrecognised MIDI event type byte: `+n}else{var s;if(n&128)s=t.readUInt8(),o=n;else{if(o===null)throw`Running status byte encountered before status byte`;s=n,n=o,e.running=!0}var c=n>>4;switch(e.channel=n&15,c){case 8:return e.type=`noteOff`,e.noteNumber=s,e.velocity=t.readUInt8(),e;case 9:var l=t.readUInt8();return e.type=l===0?`noteOff`:`noteOn`,e.noteNumber=s,e.velocity=l,l===0&&(e.byte9=!0),e;case 10:return e.type=`noteAftertouch`,e.noteNumber=s,e.amount=t.readUInt8(),e;case 11:return e.type=`controller`,e.controllerType=s,e.value=t.readUInt8(),e;case 12:return e.type=`programChange`,e.programNumber=s,e;case 13:return e.type=`channelAftertouch`,e.amount=s,e;case 14:return e.type=`pitchBend`,e.value=s+(t.readUInt8()<<7)-8192,e;default:throw`Unrecognised MIDI event type: `+c}}}var o}function a(e){this.buffer=e,this.bufferLen=this.buffer.length,this.pos=0}a.prototype.eof=function(){return this.pos>=this.bufferLen},a.prototype.readUInt8=function(){var e=this.buffer[this.pos];return this.pos+=1,e},a.prototype.readInt8=function(){var e=this.readUInt8();return e&128?e-256:e},a.prototype.readUInt16=function(){var e=this.readUInt8(),t=this.readUInt8();return(e<<8)+t},a.prototype.readInt16=function(){var e=this.readUInt16();return e&32768?e-65536:e},a.prototype.readUInt24=function(){var e=this.readUInt8(),t=this.readUInt8(),n=this.readUInt8();return(e<<16)+(t<<8)+n},a.prototype.readInt24=function(){var e=this.readUInt24();return e&8388608?e-16777216:e},a.prototype.readUInt32=function(){var e=this.readUInt8(),t=this.readUInt8(),n=this.readUInt8(),r=this.readUInt8();return(e<<24)+(t<<16)+(n<<8)+r},a.prototype.readBytes=function(e){var t=this.buffer.slice(this.pos,this.pos+e);return this.pos+=e,t},a.prototype.readString=function(e){var t=this.readBytes(e);return String.fromCharCode.apply(null,t)},a.prototype.readVarInt=function(){for(var e=0;!this.eof();){var t=this.readUInt8();if(t&128)e+=t&127,e<<=7;else return e+t}return e},a.prototype.readChunk=function(){var e=this.readString(4),t=this.readUInt32();return{id:e,length:t,data:this.readBytes(t)}},t.exports=n})),Ru=o(((e,t)=>{function n(e,t){if(typeof e!=`object`)throw`Invalid MIDI data`;t||={};var n=e.header||{},a=e.tracks||[],s,c=a.length,l=new o;for(r(l,n,c),s=0;s<c;s++)i(l,a[s],t);return l.buffer}function r(e,t,n){var r=t.format==null?1:t.format,i=128;t.timeDivision?i=t.timeDivision:t.ticksPerFrame&&t.framesPerSecond?i=-(t.framesPerSecond&255)<<8|t.ticksPerFrame&255:t.ticksPerBeat&&(i=t.ticksPerBeat&32767);var a=new o;a.writeUInt16(r),a.writeUInt16(n),a.writeUInt16(i),e.writeChunk(`MThd`,a.buffer)}function i(e,t,n){var r=new o,i,s=t.length,c=null;for(i=0;i<s;i++)(n.running===!1||!n.running&&!t[i].running)&&(c=null),c=a(r,t[i],c,n.useByte9ForNoteOff);e.writeChunk(`MTrk`,r.buffer)}function a(e,t,n,r){var i=t.type,a=t.deltaTime,o=t.text||``,s=t.data||[],c=null;switch(e.writeVarInt(a),i){case`sequenceNumber`:e.writeUInt8(255),e.writeUInt8(0),e.writeVarInt(2),e.writeUInt16(t.number);break;case`text`:e.writeUInt8(255),e.writeUInt8(1),e.writeVarInt(o.length),e.writeString(o);break;case`copyrightNotice`:e.writeUInt8(255),e.writeUInt8(2),e.writeVarInt(o.length),e.writeString(o);break;case`trackName`:e.writeUInt8(255),e.writeUInt8(3),e.writeVarInt(o.length),e.writeString(o);break;case`instrumentName`:e.writeUInt8(255),e.writeUInt8(4),e.writeVarInt(o.length),e.writeString(o);break;case`lyrics`:e.writeUInt8(255),e.writeUInt8(5),e.writeVarInt(o.length),e.writeString(o);break;case`marker`:e.writeUInt8(255),e.writeUInt8(6),e.writeVarInt(o.length),e.writeString(o);break;case`cuePoint`:e.writeUInt8(255),e.writeUInt8(7),e.writeVarInt(o.length),e.writeString(o);break;case`channelPrefix`:e.writeUInt8(255),e.writeUInt8(32),e.writeVarInt(1),e.writeUInt8(t.channel);break;case`portPrefix`:e.writeUInt8(255),e.writeUInt8(33),e.writeVarInt(1),e.writeUInt8(t.port);break;case`endOfTrack`:e.writeUInt8(255),e.writeUInt8(47),e.writeVarInt(0);break;case`setTempo`:e.writeUInt8(255),e.writeUInt8(81),e.writeVarInt(3),e.writeUInt24(t.microsecondsPerBeat);break;case`smpteOffset`:e.writeUInt8(255),e.writeUInt8(84),e.writeVarInt(5);var l=t.hour&31|{24:0,25:32,29:64,30:96}[t.frameRate];e.writeUInt8(l),e.writeUInt8(t.min),e.writeUInt8(t.sec),e.writeUInt8(t.frame),e.writeUInt8(t.subFrame);break;case`timeSignature`:e.writeUInt8(255),e.writeUInt8(88),e.writeVarInt(4),e.writeUInt8(t.numerator);var u=Math.floor(Math.log(t.denominator)/Math.LN2)&255;e.writeUInt8(u),e.writeUInt8(t.metronome),e.writeUInt8(t.thirtyseconds||8);break;case`keySignature`:e.writeUInt8(255),e.writeUInt8(89),e.writeVarInt(2),e.writeInt8(t.key),e.writeUInt8(t.scale);break;case`sequencerSpecific`:e.writeUInt8(255),e.writeUInt8(127),e.writeVarInt(s.length),e.writeBytes(s);break;case`unknownMeta`:t.metatypeByte!=null&&(e.writeUInt8(255),e.writeUInt8(t.metatypeByte),e.writeVarInt(s.length),e.writeBytes(s));break;case`sysEx`:e.writeUInt8(240),e.writeVarInt(s.length),e.writeBytes(s);break;case`endSysEx`:e.writeUInt8(247),e.writeVarInt(s.length),e.writeBytes(s);break;case`noteOff`:c=(r!==!1&&t.byte9||r&&t.velocity==0?144:128)|t.channel,c!==n&&e.writeUInt8(c),e.writeUInt8(t.noteNumber),e.writeUInt8(t.velocity);break;case`noteOn`:c=144|t.channel,c!==n&&e.writeUInt8(c),e.writeUInt8(t.noteNumber),e.writeUInt8(t.velocity);break;case`noteAftertouch`:c=160|t.channel,c!==n&&e.writeUInt8(c),e.writeUInt8(t.noteNumber),e.writeUInt8(t.amount);break;case`controller`:c=176|t.channel,c!==n&&e.writeUInt8(c),e.writeUInt8(t.controllerType),e.writeUInt8(t.value);break;case`programChange`:c=192|t.channel,c!==n&&e.writeUInt8(c),e.writeUInt8(t.programNumber);break;case`channelAftertouch`:c=208|t.channel,c!==n&&e.writeUInt8(c),e.writeUInt8(t.amount);break;case`pitchBend`:c=224|t.channel,c!==n&&e.writeUInt8(c);var d=8192+t.value,f=d&127,p=d>>7&127;e.writeUInt8(f),e.writeUInt8(p);break;default:throw`Unrecognized event type: `+i}return c}function o(){this.buffer=[]}o.prototype.writeUInt8=function(e){this.buffer.push(e&255)},o.prototype.writeInt8=o.prototype.writeUInt8,o.prototype.writeUInt16=function(e){var t=e>>8&255,n=e&255;this.writeUInt8(t),this.writeUInt8(n)},o.prototype.writeInt16=o.prototype.writeUInt16,o.prototype.writeUInt24=function(e){var t=e>>16&255,n=e>>8&255,r=e&255;this.writeUInt8(t),this.writeUInt8(n),this.writeUInt8(r)},o.prototype.writeInt24=o.prototype.writeUInt24,o.prototype.writeUInt32=function(e){var t=e>>24&255,n=e>>16&255,r=e>>8&255,i=e&255;this.writeUInt8(t),this.writeUInt8(n),this.writeUInt8(r),this.writeUInt8(i)},o.prototype.writeInt32=o.prototype.writeUInt32,o.prototype.writeBytes=function(e){this.buffer=this.buffer.concat(Array.prototype.slice.call(e,0))},o.prototype.writeString=function(e){var t,n=e.length,r=[];for(t=0;t<n;t++)r.push(e.codePointAt(t));this.writeBytes(r)},o.prototype.writeVarInt=function(e){if(e<0)throw`Cannot write negative variable-length integer`;if(e<=127)this.writeUInt8(e);else{var t=e,n=[];for(n.push(t&127),t>>=7;t;){var r=t&127|128;n.push(r),t>>=7}this.writeBytes(n.reverse())}},o.prototype.writeChunk=function(e,t){this.writeString(e),this.writeUInt32(t.length),this.writeBytes(t)},t.exports=n})),zu=o((e=>{e.parseMidi=Lu(),e.writeMidi=Ru()})),Bu=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.insert=e.search=void 0;function t(e,t,n){n===void 0&&(n=`ticks`);var r=0,i=e.length,a=i;if(i>0&&e[i-1][n]<=t)return i-1;for(;r<a;){var o=Math.floor(r+(a-r)/2),s=e[o],c=e[o+1];if(s[n]===t){for(var l=o;l<e.length;l++)e[l][n]===t&&(o=l);return o}if(s[n]<t&&c[n]>t)return o;s[n]>t?a=o:s[n]<t&&(r=o+1)}return-1}e.search=t;function n(e,n,r){if(r===void 0&&(r=`ticks`),e.length){var i=t(e,n[r],r);e.splice(i+1,0,n)}else e.push(n)}e.insert=n})),Vu=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Header=e.keySignatureKeys=void 0;var t=Bu(),n=new WeakMap;e.keySignatureKeys=[`Cb`,`Gb`,`Db`,`Ab`,`Eb`,`Bb`,`F`,`C`,`G`,`D`,`A`,`E`,`B`,`F#`,`C#`],e.Header=function(){function r(t){var r=this;if(this.tempos=[],this.timeSignatures=[],this.keySignatures=[],this.meta=[],this.name=``,n.set(this,480),t){n.set(this,t.header.ticksPerBeat),t.tracks.forEach(function(t){t.forEach(function(t){t.meta&&(t.type===`timeSignature`?r.timeSignatures.push({ticks:t.absoluteTime,timeSignature:[t.numerator,t.denominator]}):t.type===`setTempo`?r.tempos.push({bpm:6e7/t.microsecondsPerBeat,ticks:t.absoluteTime}):t.type===`keySignature`&&r.keySignatures.push({key:e.keySignatureKeys[t.key+7],scale:t.scale===0?`major`:`minor`,ticks:t.absoluteTime}))})});var i=0;t.tracks[0].forEach(function(e){i+=e.deltaTime,e.meta&&(e.type===`trackName`?r.name=e.text:(e.type===`text`||e.type===`cuePoint`||e.type===`marker`||e.type===`lyrics`)&&r.meta.push({text:e.text,ticks:i,type:e.type}))}),this.update()}}return r.prototype.update=function(){var e=this,t=0,n=0;this.tempos.sort(function(e,t){return e.ticks-t.ticks}),this.tempos.forEach(function(r,i){var a=i>0?e.tempos[i-1].bpm:e.tempos[0].bpm,o=r.ticks/e.ppq-n;r.time=60/a*o+t,t=r.time,n+=o}),this.timeSignatures.sort(function(e,t){return e.ticks-t.ticks}),this.timeSignatures.forEach(function(t,n){var r=n>0?e.timeSignatures[n-1]:e.timeSignatures[0],i=(t.ticks-r.ticks)/e.ppq/r.timeSignature[0]/(r.timeSignature[1]/4);r.measures=r.measures||0,t.measures=i+r.measures})},r.prototype.ticksToSeconds=function(e){var n=(0,t.search)(this.tempos,e);if(n!==-1){var r=this.tempos[n],i=r.time,a=(e-r.ticks)/this.ppq;return i+60/r.bpm*a}return 60/120*(e/this.ppq)},r.prototype.ticksToMeasures=function(e){var n=(0,t.search)(this.timeSignatures,e);if(n!==-1){var r=this.timeSignatures[n],i=(e-r.ticks)/this.ppq;return r.measures+i/(r.timeSignature[0]/r.timeSignature[1])/4}return e/this.ppq/4},Object.defineProperty(r.prototype,"ppq",{get:function(){return n.get(this)},enumerable:!1,configurable:!0}),r.prototype.secondsToTicks=function(e){var n=(0,t.search)(this.tempos,e,`time`);if(n!==-1){var r=this.tempos[n],i=(e-r.time)/(60/r.bpm);return Math.round(r.ticks+i*this.ppq)}var a=e/(60/120);return Math.round(a*this.ppq)},r.prototype.toJSON=function(){return{keySignatures:this.keySignatures,meta:this.meta,name:this.name,ppq:this.ppq,tempos:this.tempos.map(function(e){return{bpm:e.bpm,ticks:e.ticks}}),timeSignatures:this.timeSignatures}},r.prototype.fromJSON=function(e){this.name=e.name,this.tempos=e.tempos.map(function(e){return Object.assign({},e)}),this.timeSignatures=e.timeSignatures.map(function(e){return Object.assign({},e)}),this.keySignatures=e.keySignatures.map(function(e){return Object.assign({},e)}),this.meta=e.meta.map(function(e){return Object.assign({},e)}),n.set(this,e.ppq),this.update()},r.prototype.setTempo=function(e){this.tempos=[{bpm:e,ticks:0}],this.update()},r}()})),Hu=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ControlChange=e.controlChangeIds=e.controlChangeNames=void 0,e.controlChangeNames={1:`modulationWheel`,2:`breath`,4:`footController`,5:`portamentoTime`,7:`volume`,8:`balance`,10:`pan`,64:`sustain`,65:`portamentoTime`,66:`sostenuto`,67:`softPedal`,68:`legatoFootswitch`,84:`portamentoControl`},e.controlChangeIds=Object.keys(e.controlChangeNames).reduce(function(t,n){return t[e.controlChangeNames[n]]=n,t},{});var t=new WeakMap,n=new WeakMap;e.ControlChange=function(){function r(e,r){t.set(this,r),n.set(this,e.controllerType),this.ticks=e.absoluteTime,this.value=e.value}return Object.defineProperty(r.prototype,"number",{get:function(){return n.get(this)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return e.controlChangeNames[this.number]?e.controlChangeNames[this.number]:null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"time",{get:function(){return t.get(this).ticksToSeconds(this.ticks)},set:function(e){var n=t.get(this);this.ticks=n.secondsToTicks(e)},enumerable:!1,configurable:!0}),r.prototype.toJSON=function(){return{number:this.number,ticks:this.ticks,time:this.time,value:this.value}},r}()})),Uu=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createControlChanges=void 0;var t=Hu();function n(){return new Proxy({},{get:function(e,n){if(e[n])return e[n];if(t.controlChangeIds.hasOwnProperty(n))return e[t.controlChangeIds[n]]},set:function(e,n,r){return t.controlChangeIds.hasOwnProperty(n)?e[t.controlChangeIds[n]]=r:e[n]=r,!0}})}e.createControlChanges=n})),Wu=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PitchBend=void 0;var t=new WeakMap;e.PitchBend=function(){function e(e,n){t.set(this,n),this.ticks=e.absoluteTime,this.value=e.value}return Object.defineProperty(e.prototype,"time",{get:function(){return t.get(this).ticksToSeconds(this.ticks)},set:function(e){var n=t.get(this);this.ticks=n.secondsToTicks(e)},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){return{ticks:this.ticks,time:this.time,value:this.value}},e}()})),Gu=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DrumKitByPatchID=e.InstrumentFamilyByID=e.instrumentByPatchID=void 0,e.instrumentByPatchID=`acoustic grand piano.bright acoustic piano.electric grand piano.honky-tonk piano.electric piano 1.electric piano 2.harpsichord.clavi.celesta.glockenspiel.music box.vibraphone.marimba.xylophone.tubular bells.dulcimer.drawbar organ.percussive organ.rock organ.church organ.reed organ.accordion.harmonica.tango accordion.acoustic guitar (nylon).acoustic guitar (steel).electric guitar (jazz).electric guitar (clean).electric guitar (muted).overdriven guitar.distortion guitar.guitar harmonics.acoustic bass.electric bass (finger).electric bass (pick).fretless bass.slap bass 1.slap bass 2.synth bass 1.synth bass 2.violin.viola.cello.contrabass.tremolo strings.pizzicato strings.orchestral harp.timpani.string ensemble 1.string ensemble 2.synthstrings 1.synthstrings 2.choir aahs.voice oohs.synth voice.orchestra hit.trumpet.trombone.tuba.muted trumpet.french horn.brass section.synthbrass 1.synthbrass 2.soprano sax.alto sax.tenor sax.baritone sax.oboe.english horn.bassoon.clarinet.piccolo.flute.recorder.pan flute.blown bottle.shakuhachi.whistle.ocarina.lead 1 (square).lead 2 (sawtooth).lead 3 (calliope).lead 4 (chiff).lead 5 (charang).lead 6 (voice).lead 7 (fifths).lead 8 (bass + lead).pad 1 (new age).pad 2 (warm).pad 3 (polysynth).pad 4 (choir).pad 5 (bowed).pad 6 (metallic).pad 7 (halo).pad 8 (sweep).fx 1 (rain).fx 2 (soundtrack).fx 3 (crystal).fx 4 (atmosphere).fx 5 (brightness).fx 6 (goblins).fx 7 (echoes).fx 8 (sci-fi).sitar.banjo.shamisen.koto.kalimba.bag pipe.fiddle.shanai.tinkle bell.agogo.steel drums.woodblock.taiko drum.melodic tom.synth drum.reverse cymbal.guitar fret noise.breath noise.seashore.bird tweet.telephone ring.helicopter.applause.gunshot`.split(`.`),e.InstrumentFamilyByID=[`piano`,`chromatic percussion`,`organ`,`guitar`,`bass`,`strings`,`ensemble`,`brass`,`reed`,`pipe`,`synth lead`,`synth pad`,`synth effects`,`world`,`percussive`,`sound effects`],e.DrumKitByPatchID={0:`standard kit`,8:`room kit`,16:`power kit`,24:`electronic kit`,25:`tr-808 kit`,32:`jazz kit`,40:`brush kit`,48:`orchestra kit`,56:`sound fx kit`}})),Ku=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Instrument=void 0;var t=Gu(),n=new WeakMap;e.Instrument=function(){function e(e,t){if(this.number=0,n.set(this,t),this.number=0,e){var r=e.find(function(e){return e.type===`programChange`});r&&(this.number=r.programNumber)}}return Object.defineProperty(e.prototype,"name",{get:function(){return this.percussion?t.DrumKitByPatchID[this.number]:t.instrumentByPatchID[this.number]},set:function(e){var n=t.instrumentByPatchID.indexOf(e);n!==-1&&(this.number=n)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"family",{get:function(){return this.percussion?`drums`:t.InstrumentFamilyByID[Math.floor(this.number/8)]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"percussion",{get:function(){return n.get(this).channel===9},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){return{family:this.family,number:this.number,name:this.name}},e.prototype.fromJSON=function(e){this.number=e.number},e}()})),qu=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Note=void 0;function t(e){var t=Math.floor(e/12)-1;return n(e)+t.toString()}function n(e){return[`C`,`C#`,`D`,`D#`,`E`,`F`,`F#`,`G`,`G#`,`A`,`A#`,`B`][e%12]}function r(e){return[`C`,`C#`,`D`,`D#`,`E`,`F`,`F#`,`G`,`G#`,`A`,`A#`,`B`].indexOf(e)}var i=function(){var e=/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,t={cbb:-2,cb:-1,c:0,"c#":1,cx:2,dbb:0,db:1,d:2,"d#":3,dx:4,ebb:2,eb:3,e:4,"e#":5,ex:6,fbb:3,fb:4,f:5,"f#":6,fx:7,gbb:5,gb:6,g:7,"g#":8,gx:9,abb:7,ab:8,a:9,"a#":10,ax:11,bbb:9,bb:10,b:11,"b#":12,bx:13};return function(n){var r=e.exec(n),i=r[1],a=r[2];return t[i.toLowerCase()]+(parseInt(a,10)+1)*12}}(),a=new WeakMap;e.Note=function(){function e(e,t,n){a.set(this,n),this.midi=e.midi,this.velocity=e.velocity,this.noteOffVelocity=t.velocity,this.ticks=e.ticks,this.durationTicks=t.ticks-e.ticks}return Object.defineProperty(e.prototype,"name",{get:function(){return t(this.midi)},set:function(e){this.midi=i(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"octave",{get:function(){return Math.floor(this.midi/12)-1},set:function(e){var t=e-this.octave;this.midi+=t*12},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pitch",{get:function(){return n(this.midi)},set:function(e){this.midi=12*(this.octave+1)+r(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){var e=a.get(this);return e.ticksToSeconds(this.ticks+this.durationTicks)-e.ticksToSeconds(this.ticks)},set:function(e){var t=a.get(this).secondsToTicks(this.time+e);this.durationTicks=t-this.ticks},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"time",{get:function(){return a.get(this).ticksToSeconds(this.ticks)},set:function(e){var t=a.get(this);this.ticks=t.secondsToTicks(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bars",{get:function(){return a.get(this).ticksToMeasures(this.ticks)},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){return{duration:this.duration,durationTicks:this.durationTicks,midi:this.midi,name:this.name,ticks:this.ticks,time:this.time,velocity:this.velocity}},e}()})),Ju=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Track=void 0;var t=Bu(),n=Hu(),r=Uu(),i=Wu(),a=Ku(),o=qu(),s=new WeakMap;e.Track=function(){function e(e,t){var n=this;if(this.name=``,this.notes=[],this.controlChanges=(0,r.createControlChanges)(),this.pitchBends=[],s.set(this,t),e){var i=e.find(function(e){return e.type===`trackName`});this.name=i?i.text:``}if(this.instrument=new a.Instrument(e,this),this.channel=0,e){for(var o=e.filter(function(e){return e.type===`noteOn`}),c=e.filter(function(e){return e.type===`noteOff`}),l=function(){var e=o.shift();u.channel=e.channel;var t=c.findIndex(function(t){return t.noteNumber===e.noteNumber&&t.absoluteTime>=e.absoluteTime});if(t!==-1){var n=c.splice(t,1)[0];u.addNote({durationTicks:n.absoluteTime-e.absoluteTime,midi:e.noteNumber,noteOffVelocity:n.velocity/127,ticks:e.absoluteTime,velocity:e.velocity/127})}},u=this;o.length;)l();e.filter(function(e){return e.type===`controller`}).forEach(function(e){n.addCC({number:e.controllerType,ticks:e.absoluteTime,value:e.value/127})}),e.filter(function(e){return e.type===`pitchBend`}).forEach(function(e){n.addPitchBend({ticks:e.absoluteTime,value:e.value/8192})});var d=e.find(function(e){return e.type===`endOfTrack`});this.endOfTrackTicks=d===void 0?void 0:d.absoluteTime}}return e.prototype.addNote=function(e){var n=s.get(this),r=new o.Note({midi:0,ticks:0,velocity:1},{ticks:0,velocity:0},n);return Object.assign(r,e),(0,t.insert)(this.notes,r,`ticks`),this},e.prototype.addCC=function(e){var r=s.get(this),i=new n.ControlChange({controllerType:e.number},r);return delete e.number,Object.assign(i,e),Array.isArray(this.controlChanges[i.number])||(this.controlChanges[i.number]=[]),(0,t.insert)(this.controlChanges[i.number],i,`ticks`),this},e.prototype.addPitchBend=function(e){var n=s.get(this),r=new i.PitchBend({},n);return Object.assign(r,e),(0,t.insert)(this.pitchBends,r,`ticks`),this},Object.defineProperty(e.prototype,"duration",{get:function(){if(!this.notes.length)return 0;for(var e=this.notes[this.notes.length-1].time+this.notes[this.notes.length-1].duration,t=0;t<this.notes.length-1;t++){var n=this.notes[t].time+this.notes[t].duration;e<n&&(e=n)}return e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"durationTicks",{get:function(){if(!this.notes.length)return 0;for(var e=this.notes[this.notes.length-1].ticks+this.notes[this.notes.length-1].durationTicks,t=0;t<this.notes.length-1;t++){var n=this.notes[t].ticks+this.notes[t].durationTicks;e<n&&(e=n)}return e},enumerable:!1,configurable:!0}),e.prototype.fromJSON=function(e){var t=this;for(var n in this.name=e.name,this.channel=e.channel,this.instrument=new a.Instrument(void 0,this),this.instrument.fromJSON(e.instrument),e.endOfTrackTicks!==void 0&&(this.endOfTrackTicks=e.endOfTrackTicks),e.controlChanges)e.controlChanges[n]&&e.controlChanges[n].forEach(function(e){t.addCC({number:e.number,ticks:e.ticks,value:e.value})});e.notes.forEach(function(e){t.addNote({durationTicks:e.durationTicks,midi:e.midi,ticks:e.ticks,velocity:e.velocity})})},e.prototype.toJSON=function(){for(var e={},t=0;t<127;t++)this.controlChanges.hasOwnProperty(t)&&(e[t]=this.controlChanges[t].map(function(e){return e.toJSON()}));var n={channel:this.channel,controlChanges:e,pitchBends:this.pitchBends.map(function(e){return e.toJSON()}),instrument:this.instrument.toJSON(),name:this.name,notes:this.notes.map(function(e){return e.toJSON()})};return this.endOfTrackTicks!==void 0&&(n.endOfTrackTicks=this.endOfTrackTicks),n},e}()})),Yu=s({flatten:()=>Xu});function Xu(e){var t=[];return Zu(e,t),t}function Zu(e,t){for(var n=0;n<e.length;n++){var r=e[n];Array.isArray(r)?Zu(r,t):t.push(r)}}var Qu=o(((e,t,n)=>{var r=n&&n.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,"__esModule",{value:!0}),e.encode=void 0;var i=zu(),a=Vu(),o=u(Yu);function s(e,t){return[{absoluteTime:e.ticks,channel:t,deltaTime:0,noteNumber:e.midi,type:`noteOn`,velocity:Math.floor(e.velocity*127)},{absoluteTime:e.ticks+e.durationTicks,channel:t,deltaTime:0,noteNumber:e.midi,type:`noteOff`,velocity:Math.floor(e.noteOffVelocity*127)}]}function c(e){return(0,o.flatten)(e.notes.map(function(t){return s(t,e.channel)}))}function l(e,t){return{absoluteTime:e.ticks,channel:t,controllerType:e.number,deltaTime:0,type:`controller`,value:Math.floor(e.value*127)}}function d(e){for(var t=[],n=0;n<127;n++)e.controlChanges.hasOwnProperty(n)&&e.controlChanges[n].forEach(function(n){t.push(l(n,e.channel))});return t}function f(e,t){return{absoluteTime:e.ticks,channel:t,deltaTime:0,type:`pitchBend`,value:e.value}}function p(e){var t=[];return e.pitchBends.forEach(function(n){t.push(f(n,e.channel))}),t}function m(e){return{absoluteTime:0,channel:e.channel,deltaTime:0,programNumber:e.instrument.number,type:`programChange`}}function h(e){return{absoluteTime:0,deltaTime:0,meta:!0,text:e,type:`trackName`}}function g(e){return{absoluteTime:e.ticks,deltaTime:0,meta:!0,microsecondsPerBeat:Math.floor(6e7/e.bpm),type:`setTempo`}}function _(e){return{absoluteTime:e.ticks,deltaTime:0,denominator:e.timeSignature[1],meta:!0,metronome:24,numerator:e.timeSignature[0],thirtyseconds:8,type:`timeSignature`}}function v(e){var t=a.keySignatureKeys.indexOf(e.key);return{absoluteTime:e.ticks,deltaTime:0,key:t+7,meta:!0,scale:e.scale===`major`?0:1,type:`keySignature`}}function y(e){return{absoluteTime:e.ticks,deltaTime:0,meta:!0,text:e.text,type:e.type}}function b(e){var t={header:{format:1,numTracks:e.tracks.length+1,ticksPerBeat:e.header.ppq},tracks:r([r(r(r(r([{absoluteTime:0,deltaTime:0,meta:!0,text:e.header.name,type:`trackName`}],e.header.keySignatures.map(function(e){return v(e)}),!0),e.header.meta.map(function(e){return y(e)}),!0),e.header.tempos.map(function(e){return g(e)}),!0),e.header.timeSignatures.map(function(e){return _(e)}),!0)],e.tracks.map(function(e){return r(r(r([h(e.name),m(e)],c(e),!0),d(e),!0),p(e),!0)}),!0)};return t.tracks=t.tracks.map(function(e){e=e.sort(function(e,t){return e.absoluteTime-t.absoluteTime});var t=0;return e.forEach(function(e){e.deltaTime=e.absoluteTime-t,t=e.absoluteTime,delete e.absoluteTime}),e.push({deltaTime:0,meta:!0,type:`endOfTrack`}),e}),new Uint8Array((0,i.writeMidi)(t))}e.encode=b})),$u=l(o(((e,t,n)=>{var r=n&&n.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},i=n&&n.__generator||function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o={next:s(0),throw:s(1),return:s(2)};return typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(o){if(r)throw TypeError(`Generator is already executing.`);for(;n;)try{if(r=1,i&&(a=o[0]&2?i.return:o[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;switch(i=0,a&&(o=[o[0]&2,a.value]),o[0]){case 0:case 1:a=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if(a=n.trys,!(a=a.length>0&&a[a.length-1])&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1],a=o;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(o);break}a[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e],i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}};Object.defineProperty(e,"__esModule",{value:!0}),e.Header=e.Track=e.Midi=void 0;var a=zu(),o=Vu(),s=Ju(),c=Qu();e.Midi=function(){function e(e){var t=this,n=null;if(e){var r=e instanceof ArrayBuffer?new Uint8Array(e):e;n=(0,a.parseMidi)(r),n.tracks.forEach(function(e){var t=0;e.forEach(function(e){t+=e.deltaTime,e.absoluteTime=t})}),n.tracks=d(n.tracks)}this.header=new o.Header(n),this.tracks=[],e&&(this.tracks=n.tracks.map(function(e){return new s.Track(e,t.header)}),n.header.format===1&&this.tracks[0].duration===0&&this.tracks.shift())}return e.fromUrl=function(t){return r(this,void 0,void 0,function(){var n,r;return i(this,function(i){switch(i.label){case 0:return[4,fetch(t)];case 1:return n=i.sent(),n.ok?[4,n.arrayBuffer()]:[3,3];case 2:return r=i.sent(),[2,new e(r)];case 3:throw Error(`Could not load '${t}'`)}})})},Object.defineProperty(e.prototype,"name",{get:function(){return this.header.name},set:function(e){this.header.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){var e=this.tracks.map(function(e){return e.duration});return Math.max.apply(Math,e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"durationTicks",{get:function(){var e=this.tracks.map(function(e){return e.durationTicks});return Math.max.apply(Math,e)},enumerable:!1,configurable:!0}),e.prototype.addTrack=function(){var e=new s.Track(void 0,this.header);return this.tracks.push(e),e},e.prototype.toArray=function(){return(0,c.encode)(this)},e.prototype.toJSON=function(){return{header:this.header.toJSON(),tracks:this.tracks.map(function(e){return e.toJSON()})}},e.prototype.fromJSON=function(e){var t=this;this.header=new o.Header,this.header.fromJSON(e.header),this.tracks=e.tracks.map(function(e){var n=new s.Track(void 0,t.header);return n.fromJSON(e),n})},e.prototype.clone=function(){var t=new e;return t.fromJSON(this.toJSON()),t},e}();var l=Ju();Object.defineProperty(e,"Track",{enumerable:!0,get:function(){return l.Track}});var u=Vu();Object.defineProperty(e,"Header",{enumerable:!0,get:function(){return u.Header}});function d(e){for(var t=[],n=0;n<e.length;n++)for(var r=t.length,i=new Map,a=Array(16).fill(0),o=0,s=e[n];o<s.length;o++){var c=s[o],l=r,u=c.channel;if(u!==void 0){c.type===`programChange`&&(a[u]=c.programNumber);var d=`${a[u]} ${u}`;i.has(d)?l=i.get(d):(l=r+i.size,i.set(d,l))}t[l]||t.push([]),t[l].push(c)}return t}}))(),1),ed=$u.Midi??$u.default.Midi;function td(e,t){if(t===`backing:chords`)return`Chords`;if(t===`backing:bass`)return`Bass`;if(t===`backing:drums`)return`Drums`;for(let n of e.scenes){let e=n.layers.find(e=>e.id===t);if(e)return e.name}return t}function nd(e,t){let n=e.scenes.find(e=>e.layers.some(e=>e.id===t))??e.scenes[0];return t===`backing:chords`?n.backing.chords.volume:t===`backing:bass`?n.backing.bass.volume:t===`backing:drums`?n.backing.drums.volume:n.layers.find(e=>e.id===t)?.volume??.8}function rd(e,t){let n=new ed;n.name=e.name,n.header.setTempo(t.bpm);let r=n.header.ppq,i=new Map,a=0;for(let o of t.events){let t=i.get(o.track);t||(t=n.addTrack(),t.name=td(e,o.track),o.instrument===`drums`?t.channel=9:(t.channel=a===9?++a:a,a=(t.channel+1)%16,t.instrument.number=we[o.instrument].gm),i.set(o.track,t));let s=Math.max(.04,Math.min(1,o.velocity*(.4+.6*nd(e,o.track))));t.addNote({midi:o.midi,ticks:Math.round(o.time*r),durationTicks:Math.max(1,Math.round(o.duration*r)),velocity:s})}return n.toArray()}function id(e,t){return e.find(e=>t<=e.maxVelocity)??e[e.length-1]}var V=`15.1.22`,ad=o(((e,t)=>{function n(e){if(Array.isArray(e))return e}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),H=o(((e,t)=>{function n(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),U=o(((e,t)=>{function n(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),od=o(((e,t)=>{var n=U();function r(e,t){if(e){if(typeof e==`string`)return n(e,t);var r={}.toString.call(e).slice(8,-1);return r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`?Array.from(e):r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})),sd=o(((e,t)=>{function n(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
65
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),cd=o(((e,t)=>{var n=ad(),r=H(),i=od(),a=sd();function o(e,t){return n(e)||r(e,t)||i(e,t)||a()}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports})),ld=o(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),ud=o(((e,t)=>{function n(e){"@babel/helpers - typeof";return t.exports=n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t.exports.__esModule=!0,t.exports.default=t.exports,n(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),dd=o(((e,t)=>{var n=ud().default;function r(e,t){if(n(e)!=`object`||!e)return e;var r;if(typeof Symbol<`u`&&(r=e[Symbol.toPrimitive])!==void 0){var i=r.call(e,t||`default`);if(n(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})),fd=o(((e,t)=>{var n=ud().default,r=dd();function i(e){var t=r(e,`string`);return n(t)==`symbol`?t:t+``}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports})),pd=o(((e,t)=>{var n=fd();function r(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,`value`in i&&(i.writable=!0),Object.defineProperty(e,n(i.key),i)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports})),md=o(((e,t,n)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e,cd(),ld(),pd()):typeof define==`function`&&define.amd?define([`exports`,`@babel/runtime/helpers/slicedToArray`,`@babel/runtime/helpers/classCallCheck`,`@babel/runtime/helpers/createClass`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n.automationEvents={},n._slicedToArray,n._classCallCheck,n._createClass))})(n,(function(e,t,n,r){var i=function(e,t,n){return{endTime:t,insertTime:n,type:`exponentialRampToValue`,value:e}},a=function(e,t,n){return{endTime:t,insertTime:n,type:`linearRampToValue`,value:e}},o=function(e,t){return{startTime:t,type:`setValue`,value:e}},s=function(e,t,n){return{duration:n,startTime:t,type:`setValueCurve`,values:e}},c=function(e,t,n){var r=n.startTime,i=n.target,a=n.timeConstant;return i+(t-i)*Math.exp((r-e)/a)},l=function(e){return e.type===`exponentialRampToValue`},u=function(e){return e.type===`linearRampToValue`},d=function(e){return l(e)||u(e)},f=function(e){return e.type===`setValue`},p=function(e){return e.type===`setValueCurve`},m=function(e,t,n,r){var i=e[t];return i===void 0?r:d(i)||f(i)?i.value:p(i)?i.values[i.values.length-1]:c(n,m(e,t-1,i.startTime,r),i)},h=function(e,t,n,r,i){return n===void 0?[r.insertTime,i]:d(n)?[n.endTime,n.value]:f(n)?[n.startTime,n.value]:p(n)?[n.startTime+n.duration,n.values[n.values.length-1]]:[n.startTime,m(e,t-1,n.startTime,i)]},g=function(e){return e.type===`cancelAndHold`},_=function(e){return e.type===`cancelScheduledValues`},v=function(e){return g(e)||_(e)?e.cancelTime:l(e)||u(e)?e.endTime:e.startTime},y=function(e,t,n,r){var i=r.endTime,a=r.value;return n===a?a:0<n&&0<a||n<0&&a<0?n*(a/n)**+((e-t)/(i-t)):e<i?n:a},b=function(e,t,n,r){var i=r.endTime,a=r.value;return n+(e-t)/(i-t)*(a-n)},x=function(e,t){var n=Math.floor(t);if(n===t)return e[n];var r=Math.ceil(t);return(1-(t-n))*e[n]+(1-(r-t))*e[r]},S=function(e,t){var n=t.duration,r=t.startTime,i=t.values;return x(i,(e-r)/n*(i.length-1))},C=function(e,t,n){for(var r=e.length,i=Math.max(1,Math.floor(n/t*r))+1,a=e instanceof Float32Array?new Float32Array(i):e.slice(0,i),o=0;o<i;o+=1){var s=o/(i-1)*n/t*(r-1);a[o]=x(e,s)}return a},w=function(e){return e.type===`setTarget`};e.AutomationEventList=function(){function e(t){n(this,e),this._automationEvents=[],this._currenTime=0,this._defaultValue=t}return r(e,[{key:Symbol.iterator,value:function(){return this._automationEvents[Symbol.iterator]()}},{key:`add`,value:function(e){var t=v(e);if(g(e)||_(e)){var n=this._automationEvents.findIndex(function(n){return _(e)&&p(n)?n.startTime+n.duration>=t:v(n)>=t}),r=this._automationEvents[n];if(n!==-1&&(this._automationEvents=this._automationEvents.slice(0,n)),g(e)){var c=this._automationEvents[this._automationEvents.length-1];if(r!==void 0&&d(r)){if(c!==void 0&&w(c))throw Error(`The internal list is malformed.`);var f=c===void 0?r.insertTime:p(c)?c.startTime+c.duration:v(c),m=c===void 0?this._defaultValue:p(c)?c.values[c.values.length-1]:c.value,h=l(r)?y(t,f,m,r):b(t,f,m,r),x=l(r)?i(h,t,this._currenTime):a(h,t,this._currenTime);this._automationEvents.push(x)}if(c!==void 0&&w(c)&&this._automationEvents.push(o(this.getValue(t),t)),c!==void 0&&p(c)&&c.startTime+c.duration>t){var S=t-c.startTime;this._automationEvents[this._automationEvents.length-1]=s(C(c.values,c.duration,S),c.startTime,S)}}}else{var T=this._automationEvents.findIndex(function(e){return v(e)>t}),E=T===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[T-1];if(E!==void 0&&p(E)&&v(E)+E.duration>t)return!1;var D=l(e)?i(e.value,e.endTime,this._currenTime):u(e)?a(e.value,t,this._currenTime):e;if(T===-1)this._automationEvents.push(D);else{if(p(e)&&t+e.duration>v(this._automationEvents[T]))return!1;this._automationEvents.splice(T,0,D)}}return!0}},{key:`flush`,value:function(e){var t=this._automationEvents.findIndex(function(t){return v(t)>e});if(t>1){var n=this._automationEvents.slice(t-1),r=n[0];w(r)&&n.unshift(o(m(this._automationEvents,t-2,r.startTime,this._defaultValue),r.startTime)),this._automationEvents=n}}},{key:`getValue`,value:function(e){if(this._automationEvents.length===0)return this._defaultValue;var n=this._automationEvents.findIndex(function(t){return v(t)>e}),r=this._automationEvents[n],i=(n===-1?this._automationEvents.length:n)-1,a=this._automationEvents[i];if(a!==void 0&&w(a)&&(r===void 0||!d(r)||r.insertTime>e))return c(e,m(this._automationEvents,i-1,a.startTime,this._defaultValue),a);if(a!==void 0&&f(a)&&(r===void 0||!d(r)))return a.value;if(a!==void 0&&p(a)&&(r===void 0||!d(r)||a.startTime+a.duration>e))return e<a.startTime+a.duration?S(e,a):a.values[a.values.length-1];if(a!==void 0&&d(a)&&(r===void 0||!d(r)))return a.value;if(r!==void 0&&l(r)){var o=t(h(this._automationEvents,i,a,r,this._defaultValue),2),s=o[0],g=o[1];return y(e,s,g,r)}if(r!==void 0&&u(r)){var _=t(h(this._automationEvents,i,a,r,this._defaultValue),2),x=_[0],C=_[1];return b(e,x,C,r)}return this._defaultValue}}])}(),e.createCancelAndHoldAutomationEvent=function(e){return{cancelTime:e,type:`cancelAndHold`}},e.createCancelScheduledValuesAutomationEvent=function(e){return{cancelTime:e,type:`cancelScheduledValues`}},e.createExponentialRampToValueAutomationEvent=function(e,t){return{endTime:t,type:`exponentialRampToValue`,value:e}},e.createLinearRampToValueAutomationEvent=function(e,t){return{endTime:t,type:`linearRampToValue`,value:e}},e.createSetTargetAutomationEvent=function(e,t,n){return{startTime:t,target:e,timeConstant:n,type:`setTarget`}},e.createSetValueAutomationEvent=o,e.createSetValueCurveAutomationEvent=s}))}))(),hd=()=>new DOMException(``,`AbortError`),gd=e=>(t,n,[r,i,a],o)=>{e(t[i],[n,r,a],e=>e[0]===n&&e[1]===r,o)},_d=e=>(t,n,r)=>{let i=[];for(let e=0;e<r.numberOfInputs;e+=1)i.push(new Set);e.set(t,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:n})},vd=e=>(t,n)=>{e.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:n})},yd=new WeakSet,bd=new WeakMap,xd=new WeakMap,Sd=new WeakMap,Cd=new WeakMap,wd=new WeakMap,Td=new WeakMap,Ed=new WeakMap,Dd=new WeakMap,Od=new WeakMap,kd={construct(){return kd}},Ad=e=>{try{new new Proxy(e,kd)}catch{return!1}return!0},jd=/^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/,Md=(e,t)=>{let n=[],r=e.replace(/^[\s]+/,``),i=r.match(jd);for(;i!==null;){let e=i[1].slice(1,-1),a=i[0].replace(/([\s]+)?;?$/,``).replace(e,new URL(e,t).toString());n.push(a),r=r.slice(i[0].length).replace(/^[\s]+/,``),i=r.match(jd)}return[n.join(`;`),r]},Nd=e=>{if(e!==void 0&&!Array.isArray(e))throw TypeError(`The parameterDescriptors property of given value for processorCtor is not an array.`)},Pd=e=>{if(!Ad(e))throw TypeError(`The given value for processorCtor should be a constructor.`);if(e.prototype===null||typeof e.prototype!=`object`)throw TypeError(`The given value for processorCtor should have a prototype.`)},Fd=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=0;return(m,h,g={credentials:`omit`})=>{let _=u.get(m);if(_!==void 0&&_.has(h))return Promise.resolve();let v=l.get(m);if(v!==void 0){let e=v.get(h);if(e!==void 0)return e}let y=a(m),b=y.audioWorklet===void 0?i(h).then(([e,t])=>{let[r,i]=Md(e,t);return n(`${r};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${i}
|
|
66
|
+
})})(window,'_AWGS')`)}).then(()=>{let e=f._AWGS.pop();if(e===void 0)throw SyntaxError();r(y.currentTime,y.sampleRate,()=>e(class{},void 0,(e,n)=>{if(e.trim()===``)throw t();let r=Dd.get(y);if(r!==void 0){if(r.has(e))throw t();Pd(n),Nd(n.parameterDescriptors),r.set(e,n)}else Pd(n),Nd(n.parameterDescriptors),Dd.set(y,new Map([[e,n]]))},y.sampleRate,void 0,void 0))}):Promise.all([i(h),Promise.resolve(e(d,d))]).then(([[e,t],n])=>{let r=p+1;p=r;let[i,a]=Md(e,t),l=`${i};((AudioWorkletProcessor,registerProcessor)=>{${a}
|
|
67
|
+
})(${n?`AudioWorkletProcessor`:`class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}`},(n,p)=>registerProcessor(n,class extends p{${n?``:`__c = (a) => a.forEach(e=>this.__b.add(e.buffer));`}process(i,o,p){${n?``:`i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));`}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${r}',class extends AudioWorkletProcessor{process(){return !1}})`,u=new Blob([l],{type:`application/javascript; charset=utf-8`}),d=URL.createObjectURL(u);return y.audioWorklet.addModule(d,g).then(()=>{if(s(y))return y;let e=o(y);return e.audioWorklet.addModule(d,g).then(()=>e)}).then(e=>{if(c===null)throw SyntaxError();try{new c(e,`__sac${r}`)}catch{throw SyntaxError()}}).finally(()=>URL.revokeObjectURL(d))});return v===void 0?l.set(m,new Map([[h,b]])):v.set(h,b),b.then(()=>{let e=u.get(m);e===void 0?u.set(m,new Set([h])):e.add(h)}).finally(()=>{let e=l.get(m);e!==void 0&&e.delete(h)}),b}},Id=(e,t)=>{let n=e.get(t);if(n===void 0)throw Error(`A value with the given key could not be found.`);return n},Ld=(e,t)=>{let n=Array.from(e).filter(t);if(n.length>1)throw Error(`More than one element was found.`);if(n.length===0)throw Error(`No element was found.`);let[r]=n;return e.delete(r),r},Rd=(e,t,n,r)=>{let i=Id(e,t),a=Ld(i,e=>e[0]===n&&e[1]===r);return i.size===0&&e.delete(t),a},zd=e=>Id(Td,e),Bd=e=>{if(yd.has(e))throw Error(`The AudioNode is already stored.`);yd.add(e),zd(e).forEach(e=>e(!0))},Vd=e=>`port`in e,Hd=e=>{if(!yd.has(e))throw Error(`The AudioNode is not stored.`);yd.delete(e),zd(e).forEach(e=>e(!1))},Ud=(e,t)=>{!Vd(e)&&t.every(e=>e.size===0)&&Hd(e)},Wd=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=new WeakMap;return(m,h,g,_,v)=>{let{activeInputs:y,passiveInputs:b}=a(h),{outputs:x}=a(m),S=s(m),C=a=>{let s=c(h),l=c(m);if(a){let t=Rd(b,m,g,_);e(y,m,t,!1),!v&&!d(m)&&n(l,s,g,_),f(h)&&Bd(h)}else{let e=r(y,m,g,_);t(b,_,e,!1),!v&&!d(m)&&i(l,s,g,_);let n=o(h);if(n===0)u(h)&&Ud(h,y);else{let e=p.get(h);e!==void 0&&clearTimeout(e),p.set(h,setTimeout(()=>{u(h)&&Ud(h,y)},n*1e3))}}};return l(x,[h,g,_],e=>e[0]===h&&e[1]===g&&e[2]===_,!0)?(S.add(C),u(m)?e(y,m,[g,_,C],!0):t(b,_,[m,g,C],!0),!0):!1}},Gd=e=>(t,n,[r,i,a],o)=>{let s=t.get(r);s===void 0?t.set(r,new Set([[i,n,a]])):e(s,[i,n,a],e=>e[0]===i&&e[1]===n,o)},Kd=e=>(t,n)=>{let r=e(t,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,gain:0});n.connect(r).connect(t.destination);let i=()=>{n.removeEventListener(`ended`,i),n.disconnect(r),r.disconnect()};n.addEventListener(`ended`,i)},qd=e=>(t,n)=>{e(t).add(n)},Jd={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},Yd=(e,t,n,r,i,a)=>class extends e{constructor(e,n){let o=i(e),s=r(o,{...Jd,...n}),c=a(o)?t():null;super(e,!1,s,c),this._nativeAnalyserNode=s}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(e){this._nativeAnalyserNode.fftSize=e}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(e){let t=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=e,!(e>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=t,n()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(e){let t=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=e,!(this._nativeAnalyserNode.maxDecibels>e))throw this._nativeAnalyserNode.minDecibels=t,n()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(e){this._nativeAnalyserNode.smoothingTimeConstant=e}getByteFrequencyData(e){this._nativeAnalyserNode.getByteFrequencyData(e)}getByteTimeDomainData(e){this._nativeAnalyserNode.getByteTimeDomainData(e)}getFloatFrequencyData(e){this._nativeAnalyserNode.getFloatFrequencyData(e)}getFloatTimeDomainData(e){this._nativeAnalyserNode.getFloatTimeDomainData(e)}},Xd=(e,t)=>e.context===t,Zd=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return Xd(o,a)||(o=e(a,{channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,fftSize:o.fftSize,maxDecibels:o.maxDecibels,minDecibels:o.minDecibels,smoothingTimeConstant:o.smoothingTimeConstant})),r.set(a,o),await n(i,a,o),o};return{render(e,t){let n=r.get(t);return n===void 0?i(e,t):Promise.resolve(n)}}},Qd=e=>{try{e.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},$d=()=>new DOMException(``,`IndexSizeError`),ef=e=>{e.getChannelData=(t=>n=>{try{return t.call(e,n)}catch(e){throw e.code===12?$d():e}})(e.getChannelData)},tf={numberOfChannels:1},nf=(e,t,n,r,i,a,o,s)=>{let c=null;return class l{constructor(l){if(i===null)throw Error(`Missing the native OfflineAudioContext constructor.`);let{length:u,numberOfChannels:d,sampleRate:f}={...tf,...l};c===null&&(c=new i(1,1,44100));let p=r!==null&&t(a,a)?new r({length:u,numberOfChannels:d,sampleRate:f}):c.createBuffer(d,u,f);if(p.numberOfChannels===0)throw n();return typeof p.copyFromChannel==`function`?t(Qd,()=>Qd(p))||s(p):(o(p),ef(p)),e.add(p),p}static[Symbol.hasInstance](t){return typeof t==`object`&&!!t&&Object.getPrototypeOf(t)===l.prototype||e.has(t)}}},rf=-34028234663852886e22,af=34028234663852886e22,of=e=>yd.has(e),sf={buffer:null,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,loop:!1,loopEnd:0,loopStart:0,playbackRate:1},cf=(e,t,n,r,i,a,o,s)=>class extends e{constructor(e,r){let s=a(e),c={...sf,...r},l=i(s,c),u=o(s),d=u?t():null;super(e,!1,l,d),this._audioBufferSourceNodeRenderer=d,this._isBufferNullified=!1,this._isBufferSet=c.buffer!==null,this._nativeAudioBufferSourceNode=l,this._onended=null,this._playbackRate=n(this,u,l.playbackRate,af,rf)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(e){if(this._nativeAudioBufferSourceNode.buffer=e,e!==null){if(this._isBufferSet)throw r();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(e){this._nativeAudioBufferSourceNode.loop=e}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(e){this._nativeAudioBufferSourceNode.loopEnd=e}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(e){this._nativeAudioBufferSourceNode.loopStart=e}get onended(){return this._onended}set onended(e){let t=typeof e==`function`?s(this,e):null;this._nativeAudioBufferSourceNode.onended=t;let n=this._nativeAudioBufferSourceNode.onended;this._onended=n!==null&&n===t?e:n}get playbackRate(){return this._playbackRate}start(e=0,t=0,n){if(this._nativeAudioBufferSourceNode.start(e,t,n),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.start=n===void 0?[e,t]:[e,t,n]),this.context.state!==`closed`){Bd(this);let e=()=>{this._nativeAudioBufferSourceNode.removeEventListener(`ended`,e),of(this)&&Hd(this)};this._nativeAudioBufferSourceNode.addEventListener(`ended`,e)}}stop(e=0){this._nativeAudioBufferSourceNode.stop(e),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=e)}},lf=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=null,s=null,c=async(c,l)=>{let u=n(c),d=Xd(u,l);return d||(u=t(l,{buffer:u.buffer,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,loop:u.loop,loopEnd:u.loopEnd,loopStart:u.loopStart,playbackRate:u.playbackRate.value}),o!==null&&u.start(...o),s!==null&&u.stop(s)),a.set(l,u),d?await e(l,c.playbackRate,u.playbackRate):await r(l,c.playbackRate,u.playbackRate),await i(c,l,u),u};return{set start(e){o=e},set stop(e){s=e},render(e,t){let n=a.get(t);return n===void 0?c(e,t):Promise.resolve(n)}}},uf=e=>`playbackRate`in e,df=e=>`frequency`in e&&`gain`in e,ff=e=>`offset`in e,pf=e=>!(`frequency`in e)&&`gain`in e,mf=e=>`detune`in e&&`frequency`in e&&!(`gain`in e),hf=e=>`pan`in e,gf=e=>Id(bd,e),_f=e=>Id(Sd,e),vf=(e,t)=>{let{activeInputs:n}=gf(e);n.forEach(n=>n.forEach(([n])=>{t.includes(e)||vf(n,[...t,e])}));let r=uf(e)?[e.playbackRate]:Vd(e)?Array.from(e.parameters.values()):df(e)?[e.Q,e.detune,e.frequency,e.gain]:ff(e)?[e.offset]:pf(e)?[e.gain]:mf(e)?[e.detune,e.frequency]:hf(e)?[e.pan]:[];for(let e of r){let n=_f(e);n!==void 0&&n.activeInputs.forEach(([e])=>vf(e,t))}of(e)&&Hd(e)},yf=e=>{vf(e.destination,[])},bf=e=>e===void 0||typeof e==`number`||typeof e==`string`&&(e===`balanced`||e===`interactive`||e===`playback`),xf=(e,t,n,r,i,a,o,s,c)=>class extends e{constructor(e={}){if(c===null)throw Error(`Missing the native AudioContext constructor.`);let t;try{t=new c(e)}catch(e){throw e.code===12&&e.message===`sampleRate is not in range`?n():e}if(t===null)throw r();if(!bf(e.latencyHint))throw TypeError(`The provided value '${e.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(e.sampleRate!==void 0&&t.sampleRate!==e.sampleRate)throw n();super(t,2);let{latencyHint:i}=e,{sampleRate:a}=t;if(this._baseLatency=typeof t.baseLatency==`number`?t.baseLatency:i===`balanced`?512/a:i===`interactive`||i===void 0?256/a:i===`playback`?1024/a:Math.max(2,Math.min(128,Math.round(i*a/128)))*128/a,this._nativeAudioContext=t,c.name===`webkitAudioContext`?(this._nativeGainNode=t.createGain(),this._nativeOscillatorNode=t.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(t.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,t.state===`running`){this._state=`suspended`;let e=()=>{this._state===`suspended`&&(this._state=null),t.removeEventListener(`statechange`,e)};t.addEventListener(`statechange`,e)}}get baseLatency(){return this._baseLatency}get state(){return this._state===null?this._nativeAudioContext.state:this._state}close(){return this.state===`closed`?this._nativeAudioContext.close().then(()=>{throw t()}):(this._state===`suspended`&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),yf(this)}))}createMediaElementSource(e){return new i(this,{mediaElement:e})}createMediaStreamDestination(){return new a(this)}createMediaStreamSource(e){return new o(this,{mediaStream:e})}createMediaStreamTrackSource(e){return new s(this,{mediaStreamTrack:e})}resume(){return this._state===`suspended`?new Promise((e,t)=>{let n=()=>{this._nativeAudioContext.removeEventListener(`statechange`,n),this._nativeAudioContext.state===`running`?e():this.resume().then(e,t)};this._nativeAudioContext.addEventListener(`statechange`,n)}):this._nativeAudioContext.resume().catch(e=>{throw e===void 0||e.code===15?t():e})}suspend(){return this._nativeAudioContext.suspend().catch(e=>{throw e===void 0?t():e})}},Sf=(e,t,n,r,i,a,o,s)=>class extends e{constructor(e,n){let r=a(e),c=o(r),l=i(r,n,c),u=c?t(s):null;super(e,!1,l,u),this._isNodeOfNativeOfflineAudioContext=c,this._nativeAudioDestinationNode=l}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(e){if(this._isNodeOfNativeOfflineAudioContext)throw r();if(e>this._nativeAudioDestinationNode.maxChannelCount)throw n();this._nativeAudioDestinationNode.channelCount=e}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(e){if(this._isNodeOfNativeOfflineAudioContext)throw r();this._nativeAudioDestinationNode.channelCountMode=e}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}},Cf=e=>{let t=new WeakMap,n=async(n,r)=>{let i=r.destination;return t.set(r,i),await e(n,r,i),i};return{render(e,r){let i=t.get(r);return i===void 0?n(e,r):Promise.resolve(i)}}},wf=(e,t,n,r,i,a,o,s)=>(c,l)=>{let u=l.listener,{forwardX:d,forwardY:f,forwardZ:p,positionX:m,positionY:h,positionZ:g,upX:_,upY:v,upZ:y}=u.forwardX===void 0?(()=>{let d=new Float32Array(1),f=t(l,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:9}),p=o(l),m=!1,h=[0,0,-1,0,1,0],g=[0,0,0],_=()=>{if(m)return;m=!0;let e=r(l,256,9,0);e.onaudioprocess=({inputBuffer:e})=>{let t=[a(e,d,0),a(e,d,1),a(e,d,2),a(e,d,3),a(e,d,4),a(e,d,5)];t.some((e,t)=>e!==h[t])&&(u.setOrientation(...t),h=t);let n=[a(e,d,6),a(e,d,7),a(e,d,8)];n.some((e,t)=>e!==g[t])&&(u.setPosition(...n),g=n)},f.connect(e)},v=e=>t=>{t!==h[e]&&(h[e]=t,u.setOrientation(...h))},y=e=>t=>{t!==g[e]&&(g[e]=t,u.setPosition(...g))},b=(t,r,a)=>{let o=n(l,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,offset:r});o.connect(f,0,t),o.start(),Object.defineProperty(o.offset,"defaultValue",{get(){return r}});let u=e({context:c},p,o.offset,af,rf);return s(u,`value`,e=>()=>e.call(u),e=>t=>{try{e.call(u,t)}catch(e){if(e.code!==9)throw e}_(),p&&a(t)}),u.cancelAndHoldAtTime=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.cancelAndHoldAtTime),u.cancelScheduledValues=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.cancelScheduledValues),u.exponentialRampToValueAtTime=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.exponentialRampToValueAtTime),u.linearRampToValueAtTime=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.linearRampToValueAtTime),u.setTargetAtTime=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.setTargetAtTime),u.setValueAtTime=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.setValueAtTime),u.setValueCurveAtTime=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.setValueCurveAtTime),u};return{forwardX:b(0,0,v(0)),forwardY:b(1,0,v(1)),forwardZ:b(2,-1,v(2)),positionX:b(6,0,y(0)),positionY:b(7,0,y(1)),positionZ:b(8,0,y(2)),upX:b(3,0,v(3)),upY:b(4,1,v(4)),upZ:b(5,0,v(5))}})():u;return{get forwardX(){return d},get forwardY(){return f},get forwardZ(){return p},get positionX(){return m},get positionY(){return h},get positionZ(){return g},get upX(){return _},get upY(){return v},get upZ(){return y}}},Tf=e=>`context`in e,Ef=e=>Tf(e[0]),Df=(e,t,n,r)=>{for(let t of e)if(n(t)){if(r)return!1;throw Error(`The set contains at least one similar element.`)}return e.add(t),!0},Of=(e,t,[n,r],i)=>{Df(e,[t,n,r],e=>e[0]===t&&e[1]===n,i)},kf=(e,[t,n,r],i)=>{let a=e.get(t);a===void 0?e.set(t,new Set([[n,r]])):Df(a,[n,r],e=>e[0]===n,i)},Af=e=>`inputs`in e,jf=(e,t,n,r)=>{if(Af(t)){let i=t.inputs[r];return e.connect(i,n,0),[i,n,0]}return e.connect(t,n,r),[t,n,r]},Mf=(e,t,n)=>{for(let r of e)if(r[0]===t&&r[1]===n)return e.delete(r),r;return null},Nf=(e,t,n)=>Ld(e,e=>e[0]===t&&e[1]===n),Pf=(e,t)=>{if(!zd(e).delete(t))throw Error(`Missing the expected event listener.`)},Ff=(e,t,n)=>{let r=Id(e,t),i=Ld(r,e=>e[0]===n);return r.size===0&&e.delete(t),i},If=(e,t,n,r)=>{Af(t)?e.disconnect(t.inputs[r],n,0):e.disconnect(t,n,r)},Lf=e=>Id(xd,e),Rf=e=>Id(Cd,e),zf=e=>Ed.has(e),Bf=e=>!yd.has(e),Vf=(e,t)=>new Promise(n=>{if(t!==null)n(!0);else{let t=e.createScriptProcessor(256,1,1),r=e.createGain(),i=e.createBuffer(1,2,44100),a=i.getChannelData(0);a[0]=1,a[1]=1;let o=e.createBufferSource();o.buffer=i,o.loop=!0,o.connect(t).connect(e.destination),o.connect(r),o.disconnect(r),t.onaudioprocess=r=>{let i=r.inputBuffer.getChannelData(0);Array.prototype.some.call(i,e=>e===1)?n(!0):n(!1),o.stop(),t.onaudioprocess=null,o.disconnect(t),t.disconnect(e.destination)},o.start()}}),Hf=(e,t)=>{let n=new Map;for(let t of e)for(let e of t){let t=n.get(e);n.set(e,t===void 0?1:t+1)}n.forEach((e,n)=>t(n,e))},Uf=e=>`context`in e,Wf=e=>{let t=new Map;e.connect=(e=>(n,r=0,i=0)=>{let a=Uf(n)?e(n,r,i):e(n,r),o=t.get(n);return o===void 0?t.set(n,[{input:i,output:r}]):o.every(e=>e.input!==i||e.output!==r)&&o.push({input:i,output:r}),a})(e.connect.bind(e)),e.disconnect=(n=>(r,i,a)=>{if(n.apply(e),r===void 0)t.clear();else if(typeof r==`number`)for(let[e,n]of t){let i=n.filter(e=>e.output!==r);i.length===0?t.delete(e):t.set(e,i)}else if(t.has(r)){if(i===void 0)t.delete(r);else{let e=t.get(r);if(e!==void 0){let n=e.filter(e=>e.output!==i&&(e.input!==a||a===void 0));n.length===0?t.delete(r):t.set(r,n)}}}for(let[n,r]of t)r.forEach(t=>{Uf(n)?e.connect(n,t.output,t.input):e.connect(n,t.output)})})(e.disconnect)},Gf=(e,t,n,r)=>{let{activeInputs:i,passiveInputs:a}=_f(t),{outputs:o}=gf(e),s=zd(e),c=o=>{let s=Lf(e),c=Rf(t);if(o){let t=Ff(a,e,n);Of(i,e,t,!1),!r&&!zf(e)&&s.connect(c,n)}else{let t=Nf(i,e,n);kf(a,t,!1),!r&&!zf(e)&&s.disconnect(c,n)}};return Df(o,[t,n],e=>e[0]===t&&e[1]===n,!0)?(s.add(c),of(e)?Of(i,e,[n,c],!0):kf(a,[e,n,c],!0),!0):!1},Kf=(e,t,n,r)=>{let{activeInputs:i,passiveInputs:a}=gf(t),o=Mf(i[r],e,n);return o===null?[Rd(a,e,n,r)[2],!1]:[o[2],!0]},qf=(e,t,n)=>{let{activeInputs:r,passiveInputs:i}=_f(t),a=Mf(r,e,n);return a===null?[Ff(i,e,n)[1],!1]:[a[2],!0]},Jf=(e,t,n,r,i)=>{let[a,o]=Kf(e,n,r,i);if(a!==null&&(Pf(e,a),o&&!t&&!zf(e)&&If(Lf(e),Lf(n),r,i)),of(n)){let{activeInputs:e}=gf(n);Ud(n,e)}},Yf=(e,t,n,r)=>{let[i,a]=qf(e,n,r);i!==null&&(Pf(e,i),a&&!t&&!zf(e)&&Lf(e).disconnect(Rf(n),r))},W=(e,t)=>{let n=gf(e),r=[];for(let i of n.outputs)Ef(i)?Jf(e,t,...i):Yf(e,t,...i),r.push(i[0]);return n.outputs.clear(),r},Xf=(e,t,n)=>{let r=gf(e),i=[];for(let a of r.outputs)a[1]===n&&(Ef(a)?Jf(e,t,...a):Yf(e,t,...a),i.push(a[0]),r.outputs.delete(a));return i},Zf=(e,t,n,r,i)=>{let a=gf(e);return Array.from(a.outputs).filter(e=>e[0]===n&&(r===void 0||e[1]===r)&&(i===void 0||e[2]===i)).map(n=>(Ef(n)?Jf(e,t,...n):Yf(e,t,...n),a.outputs.delete(n),n[0]))},Qf=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)=>class extends l{constructor(t,r,i,a){super(i),this._context=t,this._nativeAudioNode=i;let o=u(t);d(o)&&!0!==n(Vf,()=>Vf(o,h))&&Wf(i),xd.set(this,i),Td.set(this,new Set),t.state!==`closed`&&r&&Bd(this),e(this,a,i)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(e){this._nativeAudioNode.channelCount=e}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(e){this._nativeAudioNode.channelCountMode=e}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(e){this._nativeAudioNode.channelInterpretation=e}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(e,n=0,s=0){if(n<0||n>=this._nativeAudioNode.numberOfOutputs)throw i();let l=m(u(this._context));if(f(e)||p(e))throw a();if(Tf(e)){let i=Lf(e);try{let t=jf(this._nativeAudioNode,i,n,s),r=Bf(this);(l||r)&&this._nativeAudioNode.disconnect(...t),this.context.state!==`closed`&&!r&&Bf(e)&&Bd(e)}catch(e){throw e.code===12?a():e}return t(this,e,n,s,l)&&Hf(c([this],e),r(l)),e}let d=Rf(e);if(d.name===`playbackRate`&&d.maxValue===1024)throw o();try{this._nativeAudioNode.connect(d,n),(l||Bf(this))&&this._nativeAudioNode.disconnect(d,n)}catch(e){throw e.code===12?a():e}Gf(this,e,n,l)&&Hf(c([this],e),r(l))}disconnect(e,t,n){let r,o=m(u(this._context));if(e===void 0)r=W(this,o);else if(typeof e==`number`){if(e<0||e>=this.numberOfOutputs)throw i();r=Xf(this,o,e)}else{if(t!==void 0&&(t<0||t>=this.numberOfOutputs)||Tf(e)&&n!==void 0&&(n<0||n>=e.numberOfInputs))throw i();if(r=Zf(this,o,e,t,n),r.length===0)throw a()}for(let e of r)Hf(c([this],e),s)}},$f=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>(p,m,h,g=null,_=null)=>{let v=h.value,y=new md.AutomationEventList(v),b=m?r(y):null,x={get defaultValue(){return v},get maxValue(){return g===null?h.maxValue:g},get minValue(){return _===null?h.minValue:_},get value(){return h.value},set value(e){h.value=e,x.setValueAtTime(e,p.context.currentTime)},cancelAndHoldAtTime(e){if(typeof h.cancelAndHoldAtTime==`function`)b===null&&y.flush(p.context.currentTime),y.add(i(e)),h.cancelAndHoldAtTime(e);else{let t=Array.from(y).pop();b===null&&y.flush(p.context.currentTime),y.add(i(e));let n=Array.from(y).pop();h.cancelScheduledValues(e),t!==n&&n!==void 0&&(n.type===`exponentialRampToValue`?h.exponentialRampToValueAtTime(n.value,n.endTime):n.type===`linearRampToValue`?h.linearRampToValueAtTime(n.value,n.endTime):n.type===`setValue`?h.setValueAtTime(n.value,n.startTime):n.type===`setValueCurve`&&h.setValueCurveAtTime(n.values,n.startTime,n.duration))}return x},cancelScheduledValues(e){return b===null&&y.flush(p.context.currentTime),y.add(a(e)),h.cancelScheduledValues(e),x},exponentialRampToValueAtTime(e,t){if(e===0||!Number.isFinite(t)||t<0)throw RangeError();let n=p.context.currentTime;return b===null&&y.flush(n),Array.from(y).length===0&&(y.add(l(v,n)),h.setValueAtTime(v,n)),y.add(o(e,t)),h.exponentialRampToValueAtTime(e,t),x},linearRampToValueAtTime(e,t){let n=p.context.currentTime;return b===null&&y.flush(n),Array.from(y).length===0&&(y.add(l(v,n)),h.setValueAtTime(v,n)),y.add(s(e,t)),h.linearRampToValueAtTime(e,t),x},setTargetAtTime(e,t,n){return b===null&&y.flush(p.context.currentTime),y.add(c(e,t,n)),h.setTargetAtTime(e,t,n),x},setValueAtTime(e,t){return b===null&&y.flush(p.context.currentTime),y.add(l(e,t)),h.setValueAtTime(e,t),x},setValueCurveAtTime(e,t,n){let r=e instanceof Float32Array?e:new Float32Array(e);if(d!==null&&d.name===`webkitAudioContext`){let e=t+n,i=p.context.sampleRate,a=Math.ceil(t*i),o=Math.floor(e*i),s=o-a,c=new Float32Array(s);for(let e=0;e<s;e+=1){let o=(r.length-1)/n*((a+e)/i-t),s=Math.floor(o),l=Math.ceil(o);c[e]=s===l?r[s]:(1-(o-s))*r[s]+(1-(l-o))*r[l]}b===null&&y.flush(p.context.currentTime),y.add(u(c,t,n)),h.setValueCurveAtTime(c,t,n);let l=o/i;l<e&&f(x,c[c.length-1],l),f(x,r[r.length-1],e)}else b===null&&y.flush(p.context.currentTime),y.add(u(r,t,n)),h.setValueCurveAtTime(r,t,n);return x}};return n.set(x,h),t.set(x,p),e(x,b),x},ep=e=>({replay(t){for(let n of e)if(n.type===`exponentialRampToValue`){let{endTime:e,value:r}=n;t.exponentialRampToValueAtTime(r,e)}else if(n.type===`linearRampToValue`){let{endTime:e,value:r}=n;t.linearRampToValueAtTime(r,e)}else if(n.type===`setTarget`){let{startTime:e,target:r,timeConstant:i}=n;t.setTargetAtTime(r,e,i)}else if(n.type===`setValue`){let{startTime:e,value:r}=n;t.setValueAtTime(r,e)}else if(n.type===`setValueCurve`){let{duration:e,startTime:r,values:i}=n;t.setValueCurveAtTime(i,r,e)}else throw Error(`Can't apply an unknown automation.`)}}),tp=class{constructor(e){this._map=new Map(e)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(e,t=null){return this._map.forEach((n,r)=>e.call(t,n,r,this))}get(e){return this._map.get(e)}has(e){return this._map.has(e)}keys(){return this._map.keys()}values(){return this._map.values()}},np={channelCount:2,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},rp=(e,t,n,r,i,a,o,s,c,l,u,d,f,p)=>class extends t{constructor(t,p,m){let h=s(t),g=c(h),_=u({...np,...m});f(_);let v=Dd.get(h)?.get(p),y=i(g||h.state!==`closed`?h:o(h)??h,g?null:t.baseLatency,l,p,v,_),b=g?r(p,_,v):null;super(t,!0,y,b);let x=[];y.parameters.forEach((e,t)=>{let r=n(this,g,e);x.push([t,r])}),this._nativeAudioWorkletNode=y,this._onprocessorerror=null,this._parameters=new tp(x),g&&e(h,this);let{activeInputs:S}=a(this);d(y,S)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(e){let t=typeof e==`function`?p(this,e):null;this._nativeAudioWorkletNode.onprocessorerror=t;let n=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=n!==null&&n===t?e:n}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function ip(e,t,n,r,i){if(typeof e.copyFromChannel==`function`)t[n].byteLength===0&&(t[n]=new Float32Array(128)),e.copyFromChannel(t[n],r,i);else{let a=e.getChannelData(r);if(t[n].byteLength===0)t[n]=a.slice(i,i+128);else{let e=new Float32Array(a.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);t[n].set(e)}}}var ap=(e,t,n,r,i)=>{typeof e.copyToChannel==`function`?t[n].byteLength!==0&&e.copyToChannel(t[n],r,i):t[n].byteLength!==0&&e.getChannelData(r).set(t[n],i)},op=(e,t)=>{let n=[];for(let r=0;r<e;r+=1){let e=[],i=typeof t==`number`?t:t[r];for(let t=0;t<i;t+=1)e.push(new Float32Array(128));n.push(e)}return n},sp=(e,t)=>Id(Id(Od,e),Lf(t)),cp=async(e,t,n,r,i,a,o)=>{let s=t===null?Math.ceil(e.context.length/128)*128:t.length,c=r.channelCount*r.numberOfInputs,l=i.reduce((e,t)=>e+t,0),u=l===0?null:n.createBuffer(l,s,n.sampleRate);if(a===void 0)throw Error(`Missing the processor constructor.`);let d=gf(e),f=await sp(n,e),p=op(r.numberOfInputs,r.channelCount),m=op(r.numberOfOutputs,i),h=Array.from(e.parameters.keys()).reduce((e,t)=>({...e,[t]:new Float32Array(128)}),{});for(let l=0;l<s;l+=128){if(r.numberOfInputs>0&&t!==null)for(let e=0;e<r.numberOfInputs;e+=1)for(let n=0;n<r.channelCount;n+=1)ip(t,p[e],n,n,l);a.parameterDescriptors!==void 0&&t!==null&&a.parameterDescriptors.forEach(({name:e},n)=>{ip(t,h,e,c+n,l)});for(let e=0;e<r.numberOfInputs;e+=1)for(let t=0;t<i[e];t+=1)m[e][t].byteLength===0&&(m[e][t]=new Float32Array(128));try{let e=p.map((e,t)=>d.activeInputs[t].size===0?[]:e),t=o(l/n.sampleRate,n.sampleRate,()=>f.process(e,m,h));if(u!==null)for(let e=0,t=0;e<r.numberOfOutputs;e+=1){for(let n=0;n<i[e];n+=1)ap(u,m[e],n,t+n,l);t+=i[e]}if(!t)break}catch(t){e.dispatchEvent(new ErrorEvent(`processorerror`,{colno:t.colno,filename:t.filename,lineno:t.lineno,message:t.message}));break}}return u},lp=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)=>(g,_,v)=>{let y=new WeakMap,b=null,x=async(s,x)=>{let S=u(s),C=null,w=Xd(S,x),T=Array.isArray(_.outputChannelCount)?_.outputChannelCount:Array.from(_.outputChannelCount);if(d===null){let e=T.reduce((e,t)=>e+t,0),n=i(x,{channelCount:Math.max(1,e),channelCountMode:`explicit`,channelInterpretation:`discrete`,numberOfOutputs:Math.max(1,e)}),a=[];for(let e=0;e<s.numberOfOutputs;e+=1)a.push(r(x,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:T[e]}));let l=o(x,{channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation,gain:1});l.connect=t.bind(null,a),l.disconnect=c.bind(null,a),C=[n,a,l]}else w||(S=new d(x,g));if(y.set(x,C===null?S:C[2]),C!==null){if(b===null){if(v===void 0)throw Error(`Missing the processor constructor.`);if(f===null)throw Error(`Missing the native OfflineAudioContext constructor.`);let e=s.channelCount*s.numberOfInputs,t=v.parameterDescriptors===void 0?0:v.parameterDescriptors.length,n=e+t;b=cp(s,n===0?null:await(async()=>{let c=new f(n,Math.ceil(s.context.length/128)*128,x.sampleRate),l=[],u=[];for(let e=0;e<_.numberOfInputs;e+=1)l.push(o(c,{channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation,gain:1})),u.push(i(c,{channelCount:_.channelCount,channelCountMode:`explicit`,channelInterpretation:`discrete`,numberOfOutputs:_.channelCount}));let d=await Promise.all(Array.from(s.parameters.values()).map(async e=>{let t=a(c,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,offset:e.value});return await p(c,e,t.offset),t})),g=r(c,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:Math.max(1,e+t)});for(let e=0;e<_.numberOfInputs;e+=1){l[e].connect(u[e]);for(let t=0;t<_.channelCount;t+=1)u[e].connect(g,t,e*_.channelCount+t)}for(let[t,n]of d.entries())n.connect(g,0,e+t),n.start(0);return g.connect(c.destination),await Promise.all(l.map(e=>m(s,c,e))),h(c)})(),x,_,T,v,l)}let e=await b,t=n(x,{buffer:null,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[c,u,d]=C;e!==null&&(t.buffer=e,t.start(0)),t.connect(c);for(let e=0,t=0;e<s.numberOfOutputs;e+=1){let n=u[e];for(let r=0;r<T[e];r+=1)c.connect(n,t+r,r);t+=T[e]}return d}if(w)for(let[t,n]of s.parameters.entries())await e(x,n,S.parameters.get(t));else for(let[e,t]of s.parameters.entries())await p(x,t,S.parameters.get(e));return await m(s,x,S),S};return{render(e,t){s(t,e);let n=y.get(t);return n===void 0?x(e,t):Promise.resolve(n)}}},up=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y)=>class extends m{constructor(t,n){super(t,n),this._nativeContext=t,this._audioWorklet=e===void 0?void 0:{addModule:(t,n)=>e(this,t,n)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new t(this)}createBiquadFilter(){return new i(this)}createBuffer(e,t,r){return new n({length:t,numberOfChannels:e,sampleRate:r})}createBufferSource(){return new r(this)}createChannelMerger(e=6){return new a(this,{numberOfInputs:e})}createChannelSplitter(e=6){return new o(this,{numberOfOutputs:e})}createConstantSource(){return new s(this)}createConvolver(){return new c(this)}createDelay(e=1){return new u(this,{maxDelayTime:e})}createDynamicsCompressor(){return new d(this)}createGain(){return new f(this)}createIIRFilter(e,t){return new p(this,{feedback:t,feedforward:e})}createOscillator(){return new h(this)}createPanner(){return new g(this)}createPeriodicWave(e,t,n={disableNormalization:!1}){return new _(this,{...n,imag:t,real:e})}createStereoPanner(){return new v(this)}createWaveShaper(){return new y(this)}decodeAudioData(e,t,n){return l(this._nativeContext,e).then(e=>(typeof t==`function`&&t(e),e),e=>{throw typeof n==`function`&&n(e),e})}},dp={Q:1,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,detune:0,frequency:350,gain:0,type:`lowpass`},fp=(e,t,n,r,i,a,o,s)=>class extends e{constructor(e,r){let c=a(e),l=i(c,{...dp,...r}),u=o(c),d=u?n():null;super(e,!1,l,d),this._Q=t(this,u,l.Q,af,rf),this._detune=t(this,u,l.detune,1200*Math.log2(af),-1200*Math.log2(af)),this._frequency=t(this,u,l.frequency,e.sampleRate/2,0),this._gain=t(this,u,l.gain,40*Math.log10(af),rf),this._nativeBiquadFilterNode=l,s(this,1)}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get Q(){return this._Q}get type(){return this._nativeBiquadFilterNode.type}set type(e){this._nativeBiquadFilterNode.type=e}getFrequencyResponse(e,t,n){try{this._nativeBiquadFilterNode.getFrequencyResponse(e,t,n)}catch(e){throw e.code===11?r():e}if(e.length!==t.length||t.length!==n.length)throw r()}},pp=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=async(o,s)=>{let c=n(o),l=Xd(c,s);return l||(c=t(s,{Q:c.Q.value,channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,detune:c.detune.value,frequency:c.frequency.value,gain:c.gain.value,type:c.type})),a.set(s,c),l?(await e(s,o.Q,c.Q),await e(s,o.detune,c.detune),await e(s,o.frequency,c.frequency),await e(s,o.gain,c.gain)):(await r(s,o.Q,c.Q),await r(s,o.detune,c.detune),await r(s,o.frequency,c.frequency),await r(s,o.gain,c.gain)),await i(o,s,c),c};return{render(e,t){let n=a.get(t);return n===void 0?o(e,t):Promise.resolve(n)}}},mp=(e,t)=>(n,r)=>{let i=t.get(n);if(i!==void 0)return i;let a=e.get(n);if(a!==void 0)return a;try{let i=r();return i instanceof Promise?(e.set(n,i),i.catch(()=>!1).then(r=>(e.delete(n),t.set(n,r),r))):(t.set(n,i),i)}catch{return t.set(n,!1),!1}},hp={channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:6},gp=(e,t,n,r,i)=>class extends e{constructor(e,a){let o=r(e),s=n(o,{...hp,...a}),c=i(o)?t():null;super(e,!1,s,c)}},_p=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return Xd(o,a)||(o=e(a,{channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,numberOfInputs:o.numberOfInputs})),r.set(a,o),await n(i,a,o),o};return{render(e,t){let n=r.get(t);return n===void 0?i(e,t):Promise.resolve(n)}}},vp={channelCount:6,channelCountMode:`explicit`,channelInterpretation:`discrete`,numberOfOutputs:6},yp=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=r(e),c=n(s,a({...vp,...o})),l=i(s)?t():null;super(e,!1,c,l)}},bp=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return Xd(o,a)||(o=e(a,{channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,numberOfOutputs:o.numberOfOutputs})),r.set(a,o),await n(i,a,o),o};return{render(e,t){let n=r.get(t);return n===void 0?i(e,t):Promise.resolve(n)}}},xp=e=>(t,n,r)=>e(n,t,r),Sp=e=>(t,n,r=0,i=0)=>{let a=t[r];if(a===void 0)throw e();return Uf(n)?a.connect(n,0,i):a.connect(n,0)},Cp=e=>(t,n)=>{let r=e(t,{buffer:null,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,loop:!1,loopEnd:0,loopStart:0,playbackRate:1});return r.buffer=t.createBuffer(1,2,44100),r.loop=!0,r.connect(n),r.start(),()=>{r.stop(),r.disconnect(n)}},wp={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,offset:1},Tp=(e,t,n,r,i,a,o)=>class extends e{constructor(e,o){let s=i(e),c=r(s,{...wp,...o}),l=a(s),u=l?n():null;super(e,!1,c,u),this._constantSourceNodeRenderer=u,this._nativeConstantSourceNode=c,this._offset=t(this,l,c.offset,af,rf),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(e){let t=typeof e==`function`?o(this,e):null;this._nativeConstantSourceNode.onended=t;let n=this._nativeConstantSourceNode.onended;this._onended=n!==null&&n===t?e:n}start(e=0){if(this._nativeConstantSourceNode.start(e),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.start=e),this.context.state!==`closed`){Bd(this);let e=()=>{this._nativeConstantSourceNode.removeEventListener(`ended`,e),of(this)&&Hd(this)};this._nativeConstantSourceNode.addEventListener(`ended`,e)}}stop(e=0){this._nativeConstantSourceNode.stop(e),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=e)}},Ep=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=null,s=null,c=async(c,l)=>{let u=n(c),d=Xd(u,l);return d||(u=t(l,{channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,offset:u.offset.value}),o!==null&&u.start(o),s!==null&&u.stop(s)),a.set(l,u),d?await e(l,c.offset,u.offset):await r(l,c.offset,u.offset),await i(c,l,u),u};return{set start(e){o=e},set stop(e){s=e},render(e,t){let n=a.get(t);return n===void 0?c(e,t):Promise.resolve(n)}}},Dp=e=>t=>(e[0]=t,e[0]),Op={buffer:null,channelCount:2,channelCountMode:`clamped-max`,channelInterpretation:`speakers`,disableNormalization:!1},kp=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=r(e),c={...Op,...o},l=n(s,c),u=i(s)?t():null;super(e,!1,l,u),this._isBufferNullified=!1,this._nativeConvolverNode=l,c.buffer!==null&&a(this,c.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(e){if(this._nativeConvolverNode.buffer=e,e===null&&this._nativeConvolverNode.buffer!==null){let e=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=e.createBuffer(1,1,e.sampleRate),this._isBufferNullified=!0,a(this,0)}else this._isBufferNullified=!1,a(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(e){this._nativeConvolverNode.normalize=e}},Ap=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return Xd(o,a)||(o=e(a,{buffer:o.buffer,channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,disableNormalization:!o.normalize})),r.set(a,o),Af(o)?await n(i,a,o.inputs[0]):await n(i,a,o),o};return{render(e,t){let n=r.get(t);return n===void 0?i(e,t):Promise.resolve(n)}}},jp=(e,t)=>(n,r,i)=>{if(t===null)throw Error(`Missing the native OfflineAudioContext constructor.`);try{return new t(n,r,i)}catch(t){throw t.name===`SyntaxError`?e():t}},Mp=()=>new DOMException(``,`DataCloneError`),Np=e=>{let{port1:t,port2:n}=new MessageChannel;return new Promise(r=>{let i=()=>{n.onmessage=null,t.close(),n.close(),r()};n.onmessage=()=>i();try{t.postMessage(e,[e])}catch{}finally{i()}})},Pp=(e,t,n,r,i,a,o,s,c,l,u)=>(d,f)=>{let p=o(d)?d:a(d);if(i.has(f)){let e=n();return Promise.reject(e)}try{i.add(f)}catch{}return t(c,()=>c(p))?p.decodeAudioData(f).then(n=>(Np(f).catch(()=>{}),t(s,()=>s(n))||u(n),e.add(n),n)):new Promise((t,n)=>{let i=async()=>{try{await Np(f)}catch{}},a=e=>{n(e),i()};try{p.decodeAudioData(f,n=>{typeof n.copyFromChannel!=`function`&&(l(n),ef(n)),e.add(n),i().then(()=>t(n))},e=>{a(e===null?r():e)})}catch(e){a(e)}})},Fp=(e,t,n,r,i,a,o,s)=>(c,l)=>{let u=t.get(c);if(u===void 0)throw Error(`Missing the expected cycle count.`);let d=s(a(c.context));if(u===l){if(t.delete(c),!d&&o(c)){let t=r(c),{outputs:a}=n(c);for(let n of a)if(Ef(n))e(t,r(n[0]),n[1],n[2]);else{let e=i(n[0]);t.connect(e,n[1])}}}else t.set(c,u-l)},Ip={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,delayTime:0,maxDelayTime:1},Lp=(e,t,n,r,i,a,o)=>class extends e{constructor(e,s){let c=i(e),l={...Ip,...s},u=r(c,l),d=a(c),f=d?n(l.maxDelayTime):null;super(e,!1,u,f),this._delayTime=t(this,d,u.delayTime),o(this,l.maxDelayTime)}get delayTime(){return this._delayTime}},Rp=(e,t,n,r,i)=>a=>{let o=new WeakMap,s=async(s,c)=>{let l=n(s),u=Xd(l,c);return u||(l=t(c,{channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,delayTime:l.delayTime.value,maxDelayTime:a})),o.set(c,l),u?await e(c,s.delayTime,l.delayTime):await r(c,s.delayTime,l.delayTime),await i(s,c,l),l};return{render(e,t){let n=o.get(t);return n===void 0?s(e,t):Promise.resolve(n)}}},zp=e=>(t,n,r,i)=>e(t[i],e=>e[0]===n&&e[1]===r),Bp=e=>(t,n)=>{e(t).delete(n)},Vp=e=>`delayTime`in e,Hp=(e,t,n)=>function r(i,a){let o=Tf(a)?a:n(e,a);if(Vp(o))return[];if(i[0]===o)return[i];if(i.includes(o))return[];let{outputs:s}=t(o);return Array.from(s).map(e=>r([...i,o],e[0])).reduce((e,t)=>e.concat(t),[])},Up=(e,t,n)=>{let r=t[n];if(r===void 0)throw e();return r},Wp=e=>(t,n=void 0,r=void 0,i=0)=>n===void 0?t.forEach(e=>e.disconnect()):typeof n==`number`?Up(e,t,n).disconnect():Uf(n)?r===void 0?t.forEach(e=>e.disconnect(n)):i===void 0?Up(e,t,r).disconnect(n,0):Up(e,t,r).disconnect(n,0,i):r===void 0?t.forEach(e=>e.disconnect(n)):Up(e,t,r).disconnect(n,0),Gp={attack:.003,channelCount:2,channelCountMode:`clamped-max`,channelInterpretation:`speakers`,knee:30,ratio:12,release:.25,threshold:-24},Kp=(e,t,n,r,i,a,o,s)=>class extends e{constructor(e,i){let c=a(e),l=r(c,{...Gp,...i}),u=o(c),d=u?n():null;super(e,!1,l,d),this._attack=t(this,u,l.attack),this._knee=t(this,u,l.knee),this._nativeDynamicsCompressorNode=l,this._ratio=t(this,u,l.ratio),this._release=t(this,u,l.release),this._threshold=t(this,u,l.threshold),s(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(e){let t=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=e,e>2)throw this._nativeDynamicsCompressorNode.channelCount=t,i()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(e){let t=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=e,e===`max`)throw this._nativeDynamicsCompressorNode.channelCountMode=t,i()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return typeof this._nativeDynamicsCompressorNode.reduction.value==`number`?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}},qp=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=async(o,s)=>{let c=n(o),l=Xd(c,s);return l||(c=t(s,{attack:c.attack.value,channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,knee:c.knee.value,ratio:c.ratio.value,release:c.release.value,threshold:c.threshold.value})),a.set(s,c),l?(await e(s,o.attack,c.attack),await e(s,o.knee,c.knee),await e(s,o.ratio,c.ratio),await e(s,o.release,c.release),await e(s,o.threshold,c.threshold)):(await r(s,o.attack,c.attack),await r(s,o.knee,c.knee),await r(s,o.ratio,c.ratio),await r(s,o.release,c.release),await r(s,o.threshold,c.threshold)),await i(o,s,c),c};return{render(e,t){let n=a.get(t);return n===void 0?o(e,t):Promise.resolve(n)}}},Jp=()=>new DOMException(``,`EncodingError`),Yp=e=>t=>new Promise((n,r)=>{if(e===null){r(SyntaxError());return}let i=e.document.head;if(i===null)r(SyntaxError());else{let a=e.document.createElement(`script`),o=new Blob([t],{type:`application/javascript`}),s=URL.createObjectURL(o),c=e.onerror,l=()=>{e.onerror=c,URL.revokeObjectURL(s)};e.onerror=(t,n,i,a,o)=>{if(n===s||n===e.location.href&&i===1&&a===1)return l(),r(o),!1;if(c!==null)return c(t,n,i,a,o)},a.onerror=()=>{l(),r(SyntaxError())},a.onload=()=>{l(),n()},a.src=s,a.type=`module`,i.appendChild(a)}}),Xp=e=>class{constructor(e){this._nativeEventTarget=e,this._listeners=new WeakMap}addEventListener(t,n,r){if(n!==null){let i=this._listeners.get(n);i===void 0&&(i=e(this,n),typeof n==`function`&&this._listeners.set(n,i)),this._nativeEventTarget.addEventListener(t,i,r)}}dispatchEvent(e){return this._nativeEventTarget.dispatchEvent(e)}removeEventListener(e,t,n){let r=t===null?void 0:this._listeners.get(t);this._nativeEventTarget.removeEventListener(e,r===void 0?null:r,n)}},Zp=e=>(t,n,r)=>{Object.defineProperties(e,{currentFrame:{configurable:!0,get(){return Math.round(t*n)}},currentTime:{configurable:!0,get(){return t}}});try{return r()}finally{e!==null&&(delete e.currentFrame,delete e.currentTime)}},Qp=e=>async t=>{try{let e=await fetch(t);if(e.ok)return[await e.text(),e.url]}catch{}throw e()},$p={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,gain:1},em=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=i(e),c=r(s,{...$p,...o}),l=a(s),u=l?n():null;super(e,!1,c,u),this._gain=t(this,l,c.gain,af,rf)}get gain(){return this._gain}},tm=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=async(o,s)=>{let c=n(o),l=Xd(c,s);return l||(c=t(s,{channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,gain:c.gain.value})),a.set(s,c),l?await e(s,o.gain,c.gain):await r(s,o.gain,c.gain),await i(o,s,c),c};return{render(e,t){let n=a.get(t);return n===void 0?o(e,t):Promise.resolve(n)}}},nm=(e,t)=>n=>t(e,n),rm=e=>t=>{let n=e(t);if(n.renderer===null)throw Error(`Missing the renderer of the given AudioNode in the audio graph.`);return n.renderer},im=e=>t=>e.get(t)??0,am=e=>t=>{let n=e(t);if(n.renderer===null)throw Error(`Missing the renderer of the given AudioParam in the audio graph.`);return n.renderer},om=e=>t=>e.get(t),sm=()=>new DOMException(``,`InvalidStateError`),cm=e=>t=>{let n=e.get(t);if(n===void 0)throw sm();return n},lm=(e,t)=>n=>{let r=e.get(n);if(r!==void 0)return r;if(t===null)throw Error(`Missing the native OfflineAudioContext constructor.`);return r=new t(1,1,44100),e.set(n,r),r},um=e=>t=>{let n=e.get(t);if(n===void 0)throw Error(`The context has no set of AudioWorkletNodes.`);return n},dm=()=>new DOMException(``,`InvalidAccessError`),fm=e=>{e.getFrequencyResponse=(t=>(n,r,i)=>{if(n.length!==r.length||r.length!==i.length)throw dm();return t.call(e,n,r,i)})(e.getFrequencyResponse)},pm={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`},mm=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=r(e),c=i(s),l={...pm,...o},u=t(s,c?null:e.baseLatency,l),d=c?n(l.feedback,l.feedforward):null;super(e,!1,u,d),fm(u),this._nativeIIRFilterNode=u,a(this,1)}getFrequencyResponse(e,t,n){return this._nativeIIRFilterNode.getFrequencyResponse(e,t,n)}},hm=(e,t,n,r,i,a,o,s,c,l,u)=>{let d=l.length,f=s;for(let s=0;s<d;s+=1){let d=n[0]*l[s];for(let t=1;t<i;t+=1){let r=f-t&c-1;d+=n[t]*a[r],d-=e[t]*o[r]}for(let e=i;e<r;e+=1)d+=n[e]*a[f-e&c-1];for(let n=i;n<t;n+=1)d-=e[n]*o[f-n&c-1];a[f]=l[s],o[f]=d,f=f+1&c-1,u[s]=d}return f},gm=(e,t,n,r)=>{let i=n instanceof Float64Array?n:new Float64Array(n),a=r instanceof Float64Array?r:new Float64Array(r),o=i.length,s=a.length,c=Math.min(o,s);if(i[0]!==1){for(let e=0;e<o;e+=1)a[e]/=i[0];for(let e=1;e<s;e+=1)i[e]/=i[0]}let l=new Float32Array(32),u=new Float32Array(32),d=t.createBuffer(e.numberOfChannels,e.length,e.sampleRate),f=e.numberOfChannels;for(let t=0;t<f;t+=1){let n=e.getChannelData(t),r=d.getChannelData(t);l.fill(0),u.fill(0),hm(i,o,a,s,c,l,u,0,32,n,r)}return d},_m=(e,t,n,r,i)=>(a,o)=>{let s=new WeakMap,c=null,l=async(l,u)=>{let d=null,f=t(l),p=Xd(f,u);if(u.createIIRFilter===void 0?d=e(u,{buffer:null,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):p||(f=u.createIIRFilter(o,a)),s.set(u,d===null?f:d),d!==null){if(c===null){if(n===null)throw Error(`Missing the native OfflineAudioContext constructor.`);let e=new n(l.context.destination.channelCount,l.context.length,u.sampleRate);c=(async()=>(await r(l,e,e.destination),gm(await i(e),u,a,o)))()}let e=await c;return d.buffer=e,d.start(0),d}return await r(l,u,f),f};return{render(e,t){let n=s.get(t);return n===void 0?l(e,t):Promise.resolve(n)}}},vm=(e,t,n,r,i,a)=>o=>(s,c)=>{let l=e.get(s);if(l===void 0){if(!o&&a(s)){let e=r(s),{outputs:a}=n(s);for(let n of a)if(Ef(n))t(e,r(n[0]),n[1],n[2]);else{let t=i(n[0]);e.disconnect(t,n[1])}}e.set(s,c)}else e.set(s,l+c)},ym=(e,t)=>n=>t(e.get(n))||t(n),bm=(e,t)=>n=>e.has(n)||t(n),xm=(e,t)=>n=>e.has(n)||t(n),Sm=(e,t)=>n=>t(e.get(n))||t(n),Cm=e=>t=>e!==null&&t instanceof e,wm=e=>t=>e!==null&&typeof e.AudioNode==`function`&&t instanceof e.AudioNode,Tm=e=>t=>e!==null&&typeof e.AudioParam==`function`&&t instanceof e.AudioParam,Em=(e,t)=>n=>e(n)||t(n),Dm=e=>t=>e!==null&&t instanceof e,Om=e=>e!==null&&e.isSecureContext,km=(e,t,n,r)=>class extends e{constructor(e,i){let a=n(e),o=t(a,i);if(r(a))throw TypeError();super(e,!0,o,null),this._nativeMediaElementAudioSourceNode=o}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}},Am={channelCount:2,channelCountMode:`explicit`,channelInterpretation:`speakers`},jm=(e,t,n,r)=>class extends e{constructor(e,i){let a=n(e);if(r(a))throw TypeError();let o=t(a,{...Am,...i});super(e,!1,o,null),this._nativeMediaStreamAudioDestinationNode=o}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}},Mm=(e,t,n,r)=>class extends e{constructor(e,i){let a=n(e),o=t(a,i);if(r(a))throw TypeError();super(e,!0,o,null),this._nativeMediaStreamAudioSourceNode=o}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}},Nm=(e,t,n)=>class extends e{constructor(e,r){let i=t(n(e),r);super(e,!0,i,null)}},Pm=(e,t,n,r,i,a)=>class extends n{constructor(n,a){super(n),this._nativeContext=n,wd.set(this,n),r(n)&&i.set(n,new Set),this._destination=new e(this,a),this._listener=t(this,n),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(e){let t=typeof e==`function`?a(this,e):null;this._nativeContext.onstatechange=t;let n=this._nativeContext.onstatechange;this._onstatechange=n!==null&&n===t?e:n}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}},Fm=e=>{let t=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{let n=e.decodeAudioData(t.buffer,()=>{});return n!==void 0&&(n.catch(()=>{}),!0)}catch{}return!1},Im=(e,t)=>(n,r,i)=>{let a=new Set;return n.connect=(i=>(o,s=0,c=0)=>{let l=a.size===0;if(t(o))return i.call(n,o,s,c),e(a,[o,s,c],e=>e[0]===o&&e[1]===s&&e[2]===c,!0),l&&r(),o;i.call(n,o,s),e(a,[o,s],e=>e[0]===o&&e[1]===s,!0),l&&r()})(n.connect),n.disconnect=(e=>(r,o,s)=>{let c=a.size>0;if(r===void 0)e.apply(n),a.clear();else if(typeof r==`number`){e.call(n,r);for(let e of a)e[1]===r&&a.delete(e)}else{t(r)?e.call(n,r,o,s):e.call(n,r,o);for(let e of a)e[0]!==r||o!==void 0&&e[1]!==o||s!==void 0&&e[2]!==s||a.delete(e)}let l=a.size===0;c&&l&&i()})(n.disconnect),n},Lm=(e,t,n)=>{let r=t[n];r!==void 0&&r!==e[n]&&(e[n]=r)},Rm=(e,t)=>{Lm(e,t,`channelCount`),Lm(e,t,`channelCountMode`),Lm(e,t,`channelInterpretation`)},zm=e=>typeof e.getFloatTimeDomainData==`function`,Bm=e=>{e.getFloatTimeDomainData=t=>{let n=new Uint8Array(t.length);e.getByteTimeDomainData(n);let r=Math.max(n.length,e.fftSize);for(let e=0;e<r;e+=1)t[e]=(n[e]-128)*.0078125;return t}},Vm=(e,t)=>(n,r)=>{let i=n.createAnalyser();if(Rm(i,r),!(r.maxDecibels>r.minDecibels))throw t();return Lm(i,r,`fftSize`),Lm(i,r,`maxDecibels`),Lm(i,r,`minDecibels`),Lm(i,r,`smoothingTimeConstant`),e(zm,()=>zm(i))||Bm(i),i},Hm=e=>e===null?null:e.hasOwnProperty(`AudioBuffer`)?e.AudioBuffer:null,Um=(e,t,n)=>{let r=t[n];r!==void 0&&r!==e[n].value&&(e[n].value=r)},Wm=e=>{e.start=(t=>{let n=!1;return(r=0,i=0,a)=>{if(n)throw sm();t.call(e,r,i,a),n=!0}})(e.start)},Gm=e=>{e.start=(t=>(n=0,r=0,i)=>{if(typeof i==`number`&&i<0||r<0||n<0)throw RangeError(`The parameters can't be negative.`);t.call(e,n,r,i)})(e.start)},Km=e=>{e.stop=(t=>(n=0)=>{if(n<0)throw RangeError(`The parameter can't be negative.`);t.call(e,n)})(e.stop)},qm=(e,t,n,r,i,a,o,s,c,l,u)=>(d,f)=>{let p=d.createBufferSource();return Rm(p,f),Um(p,f,`playbackRate`),Lm(p,f,`buffer`),Lm(p,f,`loop`),Lm(p,f,`loopEnd`),Lm(p,f,`loopStart`),t(n,()=>n(d))||Wm(p),t(r,()=>r(d))||c(p),t(i,()=>i(d))||l(p,d),t(a,()=>a(d))||Gm(p),t(o,()=>o(d))||u(p,d),t(s,()=>s(d))||Km(p),e(d,p),p},Jm=e=>e===null?null:e.hasOwnProperty(`AudioContext`)?e.AudioContext:e.hasOwnProperty(`webkitAudioContext`)?e.webkitAudioContext:null,Ym=(e,t)=>(n,r,i)=>{let a=n.destination;if(a.channelCount!==r)try{a.channelCount=r}catch{}i&&a.channelCountMode!==`explicit`&&(a.channelCountMode=`explicit`),a.maxChannelCount===0&&Object.defineProperty(a,"maxChannelCount",{value:r});let o=e(n,{channelCount:r,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,gain:1});return t(o,`channelCount`,e=>()=>e.call(o),e=>t=>{e.call(o,t);try{a.channelCount=t}catch(e){if(t>a.maxChannelCount)throw e}}),t(o,`channelCountMode`,e=>()=>e.call(o),e=>t=>{e.call(o,t),a.channelCountMode=t}),t(o,`channelInterpretation`,e=>()=>e.call(o),e=>t=>{e.call(o,t),a.channelInterpretation=t}),Object.defineProperty(o,"maxChannelCount",{get:()=>a.maxChannelCount}),o.connect(a),o},Xm=e=>e===null?null:e.hasOwnProperty(`AudioWorkletNode`)?e.AudioWorkletNode:null,Zm=e=>{let{port1:t}=new MessageChannel;try{t.postMessage(e)}finally{t.close()}},Qm=(e,t,n,r,i)=>(a,o,s,c,l,u)=>{if(s!==null)try{let t=new s(a,c,u),r=new Map,o=null;if(Object.defineProperties(t,{channelCount:{get:()=>u.channelCount,set:()=>{throw e()}},channelCountMode:{get:()=>`explicit`,set:()=>{throw e()}},onprocessorerror:{get:()=>o,set:e=>{typeof o==`function`&&t.removeEventListener(`processorerror`,o),o=typeof e==`function`?e:null,typeof o==`function`&&t.addEventListener(`processorerror`,o)}}}),t.addEventListener=(e=>(...n)=>{if(n[0]===`processorerror`){let e=typeof n[1]==`function`?n[1]:typeof n[1]==`object`&&n[1]!==null&&typeof n[1].handleEvent==`function`?n[1].handleEvent:null;if(e!==null){let t=r.get(n[1]);t===void 0?(n[1]=t=>{t.type===`error`?(Object.defineProperties(t,{type:{value:`processorerror`}}),e(t)):e(new ErrorEvent(n[0],{...t}))},r.set(e,n[1])):n[1]=t}}return e.call(t,`error`,n[1],n[2]),e.call(t,...n)})(t.addEventListener),t.removeEventListener=(e=>(...n)=>{if(n[0]===`processorerror`){let e=r.get(n[1]);e!==void 0&&(r.delete(n[1]),n[1]=e)}return e.call(t,`error`,n[1],n[2]),e.call(t,n[0],n[1],n[2])})(t.removeEventListener),u.numberOfOutputs!==0){let e=n(a,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,gain:0});return t.connect(e).connect(a.destination),i(t,()=>e.disconnect(),()=>e.connect(a.destination))}return t}catch(e){throw e.code===11?r():e}if(l===void 0)throw r();return Zm(u),t(a,o,l,u)},$m=(e,t)=>e===null?512:Math.max(512,Math.min(16384,2**Math.round(Math.log2(e*t)))),eh=e=>new Promise((t,n)=>{let{port1:r,port2:i}=new MessageChannel;r.onmessage=({data:e})=>{r.close(),i.close(),t(e)},r.onmessageerror=({data:e})=>{r.close(),i.close(),n(e)},i.postMessage(e)}),th=async(e,t)=>new e(await eh(t)),nh=(e,t,n,r)=>{let i=Od.get(e);i===void 0&&(i=new WeakMap,Od.set(e,i));let a=th(n,r);return i.set(t,a),a},rh=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>(p,m,h,g)=>{if(g.numberOfInputs===0&&g.numberOfOutputs===0)throw c();let _=Array.isArray(g.outputChannelCount)?g.outputChannelCount:Array.from(g.outputChannelCount);if(_.some(e=>e<1))throw c();if(_.length!==g.numberOfOutputs)throw t();if(g.channelCountMode!==`explicit`)throw c();let v=g.channelCount*g.numberOfInputs,y=_.reduce((e,t)=>e+t,0),b=h.parameterDescriptors===void 0?0:h.parameterDescriptors.length;if(v+b>6||y>6)throw c();let x=new MessageChannel,S=[],C=[];for(let e=0;e<g.numberOfInputs;e+=1)S.push(o(p,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1})),C.push(i(p,{channelCount:g.channelCount,channelCountMode:`explicit`,channelInterpretation:`discrete`,numberOfOutputs:g.channelCount}));let w=[];if(h.parameterDescriptors!==void 0)for(let{defaultValue:e,maxValue:t,minValue:n,name:r}of h.parameterDescriptors){let i=a(p,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,offset:g.parameterData[r]===void 0?e===void 0?0:e:g.parameterData[r]});Object.defineProperties(i.offset,{defaultValue:{get:()=>e===void 0?0:e},maxValue:{get:()=>t===void 0?af:t},minValue:{get:()=>n===void 0?rf:n}}),w.push(i)}let T=r(p,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:Math.max(1,v+b)}),E=$m(m,p.sampleRate),D=s(p,E,v+b,Math.max(1,y)),O=i(p,{channelCount:Math.max(1,y),channelCountMode:`explicit`,channelInterpretation:`discrete`,numberOfOutputs:Math.max(1,y)}),ee=[];for(let e=0;e<g.numberOfOutputs;e+=1)ee.push(r(p,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:_[e]}));for(let e=0;e<g.numberOfInputs;e+=1){S[e].connect(C[e]);for(let t=0;t<g.channelCount;t+=1)C[e].connect(T,t,e*g.channelCount+t)}let te=new tp(h.parameterDescriptors===void 0?[]:h.parameterDescriptors.map(({name:e},t)=>{let n=w[t];return n.connect(T,0,v+t),n.start(0),[e,n.offset]}));T.connect(D);let ne=g.channelInterpretation,re=null,ie=g.numberOfOutputs===0?[D]:ee,ae={get bufferSize(){return E},get channelCount(){return g.channelCount},set channelCount(e){throw n()},get channelCountMode(){return g.channelCountMode},set channelCountMode(e){throw n()},get channelInterpretation(){return ne},set channelInterpretation(e){for(let t of S)t.channelInterpretation=e;ne=e},get context(){return D.context},get inputs(){return S},get numberOfInputs(){return g.numberOfInputs},get numberOfOutputs(){return g.numberOfOutputs},get onprocessorerror(){return re},set onprocessorerror(e){typeof re==`function`&&ae.removeEventListener(`processorerror`,re),re=typeof e==`function`?e:null,typeof re==`function`&&ae.addEventListener(`processorerror`,re)},get parameters(){return te},get port(){return x.port2},addEventListener(...e){return D.addEventListener(e[0],e[1],e[2])},connect:e.bind(null,ie),disconnect:l.bind(null,ie),dispatchEvent(...e){return D.dispatchEvent(e[0])},removeEventListener(...e){return D.removeEventListener(e[0],e[1],e[2])}},oe=new Map;x.port1.addEventListener=(e=>(...t)=>{if(t[0]===`message`){let e=typeof t[1]==`function`?t[1]:typeof t[1]==`object`&&t[1]!==null&&typeof t[1].handleEvent==`function`?t[1].handleEvent:null;if(e!==null){let n=oe.get(t[1]);n===void 0?(t[1]=t=>{u(p.currentTime,p.sampleRate,()=>e(t))},oe.set(e,t[1])):t[1]=n}}return e.call(x.port1,t[0],t[1],t[2])})(x.port1.addEventListener),x.port1.removeEventListener=(e=>(...t)=>{if(t[0]===`message`){let e=oe.get(t[1]);e!==void 0&&(oe.delete(t[1]),t[1]=e)}return e.call(x.port1,t[0],t[1],t[2])})(x.port1.removeEventListener);let se=null;Object.defineProperty(x.port1,"onmessage",{get:()=>se,set:e=>{typeof se==`function`&&x.port1.removeEventListener(`message`,se),se=typeof e==`function`?e:null,typeof se==`function`&&(x.port1.addEventListener(`message`,se),x.port1.start())}}),h.prototype.port=x.port1;let ce=null;nh(p,ae,h,g).then(e=>ce=e);let le=op(g.numberOfInputs,g.channelCount),ue=op(g.numberOfOutputs,_),de=h.parameterDescriptors===void 0?[]:h.parameterDescriptors.reduce((e,{name:t})=>({...e,[t]:new Float32Array(128)}),{}),k=!0,fe=()=>{g.numberOfOutputs>0&&D.disconnect(O);for(let e=0,t=0;e<g.numberOfOutputs;e+=1){let n=ee[e];for(let r=0;r<_[e];r+=1)O.disconnect(n,t+r,r);t+=_[e]}},pe=new Map;D.onaudioprocess=({inputBuffer:e,outputBuffer:t})=>{if(ce!==null){let n=d(ae);for(let r=0;r<E;r+=128){for(let t=0;t<g.numberOfInputs;t+=1)for(let n=0;n<g.channelCount;n+=1)ip(e,le[t],n,n,r);h.parameterDescriptors!==void 0&&h.parameterDescriptors.forEach(({name:t},n)=>{ip(e,de,t,v+n,r)});for(let e=0;e<g.numberOfInputs;e+=1)for(let t=0;t<_[e];t+=1)ue[e][t].byteLength===0&&(ue[e][t]=new Float32Array(128));try{let e=le.map((e,t)=>{if(n[t].size>0)return pe.set(t,E/128),e;let r=pe.get(t);return r===void 0?[]:(e.every(e=>e.every(e=>e===0))&&(r===1?pe.delete(t):pe.set(t,r-1)),e)});k=u(p.currentTime+r/p.sampleRate,p.sampleRate,()=>ce.process(e,ue,de));for(let e=0,n=0;e<g.numberOfOutputs;e+=1){for(let i=0;i<_[e];i+=1)ap(t,ue[e],i,n+i,r);n+=_[e]}}catch(e){k=!1,ae.dispatchEvent(new ErrorEvent(`processorerror`,{colno:e.colno,filename:e.filename,lineno:e.lineno,message:e.message}))}if(!k){for(let e=0;e<g.numberOfInputs;e+=1){S[e].disconnect(C[e]);for(let t=0;t<g.channelCount;t+=1)C[r].disconnect(T,t,e*g.channelCount+t)}if(h.parameterDescriptors!==void 0){let e=h.parameterDescriptors.length;for(let t=0;t<e;t+=1){let e=w[t];e.disconnect(T,0,v+t),e.stop()}}T.disconnect(D),D.onaudioprocess=null,me?fe():_e();break}}}};let me=!1,he=o(p,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,gain:0}),ge=()=>D.connect(he).connect(p.destination),_e=()=>{D.disconnect(he),he.disconnect()};return ge(),f(ae,()=>{if(k){_e(),g.numberOfOutputs>0&&D.connect(O);for(let e=0,t=0;e<g.numberOfOutputs;e+=1){let n=ee[e];for(let r=0;r<_[e];r+=1)O.connect(n,t+r,r);t+=_[e]}}me=!0},()=>{k&&(ge(),fe()),me=!1})},ih=(e,t)=>{let n=e.createBiquadFilter();return Rm(n,t),Um(n,t,`Q`),Um(n,t,`detune`),Um(n,t,`frequency`),Um(n,t,`gain`),Lm(n,t,`type`),n},ah=(e,t)=>(n,r)=>{let i=n.createChannelMerger(r.numberOfInputs);return e!==null&&e.name===`webkitAudioContext`&&t(n,i),Rm(i,r),i},oh=e=>{let t=e.numberOfOutputs;Object.defineProperty(e,"channelCount",{get:()=>t,set:e=>{if(e!==t)throw sm()}}),Object.defineProperty(e,"channelCountMode",{get:()=>`explicit`,set:e=>{if(e!==`explicit`)throw sm()}}),Object.defineProperty(e,"channelInterpretation",{get:()=>`discrete`,set:e=>{if(e!==`discrete`)throw sm()}})},sh=(e,t)=>{let n=e.createChannelSplitter(t.numberOfOutputs);return Rm(n,t),oh(n),n},ch=(e,t,n,r,i)=>(a,o)=>{if(a.createConstantSource===void 0)return n(a,o);let s=a.createConstantSource();return Rm(s,o),Um(s,o,`offset`),t(r,()=>r(a))||Gm(s),t(i,()=>i(a))||Km(s),e(a,s),s},lh=(e,t)=>(e.connect=t.connect.bind(t),e.disconnect=t.disconnect.bind(t),e),uh=(e,t,n,r)=>(i,{offset:a,...o})=>{let s=i.createBuffer(1,2,44100),c=t(i,{buffer:null,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),l=n(i,{...o,gain:a}),u=s.getChannelData(0);return u[0]=1,u[1]=1,c.buffer=s,c.loop=!0,e(i,c),r(lh({get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(e){l.channelCount=e},get channelCountMode(){return l.channelCountMode},set channelCountMode(e){l.channelCountMode=e},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(e){l.channelInterpretation=e},get context(){return l.context},get inputs(){return[]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get offset(){return l.gain},get onended(){return c.onended},set onended(e){c.onended=e},addEventListener(...e){return c.addEventListener(e[0],e[1],e[2])},dispatchEvent(...e){return c.dispatchEvent(e[0])},removeEventListener(...e){return c.removeEventListener(e[0],e[1],e[2])},start(e=0){c.start.call(c,e)},stop(e=0){c.stop.call(c,e)}},l),()=>c.connect(l),()=>c.disconnect(l))},dh=(e,t)=>(n,r)=>{let i=n.createConvolver();if(Rm(i,r),r.disableNormalization===i.normalize&&(i.normalize=!r.disableNormalization),Lm(i,r,`buffer`),r.channelCount>2||(t(i,`channelCount`,e=>()=>e.call(i),t=>n=>{if(n>2)throw e();return t.call(i,n)}),r.channelCountMode===`max`))throw e();return t(i,`channelCountMode`,e=>()=>e.call(i),t=>n=>{if(n===`max`)throw e();return t.call(i,n)}),i},fh=(e,t)=>{let n=e.createDelay(t.maxDelayTime);return Rm(n,t),Um(n,t,`delayTime`),n},ph=e=>(t,n)=>{let r=t.createDynamicsCompressor();if(Rm(r,n),n.channelCount>2||n.channelCountMode===`max`)throw e();return Um(r,n,`attack`),Um(r,n,`knee`),Um(r,n,`ratio`),Um(r,n,`release`),Um(r,n,`threshold`),r},mh=(e,t)=>{let n=e.createGain();return Rm(n,t),Um(n,t,`gain`),n},hh=e=>(t,n,r)=>{if(t.createIIRFilter===void 0)return e(t,n,r);let i=t.createIIRFilter(r.feedforward,r.feedback);return Rm(i,r),i};function gh(e,t){let n=t[0]*t[0]+t[1]*t[1];return[(e[0]*t[0]+e[1]*t[1])/n,(e[1]*t[0]-e[0]*t[1])/n]}function _h(e,t){return[e[0]*t[0]-e[1]*t[1],e[0]*t[1]+e[1]*t[0]]}function vh(e,t){let n=[0,0];for(let r=e.length-1;r>=0;--r)n=_h(n,t),n[0]+=e[r];return n}var yh=(e,t,n,r)=>(i,a,{channelCount:o,channelCountMode:s,channelInterpretation:c,feedback:l,feedforward:u})=>{let d=$m(a,i.sampleRate),f=l instanceof Float64Array?l:new Float64Array(l),p=u instanceof Float64Array?u:new Float64Array(u),m=f.length,h=p.length,g=Math.min(m,h);if(m===0||m>20)throw r();if(f[0]===0)throw t();if(h===0||h>20)throw r();if(p[0]===0)throw t();if(f[0]!==1){for(let e=0;e<h;e+=1)p[e]/=f[0];for(let e=1;e<m;e+=1)f[e]/=f[0]}let _=n(i,d,o,o);_.channelCount=o,_.channelCountMode=s,_.channelInterpretation=c;let v=[],y=[],b=[];for(let e=0;e<o;e+=1){v.push(0);let e=new Float32Array(32),t=new Float32Array(32);e.fill(0),t.fill(0),y.push(e),b.push(t)}_.onaudioprocess=e=>{let t=e.inputBuffer,n=e.outputBuffer,r=t.numberOfChannels;for(let e=0;e<r;e+=1){let r=t.getChannelData(e),i=n.getChannelData(e);v[e]=hm(f,m,p,h,g,y[e],b[e],v[e],32,r,i)}};let x=i.sampleRate/2;return lh({get bufferSize(){return d},get channelCount(){return _.channelCount},set channelCount(e){_.channelCount=e},get channelCountMode(){return _.channelCountMode},set channelCountMode(e){_.channelCountMode=e},get channelInterpretation(){return _.channelInterpretation},set channelInterpretation(e){_.channelInterpretation=e},get context(){return _.context},get inputs(){return[_]},get numberOfInputs(){return _.numberOfInputs},get numberOfOutputs(){return _.numberOfOutputs},addEventListener(...e){return _.addEventListener(e[0],e[1],e[2])},dispatchEvent(...e){return _.dispatchEvent(e[0])},getFrequencyResponse(t,n,r){if(t.length!==n.length||n.length!==r.length)throw e();let i=t.length;for(let e=0;e<i;e+=1){let i=-Math.PI*(t[e]/x),a=[Math.cos(i),Math.sin(i)],o=gh(vh(p,a),vh(f,a));n[e]=Math.sqrt(o[0]*o[0]+o[1]*o[1]),r[e]=Math.atan2(o[1],o[0])}},removeEventListener(...e){return _.removeEventListener(e[0],e[1],e[2])}},_)},bh=(e,t)=>e.createMediaElementSource(t.mediaElement),xh=(e,t)=>{let n=e.createMediaStreamDestination();return Rm(n,t),n.numberOfOutputs===1&&Object.defineProperty(n,"numberOfOutputs",{get:()=>0}),n},Sh=(e,{mediaStream:t})=>{let n=t.getAudioTracks();n.sort((e,t)=>e.id<t.id?-1:+(e.id>t.id));let r=n.slice(0,1),i=e.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(i,"mediaStream",{value:t}),i},Ch=(e,t)=>(n,{mediaStreamTrack:r})=>{if(typeof n.createMediaStreamTrackSource==`function`)return n.createMediaStreamTrackSource(r);let i=new MediaStream([r]),a=n.createMediaStreamSource(i);if(r.kind!==`audio`)throw e();if(t(n))throw TypeError();return a},wh=e=>e===null?null:e.hasOwnProperty(`OfflineAudioContext`)?e.OfflineAudioContext:e.hasOwnProperty(`webkitOfflineAudioContext`)?e.webkitOfflineAudioContext:null,Th=(e,t,n,r,i,a)=>(o,s)=>{let c=o.createOscillator();return Rm(c,s),Um(c,s,`detune`),Um(c,s,`frequency`),s.periodicWave===void 0?Lm(c,s,`type`):c.setPeriodicWave(s.periodicWave),t(n,()=>n(o))||Gm(c),t(r,()=>r(o))||a(c,o),t(i,()=>i(o))||Km(c),e(o,c),c},Eh=e=>(t,n)=>{let r=t.createPanner();return r.orientationX===void 0?e(t,n):(Rm(r,n),Um(r,n,`orientationX`),Um(r,n,`orientationY`),Um(r,n,`orientationZ`),Um(r,n,`positionX`),Um(r,n,`positionY`),Um(r,n,`positionZ`),Lm(r,n,`coneInnerAngle`),Lm(r,n,`coneOuterAngle`),Lm(r,n,`coneOuterGain`),Lm(r,n,`distanceModel`),Lm(r,n,`maxDistance`),Lm(r,n,`panningModel`),Lm(r,n,`refDistance`),Lm(r,n,`rolloffFactor`),r)},Dh=(e,t,n,r,i,a,o,s,c,l)=>(u,{coneInnerAngle:d,coneOuterAngle:f,coneOuterGain:p,distanceModel:m,maxDistance:h,orientationX:g,orientationY:_,orientationZ:v,panningModel:y,positionX:b,positionY:x,positionZ:S,refDistance:C,rolloffFactor:w,...T})=>{let E=u.createPanner();if(T.channelCount>2||T.channelCountMode===`max`)throw o();Rm(E,T);let D={channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`},O=n(u,{...D,channelInterpretation:`speakers`,numberOfInputs:6}),ee=r(u,{...T,gain:1}),te=r(u,{...D,gain:1}),ne=r(u,{...D,gain:0}),re=r(u,{...D,gain:0}),ie=r(u,{...D,gain:0}),ae=r(u,{...D,gain:0}),oe=r(u,{...D,gain:0}),se=i(u,256,6,1),ce=a(u,{...D,curve:new Float32Array([1,1]),oversample:`none`}),le=[g,_,v],ue=[b,x,S],de=new Float32Array(1);se.onaudioprocess=({inputBuffer:e})=>{let t=[c(e,de,0),c(e,de,1),c(e,de,2)];t.some((e,t)=>e!==le[t])&&(E.setOrientation(...t),le=t);let n=[c(e,de,3),c(e,de,4),c(e,de,5)];n.some((e,t)=>e!==ue[t])&&(E.setPosition(...n),ue=n)},Object.defineProperty(ne.gain,"defaultValue",{get:()=>0}),Object.defineProperty(re.gain,"defaultValue",{get:()=>0}),Object.defineProperty(ie.gain,"defaultValue",{get:()=>0}),Object.defineProperty(ae.gain,"defaultValue",{get:()=>0}),Object.defineProperty(oe.gain,"defaultValue",{get:()=>0});let k={get bufferSize(){},get channelCount(){return E.channelCount},set channelCount(e){if(e>2)throw o();ee.channelCount=e,E.channelCount=e},get channelCountMode(){return E.channelCountMode},set channelCountMode(e){if(e===`max`)throw o();ee.channelCountMode=e,E.channelCountMode=e},get channelInterpretation(){return E.channelInterpretation},set channelInterpretation(e){ee.channelInterpretation=e,E.channelInterpretation=e},get coneInnerAngle(){return E.coneInnerAngle},set coneInnerAngle(e){E.coneInnerAngle=e},get coneOuterAngle(){return E.coneOuterAngle},set coneOuterAngle(e){E.coneOuterAngle=e},get coneOuterGain(){return E.coneOuterGain},set coneOuterGain(e){if(e<0||e>1)throw t();E.coneOuterGain=e},get context(){return E.context},get distanceModel(){return E.distanceModel},set distanceModel(e){E.distanceModel=e},get inputs(){return[ee]},get maxDistance(){return E.maxDistance},set maxDistance(e){if(e<0)throw RangeError();E.maxDistance=e},get numberOfInputs(){return E.numberOfInputs},get numberOfOutputs(){return E.numberOfOutputs},get orientationX(){return te.gain},get orientationY(){return ne.gain},get orientationZ(){return re.gain},get panningModel(){return E.panningModel},set panningModel(e){E.panningModel=e},get positionX(){return ie.gain},get positionY(){return ae.gain},get positionZ(){return oe.gain},get refDistance(){return E.refDistance},set refDistance(e){if(e<0)throw RangeError();E.refDistance=e},get rolloffFactor(){return E.rolloffFactor},set rolloffFactor(e){if(e<0)throw RangeError();E.rolloffFactor=e},addEventListener(...e){return ee.addEventListener(e[0],e[1],e[2])},dispatchEvent(...e){return ee.dispatchEvent(e[0])},removeEventListener(...e){return ee.removeEventListener(e[0],e[1],e[2])}};return d!==k.coneInnerAngle&&(k.coneInnerAngle=d),f!==k.coneOuterAngle&&(k.coneOuterAngle=f),p!==k.coneOuterGain&&(k.coneOuterGain=p),m!==k.distanceModel&&(k.distanceModel=m),h!==k.maxDistance&&(k.maxDistance=h),g!==k.orientationX.value&&(k.orientationX.value=g),_!==k.orientationY.value&&(k.orientationY.value=_),v!==k.orientationZ.value&&(k.orientationZ.value=v),y!==k.panningModel&&(k.panningModel=y),b!==k.positionX.value&&(k.positionX.value=b),x!==k.positionY.value&&(k.positionY.value=x),S!==k.positionZ.value&&(k.positionZ.value=S),C!==k.refDistance&&(k.refDistance=C),w!==k.rolloffFactor&&(k.rolloffFactor=w),(le[0]!==1||le[1]!==0||le[2]!==0)&&E.setOrientation(...le),(ue[0]!==0||ue[1]!==0||ue[2]!==0)&&E.setPosition(...ue),l(lh(k,E),()=>{ee.connect(E),e(ee,ce,0,0),ce.connect(te).connect(O,0,0),ce.connect(ne).connect(O,0,1),ce.connect(re).connect(O,0,2),ce.connect(ie).connect(O,0,3),ce.connect(ae).connect(O,0,4),ce.connect(oe).connect(O,0,5),O.connect(se).connect(u.destination)},()=>{ee.disconnect(E),s(ee,ce,0,0),ce.disconnect(te),te.disconnect(O),ce.disconnect(ne),ne.disconnect(O),ce.disconnect(re),re.disconnect(O),ce.disconnect(ie),ie.disconnect(O),ce.disconnect(ae),ae.disconnect(O),ce.disconnect(oe),oe.disconnect(O),O.disconnect(se),se.disconnect(u.destination)})},Oh=e=>(t,{disableNormalization:n,imag:r,real:i})=>{let a=r instanceof Float32Array?r:new Float32Array(r),o=i instanceof Float32Array?i:new Float32Array(i),s=t.createPeriodicWave(o,a,{disableNormalization:n});if(Array.from(r).length<2)throw e();return s},kh=(e,t,n,r)=>e.createScriptProcessor(t,n,r),Ah=(e,t)=>(n,r)=>{let i=r.channelCountMode;if(i===`clamped-max`)throw t();if(n.createStereoPanner===void 0)return e(n,r);let a=n.createStereoPanner();return Rm(a,r),Um(a,r,`pan`),Object.defineProperty(a,"channelCountMode",{get:()=>i,set:e=>{if(e!==i)throw t()}}),a},jh=(e,t,n,r,i,a)=>{let o=16385,s=new Float32Array([1,1]),c=Math.PI/2,l={channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`},u={...l,oversample:`none`},d=(e,t,i,a)=>{let d=new Float32Array(o),f=new Float32Array(o);for(let e=0;e<o;e+=1){let t=e/16384*c;d[e]=Math.cos(t),f[e]=Math.sin(t)}let p=n(e,{...l,gain:0}),m=r(e,{...u,curve:d}),h=r(e,{...u,curve:s}),g=n(e,{...l,gain:0}),_=r(e,{...u,curve:f});return{connectGraph(){t.connect(p),t.connect(h.inputs===void 0?h:h.inputs[0]),t.connect(g),h.connect(i),i.connect(m.inputs===void 0?m:m.inputs[0]),i.connect(_.inputs===void 0?_:_.inputs[0]),m.connect(p.gain),_.connect(g.gain),p.connect(a,0,0),g.connect(a,0,1)},disconnectGraph(){t.disconnect(p),t.disconnect(h.inputs===void 0?h:h.inputs[0]),t.disconnect(g),h.disconnect(i),i.disconnect(m.inputs===void 0?m:m.inputs[0]),i.disconnect(_.inputs===void 0?_:_.inputs[0]),m.disconnect(p.gain),_.disconnect(g.gain),p.disconnect(a,0,0),g.disconnect(a,0,1)}}},f=(e,i,a,d)=>{let f=new Float32Array(o),p=new Float32Array(o),m=new Float32Array(o),h=new Float32Array(o),g=8192;for(let e=0;e<o;e+=1)if(e>g){let t=(e-g)/8192*c;f[e]=Math.cos(t),p[e]=Math.sin(t),m[e]=0,h[e]=1}else{let t=e/8192*c;f[e]=1,p[e]=0,m[e]=Math.cos(t),h[e]=Math.sin(t)}let _=t(e,{channelCount:2,channelCountMode:`explicit`,channelInterpretation:`discrete`,numberOfOutputs:2}),v=n(e,{...l,gain:0}),y=r(e,{...u,curve:f}),b=n(e,{...l,gain:0}),x=r(e,{...u,curve:p}),S=r(e,{...u,curve:s}),C=n(e,{...l,gain:0}),w=r(e,{...u,curve:m}),T=n(e,{...l,gain:0}),E=r(e,{...u,curve:h});return{connectGraph(){i.connect(_),i.connect(S.inputs===void 0?S:S.inputs[0]),_.connect(v,0),_.connect(b,0),_.connect(C,1),_.connect(T,1),S.connect(a),a.connect(y.inputs===void 0?y:y.inputs[0]),a.connect(x.inputs===void 0?x:x.inputs[0]),a.connect(w.inputs===void 0?w:w.inputs[0]),a.connect(E.inputs===void 0?E:E.inputs[0]),y.connect(v.gain),x.connect(b.gain),w.connect(C.gain),E.connect(T.gain),v.connect(d,0,0),C.connect(d,0,0),b.connect(d,0,1),T.connect(d,0,1)},disconnectGraph(){i.disconnect(_),i.disconnect(S.inputs===void 0?S:S.inputs[0]),_.disconnect(v,0),_.disconnect(b,0),_.disconnect(C,1),_.disconnect(T,1),S.disconnect(a),a.disconnect(y.inputs===void 0?y:y.inputs[0]),a.disconnect(x.inputs===void 0?x:x.inputs[0]),a.disconnect(w.inputs===void 0?w:w.inputs[0]),a.disconnect(E.inputs===void 0?E:E.inputs[0]),y.disconnect(v.gain),x.disconnect(b.gain),w.disconnect(C.gain),E.disconnect(T.gain),v.disconnect(d,0,0),C.disconnect(d,0,0),b.disconnect(d,0,1),T.disconnect(d,0,1)}}},p=(e,t,n,r,a)=>{if(t===1)return d(e,n,r,a);if(t===2)return f(e,n,r,a);throw i()};return(t,{channelCount:r,channelCountMode:o,pan:s,...c})=>{if(o===`max`)throw i();let l=e(t,{...c,channelCount:1,channelCountMode:o,numberOfInputs:2}),u=n(t,{...c,channelCount:r,channelCountMode:o,gain:1}),d=n(t,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,gain:s}),{connectGraph:f,disconnectGraph:m}=p(t,r,u,d,l);Object.defineProperty(d.gain,"defaultValue",{get:()=>0}),Object.defineProperty(d.gain,"maxValue",{get:()=>1}),Object.defineProperty(d.gain,"minValue",{get:()=>-1});let h={get bufferSize(){},get channelCount(){return u.channelCount},set channelCount(e){u.channelCount!==e&&(g&&m(),{connectGraph:f,disconnectGraph:m}=p(t,e,u,d,l),g&&f()),u.channelCount=e},get channelCountMode(){return u.channelCountMode},set channelCountMode(e){if(e===`clamped-max`||e===`max`)throw i();u.channelCountMode=e},get channelInterpretation(){return u.channelInterpretation},set channelInterpretation(e){u.channelInterpretation=e},get context(){return u.context},get inputs(){return[u]},get numberOfInputs(){return u.numberOfInputs},get numberOfOutputs(){return u.numberOfOutputs},get pan(){return d.gain},addEventListener(...e){return u.addEventListener(e[0],e[1],e[2])},dispatchEvent(...e){return u.dispatchEvent(e[0])},removeEventListener(...e){return u.removeEventListener(e[0],e[1],e[2])}},g=!1;return a(lh(h,l),()=>{f(),g=!0},()=>{m(),g=!1})}},Mh=(e,t,n,r,i,a,o)=>(s,c)=>{let l=s.createWaveShaper();if(a!==null&&a.name===`webkitAudioContext`&&s.createGain().gain.automationRate===void 0)return n(s,c);Rm(l,c);let u=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(u!==null&&u.length<2)throw t();Lm(l,{curve:u},`curve`),Lm(l,c,`oversample`);let d=null,f=!1;return o(l,`curve`,e=>()=>e.call(l),t=>n=>(t.call(l,n),f&&(r(n)&&d===null?d=e(s,l):!r(n)&&d!==null&&(d(),d=null)),n)),i(l,()=>{f=!0,r(l.curve)&&(d=e(s,l))},()=>{f=!1,d!==null&&(d(),d=null)})},Nh=(e,t,n,r,i)=>(a,{curve:o,oversample:s,...c})=>{let l=a.createWaveShaper(),u=a.createWaveShaper();Rm(l,c),Rm(u,c);let d=n(a,{...c,gain:1}),f=n(a,{...c,gain:-1}),p=n(a,{...c,gain:1}),m=n(a,{...c,gain:-1}),h=null,g=!1,_=null,v={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(e){d.channelCount=e,f.channelCount=e,l.channelCount=e,p.channelCount=e,u.channelCount=e,m.channelCount=e},get channelCountMode(){return l.channelCountMode},set channelCountMode(e){d.channelCountMode=e,f.channelCountMode=e,l.channelCountMode=e,p.channelCountMode=e,u.channelCountMode=e,m.channelCountMode=e},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(e){d.channelInterpretation=e,f.channelInterpretation=e,l.channelInterpretation=e,p.channelInterpretation=e,u.channelInterpretation=e,m.channelInterpretation=e},get context(){return l.context},get curve(){return _},set curve(n){if(n!==null&&n.length<2)throw t();if(n===null)l.curve=n,u.curve=n;else{let e=n.length,t=new Float32Array(e+2-e%2),r=new Float32Array(e+2-e%2);t[0]=n[0],r[0]=-n[e-1];let i=Math.ceil((e+1)/2),a=(e+1)/2-1;for(let o=1;o<i;o+=1){let s=o/i*a,c=Math.floor(s),l=Math.ceil(s);t[o]=c===l?n[c]:(1-(s-c))*n[c]+(1-(l-s))*n[l],r[o]=c===l?-n[e-1-c]:-((1-(s-c))*n[e-1-c])-(1-(l-s))*n[e-1-l]}t[i]=e%2==1?n[i-1]:(n[i-2]+n[i-1])/2,l.curve=t,u.curve=r}_=n,g&&(r(_)&&h===null?h=e(a,d):h!==null&&(h(),h=null))},get inputs(){return[d]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get oversample(){return l.oversample},set oversample(e){l.oversample=e,u.oversample=e},addEventListener(...e){return d.addEventListener(e[0],e[1],e[2])},dispatchEvent(...e){return d.dispatchEvent(e[0])},removeEventListener(...e){return d.removeEventListener(e[0],e[1],e[2])}};return o!==null&&(v.curve=o instanceof Float32Array?o:new Float32Array(o)),s!==v.oversample&&(v.oversample=s),i(lh(v,p),()=>{d.connect(l).connect(p),d.connect(f).connect(u).connect(m).connect(p),g=!0,r(_)&&(h=e(a,d))},()=>{d.disconnect(l),l.disconnect(p),d.disconnect(f),f.disconnect(u),u.disconnect(m),m.disconnect(p),g=!1,h!==null&&(h(),h=null)})},Ph=()=>new DOMException(``,`NotSupportedError`),Fh={numberOfChannels:1},Ih=(e,t,n,r,i)=>class extends e{constructor(e,n,i){let a;if(typeof e==`number`&&n!==void 0&&i!==void 0)a={length:n,numberOfChannels:e,sampleRate:i};else if(typeof e==`object`)a=e;else throw Error(`The given parameters are not valid.`);let{length:o,numberOfChannels:s,sampleRate:c}={...Fh,...a},l=r(s,o,c);t(Fm,()=>Fm(l))||l.addEventListener(`statechange`,(()=>{let e=0,t=n=>{this._state===`running`&&(e>0?(l.removeEventListener(`statechange`,t),n.stopImmediatePropagation(),this._waitForThePromiseToSettle(n)):e+=1)};return t})()),super(l,s),this._length=o,this._nativeOfflineAudioContext=l,this._state=null}get length(){return this._nativeOfflineAudioContext.length===void 0?this._length:this._nativeOfflineAudioContext.length}get state(){return this._state===null?this._nativeOfflineAudioContext.state:this._state}startRendering(){return this._state===`running`?Promise.reject(n()):(this._state=`running`,i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,yf(this)}))}_waitForThePromiseToSettle(e){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(e):setTimeout(()=>this._waitForThePromiseToSettle(e))}},Lh={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,detune:0,frequency:440,periodicWave:void 0,type:`sine`},Rh=(e,t,n,r,i,a,o)=>class extends e{constructor(e,o){let s=i(e),c={...Lh,...o},l=n(s,c),u=a(s),d=u?r():null,f=e.sampleRate/2;super(e,!1,l,d),this._detune=t(this,u,l.detune,153600,-153600),this._frequency=t(this,u,l.frequency,f,-f),this._nativeOscillatorNode=l,this._onended=null,this._oscillatorNodeRenderer=d,this._oscillatorNodeRenderer!==null&&c.periodicWave!==void 0&&(this._oscillatorNodeRenderer.periodicWave=c.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(e){let t=typeof e==`function`?o(this,e):null;this._nativeOscillatorNode.onended=t;let n=this._nativeOscillatorNode.onended;this._onended=n!==null&&n===t?e:n}get type(){return this._nativeOscillatorNode.type}set type(e){this._nativeOscillatorNode.type=e,this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(e){this._nativeOscillatorNode.setPeriodicWave(e),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=e)}start(e=0){if(this._nativeOscillatorNode.start(e),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.start=e),this.context.state!==`closed`){Bd(this);let e=()=>{this._nativeOscillatorNode.removeEventListener(`ended`,e),of(this)&&Hd(this)};this._nativeOscillatorNode.addEventListener(`ended`,e)}}stop(e=0){this._nativeOscillatorNode.stop(e),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=e)}},zh=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=null,s=null,c=null,l=async(l,u)=>{let d=n(l),f=Xd(d,u);return f||(d=t(u,{channelCount:d.channelCount,channelCountMode:d.channelCountMode,channelInterpretation:d.channelInterpretation,detune:d.detune.value,frequency:d.frequency.value,periodicWave:o===null?void 0:o,type:d.type}),s!==null&&d.start(s),c!==null&&d.stop(c)),a.set(u,d),f?(await e(u,l.detune,d.detune),await e(u,l.frequency,d.frequency)):(await r(u,l.detune,d.detune),await r(u,l.frequency,d.frequency)),await i(l,u,d),d};return{set periodicWave(e){o=e},set start(e){s=e},set stop(e){c=e},render(e,t){let n=a.get(t);return n===void 0?l(e,t):Promise.resolve(n)}}},Bh={channelCount:2,channelCountMode:`clamped-max`,channelInterpretation:`speakers`,coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:`inverse`,maxDistance:1e4,orientationX:1,orientationY:0,orientationZ:0,panningModel:`equalpower`,positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1},Vh=(e,t,n,r,i,a,o)=>class extends e{constructor(e,s){let c=i(e),l=n(c,{...Bh,...s}),u=a(c),d=u?r():null;super(e,!1,l,d),this._nativePannerNode=l,this._orientationX=t(this,u,l.orientationX,af,rf),this._orientationY=t(this,u,l.orientationY,af,rf),this._orientationZ=t(this,u,l.orientationZ,af,rf),this._positionX=t(this,u,l.positionX,af,rf),this._positionY=t(this,u,l.positionY,af,rf),this._positionZ=t(this,u,l.positionZ,af,rf),o(this,1)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(e){this._nativePannerNode.coneInnerAngle=e}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(e){this._nativePannerNode.coneOuterAngle=e}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(e){this._nativePannerNode.coneOuterGain=e}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(e){this._nativePannerNode.distanceModel=e}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(e){this._nativePannerNode.maxDistance=e}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(e){this._nativePannerNode.panningModel=e}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(e){this._nativePannerNode.refDistance=e}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(e){this._nativePannerNode.rolloffFactor=e}},Hh=(e,t,n,r,i,a,o,s,c,l)=>()=>{let u=new WeakMap,d=null,f=async(f,p)=>{let m=null,h=a(f),g={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation},_={...g,coneInnerAngle:h.coneInnerAngle,coneOuterAngle:h.coneOuterAngle,coneOuterGain:h.coneOuterGain,distanceModel:h.distanceModel,maxDistance:h.maxDistance,panningModel:h.panningModel,refDistance:h.refDistance,rolloffFactor:h.rolloffFactor},v=Xd(h,p);if(`bufferSize`in h?m=r(p,{...g,gain:1}):v||(h=i(p,{..._,orientationX:h.orientationX.value,orientationY:h.orientationY.value,orientationZ:h.orientationZ.value,positionX:h.positionX.value,positionY:h.positionY.value,positionZ:h.positionZ.value})),u.set(p,m===null?h:m),m!==null){if(d===null){if(o===null)throw Error(`Missing the native OfflineAudioContext constructor.`);let e=new o(6,f.context.length,p.sampleRate),r=t(e,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:6});r.connect(e.destination),d=(async()=>{let t=await Promise.all([f.orientationX,f.orientationY,f.orientationZ,f.positionX,f.positionY,f.positionZ].map(async(t,r)=>{let i=n(e,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,offset:+(r===0)});return await s(e,t,i.offset),i}));for(let e=0;e<6;e+=1)t[e].connect(r,0,e),t[e].start(0);return l(e)})()}let e=await d,a=r(p,{...g,gain:1});await c(f,p,a);let u=[];for(let t=0;t<e.numberOfChannels;t+=1)u.push(e.getChannelData(t));let h=[u[0][0],u[1][0],u[2][0]],v=[u[3][0],u[4][0],u[5][0]],y=r(p,{...g,gain:1}),b=i(p,{..._,orientationX:h[0],orientationY:h[1],orientationZ:h[2],positionX:v[0],positionY:v[1],positionZ:v[2]});a.connect(y).connect(b.inputs[0]),b.connect(m);for(let t=128;t<e.length;t+=128){let e=[u[0][t],u[1][t],u[2][t]],n=[u[3][t],u[4][t],u[5][t]];if(e.some((e,t)=>e!==h[t])||n.some((e,t)=>e!==v[t])){h=e,v=n;let o=t/p.sampleRate;y.gain.setValueAtTime(0,o),y=r(p,{...g,gain:0}),b=i(p,{..._,orientationX:h[0],orientationY:h[1],orientationZ:h[2],positionX:v[0],positionY:v[1],positionZ:v[2]}),y.gain.setValueAtTime(1,o),a.connect(y).connect(b.inputs[0]),b.connect(m)}}return m}return v?(await e(p,f.orientationX,h.orientationX),await e(p,f.orientationY,h.orientationY),await e(p,f.orientationZ,h.orientationZ),await e(p,f.positionX,h.positionX),await e(p,f.positionY,h.positionY),await e(p,f.positionZ,h.positionZ)):(await s(p,f.orientationX,h.orientationX),await s(p,f.orientationY,h.orientationY),await s(p,f.orientationZ,h.orientationZ),await s(p,f.positionX,h.positionX),await s(p,f.positionY,h.positionY),await s(p,f.positionZ,h.positionZ)),Af(h)?await c(f,p,h.inputs[0]):await c(f,p,h),h};return{render(e,t){let n=u.get(t);return n===void 0?f(e,t):Promise.resolve(n)}}},Uh={disableNormalization:!1},Wh=(e,t,n,r)=>class i{constructor(i,a){let o=e(t(i),r({...Uh,...a}));return n.add(o),o}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===i.prototype||n.has(e)}},Gh=(e,t)=>(n,r,i)=>(e(r).replay(i),t(r,n,i)),Kh=(e,t,n)=>async(r,i,a)=>{let o=e(r);await Promise.all(o.activeInputs.map((e,o)=>Array.from(e).map(async([e,s])=>{let c=await t(e).render(e,i),l=r.context.destination;n(e)||r===l&&n(r)||c.connect(a,s,o)})).reduce((e,t)=>[...e,...t],[]))},qh=(e,t,n)=>async(r,i,a)=>{let o=t(r);await Promise.all(Array.from(o.activeInputs).map(async([t,r])=>{let o=await e(t).render(t,i);n(t)||o.connect(a,r)}))},Jh=(e,t,n,r)=>i=>e(Fm,()=>Fm(i))?Promise.resolve(e(r,r)).then(e=>{if(!e){let e=n(i,512,0,1);i.oncomplete=()=>{e.onaudioprocess=null,e.disconnect()},e.onaudioprocess=()=>i.currentTime,e.connect(i.destination)}return i.startRendering()}):new Promise(e=>{let n=t(i,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,gain:0});i.oncomplete=t=>{n.disconnect(),e(t.renderedBuffer)},n.connect(i.destination),i.startRendering()}),Yh=e=>(t,n)=>{e.set(t,n)},Xh=e=>(t,n)=>e.set(t,n),Zh=(e,t,n,r,i,a,o,s)=>(c,l)=>n(c).render(c,l).then(()=>Promise.all(Array.from(r(l)).map(e=>n(e).render(e,l)))).then(()=>i(l)).then(n=>(typeof n.copyFromChannel==`function`?t(a,()=>a(n))||s(n):(o(n),ef(n)),e.add(n),n)),Qh={channelCount:2,channelCountMode:`explicit`,channelInterpretation:`speakers`,pan:0},$h=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=i(e),c=n(s,{...Qh,...o}),l=a(s),u=l?r():null;super(e,!1,c,u),this._pan=t(this,l,c.pan)}get pan(){return this._pan}},eg=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=async(o,s)=>{let c=n(o),l=Xd(c,s);return l||(c=t(s,{channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,pan:c.pan.value})),a.set(s,c),l?await e(s,o.pan,c.pan):await r(s,o.pan,c.pan),Af(c)?await i(o,s,c.inputs[0]):await i(o,s,c),c};return{render(e,t){let n=a.get(t);return n===void 0?o(e,t):Promise.resolve(n)}}},tg=e=>()=>{if(e===null)return!1;try{new e({length:1,sampleRate:44100})}catch{return!1}return!0},ng=(e,t)=>async()=>{if(e===null)return!0;if(t===null)return!1;let n=new Blob([`class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)`],{type:`application/javascript; charset=utf-8`}),r=new t(1,128,44100),i=URL.createObjectURL(n),a=!1,o=!1;try{await r.audioWorklet.addModule(i);let t=new e(r,`a`,{numberOfOutputs:0}),n=r.createOscillator();t.port.onmessage=()=>a=!0,t.onprocessorerror=()=>o=!0,n.connect(t),n.start(0),await r.startRendering(),await new Promise(e=>setTimeout(e))}catch{}finally{URL.revokeObjectURL(i)}return a&&!o},rg=(e,t)=>()=>{if(t===null)return Promise.resolve(!1);let n=new t(1,1,44100),r=e(n,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,gain:0});return new Promise(e=>{n.oncomplete=()=>{r.disconnect(),e(n.currentTime!==0)},n.startRendering()})},ig=()=>new DOMException(``,`UnknownError`),ag={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,curve:null,oversample:`none`},og=(e,t,n,r,i,a,o)=>class extends e{constructor(e,t){let s=i(e),c=n(s,{...ag,...t}),l=a(s)?r():null;super(e,!0,c,l),this._isCurveNullified=!1,this._nativeWaveShaperNode=c,o(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(e){if(e===null)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(e.length<2)throw t();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=e}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(e){this._nativeWaveShaperNode.oversample=e}},sg=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return Xd(o,a)||(o=e(a,{channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,curve:o.curve,oversample:o.oversample})),r.set(a,o),Af(o)?await n(i,a,o.inputs[0]):await n(i,a,o),o};return{render(e,t){let n=r.get(t);return n===void 0?i(e,t):Promise.resolve(n)}}},cg=()=>typeof window>`u`?null:window,lg=(e,t)=>n=>{n.copyFromChannel=(r,i,a=0)=>{let o=e(a),s=e(i);if(s>=n.numberOfChannels)throw t();let c=n.length,l=n.getChannelData(s),u=r.length;for(let e=o<0?-o:0;e+o<c&&e<u;e+=1)r[e]=l[e+o]},n.copyToChannel=(r,i,a=0)=>{let o=e(a),s=e(i);if(s>=n.numberOfChannels)throw t();let c=n.length,l=n.getChannelData(s),u=r.length;for(let e=o<0?-o:0;e+o<c&&e<u;e+=1)l[e+o]=r[e]}},ug=e=>t=>{t.copyFromChannel=(n=>(r,i,a=0)=>{let o=e(a),s=e(i);if(o<t.length)return n.call(t,r,s,o)})(t.copyFromChannel),t.copyToChannel=(n=>(r,i,a=0)=>{let o=e(a),s=e(i);if(o<t.length)return n.call(t,r,s,o)})(t.copyToChannel)},dg=e=>(t,n)=>{let r=n.createBuffer(1,1,44100);t.buffer===null&&(t.buffer=r),e(t,`buffer`,e=>()=>{let n=e.call(t);return n===r?null:n},e=>n=>e.call(t,n===null?r:n))},fg=(e,t)=>(n,r)=>{r.channelCount=1,r.channelCountMode=`explicit`,Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw e()}}),Object.defineProperty(r,"channelCountMode",{get:()=>`explicit`,set:()=>{throw e()}});let i=n.createBufferSource();t(r,()=>{let e=r.numberOfInputs;for(let t=0;t<e;t+=1)i.connect(r,0,t)},()=>i.disconnect(r))},pg=(e,t,n)=>e.copyFromChannel===void 0?e.getChannelData(n)[0]:(e.copyFromChannel(t,n),t[0]),mg=e=>{if(e===null)return!1;let t=e.length;return t%2==0?e[t/2-1]+e[t/2]!==0:e[Math.floor(t/2)]!==0},hg=(e,t,n,r)=>{let i=e;for(;!i.hasOwnProperty(t);)i=Object.getPrototypeOf(i);let{get:a,set:o}=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,{get:n(a),set:r(o)})},gg=e=>({...e,outputChannelCount:e.outputChannelCount===void 0?e.numberOfInputs===1&&e.numberOfOutputs===1?[e.channelCount]:Array.from({length:e.numberOfOutputs},()=>1):e.outputChannelCount}),_g=e=>({...e,channelCount:e.numberOfOutputs}),vg=e=>{let{imag:t,real:n}=e;return t===void 0?n===void 0?{...e,imag:[0,0],real:[0,0]}:{...e,imag:Array.from(n,()=>0),real:n}:n===void 0?{...e,imag:t,real:Array.from(t,()=>0)}:{...e,imag:t,real:n}},yg=(e,t,n)=>{try{e.setValueAtTime(t,n)}catch(r){if(r.code!==9)throw r;yg(e,t,n+1e-7)}},bg=e=>{let t=e.createBufferSource();t.start();try{t.start()}catch{return!0}return!1},xg=e=>{let t=e.createBufferSource();t.buffer=e.createBuffer(1,1,44100);try{t.start(0,1)}catch{return!1}return!0},Sg=e=>{let t=e.createBufferSource();t.start();try{t.stop()}catch{return!1}return!0},Cg=e=>{let t=e.createOscillator();try{t.start(-1)}catch(e){return e instanceof RangeError}return!1},wg=e=>{let t=e.createBuffer(1,1,44100),n=e.createBufferSource();n.buffer=t,n.start(),n.stop();try{return n.stop(),!0}catch{return!1}},Tg=e=>{let t=e.createOscillator();try{t.stop(-1)}catch(e){return e instanceof RangeError}return!1},Eg=e=>{let{port1:t,port2:n}=new MessageChannel;try{t.postMessage(e)}finally{t.close(),n.close()}},Dg=e=>{e.start=(t=>(n=0,r=0,i)=>{let a=e.buffer,o=a===null?r:Math.min(a.duration,r);a!==null&&o>a.duration-.5/e.context.sampleRate?t.call(e,n,0,0):t.call(e,n,o,i)})(e.start)},Og=(e,t)=>{let n=t.createGain();e.connect(n);let r=(t=>()=>{t.call(e,n),e.removeEventListener(`ended`,r)})(e.disconnect);e.addEventListener(`ended`,r),lh(e,n),e.stop=(t=>{let r=!1;return(i=0)=>{if(r)try{t.call(e,i)}catch{n.gain.setValueAtTime(0,i)}else t.call(e,i),r=!0}})(e.stop)},kg=(e,t)=>n=>{let r={value:e};return Object.defineProperties(n,{currentTarget:r,target:r}),typeof t==`function`?t.call(e,n):t.handleEvent.call(e,n)},Ag=gd(Df),jg=Gd(Df),Mg=zp(Ld),Ng=new WeakMap,Pg=im(Ng),Fg=mp(new Map,new WeakMap),Ig=cg(),Lg=Vm(Fg,$d),Rg=rm(gf),zg=Kh(gf,Rg,zf),Bg=Zd(Lg,Lf,zg),Vg=cm(wd),Hg=wh(Ig),Ug=Dm(Hg),Wg=new WeakMap,Gg=Xp(kg),Kg=Jm(Ig),qg=Cm(Kg),Jg=wm(Ig),Yg=Tm(Ig),Xg=Xm(Ig),Zg=Qf(_d(bd),Wd(Ag,jg,jf,Mg,If,gf,Pg,zd,Lf,Df,of,zf,Bf),Fg,vm(Ed,If,gf,Lf,Rf,of),$d,dm,Ph,Fp(jf,Ed,gf,Lf,Rf,Vg,of,Ug),Hp(Wg,gf,Id),Gg,Vg,qg,Jg,Yg,Ug,Xg),Qg=Yd(Zg,Bg,$d,Lg,Vg,Ug),$g=new WeakSet,e_=Hm(Ig),t_=Dp(new Uint32Array(1)),n_=lg(t_,$d),r_=ug(t_),i_=nf($g,Fg,Ph,e_,Hg,tg(e_),n_,r_),a_=Kd(mh),o_=qh(Rg,_f,zf),s_=xp(o_),c_=qm(a_,Fg,bg,xg,Sg,Cg,wg,Tg,Dg,dg(hg),Og),l_=Gh(am(_f),o_),u_=lf(s_,c_,Lf,l_,zg),d_=$f(vd(Sd),Wg,Cd,ep,md.createCancelAndHoldAutomationEvent,md.createCancelScheduledValuesAutomationEvent,md.createExponentialRampToValueAutomationEvent,md.createLinearRampToValueAutomationEvent,md.createSetTargetAutomationEvent,md.createSetValueAutomationEvent,md.createSetValueCurveAutomationEvent,Kg,yg),f_=cf(Zg,u_,d_,sm,c_,Vg,Ug,kg),p_=Sf(Zg,Cf,$d,sm,Ym(mh,hg),Vg,Ug,zg),m_=pp(s_,ih,Lf,l_,zg),h_=Xh(Ng),g_=fp(Zg,d_,m_,dm,ih,Vg,Ug,h_),__=Im(Df,Jg),v_=ah(Kg,fg(sm,__)),y_=gp(Zg,_p(v_,Lf,zg),v_,Vg,Ug),b_=yp(Zg,bp(sh,Lf,zg),sh,Vg,Ug,_g),x_=ch(a_,Fg,uh(a_,c_,mh,__),Cg,Tg),S_=Tp(Zg,d_,Ep(s_,x_,Lf,l_,zg),x_,Vg,Ug,kg),C_=dh(Ph,hg),w_=kp(Zg,Ap(C_,Lf,zg),C_,Vg,Ug,h_),T_=Lp(Zg,d_,Rp(s_,fh,Lf,l_,zg),fh,Vg,Ug,h_),E_=ph(Ph),D_=Kp(Zg,d_,qp(s_,E_,Lf,l_,zg),E_,Ph,Vg,Ug,h_),O_=em(Zg,d_,tm(s_,mh,Lf,l_,zg),mh,Vg,Ug),k_=yh(dm,sm,kh,Ph),A_=Jh(Fg,mh,kh,rg(mh,Hg)),j_=_m(c_,Lf,Hg,zg,A_),M_=mm(Zg,hh(k_),j_,Vg,Ug,h_),N_=wf(d_,v_,x_,kh,Ph,pg,Ug,hg),P_=new WeakMap,F_=Pm(p_,N_,Gg,Ug,P_,kg),I_=Th(a_,Fg,Cg,wg,Tg,Og),L_=Rh(Zg,d_,I_,zh(s_,I_,Lf,l_,zg),Vg,Ug,kg),R_=Cp(c_),z_=Mh(R_,sm,Nh(R_,sm,mh,mg,__),mg,__,Kg,hg),B_=Eh(Dh(jf,sm,v_,mh,kh,z_,Ph,If,pg,__)),V_=Vh(Zg,d_,B_,Hh(s_,v_,x_,mh,B_,Lf,Hg,l_,zg,A_),Vg,Ug,h_),H_=Wh(Oh($d),Vg,new WeakSet,vg),U_=Ah(jh(v_,sh,mh,z_,Ph,__),Ph),W_=$h(Zg,d_,U_,eg(s_,U_,Lf,l_,zg),Vg,Ug),G_=og(Zg,sm,z_,sg(z_,Lf,zg),Vg,Ug,h_),K_=Om(Ig),q_=Zp(Ig),J_=new WeakMap,Y_=lm(J_,Hg),X_=K_?Fd(Fg,Ph,Yp(Ig),q_,Qp(hd),Vg,Y_,Ug,Xg,new WeakMap,new WeakMap,ng(Xg,Hg),Ig):void 0,Z_=Em(qg,Ug),Q_=up(X_,Qg,i_,f_,g_,y_,b_,S_,w_,Pp($g,Fg,Mp,Jp,new WeakSet,Vg,Z_,Qd,Fm,n_,r_),T_,D_,O_,M_,F_,L_,V_,H_,W_,G_),$_=xf(Q_,sm,Ph,ig,km(Zg,bh,Vg,Ug),jm(Zg,xh,Vg,Ug),Mm(Zg,Sh,Vg,Ug),Nm(Zg,Ch(sm,Ug),Vg),Kg),ev=um(P_),tv=qd(ev),nv=Sp($d),rv=Bp(ev),iv=Wp($d),av=new WeakMap,ov=Qm(sm,rh(nv,$d,sm,v_,sh,x_,mh,kh,Ph,iv,q_,nm(av,Id),__),mh,Ph,__),sv=lp(s_,nv,c_,v_,sh,x_,mh,rv,iv,q_,Lf,Xg,Hg,l_,zg,A_),cv=om(J_),lv=Yh(av),uv=K_?rp(tv,Zg,d_,sv,ov,gf,cv,Vg,Ug,Xg,gg,lv,Eg,kg):void 0,dv=Ih(Q_,Fg,sm,jp(Ph,Hg),Zh($g,Fg,Rg,ev,A_,Qd,n_,r_)),fv=ym(wd,qg),pv=bm(xd,Jg),mv=xm(Cd,Yg),hv=Sm(wd,Ug);function gv(e){return e===void 0}function G(e){return e!==void 0}function _v(e){return typeof e==`function`}function vv(e){return typeof e==`number`}function yv(e){return Object.prototype.toString.call(e)===`[object Object]`&&e.constructor===Object}function bv(e){return typeof e==`boolean`}function xv(e){return Array.isArray(e)}function Sv(e){return typeof e==`string`}function Cv(e){return Sv(e)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(e)}function K(e,t){if(!e)throw Error(t)}function wv(e,t,n=1/0){if(!(t<=e&&e<=n))throw RangeError(`Value must be within [${t}, ${n}], got: ${e}`)}function Tv(e){!e.isOffline&&e.state!==`running`&&Mv(`The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.`)}var Ev=!1,Dv=!1;function Ov(e){Ev=e}function kv(e){gv(e)&&Ev&&!Dv&&(Dv=!0,Mv(`Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing`))}var Av=console;function jv(...e){Av.log(...e)}function Mv(...e){Av.warn(...e)}function Nv(e){return new $_(e)}function Pv(e,t,n){return new dv(e,t,n)}var Fv=typeof self==`object`?self:null,Iv=Fv&&(Fv.hasOwnProperty(`AudioContext`)||Fv.hasOwnProperty(`webkitAudioContext`));function Lv(e,t,n){return K(G(uv),`AudioWorkletNode only works in a secure context (https or localhost)`),new(e instanceof Fv?.BaseAudioContext?Fv?.AudioWorkletNode:uv)(e,t,n)}function Rv(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function zv(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}var Bv=class{constructor(e,t,n,r){this._callback=e,this._type=t,this._minimumUpdateInterval=Math.max(128/(r||44100),.001),this.updateInterval=n,this._createClock()}_createWorker(){let e=new Blob([`
|
|
68
|
+
// the initial timeout time
|
|
69
|
+
let timeoutTime = ${(this._updateInterval*1e3).toFixed(1)};
|
|
70
|
+
// onmessage callback
|
|
71
|
+
self.onmessage = function(msg){
|
|
72
|
+
timeoutTime = parseInt(msg.data);
|
|
73
|
+
};
|
|
74
|
+
// the tick function which posts a message
|
|
75
|
+
// and schedules a new tick
|
|
76
|
+
function tick(){
|
|
77
|
+
setTimeout(tick, timeoutTime);
|
|
78
|
+
self.postMessage('tick');
|
|
79
|
+
}
|
|
80
|
+
// call tick initially
|
|
81
|
+
tick();
|
|
82
|
+
`],{type:`text/javascript`}),t=URL.createObjectURL(e),n=new Worker(t);n.onmessage=this._callback.bind(this),this._worker=n}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},this._updateInterval*1e3)}_createClock(){if(this._type===`worker`)try{this._createWorker()}catch{this._type=`timeout`,this._createClock()}else this._type===`timeout`&&this._createTimeout()}_disposeClock(){this._timeout&&clearTimeout(this._timeout),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(e){var t;this._updateInterval=Math.max(e,this._minimumUpdateInterval),this._type===`worker`&&((t=this._worker)==null||t.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(e){this._disposeClock(),this._type=e,this._createClock()}dispose(){this._disposeClock()}};function Vv(e){return mv(e)}function Hv(e){return pv(e)}function Uv(e){return hv(e)}function Wv(e){return fv(e)}function Gv(e){return e instanceof i_}function Kv(e,t){return e===`value`||Vv(t)||Hv(t)||Gv(t)}function qv(e,...t){if(!t.length)return e;let n=t.shift();if(yv(e)&&yv(n))for(let t in n)Kv(t,n[t])?e[t]=n[t]:yv(n[t])?(e[t]||Object.assign(e,{[t]:{}}),qv(e[t],n[t])):Object.assign(e,{[t]:n[t]});return qv(e,...t)}function Jv(e,t){return e.length===t.length&&e.every((e,n)=>t[n]===e)}function q(e,t,n=[],r){let i={},a=Array.from(t);if(yv(a[0])&&r&&!Reflect.has(a[0],r)&&(Object.keys(a[0]).some(t=>Reflect.has(e,t))||(qv(i,{[r]:a[0]}),n.splice(n.indexOf(r),1),a.shift())),a.length===1&&yv(a[0]))qv(i,a[0]);else for(let e=0;e<n.length;e++)G(a[e])&&(i[n[e]]=a[e]);return qv(e,i)}function Yv(e){return e.constructor.getDefaults()}function Xv(e,t){return gv(e)?t:e}function Zv(e,t){return t.forEach(t=>{Reflect.has(e,t)&&delete e[t]}),e}var Qv=class{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...e){(this.debug||Fv&&this.toString()===Fv.TONE_DEBUG_CLASS)&&jv(this,...e)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}};Qv.version=V;var $v=1e-6;function ey(e,t){return e>t+$v}function ty(e,t){return ey(e,t)||ry(e,t)}function ny(e,t){return e+$v<t}function ry(e,t){return Math.abs(e-t)<$v}function iy(e,t,n){return Math.max(Math.min(e,n),t)}var ay=class e extends Qv{constructor(){super(),this.name=`Timeline`,this._timeline=[];let t=q(e.getDefaults(),arguments,[`memory`]);this.memory=t.memory,this.increasing=t.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(e){if(K(Reflect.has(e,`time`),`Timeline: events must have a time attribute`),e.time=e.time.valueOf(),this.increasing&&this.length){let t=this._timeline[this.length-1];K(ty(e.time,t.time),`The time must be greater than or equal to the last scheduled time`),this._timeline.push(e)}else{let t=this._search(e.time);this._timeline.splice(t+1,0,e)}if(this.length>this.memory){let e=this.length-this.memory;this._timeline.splice(0,e)}return this}remove(e){let t=this._timeline.indexOf(e);return t!==-1&&this._timeline.splice(t,1),this}get(e,t=`time`){let n=this._search(e,t);return n===-1?null:this._timeline[n]}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(e,t=`time`){let n=this._search(e,t);return n+1<this._timeline.length?this._timeline[n+1]:null}getBefore(e){let t=this._timeline.length;if(t>0&&this._timeline[t-1].time<e)return this._timeline[t-1];let n=this._search(e);return n-1>=0?this._timeline[n-1]:null}cancel(e){if(this._timeline.length>1){let t=this._search(e);if(t>=0){if(ry(this._timeline[t].time,e)){for(let n=t;n>=0&&ry(this._timeline[n].time,e);n--)t=n;this._timeline=this._timeline.slice(0,t)}else this._timeline=this._timeline.slice(0,t+1)}else this._timeline=[]}else this._timeline.length===1&&ty(this._timeline[0].time,e)&&(this._timeline=[]);return this}cancelBefore(e){let t=this._search(e);return t>=0&&(this._timeline=this._timeline.slice(t+1)),this}previousEvent(e){let t=this._timeline.indexOf(e);return t>0?this._timeline[t-1]:null}_search(e,t=`time`){if(this._timeline.length===0)return-1;let n=0,r=this._timeline.length,i=r;if(r>0&&this._timeline[r-1][t]<=e)return r-1;for(;n<i;){let r=Math.floor(n+(i-n)/2),a=this._timeline[r],o=this._timeline[r+1];if(ry(a[t],e)){for(let n=r;n<this._timeline.length;n++){let i=this._timeline[n];if(ry(i[t],e))r=n;else break}return r}if(ny(a[t],e)&&ey(o[t],e))return r;ey(a[t],e)?i=r:n=r+1}return-1}_iterate(e,t=0,n=this._timeline.length-1){this._timeline.slice(t,n+1).forEach(e)}forEach(e){return this._iterate(e),this}forEachBefore(e,t){let n=this._search(e);return n!==-1&&this._iterate(t,0,n),this}forEachAfter(e,t){let n=this._search(e);return this._iterate(t,n+1),this}forEachBetween(e,t,n){let r=this._search(e),i=this._search(t);return r!==-1&&i!==-1?(this._timeline[r].time!==e&&(r+=1),this._timeline[i].time===t&&--i,this._iterate(n,r,i)):r===-1&&this._iterate(n,0,i),this}forEachFrom(e,t){let n=this._search(e);for(;n>=0&&this._timeline[n].time>=e;)n--;return this._iterate(t,n+1),this}forEachAtTime(e,t){let n=this._search(e);if(n!==-1&&ry(this._timeline[n].time,e)){let r=n;for(let t=n;t>=0&&ry(this._timeline[t].time,e);t--)r=t;this._iterate(e=>{t(e)},r,n)}return this}dispose(){return super.dispose(),this._timeline=[],this}},oy=[];function sy(e){oy.push(e)}function cy(e){oy.forEach(t=>t(e))}var ly=[];function uy(e){ly.push(e)}function dy(e){ly.forEach(t=>t(e))}var fy=class e extends Qv{constructor(){super(...arguments),this.name=`Emitter`}on(e,t){return e.split(/\W+/).forEach(e=>{gv(this._events)&&(this._events={}),this._events.hasOwnProperty(e)||(this._events[e]=[]),this._events[e].push(t)}),this}once(e,t){let n=(...r)=>{t(...r),this.off(e,n)};return this.on(e,n),this}off(e,t){return e.split(/\W+/).forEach(e=>{if(gv(this._events)&&(this._events={}),this._events.hasOwnProperty(e)){if(gv(t))this._events[e]=[];else{let n=this._events[e];for(let e=n.length-1;e>=0;e--)n[e]===t&&n.splice(e,1)}}}),this}emit(e,...t){if(this._events&&this._events.hasOwnProperty(e)){let n=this._events[e].slice(0);for(let e=0,r=n.length;e<r;e++)n[e].apply(this,t)}return this}static mixin(t){[`on`,`once`,`off`,`emit`].forEach(n=>{let r=Object.getOwnPropertyDescriptor(e.prototype,n);Object.defineProperty(t.prototype,n,r)})}dispose(){return super.dispose(),this._events=void 0,this}},py=class extends fy{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}},my=class e extends py{constructor(){super(),this.name=`Context`,this._constants=new Map,this._timeouts=new ay,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;let t=q(e.getDefaults(),arguments,[`context`]);t.context?(this._context=t.context,this._latencyHint=arguments[0]?.latencyHint||``):(this._context=Nv({latencyHint:t.latencyHint}),this._latencyHint=t.latencyHint),this._ticker=new Bv(this.emit.bind(this,`tick`),t.clockSource,t.updateInterval,this._context.sampleRate),this.on(`tick`,this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit(`statechange`,this.state)},this[arguments[0]?.hasOwnProperty(`updateInterval`)?`_lookAhead`:`lookAhead`]=t.lookAhead}static getDefaults(){return{clockSource:`worker`,latencyHint:`interactive`,lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||=(cy(this),!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(e,t,n){return this._context.createBuffer(e,t,n)}createChannelMerger(e){return this._context.createChannelMerger(e)}createChannelSplitter(e){return this._context.createChannelSplitter(e)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(e){return this._context.createDelay(e)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(e,t){return this._context.createIIRFilter(e,t)}createPanner(){return this._context.createPanner()}createPeriodicWave(e,t,n){return this._context.createPeriodicWave(e,t,n)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(e){return K(Wv(this._context),`Not available if OfflineAudioContext`),this._context.createMediaStreamSource(e)}createMediaElementSource(e){return K(Wv(this._context),`Not available if OfflineAudioContext`),this._context.createMediaElementSource(e)}createMediaStreamDestination(){return K(Wv(this._context),`Not available if OfflineAudioContext`),this._context.createMediaStreamDestination()}decodeAudioData(e){return this._context.decodeAudioData(e)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(e){K(!this._initialized,`The listener cannot be set after initialization.`),this._listener=e}get transport(){return this.initialize(),this._transport}set transport(e){K(!this._initialized,`The transport cannot be set after initialization.`),this._transport=e}get draw(){return this.initialize(),this._draw}set draw(e){K(!this._initialized,`Draw cannot be set after initialization.`),this._draw=e}get destination(){return this.initialize(),this._destination}set destination(e){K(!this._initialized,`The destination cannot be set after initialization.`),this._destination=e}createAudioWorkletNode(e,t){return Lv(this.rawContext,e,t)}addAudioWorkletModule(e){return zv(this,void 0,void 0,function*(){K(G(this.rawContext.audioWorklet),`AudioWorkletNode is only available in a secure context (https or localhost)`),this._workletPromise||=this.rawContext.audioWorklet.addModule(e),yield this._workletPromise})}workletsAreReady(){return zv(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(e){this._ticker.updateInterval=e}get clockSource(){return this._ticker.type}set clockSource(e){this._ticker.type=e}get lookAhead(){return this._lookAhead}set lookAhead(e){this._lookAhead=e,this.updateInterval=e?e/2:.01}get latencyHint(){return this._latencyHint}get rawContext(){return this._context}now(){return this._context.currentTime+this._lookAhead}immediate(){return this._context.currentTime}resume(){return Wv(this._context)?this._context.resume():Promise.resolve()}close(){return zv(this,void 0,void 0,function*(){Wv(this._context)&&this.state!==`closed`&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&dy(this)})}getConstant(e){if(this._constants.has(e))return this._constants.get(e);{let t=this._context.createBuffer(1,128,this._context.sampleRate),n=t.getChannelData(0);for(let t=0;t<n.length;t++)n[t]=e;let r=this._context.createBufferSource();return r.channelCount=1,r.channelCountMode=`explicit`,r.buffer=t,r.loop=!0,r.start(0),this._constants.set(e,r),r}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(e=>this._constants[e].disconnect()),this.close(),this}_timeoutLoop(){let e=this.now();this._timeouts.forEachBefore(e,e=>{e.callback(),this._timeouts.remove(e)})}setTimeout(e,t){this._timeoutIds++;let n=this.now();return this._timeouts.add({callback:e,id:this._timeoutIds,time:n+t}),this._timeoutIds}clearTimeout(e){return this._timeouts.forEach(t=>{t.id===e&&this._timeouts.remove(t)}),this}clearInterval(e){return this.clearTimeout(e)}setInterval(e,t){let n=++this._timeoutIds,r=()=>{let i=this.now();this._timeouts.add({callback:()=>{e(),r()},id:n,time:i+t})};return r(),n}},hy=class extends py{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(e,t,n){return{}}createChannelMerger(e){return{}}createChannelSplitter(e){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(e){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(e,t){return{}}createPanner(){return{}}createPeriodicWave(e,t,n){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(e){return{}}createMediaElementSource(e){return{}}createMediaStreamDestination(){return{}}decodeAudioData(e){return Promise.resolve({})}createAudioWorkletNode(e,t){return{}}get rawContext(){return{}}addAudioWorkletModule(e){return zv(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(e,t){return 0}clearTimeout(e){return this}setInterval(e,t){return 0}clearInterval(e){return this}getConstant(e){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(e){}get destination(){return{}}set destination(e){}now(){return 0}immediate(){return 0}};function J(e,t){xv(t)?t.forEach(t=>J(e,t)):Object.defineProperty(e,t,{enumerable:!0,writable:!1})}function gy(e,t){xv(t)?t.forEach(t=>gy(e,t)):Object.defineProperty(e,t,{writable:!0})}var _y=()=>{},vy=class e extends Qv{constructor(){super(),this.name=`ToneAudioBuffer`,this.onload=_y;let t=q(e.getDefaults(),arguments,[`url`,`onload`,`onerror`]);this.reverse=t.reverse,this.onload=t.onload,Sv(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:_y,onload:_y,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Sy().sampleRate}set(t){return t instanceof e?t.loaded?this._buffer=t.get():t.onload=()=>{this.set(t),this.onload(this)}:this._buffer=t,this._reversed&&this._reverse(),this}get(){return this._buffer}load(t){return zv(this,void 0,void 0,function*(){let n=e.load(t).then(e=>{this.set(e),this.onload(this)});e.downloads.push(n);try{yield n}finally{let t=e.downloads.indexOf(n);e.downloads.splice(t,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(e){let t=xv(e)&&e[0].length>0,n=t?e.length:1,r=t?e[0].length:e.length,i=Sy(),a=i.createBuffer(n,r,i.sampleRate),o=!t&&n===1?[e]:e;for(let e=0;e<n;e++)a.copyToChannel(o[e],e);return this._buffer=a,this}toMono(e){if(vv(e))this.fromArray(this.toArray(e));else{let e=new Float32Array(this.length),t=this.numberOfChannels;for(let n=0;n<t;n++){let t=this.toArray(n);for(let n=0;n<t.length;n++)e[n]+=t[n]}e=e.map(e=>e/t),this.fromArray(e)}return this}toArray(e){if(vv(e))return this.getChannelData(e);if(this.numberOfChannels===1)return this.toArray(0);{let e=[];for(let t=0;t<this.numberOfChannels;t++)e[t]=this.getChannelData(t);return e}}getChannelData(e){return this._buffer?this._buffer.getChannelData(e):new Float32Array}slice(t,n=this.duration){K(this.loaded,`Buffer is not loaded`);let r=Math.floor(t*this.sampleRate),i=Math.floor(n*this.sampleRate);K(r<i,`The start time must be less than the end time`);let a=i-r,o=Sy().createBuffer(this.numberOfChannels,a,this.sampleRate);for(let e=0;e<this.numberOfChannels;e++)o.copyToChannel(this.getChannelData(e).subarray(r,i),e);return new e(o)}_reverse(){if(this.loaded)for(let e=0;e<this.numberOfChannels;e++)this.getChannelData(e).reverse();return this}get loaded(){return this.length>0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(e){this._reversed!==e&&(this._reversed=e,this._reverse())}static fromArray(t){return new e().fromArray(t)}static fromUrl(t){return zv(this,void 0,void 0,function*(){return yield new e().load(t)})}static load(t){return zv(this,void 0,void 0,function*(){let n=e.baseUrl===``||e.baseUrl.endsWith(`/`)?e.baseUrl:e.baseUrl+`/`,r=yield fetch(n+t);if(!r.ok)throw Error(`could not load url: ${t}`);let i=yield r.arrayBuffer();return yield Sy().decodeAudioData(i)})}static supportsType(e){let t=e.split(`.`),n=t[t.length-1];return document.createElement(`audio`).canPlayType(`audio/`+n)!==``}static loaded(){return zv(this,void 0,void 0,function*(){for(yield Promise.resolve();e.downloads.length;)yield e.downloads[0]})}};vy.baseUrl=``,vy.downloads=[];var yy=class extends my{constructor(){super({clockSource:`offline`,context:Uv(arguments[0])?arguments[0]:Pv(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:Uv(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name=`OfflineContext`,this._currentTime=0,this.isOffline=!0,this._duration=Uv(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(e){return zv(this,void 0,void 0,function*(){let t=0;for(;this._duration-this._currentTime>=0;){this.emit(`tick`),this._currentTime+=128/this.sampleRate,t++;let n=Math.floor(this.sampleRate/128);e&&t%n===0&&(yield new Promise(e=>setTimeout(e,1)))}})}render(){return zv(this,arguments,void 0,function*(e=!0){return yield this.workletsAreReady(),yield this._renderClock(e),new vy(yield this._context.startRendering())})}close(){return Promise.resolve()}},by=new hy,xy=by;function Sy(){return xy===by&&Iv&&Cy(new my),xy}function Cy(e,t=!1){t&&xy.dispose(),xy=Wv(e)?new my(e):Uv(e)?new yy(e):e}function wy(){return xy.resume()}if(Fv&&!Fv.TONE_SILENCE_LOGGING){let e=` * Tone.js v${V} * `;console.log(`%c${e}`,`background: #000; color: #fff`)}function Ty(e){return 10**(e/20)}function Ey(e){return Math.log(e)/Math.LN10*20}function Dy(e){return 2**(e/12)}var Oy=440;function ky(){return Oy}function Ay(e){Oy=e}function jy(e){return Math.round(My(e))}function My(e){return 69+12*Math.log2(e/Oy)}function Ny(e){return Oy*2**((e-69)/12)}var Py=class e extends Qv{constructor(e,t,n){super(),this.defaultUnits=`s`,this._val=t,this._units=n,this.context=e,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:e=>this._frequencyToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:e=>this._ticksToUnits(parseInt(e,10)),regexp:/^(\d+)i$/i},m:{method:e=>this._beatsToUnits(parseInt(e,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(e,t)=>{let n=parseInt(e,10),r=t===`.`?1.5:1;return n===1?this._beatsToUnits(this._getTimeSignature())*r:this._beatsToUnits(4/n)*r},regexp:/^(\d+)n(\.?)$/i},number:{method:e=>this._expressions[this.defaultUnits].method.call(this,e),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:e=>this._secondsToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:e=>parseInt(e,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:e=>{let t=parseInt(e,10);return this._beatsToUnits(8/(Math.floor(t)*3))},regexp:/^(\d+)t$/i},tr:{method:(e,t,n)=>{let r=0;return e&&e!==`0`&&(r+=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!==`0`&&(r+=this._beatsToUnits(parseFloat(t))),n&&n!==`0`&&(r+=this._beatsToUnits(parseFloat(n)/4)),r},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof e&&this.fromType(this._val),gv(this._val))return this._noArg();if(Sv(this._val)&&gv(this._units)){for(let e in this._expressions)if(this._expressions[e].regexp.test(this._val.trim())){this._units=e;break}}else if(yv(this._val)){let e=0;for(let t in this._val)if(G(this._val[t])){let n=this._val[t],r=new this.constructor(this.context,t).valueOf()*n;e+=r}return e}if(G(this._units)){let e=this._expressions[this._units],t=this._val.toString().trim().match(e.regexp);return t?e.method.apply(this,t.slice(1)):e.method.call(this,this._val)}return Sv(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(e){return 1/e}_beatsToUnits(e){return 60/this._getBpm()*e}_secondsToUnits(e){return e}_ticksToUnits(e){return e*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(e){switch(this._units=void 0,this.defaultUnits){case`s`:this._val=e.toSeconds();break;case`i`:this._val=e.toTicks();break;case`hz`:this._val=e.toFrequency();break;case`midi`:this._val=e.toMidi()}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}},Fy=class e extends Py{constructor(){super(...arguments),this.name=`TimeClass`}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:e=>this._now()+new this.constructor(this.context,e).valueOf(),regexp:/^\+(.+)/},quantize:{method:t=>{let n=new e(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(n))},regexp:/^@(.+)/}})}quantize(e,t=1){let n=new this.constructor(this.context,e).valueOf(),r=this.valueOf();return r+(Math.round(r/n)*n-r)*t}toNotation(){let t=this.toSeconds(),n=[`1m`];for(let e=1;e<9;e++){let t=2**e;n.push(t+`n.`),n.push(t+`n`),n.push(t+`t`)}n.push(`0`);let r=n[0],i=new e(this.context,n[0]).toSeconds();return n.forEach(n=>{let a=new e(this.context,n).toSeconds();Math.abs(a-t)<Math.abs(i-t)&&(r=n,i=a)}),r}toBarsBeatsSixteenths(){let e=this._beatsToUnits(1),t=this.valueOf()/e;t=parseFloat(t.toFixed(4));let n=Math.floor(t/this._getTimeSignature()),r=t%1*4;t=Math.floor(t)%this._getTimeSignature();let i=r.toString();return i.length>3&&(r=parseFloat(parseFloat(i).toFixed(3))),[n,t,r].join(`:`)}toTicks(){let e=this._beatsToUnits(1);return this.valueOf()/e*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return jy(this.toFrequency())}_now(){return this.context.now()}},Iy=class e extends Fy{constructor(){super(...arguments),this.name=`Frequency`,this.defaultUnits=`hz`}static get A4(){return ky()}static set A4(e){Ay(e)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return this.defaultUnits===`midi`?t:e.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,n){let r=Ly[t.toLowerCase()]+(parseInt(n,10)+1)*12;return this.defaultUnits===`midi`?r:e.mtof(r)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(e,t,n){let r=1;return e&&e!==`0`&&(r*=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!==`0`&&(r*=this._beatsToUnits(parseFloat(t))),n&&n!==`0`&&(r*=this._beatsToUnits(parseFloat(n)/4)),r}}})}transpose(t){return new e(this.context,this.valueOf()*Dy(t))}harmonize(e){return e.map(e=>this.transpose(e))}toMidi(){return jy(this.valueOf())}toNote(){let t=this.toFrequency(),n=Math.log2(t/e.A4),r=Math.round(12*n)+57,i=Math.floor(r/12);return i<0&&(r+=-12*i),Ry[r%12]+i.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){let e=this._beatsToUnits(1),t=this.valueOf()/e;return Math.floor(t*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(e){return e}_ticksToUnits(e){return 1/(e*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(e){return 1/super._beatsToUnits(e)}_secondsToUnits(e){return 1/e}static mtof(e){return Ny(e)}static ftom(e){return jy(e)}},Ly={cbbb:-3,cbb:-2,cb:-1,c:0,"c#":1,cx:2,"c##":2,"c###":3,"cx#":3,"c#x":3,dbbb:-1,dbb:0,db:1,d:2,"d#":3,dx:4,"d##":4,"d###":5,"dx#":5,"d#x":5,ebbb:1,ebb:2,eb:3,e:4,"e#":5,ex:6,"e##":6,"e###":7,"ex#":7,"e#x":7,fbbb:2,fbb:3,fb:4,f:5,"f#":6,fx:7,"f##":7,"f###":8,"fx#":8,"f#x":8,gbbb:4,gbb:5,gb:6,g:7,"g#":8,gx:9,"g##":9,"g###":10,"gx#":10,"g#x":10,abbb:6,abb:7,ab:8,a:9,"a#":10,ax:11,"a##":11,"a###":12,"ax#":12,"a#x":12,bbbb:8,bbb:9,bb:10,b:11,"b#":12,bx:13,"b##":13,"b###":14,"bx#":14,"b#x":14},Ry=[`C`,`C#`,`D`,`D#`,`E`,`F`,`F#`,`G`,`G#`,`A`,`A#`,`B`];function zy(e,t){return new Iy(Sy(),e,t)}var By=class extends Fy{constructor(){super(...arguments),this.name=`TransportTime`}_now(){return this.context.transport.seconds}},Vy=class e extends Qv{constructor(){super();let t=q(e.getDefaults(),arguments,[`context`]);this.context=this.defaultContext?this.defaultContext:t.context}static getDefaults(){return{context:Sy()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(e){return kv(e),new Fy(this.context,e).toSeconds()}toFrequency(e){return new Iy(this.context,e).toFrequency()}toTicks(e){return new By(this.context,e).toTicks()}_getPartialProperties(e){let t=this.get();return Object.keys(t).forEach(n=>{gv(e[n])&&delete t[n]}),t}get(){let t=Yv(this);return Object.keys(t).forEach(n=>{if(Reflect.has(this,n)){let r=this[n];G(r)&&G(r.value)&&G(r.setValueAtTime)?t[n]=r.value:r instanceof e?t[n]=r._getPartialProperties(t[n]):xv(r)||vv(r)||Sv(r)||bv(r)?t[n]=r:delete t[n]}}),t}set(t){return Object.keys(t).forEach(n=>{Reflect.has(this,n)&&G(this[n])&&(this[n]&&G(this[n].value)&&G(this[n].setValueAtTime)?this[n].value!==t[n]&&(this[n].value=t[n]):this[n]instanceof e?this[n].set(t[n]):this[n]=t[n])}),this}},Hy=class extends ay{constructor(e=`stopped`){super(),this.name=`StateTimeline`,this._initial=e,this.setStateAtTime(this._initial,0)}getValueAtTime(e){let t=this.get(e);return t===null?this._initial:t.state}setStateAtTime(e,t,n){return wv(t,0),this.add(Object.assign({},n,{state:e,time:t})),this}getLastState(e,t){let n=this._search(t);for(let t=n;t>=0;t--){let n=this._timeline[t];if(n.state===e)return n}}getNextState(e,t){let n=this._search(t);if(n!==-1)for(let t=n;t<this._timeline.length;t++){let n=this._timeline[t];if(n.state===e)return n}}},Y=class e extends Vy{constructor(){let t=q(e.getDefaults(),arguments,[`param`,`units`,`convert`]);for(super(t),this.name=`Param`,this.overridden=!1,this._minOutput=1e-7,K(G(t.param)&&(Vv(t.param)||t.param instanceof e),`param must be an AudioParam`);!Vv(t.param);)t.param=t.param._param;this._swappable=G(t.swappable)?t.swappable:!1,this._swappable?(this.input=this.context.createGain(),this._param=t.param,this.input.connect(this._param)):this._param=this.input=t.param,this._events=new ay(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,G(t.value)&&t.value!==this._toType(this._initialValue)&&this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(Vy.getDefaults(),{convert:!0,units:`number`})}get value(){let e=this.now();return this.getValueAtTime(e)}set value(e){this.cancelScheduledValues(this.now()),this.setValueAtTime(e,this.now())}get minValue(){return G(this._minValue)?this._minValue:this.units===`time`||this.units===`frequency`||this.units===`normalRange`||this.units===`positive`||this.units===`transportTime`||this.units===`ticks`||this.units===`bpm`||this.units===`hertz`||this.units===`samples`?0:this.units===`audioRange`?-1:this.units===`decibels`?-1/0:this._param.minValue}get maxValue(){return G(this._maxValue)?this._maxValue:this.units===`normalRange`||this.units===`audioRange`?1:this._param.maxValue}_is(e,t){return this.units===t}_assertRange(e){return G(this.maxValue)&&G(this.minValue)&&wv(e,this._fromType(this.minValue),this._fromType(this.maxValue)),e}_fromType(e){return this.convert&&!this.overridden?this._is(e,`time`)?this.toSeconds(e):this._is(e,`decibels`)?Ty(e):this._is(e,`frequency`)?this.toFrequency(e):e:this.overridden?0:e}_toType(e){return this.convert&&this.units===`decibels`?Ey(e):e}setValueAtTime(e,t){let n=this.toSeconds(t),r=this._fromType(e);return K(isFinite(r)&&isFinite(n),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(r),this.log(this.units,`setValueAtTime`,e,n),this._events.add({time:n,type:`setValueAtTime`,value:r}),this._param.setValueAtTime(r,n),this}getValueAtTime(e){let t=Math.max(this.toSeconds(e),0),n=this._events.getAfter(t),r=this._events.get(t),i=this._initialValue;if(r===null)i=this._initialValue;else if(r.type===`setTargetAtTime`&&(n===null||n.type===`setValueAtTime`)){let e=this._events.getBefore(r.time),n;n=e===null?this._initialValue:e.value,r.type===`setTargetAtTime`&&(i=this._exponentialApproach(r.time,n,r.value,r.constant,t))}else if(n===null)i=r.value;else if(n.type===`linearRampToValueAtTime`||n.type===`exponentialRampToValueAtTime`){let e=r.value;if(r.type===`setTargetAtTime`){let t=this._events.getBefore(r.time);e=t===null?this._initialValue:t.value}i=n.type===`linearRampToValueAtTime`?this._linearInterpolate(r.time,e,n.time,n.value,t):this._exponentialInterpolate(r.time,e,n.time,n.value,t)}else i=r.value;return this._toType(i)}setRampPoint(e){e=this.toSeconds(e);let t=this.getValueAtTime(e);return this.cancelAndHoldAtTime(e),this._fromType(t)===0&&(t=this._toType(this._minOutput)),this.setValueAtTime(t,e),this}linearRampToValueAtTime(e,t){let n=this._fromType(e),r=this.toSeconds(t);return K(isFinite(n)&&isFinite(r),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(n),this._events.add({time:r,type:`linearRampToValueAtTime`,value:n}),this.log(this.units,`linearRampToValueAtTime`,e,r),this._param.linearRampToValueAtTime(n,r),this}exponentialRampToValueAtTime(e,t){let n=this._fromType(e);n=ry(n,0)?this._minOutput:n,this._assertRange(n);let r=this.toSeconds(t);return K(isFinite(n)&&isFinite(r),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({time:r,type:`exponentialRampToValueAtTime`,value:n}),this.log(this.units,`exponentialRampToValueAtTime`,e,r),this._param.exponentialRampToValueAtTime(n,r),this}exponentialRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialRampToValueAtTime(e,n+this.toSeconds(t)),this}linearRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.linearRampToValueAtTime(e,n+this.toSeconds(t)),this}targetRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialApproachValueAtTime(e,n,t),this}exponentialApproachValueAtTime(e,t,n){t=this.toSeconds(t),n=this.toSeconds(n);let r=Math.log(n+1)/Math.log(200);return this.setTargetAtTime(e,t,r),this.cancelAndHoldAtTime(t+n*.9),this.linearRampToValueAtTime(e,t+n),this}setTargetAtTime(e,t,n){let r=this._fromType(e);K(isFinite(n)&&n>0,`timeConstant must be a number greater than 0`);let i=this.toSeconds(t);return this._assertRange(r),K(isFinite(r)&&isFinite(i),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({constant:n,time:i,type:`setTargetAtTime`,value:r}),this.log(this.units,`setTargetAtTime`,e,i,n),this._param.setTargetAtTime(r,i,n),this}setValueCurveAtTime(e,t,n,r=1){n=this.toSeconds(n),t=this.toSeconds(t);let i=this._fromType(e[0])*r;this.setValueAtTime(this._toType(i),t);let a=n/(e.length-1);for(let n=1;n<e.length;n++){let i=this._fromType(e[n])*r;this.linearRampToValueAtTime(this._toType(i),t+n*a)}return this}cancelScheduledValues(e){let t=this.toSeconds(e);return K(isFinite(t),`Invalid argument to cancelScheduledValues: ${JSON.stringify(e)}`),this._events.cancel(t),this._param.cancelScheduledValues(t),this.log(this.units,`cancelScheduledValues`,t),this}cancelAndHoldAtTime(e){let t=this.toSeconds(e),n=this._fromType(this.getValueAtTime(t));K(isFinite(t),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(e)}`),this.log(this.units,`cancelAndHoldAtTime`,t,`value=`+n);let r=this._events.get(t),i=this._events.getAfter(t);return r&&ry(r.time,t)?i?(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time)):(this._param.cancelAndHoldAtTime(t),this._events.cancel(t+this.sampleTime)):i&&(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time),i.type===`linearRampToValueAtTime`?this.linearRampToValueAtTime(this._toType(n),t):i.type===`exponentialRampToValueAtTime`&&this.exponentialRampToValueAtTime(this._toType(n),t)),this._events.add({time:t,type:`setValueAtTime`,value:n}),this._param.setValueAtTime(n,t),this}rampTo(e,t=.1,n){return this.units===`frequency`||this.units===`bpm`||this.units===`decibels`?this.exponentialRampTo(e,t,n):this.linearRampTo(e,t,n),this}apply(e){let t=this.context.currentTime;e.setValueAtTime(this.getValueAtTime(t),t);let n=this._events.get(t);if(n&&n.type===`setTargetAtTime`){let r=this._events.getAfter(n.time),i=r?r.time:t+2,a=(i-t)/10;for(let n=t;n<i;n+=a)e.linearRampToValueAtTime(this.getValueAtTime(n),n)}return this._events.forEachAfter(this.context.currentTime,t=>{t.type===`cancelScheduledValues`?e.cancelScheduledValues(t.time):t.type===`setTargetAtTime`?e.setTargetAtTime(t.value,t.time,t.constant):e[t.type](t.value,t.time)}),this}setParam(e){K(this._swappable,`The Param must be assigned as 'swappable' in the constructor`);let t=this.input;return t.disconnect(this._param),this.apply(e),this._param=e,t.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(e,t,n,r,i){return n+(t-n)*Math.exp(-(i-e)/r)}_linearInterpolate(e,t,n,r,i){return t+(r-t)*((i-e)/(n-e))}_exponentialInterpolate(e,t,n,r,i){return t*(r/t)**+((i-e)/(n-e))}},X=class e extends Vy{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return G(this.input)?Vv(this.input)||this.input instanceof Y?1:this.input.numberOfInputs:0}get numberOfOutputs(){return G(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return G(t)&&(t instanceof e||Hv(t))}_getInternalNodes(){let e=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&e.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&e.push(this.output),e}_setChannelProperties(e){this._getInternalNodes().forEach(t=>{t.channelCount=e.channelCount,t.channelCountMode=e.channelCountMode,t.channelInterpretation=e.channelInterpretation})}_getChannelProperties(){let e=this._getInternalNodes();K(e.length>0,`ToneAudioNode does not have any internal nodes`);let t=e[0];return{channelCount:t.channelCount,channelCountMode:t.channelCountMode,channelInterpretation:t.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(e){let t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCount:e}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(e){let t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCountMode:e}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(e){let t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelInterpretation:e}))}connect(e,t=0,n=0){return Wy(this,e,t,n),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return Mv(`toMaster() has been renamed toDestination()`),this.toDestination()}disconnect(e,t=0,n=0){return Gy(this,e,t,n),this}chain(...e){return Uy(this,...e),this}fan(...e){return e.forEach(e=>this.connect(e)),this}dispose(){return super.dispose(),G(this.input)&&(this.input instanceof e?this.input.dispose():Hv(this.input)&&this.input.disconnect()),G(this.output)&&(this.output instanceof e?this.output.dispose():Hv(this.output)&&this.output.disconnect()),this._internalChannels=[],this}};function Uy(...e){let t=e.shift();e.reduce((e,t)=>(e instanceof X?e.connect(t):Hv(e)&&Wy(e,t),t),t)}function Wy(e,t,n=0,r=0){for(K(G(e),`Cannot connect from undefined node`),K(G(t),`Cannot connect to undefined node`),(t instanceof X||Hv(t))&&K(t.numberOfInputs>0,`Cannot connect to node with no inputs`),K(e.numberOfOutputs>0,`Cannot connect from node with no outputs`);t instanceof X||t instanceof Y;)G(t.input)&&(t=t.input);for(;e instanceof X;)G(e.output)&&(e=e.output);Vv(t)?e.connect(t,n):e.connect(t,n,r)}function Gy(e,t,n=0,r=0){if(G(t))for(;t instanceof X;)t=t.input;for(;!Hv(e);)G(e.output)&&(e=e.output);Vv(t)?e.disconnect(t,n):Hv(t)?e.disconnect(t,n,r):e.disconnect()}var Z=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`gain`,`units`]);super(t),this.name=`Gain`,this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new Y({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),J(this,`gain`)}static getDefaults(){return Object.assign(X.getDefaults(),{convert:!0,gain:1,units:`gain`})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}},Ky=class extends X{constructor(e){super(e),this.onended=_y,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new Z({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(e){let t=this.toSeconds(e);return this._startTime!==-1&&t>=this._startTime&&(this._stopTime===-1||t<=this._stopTime)?`started`:`stopped`},this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut,this._curve=e.curve,this.onended=e.onended}static getDefaults(){return Object.assign(X.getDefaults(),{curve:`linear`,fadeIn:0,fadeOut:0,onended:_y})}_startGain(e,t=1){K(this._startTime===-1,`Source cannot be started more than once`);let n=this.toSeconds(this._fadeIn);return this._startTime=e+n,this._startTime=Math.max(this._startTime,this.context.currentTime),n>0?(this._gainNode.gain.setValueAtTime(0,e),this._curve===`linear`?this._gainNode.gain.linearRampToValueAtTime(t,e+n):this._gainNode.gain.exponentialApproachValueAtTime(t,e,n)):this._gainNode.gain.setValueAtTime(t,e),this}stop(e){return this.log(`stop`,e),this._stopGain(this.toSeconds(e)),this}_stopGain(e){K(this._startTime!==-1,`'start' must be called before 'stop'`),this.cancelStop();let t=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(e)+t,this._stopTime=Math.max(this._stopTime,this.now()),t>0?this._curve===`linear`?this._gainNode.gain.linearRampTo(0,t,e):this._gainNode.gain.targetRampTo(0,t,e):(this._gainNode.gain.cancelAndHoldAtTime(e),this._gainNode.gain.setValueAtTime(0,e)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{let e=this._curve===`exponential`?t*2:0;this._stopSource(this.now()+e),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==_y&&(this.onended(this),this.onended=_y,!this.context.isOffline)){let e=()=>this.dispose();typeof requestIdleCallback<`u`?requestIdleCallback(e):setTimeout(e,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log(`cancelStop`),K(this._startTime!==-1,`Source is not started`),this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),this.context.clearTimeout(this._timeout),this._stopTime=-1,this}dispose(){return super.dispose(),this._gainNode.dispose(),this.onended=_y,this}},qy=class e extends Ky{constructor(){let t=q(e.getDefaults(),arguments,[`offset`]);super(t),this.name=`ToneConstantSource`,this._source=this.context.createConstantSource(),Wy(this._source,this._gainNode),this.offset=new Y({context:this.context,convert:t.convert,param:this._source.offset,units:t.units,value:t.offset,minValue:t.minValue,maxValue:t.maxValue})}static getDefaults(){return Object.assign(Ky.getDefaults(),{convert:!0,offset:1,units:`number`})}start(e){let t=this.toSeconds(e);return this.log(`start`,t),this._startGain(t),this._source.start(t),this}_stopSource(e){this._source.stop(e)}dispose(){return super.dispose(),this.state===`started`&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}},Jy=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`value`,`units`]);super(t),this.name=`Signal`,this.override=!0,this.output=this._constantSource=new qy({context:this.context,convert:t.convert,offset:t.value,units:t.units,minValue:t.minValue,maxValue:t.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign(X.getDefaults(),{convert:!0,units:`number`,value:0})}connect(e,t=0,n=0){return Yy(this,e,t,n),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(e,t){return this._param.setValueAtTime(e,t),this}getValueAtTime(e){return this._param.getValueAtTime(e)}setRampPoint(e){return this._param.setRampPoint(e),this}linearRampToValueAtTime(e,t){return this._param.linearRampToValueAtTime(e,t),this}exponentialRampToValueAtTime(e,t){return this._param.exponentialRampToValueAtTime(e,t),this}exponentialRampTo(e,t,n){return this._param.exponentialRampTo(e,t,n),this}linearRampTo(e,t,n){return this._param.linearRampTo(e,t,n),this}targetRampTo(e,t,n){return this._param.targetRampTo(e,t,n),this}exponentialApproachValueAtTime(e,t,n){return this._param.exponentialApproachValueAtTime(e,t,n),this}setTargetAtTime(e,t,n){return this._param.setTargetAtTime(e,t,n),this}setValueCurveAtTime(e,t,n,r){return this._param.setValueCurveAtTime(e,t,n,r),this}cancelScheduledValues(e){return this._param.cancelScheduledValues(e),this}cancelAndHoldAtTime(e){return this._param.cancelAndHoldAtTime(e),this}rampTo(e,t,n){return this._param.rampTo(e,t,n),this}get value(){return this._param.value}set value(e){this._param.value=e}get convert(){return this._param.convert}set convert(e){this._param.convert=e}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(e){this._param.overridden=e}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(e){return this._param.apply(e),this}};function Yy(e,t,n,r){(t instanceof Y||Vv(t)||t instanceof Jy&&t.override)&&(t.cancelScheduledValues(0),t.setValueAtTime(0,0),t instanceof Jy&&(t.overridden=!0)),Wy(e,t,n,r)}var Xy=class e extends Y{constructor(){let t=q(e.getDefaults(),arguments,[`value`]);super(t),this.name=`TickParam`,this._events=new ay(1/0),this._multiplier=1,this._multiplier=t.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:`setValueAtTime`,value:this._fromType(t.value)}),this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(Y.getDefaults(),{multiplier:1,units:`hertz`,value:1})}setTargetAtTime(e,t,n){t=this.toSeconds(t),this.setRampPoint(t);let r=this._fromType(e),i=this._events.get(t),a=Math.round(Math.max(1/n,1));for(let e=0;e<=a;e++){let a=n*e+t,o=this._exponentialApproach(i.time,i.value,r,n,a);this.linearRampToValueAtTime(this._toType(o),a)}return this}setValueAtTime(e,t){let n=this.toSeconds(t);super.setValueAtTime(e,t);let r=this._events.get(n),i=this._events.previousEvent(r),a=this._getTicksUntilEvent(i,n);return r.ticks=Math.max(a,0),this}linearRampToValueAtTime(e,t){let n=this.toSeconds(t);super.linearRampToValueAtTime(e,t);let r=this._events.get(n),i=this._events.previousEvent(r),a=this._getTicksUntilEvent(i,n);return r.ticks=Math.max(a,0),this}exponentialRampToValueAtTime(e,t){t=this.toSeconds(t);let n=this._fromType(e),r=this._events.get(t),i=Math.round(Math.max((t-r.time)*10,1)),a=(t-r.time)/i;for(let e=0;e<=i;e++){let i=a*e+r.time,o=this._exponentialInterpolate(r.time,r.value,t,n,i);this.linearRampToValueAtTime(this._toType(o),i)}return this}_getTicksUntilEvent(e,t){if(e===null)e={ticks:0,time:0,type:`setValueAtTime`,value:0};else if(gv(e.ticks)){let t=this._events.previousEvent(e);e.ticks=this._getTicksUntilEvent(t,e.time)}let n=this._fromType(this.getValueAtTime(e.time)),r=this._fromType(this.getValueAtTime(t)),i=this._events.get(t);return i&&i.time===t&&i.type===`setValueAtTime`&&(r=this._fromType(this.getValueAtTime(t-this.sampleTime))),.5*(t-e.time)*(n+r)+e.ticks}getTicksAtTime(e){let t=this.toSeconds(e),n=this._events.get(t);return Math.max(this._getTicksUntilEvent(n,t),0)}getDurationOfTicks(e,t){let n=this.toSeconds(t),r=this.getTicksAtTime(t);return this.getTimeOfTick(r+e)-n}getTimeOfTick(e){let t=this._events.get(e,`ticks`),n=this._events.getAfter(e,`ticks`);if(t&&t.ticks===e)return t.time;if(t&&n&&n.type===`linearRampToValueAtTime`&&t.value!==n.value){let r=this._fromType(this.getValueAtTime(t.time)),i=(this._fromType(this.getValueAtTime(n.time))-r)/(n.time-t.time),a=Math.sqrt(r**2-2*i*(t.ticks-e)),o=(-r+a)/i,s=(-r-a)/i;return(o>0?o:s)+t.time}return t?t.value===0?1/0:t.time+(e-t.ticks)/t.value:e/this._initialValue}ticksToTime(e,t){return this.getDurationOfTicks(e,t)}timeToTicks(e,t){let n=this.toSeconds(t),r=this.toSeconds(e),i=this.getTicksAtTime(n);return this.getTicksAtTime(n+r)-i}_fromType(e){return this.units===`bpm`&&this.multiplier?1/(60/e/this.multiplier):super._fromType(e)}_toType(e){return this.units===`bpm`&&this.multiplier?e/this.multiplier*60:super._toType(e)}get multiplier(){return this._multiplier}set multiplier(e){let t=this.value;this._multiplier=e,this.cancelScheduledValues(0),this.setValueAtTime(t,0)}},Zy=class e extends Jy{constructor(){let t=q(e.getDefaults(),arguments,[`value`]);super(t),this.name=`TickSignal`,this.input=this._param=new Xy({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(Jy.getDefaults(),{multiplier:1,units:`hertz`,value:1})}ticksToTime(e,t){return this._param.ticksToTime(e,t)}timeToTicks(e,t){return this._param.timeToTicks(e,t)}getTimeOfTick(e){return this._param.getTimeOfTick(e)}getDurationOfTicks(e,t){return this._param.getDurationOfTicks(e,t)}getTicksAtTime(e){return this._param.getTicksAtTime(e)}get multiplier(){return this._param.multiplier}set multiplier(e){this._param.multiplier=e}dispose(){return super.dispose(),this._param.dispose(),this}},Qy=class e extends Vy{constructor(){let t=q(e.getDefaults(),arguments,[`frequency`]);super(t),this.name=`TickSource`,this._state=new Hy,this._tickOffset=new ay,this._ticksAtTime=new ay,this._secondsAtTime=new ay,this.frequency=new Zy({context:this.context,units:t.units,value:t.frequency}),J(this,`frequency`),this._state.setStateAtTime(`stopped`,0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:`hertz`},Vy.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(e,t){let n=this.toSeconds(e);return this._state.getValueAtTime(n)!==`started`&&(this._state.setStateAtTime(`started`,n),G(t)&&this.setTicksAtTime(t,n),this._ticksAtTime.cancel(n),this._secondsAtTime.cancel(n)),this}stop(e){let t=this.toSeconds(e);if(this._state.getValueAtTime(t)===`stopped`){let e=this._state.get(t);e&&e.time>0&&(this._tickOffset.cancel(e.time),this._state.cancel(e.time))}return this._state.cancel(t),this._state.setStateAtTime(`stopped`,t),this.setTicksAtTime(0,t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}pause(e){let t=this.toSeconds(e);return this._state.getValueAtTime(t)===`started`&&(this._state.setStateAtTime(`paused`,t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t)),this}cancel(e){return e=this.toSeconds(e),this._state.cancel(e),this._tickOffset.cancel(e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getTicksAtTime(e){let t=this.toSeconds(e),n=this._state.getLastState(`stopped`,t),r=this._ticksAtTime.get(t),i={state:`paused`,time:t};this._state.add(i);let a=r||n,o=r?r.ticks:0,s=null;return this._state.forEachBetween(a.time,t+this.sampleTime,e=>{let t=a.time,n=this._tickOffset.get(e.time);n&&n.time>=a.time&&(o=n.ticks,t=n.time),a.state===`started`&&e.state!==`started`&&(o+=this.frequency.getTicksAtTime(e.time)-this.frequency.getTicksAtTime(t),e.time!==i.time&&(s={state:e.state,time:e.time,ticks:o})),a=e}),this._state.remove(i),s&&this._ticksAtTime.add(s),o}get ticks(){return this.getTicksAtTime(this.now())}set ticks(e){this.setTicksAtTime(e,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(e){let t=this.now(),n=this.frequency.timeToTicks(e,t);this.setTicksAtTime(n,t)}getSecondsAtTime(e){e=this.toSeconds(e);let t=this._state.getLastState(`stopped`,e),n={state:`paused`,time:e};this._state.add(n);let r=this._secondsAtTime.get(e),i=r||t,a=r?r.seconds:0,o=null;return this._state.forEachBetween(i.time,e+this.sampleTime,e=>{let t=i.time,r=this._tickOffset.get(e.time);r&&r.time>=i.time&&(a=r.seconds,t=r.time),i.state===`started`&&e.state!==`started`&&(a+=e.time-t,e.time!==n.time&&(o={state:e.state,time:e.time,seconds:a})),i=e}),this._state.remove(n),o&&this._secondsAtTime.add(o),a}setTicksAtTime(e,t){return t=this.toSeconds(t),this._tickOffset.cancel(t),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(e,t),ticks:e,time:t}),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getStateAtTime(e){return e=this.toSeconds(e),this._state.getValueAtTime(e)}getTimeOfTick(e,t=this.now()){let n=this._tickOffset.get(t),r=this._state.get(t),i=Math.max(n.time,r.time),a=this.frequency.getTicksAtTime(i)+e-n.ticks;return this.frequency.getTimeOfTick(a)}forEachTickBetween(e,t,n){let r=this._state.get(e);this._state.forEachBetween(e,t,t=>{r&&r.state===`started`&&t.state!==`started`&&this.forEachTickBetween(Math.max(r.time,e),t.time-this.sampleTime,n),r=t});let i=null;if(r&&r.state===`started`){let a=Math.max(r.time,e),o=this.frequency.getTicksAtTime(a),s=o-this.frequency.getTicksAtTime(r.time),c=Math.ceil(s)-s;c=ry(c,1)?0:c;let l=this.frequency.getTimeOfTick(o+c);for(;l<t;){try{n(l,Math.round(this.getTicksAtTime(l)))}catch(e){i=e;break}l+=this.frequency.getDurationOfTicks(1,l)}}if(i)throw i;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}},$y=class e extends Vy{constructor(){let t=q(e.getDefaults(),arguments,[`callback`,`frequency`]);super(t),this.name=`Clock`,this.callback=_y,this._lastUpdate=0,this._state=new Hy(`stopped`),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new Qy({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,J(this,`frequency`),this._state.setStateAtTime(`stopped`,0),this.context.on(`tick`,this._boundLoop)}static getDefaults(){return Object.assign(Vy.getDefaults(),{callback:_y,frequency:1,units:`hertz`})}get state(){return this._state.getValueAtTime(this.now())}start(e,t){Tv(this.context);let n=this.toSeconds(e);return this.log(`start`,n),this._state.getValueAtTime(n)!==`started`&&(this._state.setStateAtTime(`started`,n),this._tickSource.start(n,t),n<this._lastUpdate&&this.emit(`start`,n,t)),this}stop(e){let t=this.toSeconds(e);return this.log(`stop`,t),this._state.cancel(t),this._state.setStateAtTime(`stopped`,t),this._tickSource.stop(t),t<this._lastUpdate&&this.emit(`stop`,t),this}pause(e){let t=this.toSeconds(e);return this._state.getValueAtTime(t)===`started`&&(this._state.setStateAtTime(`paused`,t),this._tickSource.pause(t),t<this._lastUpdate&&this.emit(`pause`,t)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(e){this._tickSource.ticks=e}get seconds(){return this._tickSource.seconds}set seconds(e){this._tickSource.seconds=e}getSecondsAtTime(e){return this._tickSource.getSecondsAtTime(e)}setTicksAtTime(e,t){return this._tickSource.setTicksAtTime(e,t),this}getTimeOfTick(e,t=this.now()){return this._tickSource.getTimeOfTick(e,t)}getTicksAtTime(e){return this._tickSource.getTicksAtTime(e)}nextTickTime(e,t){let n=this.toSeconds(t),r=this.getTicksAtTime(n);return this._tickSource.getTimeOfTick(r+e,n)}_loop(){let e=this._lastUpdate,t=this.now();this._lastUpdate=t,this.log(`loop`,e,t),e!==t&&(this._state.forEachBetween(e,t,e=>{switch(e.state){case`started`:let t=this._tickSource.getTicksAtTime(e.time);this.emit(`start`,e.time,t);break;case`stopped`:e.time!==0&&this.emit(`stop`,e.time);break;case`paused`:this.emit(`pause`,e.time)}}),this._tickSource.forEachTickBetween(e,t,(e,t)=>{this.callback(e,t)}))}getStateAtTime(e){let t=this.toSeconds(e);return this._state.getValueAtTime(t)}dispose(){return super.dispose(),this.context.off(`tick`,this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}};fy.mixin($y);var eb=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`delayTime`,`maxDelay`]);super(t),this.name=`Delay`;let n=this.toSeconds(t.maxDelay);this._maxDelay=Math.max(n,this.toSeconds(t.delayTime)),this._delayNode=this.input=this.output=this.context.createDelay(n),this.delayTime=new Y({context:this.context,param:this._delayNode.delayTime,units:`time`,value:t.delayTime,minValue:0,maxValue:this.maxDelay}),J(this,`delayTime`)}static getDefaults(){return Object.assign(X.getDefaults(),{delayTime:0,maxDelay:1})}get maxDelay(){return this._maxDelay}dispose(){return super.dispose(),this._delayNode.disconnect(),this.delayTime.dispose(),this}},tb=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`volume`]);super(t),this.name=`Volume`,this.input=this.output=new Z({context:this.context,gain:t.volume,units:`decibels`}),this.volume=this.output.gain,J(this,`volume`),this._unmutedVolume=t.volume,this.mute=t.mute}static getDefaults(){return Object.assign(X.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(e){!this.mute&&e?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!e&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}},nb=class e extends X{constructor(){let t=q(e.getDefaults(),arguments);super(t),this.name=`Destination`,this.input=new tb({context:this.context}),this.output=new Z({context:this.context}),this.volume=this.input.volume,Uy(this.input,this.output,this.context.rawContext.destination),this.mute=t.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign(X.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(e){this.input.mute=e}chain(...e){return this.input.disconnect(),e.unshift(this.input),e.push(this.output),Uy(...e),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}};sy(e=>{e.destination=new nb({context:e})}),uy(e=>{e.destination.dispose()});var rb=class extends X{constructor(){super(...arguments),this.name=`Listener`,this.positionX=new Y({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new Y({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new Y({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new Y({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new Y({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new Y({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new Y({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new Y({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new Y({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(X.getDefaults(),{positionX:0,positionY:0,positionZ:0,forwardX:0,forwardY:0,forwardZ:-1,upX:0,upY:1,upZ:0})}dispose(){return super.dispose(),this.positionX.dispose(),this.positionY.dispose(),this.positionZ.dispose(),this.forwardX.dispose(),this.forwardY.dispose(),this.forwardZ.dispose(),this.upX.dispose(),this.upY.dispose(),this.upZ.dispose(),this}};sy(e=>{e.listener=new rb({context:e})}),uy(e=>{e.listener.dispose()});function ib(e,t){return zv(this,arguments,void 0,function*(e,t,n=2,r=Sy().sampleRate){let i=Sy(),a=new yy(n,t,r);Cy(a),yield e(a);let o=a.render();return Cy(i),new vy(yield o)})}var ab=class e extends Qv{constructor(){super(),this.name=`ToneAudioBuffers`,this._buffers=new Map,this._loadingCount=0;let t=q(e.getDefaults(),arguments,[`urls`,`onload`,`baseUrl`],`urls`);this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach(e=>{this._loadingCount++;let n=t.urls[e];this.add(e,n,this._bufferLoaded.bind(this,t.onload),t.onerror)})}static getDefaults(){return{baseUrl:``,onerror:_y,onload:_y,urls:{}}}has(e){return this._buffers.has(e.toString())}get(e){return K(this.has(e),`ToneAudioBuffers has no buffer named: ${e}`),this._buffers.get(e.toString())}_bufferLoaded(e){this._loadingCount--,this._loadingCount===0&&e&&e()}get loaded(){return Array.from(this._buffers).every(([e,t])=>t.loaded)}add(e,t,n=_y,r=_y){return Sv(t)?(this.baseUrl&&t.trim().substring(0,11).toLowerCase()===`data:audio/`&&(this.baseUrl=``),this._buffers.set(e.toString(),new vy(this.baseUrl+t,n,r))):this._buffers.set(e.toString(),new vy(t,n,r)),this}dispose(){return super.dispose(),this._buffers.forEach(e=>e.dispose()),this._buffers.clear(),this}},ob=class e extends Iy{constructor(){super(...arguments),this.name=`MidiClass`,this.defaultUnits=`midi`}_frequencyToUnits(e){return jy(super._frequencyToUnits(e))}_ticksToUnits(e){return jy(super._ticksToUnits(e))}_beatsToUnits(e){return jy(super._beatsToUnits(e))}_secondsToUnits(e){return jy(super._secondsToUnits(e))}toMidi(){return this.valueOf()}toFrequency(){return Ny(this.toMidi())}transpose(t){return new e(this.context,this.toMidi()+t)}},sb=class extends By{constructor(){super(...arguments),this.name=`Ticks`,this.defaultUnits=`i`}_now(){return this.context.transport.ticks}_beatsToUnits(e){return this._getPPQ()*e}_secondsToUnits(e){return Math.floor(e/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(e){return e}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}},cb=class extends Vy{constructor(){super(...arguments),this.name=`Draw`,this.expiration=.25,this.anticipation=.008,this._events=new ay,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(e,t){return this._events.add({callback:e,time:this.toSeconds(t)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(e){return this._events.cancel(this.toSeconds(e)),this}_drawLoop(){let e=this.context.currentTime;this._events.forEachBefore(e+this.anticipation,t=>{e-t.time<=this.expiration&&t.callback(),this._events.remove(t)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}};sy(e=>{e.draw=new cb({context:e})}),uy(e=>{e.draw.dispose()});var lb=class extends Qv{constructor(){super(...arguments),this.name=`IntervalTimeline`,this._root=null,this._length=0}add(e){K(G(e.time),`Events must have a time property`),K(G(e.duration),`Events must have a duration parameter`),e.time=e.time.valueOf();let t=new ub(e.time,e.time+e.duration,e);for(this._root===null?this._root=t:this._root.insert(t),this._length++;t!==null;)t.updateHeight(),t.updateMax(),this._rebalance(t),t=t.parent;return this}remove(e){if(this._root!==null){let t=[];this._root.search(e.time,t);for(let n of t)if(n.event===e){this._removeNode(n),this._length--;break}}return this}get length(){return this._length}cancel(e){return this.forEachFrom(e,e=>this.remove(e)),this}_setRoot(e){this._root=e,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(e,t){e.parent===null?this._setRoot(t):(e.isLeftChild()?e.parent.left=t:e.parent.right=t,this._rebalance(e.parent))}_removeNode(e){if(e.left===null&&e.right===null)this._replaceNodeInParent(e,null);else if(e.right===null)this._replaceNodeInParent(e,e.left);else if(e.left===null)this._replaceNodeInParent(e,e.right);else{let t=e.getBalance(),n,r=null;if(t>0){if(e.left.right===null)n=e.left,n.right=e.right,r=n;else{for(n=e.left.right;n.right!==null;)n=n.right;n.parent&&(n.parent.right=n.left,r=n.parent,n.left=e.left,n.right=e.right)}}else if(e.right.left===null)n=e.right,n.left=e.left,r=n;else{for(n=e.right.left;n.left!==null;)n=n.left;n.parent&&(n.parent.left=n.right,r=n.parent,n.left=e.left,n.right=e.right)}e.parent===null?this._setRoot(n):e.isLeftChild()?e.parent.left=n:e.parent.right=n,r&&this._rebalance(r)}e.dispose()}_rotateLeft(e){let t=e.parent,n=e.isLeftChild(),r=e.right;r&&(e.right=r.left,r.left=e),t===null?this._setRoot(r):n?t.left=r:t.right=r}_rotateRight(e){let t=e.parent,n=e.isLeftChild(),r=e.left;r&&(e.left=r.right,r.right=e),t===null?this._setRoot(r):n?t.left=r:t.right=r}_rebalance(e){let t=e.getBalance();t>1&&e.left?e.left.getBalance()<0?this._rotateLeft(e.left):this._rotateRight(e):t<-1&&e.right&&(e.right.getBalance()>0?this._rotateRight(e.right):this._rotateLeft(e))}get(e){if(this._root!==null){let t=[];if(this._root.search(e,t),t.length>0){let e=t[0];for(let n=1;n<t.length;n++)t[n].low>e.low&&(e=t[n]);return e.event}}return null}forEach(e){if(this._root!==null){let t=[];this._root.traverse(e=>t.push(e)),t.forEach(t=>{t.event&&e(t.event)})}return this}forEachAtTime(e,t){if(this._root!==null){let n=[];this._root.search(e,n),n.forEach(e=>{e.event&&t(e.event)})}return this}forEachFrom(e,t){if(this._root!==null){let n=[];this._root.searchAfter(e,n),n.forEach(e=>{e.event&&t(e.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(e=>e.dispose()),this._root=null,this}},ub=class{constructor(e,t,n){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=n,this.low=e,this.high=t,this.max=this.high}insert(e){e.low<=this.low?this.left===null?this.left=e:this.left.insert(e):this.right===null?this.right=e:this.right.insert(e)}search(e,t){e>this.max||(this.left!==null&&this.left.search(e,t),this.low<=e&&this.high>e&&t.push(this),this.low>e||this.right!==null&&this.right.search(e,t))}searchAfter(e,t){this.low>=e&&(t.push(this),this.left!==null&&this.left.searchAfter(e,t)),this.right!==null&&this.right.searchAfter(e,t)}traverse(e){e(this),this.left!==null&&this.left.traverse(e),this.right!==null&&this.right.traverse(e)}updateHeight(){this.height=this.left!==null&&this.right!==null?Math.max(this.left.height,this.right.height)+1:this.right===null?this.left===null?0:this.left.height+1:this.right.height+1}updateMax(){this.max=this.high,this.left!==null&&(this.max=Math.max(this.max,this.left.max)),this.right!==null&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let e=0;return this.left!==null&&this.right!==null?e=this.left.height-this.right.height:this.left===null?this.right!==null&&(e=-(this.right.height+1)):e=this.left.height+1,e}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(e){this._left=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(e){this._right=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}},db=class extends Qv{constructor(e){super(),this.name=`TimelineValue`,this._timeline=new ay({memory:10}),this._initialValue=e}set(e,t){return this._timeline.add({value:e,time:t}),this}get(e){let t=this._timeline.get(e);return t?t.value:this._initialValue}},fb=class e extends X{constructor(){super(q(e.getDefaults(),arguments,[`context`]))}connect(e,t=0,n=0){return Yy(this,e,t,n),this}},pb=class e extends fb{constructor(){let t=q(e.getDefaults(),arguments,[`mapping`,`length`]);super(t),this.name=`WaveShaper`,this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,xv(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):_v(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign(Jy.getDefaults(),{length:1024})}setMap(e,t=1024){let n=new Float32Array(t);for(let r=0,i=t;r<i;r++){let t=r/(i-1)*2-1;n[r]=e(t,r)}return this.curve=n,this}get curve(){return this._shaper.curve}set curve(e){this._shaper.curve=e}get oversample(){return this._shaper.oversample}set oversample(e){K([`none`,`2x`,`4x`].some(t=>t.includes(e)),`oversampling must be either 'none', '2x', or '4x'`),this._shaper.oversample=e}dispose(){return super.dispose(),this._shaper.disconnect(),this}},mb=class e extends fb{constructor(){let t=q(e.getDefaults(),arguments,[`value`]);super(t),this.name=`Pow`,this._exponentScaler=this.input=this.output=new pb({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(fb.getDefaults(),{value:1})}_expFunc(e){return t=>Math.abs(t)**+e}get value(){return this._exponent}set value(e){this._exponent=e,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}},hb=class e{constructor(t,n){this.id=e._eventId++,this._remainderTime=0;let r=Object.assign(e.getDefaults(),n);this.transport=t,this.callback=r.callback,this._once=r.once,this.time=Math.floor(r.time),this._remainderTime=r.time-this.time}static getDefaults(){return{callback:_y,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(e){if(this.callback){let t=this.transport.bpm.getDurationOfTicks(1,e);this.callback(e+this._remainderTime*t),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}};hb._eventId=0;var gb=class e extends hb{constructor(t,n){super(t,n),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);let r=Object.assign(e.getDefaults(),n);this.duration=r.duration,this._interval=r.interval,this._nextTick=r.time,this.transport.on(`start`,this._boundRestart),this.transport.on(`loopStart`,this._boundRestart),this.transport.on(`ticks`,this._boundRestart),this.context=this.transport.context,this._restart()}static getDefaults(){return Object.assign({},hb.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(e){this._createEvents(e),super.invoke(e)}_createEvent(){return ny(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new sb(this.context,this._nextTick).toSeconds()):-1}_createEvents(e){ny(this._nextTick+this._interval,this.floatTime+this.duration)&&(this._nextTick+=this._interval,this._currentId=this._nextId,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new sb(this.context,this._nextTick).toSeconds()))}_restart(e){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;let t=this.transport.getTicksAtTime(e);ey(t,this.time)&&(this._nextTick=this.floatTime+Math.ceil((t-this.floatTime)/this._interval)*this._interval),this._currentId=this._createEvent(),this._nextTick+=this._interval,this._nextId=this._createEvent()}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off(`start`,this._boundRestart),this.transport.off(`loopStart`,this._boundRestart),this.transport.off(`ticks`,this._boundRestart),this}},_b=class e extends Vy{constructor(){let t=q(e.getDefaults(),arguments);super(t),this.name=`Transport`,this._loop=new db(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new ay,this._repeatedEvents=new lb,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new $y({callback:this._processTick.bind(this),context:this.context,frequency:0,units:`bpm`}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=t.ppq,this.bpm.setValueAtTime(t.bpm,0),J(this,`bpm`),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(Vy.getDefaults(),{bpm:120,loopEnd:`4m`,loopStart:0,ppq:192,swing:0,swingSubdivision:`8n`,timeSignature:4})}_processTick(e,t){if(this._loop.get(e)&&t>=this._loopEnd&&(this.emit(`loopEnd`,e),this._clock.setTicksAtTime(this._loopStart,e),t=this._loopStart,this.emit(`loopStart`,e,this._clock.getSecondsAtTime(e)),this.emit(`loop`,e)),this._swingAmount>0&&t%this._ppq!==0&&t%(this._swingTicks*2)!=0){let n=t%(this._swingTicks*2)/(this._swingTicks*2),r=Math.sin(n*Math.PI)*this._swingAmount;e+=new sb(this.context,this._swingTicks*2/3).toSeconds()*r}Ov(!0),this._timeline.forEachAtTime(t,t=>t.invoke(e)),Ov(!1)}schedule(e,t){let n=new hb(this,{callback:e,time:new By(this.context,t).toTicks()});return this._addEvent(n,this._timeline)}scheduleRepeat(e,t,n,r=1/0){let i=new gb(this,{callback:e,duration:new Fy(this.context,r).toTicks(),interval:new Fy(this.context,t).toTicks(),time:new By(this.context,n).toTicks()});return this._addEvent(i,this._repeatedEvents)}scheduleOnce(e,t){let n=new hb(this,{callback:e,once:!0,time:new By(this.context,t).toTicks()});return this._addEvent(n,this._timeline)}clear(e){if(this._scheduledEvents.hasOwnProperty(e)){let t=this._scheduledEvents[e.toString()];t.timeline.remove(t.event),t.event.dispose(),delete this._scheduledEvents[e.toString()]}return this}_addEvent(e,t){return this._scheduledEvents[e.id.toString()]={event:e,timeline:t},t.add(e),e.id}cancel(e=0){let t=this.toTicks(e);return this._timeline.forEachFrom(t,e=>this.clear(e.id)),this._repeatedEvents.forEachFrom(t,e=>this.clear(e.id)),this}_bindClockEvents(){this._clock.on(`start`,(e,t)=>{t=new sb(this.context,t).toSeconds(),this.emit(`start`,e,t)}),this._clock.on(`stop`,e=>{this.emit(`stop`,e)}),this._clock.on(`pause`,e=>{this.emit(`pause`,e)})}get state(){return this._clock.getStateAtTime(this.now())}start(e,t){this.context.resume();let n;return G(t)&&(n=this.toTicks(t)),this._clock.start(e,n),this}stop(e){return this._clock.stop(e),this}pause(e){return this._clock.pause(e),this}toggle(e){return e=this.toSeconds(e),this._clock.getStateAtTime(e)===`started`?this.stop(e):this.start(e),this}get timeSignature(){return this._timeSignature}set timeSignature(e){xv(e)&&(e=e[0]/e[1]*4),this._timeSignature=e}get loopStart(){return new Fy(this.context,this._loopStart,`i`).toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e)}get loopEnd(){return new Fy(this.context,this._loopEnd,`i`).toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e)}get loop(){return this._loop.get(this.now())}set loop(e){this._loop.set(e,this.now())}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}get swing(){return this._swingAmount}set swing(e){this._swingAmount=e}get swingSubdivision(){return new sb(this.context,this._swingTicks).toNotation()}set swingSubdivision(e){this._swingTicks=this.toTicks(e)}get position(){let e=this.now(),t=this._clock.getTicksAtTime(e);return new sb(this.context,t).toBarsBeatsSixteenths()}set position(e){let t=this.toTicks(e);this.ticks=t}get seconds(){return this._clock.seconds}set seconds(e){let t=this.now(),n=this._clock.frequency.timeToTicks(e,t);this.ticks=n}get progress(){if(this.loop){let e=this.now();return(this._clock.getTicksAtTime(e)-this._loopStart)/(this._loopEnd-this._loopStart)}return 0}get ticks(){return this._clock.ticks}set ticks(e){if(this._clock.ticks!==e){let t=this.now();if(this.state===`started`){let n=this._clock.getTicksAtTime(t),r=t+this._clock.frequency.getDurationOfTicks(Math.ceil(n)-n,t);this.emit(`stop`,r),this._clock.setTicksAtTime(e,r),this.emit(`start`,r,this._clock.getSecondsAtTime(r))}else this.emit(`ticks`,t),this._clock.setTicksAtTime(e,t)}}getTicksAtTime(e){return this._clock.getTicksAtTime(e)}getSecondsAtTime(e){return this._clock.getSecondsAtTime(e)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(e){this._clock.frequency.multiplier=e}nextSubdivision(e){if(e=this.toTicks(e),this.state!==`started`)return 0;{let t=this.now(),n=this.getTicksAtTime(t),r=e-n%e;return this._clock.nextTickTime(r,t)}}syncSignal(e,t){let n=this.now(),r=this.bpm,i=1/(60/r.getValueAtTime(n)/this.PPQ),a=[];if(e.units===`time`){let e=1/64/i,t=new Z(e),n=new mb(-1),o=new Z(e);r.chain(t,n,o),r=o,i=1/i,a=[t,n,o]}t||=e.getValueAtTime(n)===0?0:e.getValueAtTime(n)/i;let o=new Z(t);return r.connect(o),o.connect(e._param),a.push(o),this._syncedSignals.push({initial:e.value,nodes:a,signal:e}),e.value=0,this}unsyncSignal(e){for(let t=this._syncedSignals.length-1;t>=0;t--){let n=this._syncedSignals[t];n.signal===e&&(n.nodes.forEach(e=>e.dispose()),n.signal.value=n.initial,this._syncedSignals.splice(t,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),gy(this,`bpm`),this._timeline.dispose(),this._repeatedEvents.dispose(),this}};fy.mixin(_b),sy(e=>{e.transport=new _b({context:e})}),uy(e=>{e.transport.dispose()});var vb=class extends X{constructor(e){super(e),this.input=void 0,this._state=new Hy(`stopped`),this._synced=!1,this._scheduled=[],this._syncedStart=_y,this._syncedStop=_y,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new tb({context:this.context,mute:e.mute,volume:e.volume}),this.volume=this._volume.volume,J(this,`volume`),this.onstop=e.onstop}static getDefaults(){return Object.assign(X.getDefaults(),{mute:!1,onstop:_y,volume:0})}get state(){return this._synced?this.context.transport.state===`started`?this._state.getValueAtTime(this.context.transport.seconds):`stopped`:this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}_clampToCurrentTime(e){return this._synced?e:Math.max(e,this.context.currentTime)}start(e,t,n){let r=gv(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(r=this._clampToCurrentTime(r),!this._synced&&this._state.getValueAtTime(r)===`started`)K(ey(r,this._state.get(r).time),`Start time must be strictly greater than previous start time`),this._state.cancel(r),this._state.setStateAtTime(`started`,r),this.log(`restart`,r),this.restart(r,t,n);else if(this.log(`start`,r),this._state.setStateAtTime(`started`,r),this._synced){let e=this._state.get(r);e&&(e.offset=this.toSeconds(Xv(t,0)),e.duration=n?this.toSeconds(n):void 0);let i=this.context.transport.schedule(e=>{this._start(e,t,n)},r);this._scheduled.push(i),this.context.transport.state===`started`&&this.context.transport.getSecondsAtTime(this.immediate())>r&&this._syncedStart(this.now(),this.context.transport.seconds)}else Tv(this.context),this._start(r,t,n);return this}stop(e){let t=gv(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(t=this._clampToCurrentTime(t),this._state.getValueAtTime(t)===`started`||G(this._state.getNextState(`started`,t))){if(this.log(`stop`,t),!this._synced)this._stop(t);else{let e=this.context.transport.schedule(this._stop.bind(this),t);this._scheduled.push(e)}this._state.cancel(t),this._state.setStateAtTime(`stopped`,t)}return this}restart(e,t,n){return e=this.toSeconds(e),this._state.getValueAtTime(e)===`started`&&(this._state.cancel(e),this._restart(e,t,n)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(e,t)=>{if(ey(t,0)){let n=this._state.get(t);if(n&&n.state===`started`&&n.time!==t){let r=t-this.toSeconds(n.time),i;n.duration&&(i=this.toSeconds(n.duration)-r),this._start(e,this.toSeconds(n.offset)+r,i)}}},this._syncedStop=e=>{let t=this.context.transport.getSecondsAtTime(Math.max(e-this.sampleTime,0));this._state.getValueAtTime(t)===`started`&&this._stop(e)},this.context.transport.on(`start`,this._syncedStart),this.context.transport.on(`loopStart`,this._syncedStart),this.context.transport.on(`stop`,this._syncedStop),this.context.transport.on(`pause`,this._syncedStop),this.context.transport.on(`loopEnd`,this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off(`stop`,this._syncedStop),this.context.transport.off(`pause`,this._syncedStop),this.context.transport.off(`loopEnd`,this._syncedStop),this.context.transport.off(`start`,this._syncedStart),this.context.transport.off(`loopStart`,this._syncedStart)),this._synced=!1,this._scheduled.forEach(e=>this.context.transport.clear(e)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=_y,this.unsync(),this._volume.dispose(),this._state.dispose(),this}},yb=class e extends Ky{constructor(){let t=q(e.getDefaults(),arguments,[`url`,`onload`]);super(t),this.name=`ToneBufferSource`,this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,Wy(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new Y({context:this.context,param:this._source.playbackRate,units:`positive`,value:t.playbackRate}),this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this._buffer=new vy(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(Ky.getDefaults(),{url:new vy,loop:!1,loopEnd:0,loopStart:0,onload:_y,onerror:_y,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e}get curve(){return this._curve}set curve(e){this._curve=e}start(e,t,n,r=1){K(this.buffer.loaded,`buffer is either not set or not loaded`);let i=this.toSeconds(e);this._startGain(i,r),t=this.loop?Xv(t,this.loopStart):Xv(t,0);let a=Math.max(this.toSeconds(t),0);if(this.loop){let e=this.toSeconds(this.loopEnd)||this.buffer.duration,t=this.toSeconds(this.loopStart),n=e-t;ty(a,e)&&(a=(a-t)%n+t),ry(a,this.buffer.duration)&&(a=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,ny(a,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(i,a)),G(n)){let e=this.toSeconds(n);e=Math.max(e,0),this.stop(i+e)}return this}_stopSource(e){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(e)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(e){this._source.loopStart=this.toSeconds(e)}get loopEnd(){return this._source.loopEnd}set loopEnd(e){this._source.loopEnd=this.toSeconds(e)}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._source.loop}set loop(e){this._source.loop=e,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}},bb=class e extends vb{constructor(){let t=q(e.getDefaults(),arguments,[`type`]);super(t),this.name=`Noise`,this._source=null,this._playbackRate=t.playbackRate,this.type=t.type,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(vb.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:`white`})}get type(){return this._type}set type(e){if(K(e in wb,`Noise: invalid type: `+e),this._type!==e&&(this._type=e,this.state===`started`)){let e=this.now();this._stop(e),this._start(e)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._source&&(this._source.playbackRate.value=e)}_start(e){let t=wb[this._type];this._source=new yb({url:t,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(e),Math.random()*(t.duration-.001))}_stop(e){this._source&&=(this._source.stop(this.toSeconds(e)),null)}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(e){this._stop(e),this._start(e)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}},xb=220500,Sb=2,Cb={brown:null,pink:null,white:null},wb={get brown(){if(!Cb.brown){let e=[];for(let t=0;t<Sb;t++){let n=new Float32Array(xb);e[t]=n;let r=0;for(let e=0;e<xb;e++){let t=Math.random()*2-1;n[e]=(r+.02*t)/1.02,r=n[e],n[e]*=3.5}}Cb.brown=new vy().fromArray(e)}return Cb.brown},get pink(){if(!Cb.pink){let e=[];for(let t=0;t<Sb;t++){let n=new Float32Array(xb);e[t]=n;let r,i,a,o,s,c,l;r=i=a=o=s=c=l=0;for(let e=0;e<xb;e++){let t=Math.random()*2-1;r=.99886*r+t*.0555179,i=.99332*i+t*.0750759,a=.969*a+t*.153852,o=.8665*o+t*.3104856,s=.55*s+t*.5329522,c=-.7616*c-t*.016898,n[e]=r+i+a+o+s+c+l+t*.5362,n[e]*=.11,l=t*.115926}}Cb.pink=new vy().fromArray(e)}return Cb.pink},get white(){if(!Cb.white){let e=[];for(let t=0;t<Sb;t++){let n=new Float32Array(xb);e[t]=n;for(let e=0;e<xb;e++)n[e]=Math.random()*2-1}Cb.white=new vy().fromArray(e)}return Cb.white}};function Tb(e,t){return zv(this,void 0,void 0,function*(){let n=t/e.context.sampleRate,r=new yy(1,n,e.context.sampleRate);return new e.constructor(Object.assign(e.get(),{frequency:2/n,detune:0,context:r})).toDestination().start(0),(yield r.render()).getChannelData(0)})}var Eb=class e extends Ky{constructor(){let t=q(e.getDefaults(),arguments,[`frequency`,`type`]);super(t),this.name=`ToneOscillatorNode`,this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],Wy(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new Y({context:this.context,param:this._oscillator.frequency,units:`frequency`,value:t.frequency}),this.detune=new Y({context:this.context,param:this._oscillator.detune,units:`cents`,value:t.detune}),J(this,[`frequency`,`detune`])}static getDefaults(){return Object.assign(Ky.getDefaults(),{detune:0,frequency:440,type:`sine`})}start(e){let t=this.toSeconds(e);return this.log(`start`,t),this._startGain(t),this._oscillator.start(t),this}_stopSource(e){this._oscillator.stop(e)}setPeriodicWave(e){return this._oscillator.setPeriodicWave(e),this}get type(){return this._oscillator.type}set type(e){this._oscillator.type=e}dispose(){return super.dispose(),this.state===`started`&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}},Db=class e extends vb{constructor(){let t=q(e.getDefaults(),arguments,[`frequency`,`type`]);super(t),this.name=`Oscillator`,this._oscillator=null,this.frequency=new Jy({context:this.context,units:`frequency`,value:t.frequency}),J(this,`frequency`),this.detune=new Jy({context:this.context,units:`cents`,value:t.detune}),J(this,`detune`),this._partials=t.partials,this._partialCount=t.partialCount,this._type=t.type,t.partialCount&&t.type!==`custom`&&(this._type=this.baseType+t.partialCount.toString()),this.phase=t.phase}static getDefaults(){return Object.assign(vb.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:`sine`})}_start(e){let t=this.toSeconds(e),n=new Eb({context:this.context,onended:()=>this.onstop(this)});this._oscillator=n,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(t)}_stop(e){let t=this.toSeconds(e);this._oscillator&&this._oscillator.stop(t)}_restart(e){let t=this.toSeconds(e);return this.log(`restart`,t),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(t),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if(this._type===`custom`)return e._periodicWaveCache.find(e=>e.phase===this._phase&&Jv(e.partials,this._partials));{let t=e._periodicWaveCache.find(e=>e.type===this._type&&e.phase===this._phase);return this._partialCount=t?t.partialCount:this._partialCount,t}}get type(){return this._type}set type(t){this._type=t;let n=[`sine`,`square`,`sawtooth`,`triangle`].indexOf(t)!==-1;if(this._phase===0&&n)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=t);else{let n=this._getCachedPeriodicWave();if(G(n)){let{partials:e,wave:t}=n;this._wave=t,this._partials=e,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{let[n,r]=this._getRealImaginary(t,this._phase),i=this.context.createPeriodicWave(n,r);this._wave=i,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),e._periodicWaveCache.push({imag:r,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:n,type:this._type,wave:this._wave}),e._periodicWaveCache.length>100&&e._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),``)}set baseType(e){this.type=this.partialCount&&this._type!==`custom`&&e!==`custom`?e+this.partialCount:e}get partialCount(){return this._partialCount}set partialCount(e){wv(e,0);let t=this._type,n=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(n&&(t=n[1]),this._type!==`custom`)this.type=e===0?t:t+e.toString();else{let t=new Float32Array(e);this._partials.forEach((e,n)=>t[n]=e),this._partials=Array.from(t),this.type=this._type}}_getRealImaginary(e,t){let n=2048,r=new Float32Array(n),i=new Float32Array(n),a=1;if(e===`custom`){if(a=this._partials.length+1,this._partialCount=this._partials.length,n=a,this._partials.length===0)return[r,i]}else{let t=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(e);t?(a=parseInt(t[2],10)+1,this._partialCount=parseInt(t[2],10),e=t[1],a=Math.max(a,2),n=a):this._partialCount=0,this._partials=[]}for(let o=1;o<n;++o){let n=2/(o*Math.PI),s;switch(e){case`sine`:s=+(o<=a),this._partials[o-1]=s;break;case`square`:s=o&1?2*n:0,this._partials[o-1]=s;break;case`sawtooth`:s=n*(o&1?1:-1),this._partials[o-1]=s;break;case`triangle`:s=o&1?n*n*2*(o-1>>1&1?-1:1):0,this._partials[o-1]=s;break;case`custom`:s=this._partials[o-1];break;default:throw TypeError(`Oscillator: invalid type: `+e)}s===0?(r[o]=0,i[o]=0):(r[o]=-s*Math.sin(t*o),i[o]=s*Math.cos(t*o))}return[r,i]}_inverseFFT(e,t,n){let r=0,i=e.length;for(let a=0;a<i;a++)r+=e[a]*Math.cos(a*n)+t[a]*Math.sin(a*n);return r}getInitialValue(){let[e,t]=this._getRealImaginary(this._type,0),n=0,r=Math.PI*2;for(let i=0;i<32;i++)n=Math.max(this._inverseFFT(e,t,i/32*r),n);return iy(-this._inverseFFT(e,t,this._phase)/n,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this.type=`custom`)}get phase(){return this._phase*(180/Math.PI)}set phase(e){this._phase=e*Math.PI/180,this.type=this._type}asArray(){return zv(this,arguments,void 0,function*(e=1024){return Tb(this,e)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};Db._periodicWaveCache=[];var Ob=class extends fb{constructor(){super(...arguments),this.name=`AudioToGain`,this._norm=new pb({context:this.context,mapping:e=>(e+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}},kb=class e extends Jy{constructor(){let t=q(e.getDefaults(),arguments,[`value`]);super(t),this.name=`Multiply`,this.override=!1,this._mult=this.input=this.output=new Z({context:this.context,minValue:t.minValue,maxValue:t.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(Jy.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}},Ab=class e extends vb{constructor(){let t=q(e.getDefaults(),arguments,[`frequency`,`type`,`modulationType`]);super(t),this.name=`AMOscillator`,this._modulationScale=new Ob({context:this.context}),this._modulationNode=new Z({context:this.context}),this._carrier=new Db({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new Db({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new kb({context:this.context,units:`positive`,value:t.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),J(this,[`frequency`,`detune`,`harmonicity`])}static getDefaults(){return Object.assign(Db.getDefaults(),{harmonicity:1,modulationType:`square`})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){this._modulator.restart(e),this._carrier.restart(e)}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return zv(this,arguments,void 0,function*(e=1024){return Tb(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}},jb=class e extends vb{constructor(){let t=q(e.getDefaults(),arguments,[`frequency`,`type`,`modulationType`]);super(t),this.name=`FMOscillator`,this._modulationNode=new Z({context:this.context,gain:0}),this._carrier=new Db({context:this.context,detune:t.detune,frequency:0,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.detune=this._carrier.detune,this.frequency=new Jy({context:this.context,units:`frequency`,value:t.frequency}),this._modulator=new Db({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new kb({context:this.context,units:`positive`,value:t.harmonicity}),this.modulationIndex=new kb({context:this.context,units:`positive`,value:t.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),J(this,[`modulationIndex`,`frequency`,`detune`,`harmonicity`])}static getDefaults(){return Object.assign(Db.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:`square`})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){return this._modulator.restart(e),this._carrier.restart(e),this}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return zv(this,arguments,void 0,function*(e=1024){return Tb(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}},Mb=class e extends vb{constructor(){let t=q(e.getDefaults(),arguments,[`frequency`,`width`]);super(t),this.name=`PulseOscillator`,this._widthGate=new Z({context:this.context,gain:0}),this._thresh=new pb({context:this.context,mapping:e=>e<=0?-1:1}),this.width=new Jy({context:this.context,units:`audioRange`,value:t.width}),this._triangle=new Db({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:`triangle`}),this.frequency=this._triangle.frequency,this.detune=this._triangle.detune,this._triangle.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),J(this,[`width`,`frequency`,`detune`])}static getDefaults(){return Object.assign(vb.getDefaults(),{detune:0,frequency:440,phase:0,type:`pulse`,width:.2})}_start(e){e=this.toSeconds(e),this._triangle.start(e),this._widthGate.gain.setValueAtTime(1,e)}_stop(e){e=this.toSeconds(e),this._triangle.stop(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(0,e)}_restart(e){this._triangle.restart(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(1,e)}get phase(){return this._triangle.phase}set phase(e){this._triangle.phase=e}get type(){return`pulse`}get baseType(){return`pulse`}get partials(){return[]}get partialCount(){return 0}set carrierType(e){this._triangle.type=e}asArray(){return zv(this,arguments,void 0,function*(e=1024){return Tb(this,e)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}},Nb=class e extends vb{constructor(){let t=q(e.getDefaults(),arguments,[`frequency`,`type`,`spread`]);super(t),this.name=`FatOscillator`,this._oscillators=[],this.frequency=new Jy({context:this.context,units:`frequency`,value:t.frequency}),this.detune=new Jy({context:this.context,units:`cents`,value:t.detune}),this._spread=t.spread,this._type=t.type,this._phase=t.phase,this._partials=t.partials,this._partialCount=t.partialCount,this.count=t.count,J(this,[`frequency`,`detune`])}static getDefaults(){return Object.assign(Db.getDefaults(),{count:3,spread:20,type:`sawtooth`})}_start(e){e=this.toSeconds(e),this._forEach(t=>t.start(e))}_stop(e){e=this.toSeconds(e),this._forEach(t=>t.stop(e))}_restart(e){this._forEach(t=>t.restart(e))}_forEach(e){for(let t=0;t<this._oscillators.length;t++)e(this._oscillators[t],t)}get type(){return this._type}set type(e){this._type=e,this._forEach(t=>t.type=e)}get spread(){return this._spread}set spread(e){if(this._spread=e,this._oscillators.length>1){let t=-e/2,n=e/(this._oscillators.length-1);this._forEach((e,r)=>e.detune.value=t+n*r)}}get count(){return this._oscillators.length}set count(e){if(wv(e,1),this._oscillators.length!==e){this._forEach(e=>e.dispose()),this._oscillators=[];for(let t=0;t<e;t++){let n=new Db({context:this.context,volume:-6-e*1.1,type:this._type,phase:this._phase+t/e*360,partialCount:this._partialCount,onstop:t===0?()=>this.onstop(this):_y});this.type===`custom`&&(n.partials=this._partials),this.frequency.connect(n.frequency),this.detune.connect(n.detune),n.detune.overridden=!1,n.connect(this.output),this._oscillators[t]=n}this.spread=this._spread,this.state===`started`&&this._forEach(e=>e.start())}}get phase(){return this._phase}set phase(e){this._phase=e,this._forEach((e,t)=>e.phase=this._phase+t/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(e){this._forEach(t=>t.baseType=e),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this._type=`custom`,this._forEach(t=>t.partials=e))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(e){this._partialCount=e,this._forEach(t=>t.partialCount=e),this._type=this._oscillators[0].type}asArray(){return zv(this,arguments,void 0,function*(e=1024){return Tb(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(e=>e.dispose()),this}},Pb=class e extends vb{constructor(){let t=q(e.getDefaults(),arguments,[`frequency`,`modulationFrequency`]);super(t),this.name=`PWMOscillator`,this.sourceType=`pwm`,this._scale=new kb({context:this.context,value:2}),this._pulse=new Mb({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType=`sine`,this.modulationFrequency=this._pulse.frequency,this._modulator=new Db({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),J(this,[`modulationFrequency`,`frequency`,`detune`])}static getDefaults(){return Object.assign(vb.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:`pwm`})}_start(e){e=this.toSeconds(e),this._modulator.start(e),this._pulse.start(e)}_stop(e){e=this.toSeconds(e),this._modulator.stop(e),this._pulse.stop(e)}_restart(e){this._modulator.restart(e),this._pulse.restart(e)}get type(){return`pwm`}get baseType(){return`pwm`}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(e){this._modulator.phase=e}asArray(){return zv(this,arguments,void 0,function*(e=1024){return Tb(this,e)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}},Fb={am:Ab,fat:Nb,fm:jb,oscillator:Db,pulse:Mb,pwm:Pb},Ib=class e extends vb{constructor(){let t=q(e.getDefaults(),arguments,[`frequency`,`type`]);super(t),this.name=`OmniOscillator`,this.frequency=new Jy({context:this.context,units:`frequency`,value:t.frequency}),this.detune=new Jy({context:this.context,units:`cents`,value:t.detune}),J(this,[`frequency`,`detune`]),this.set(t)}static getDefaults(){return Object.assign(Db.getDefaults(),jb.getDefaults(),Ab.getDefaults(),Nb.getDefaults(),Mb.getDefaults(),Pb.getDefaults())}_start(e){this._oscillator.start(e)}_stop(e){this._oscillator.stop(e)}_restart(e){return this._oscillator.restart(e),this}get type(){let e=``;return[`am`,`fm`,`fat`].some(e=>this._sourceType===e)&&(e=this._sourceType),e+this._oscillator.type}set type(e){e.substr(0,2)===`fm`?(this._createNewOscillator(`fm`),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,2)===`am`?(this._createNewOscillator(`am`),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,3)===`fat`?(this._createNewOscillator(`fat`),this._oscillator=this._oscillator,this._oscillator.type=e.substr(3)):e===`pwm`?(this._createNewOscillator(`pwm`),this._oscillator=this._oscillator):e===`pulse`?this._createNewOscillator(`pulse`):(this._createNewOscillator(`oscillator`),this._oscillator=this._oscillator,this._oscillator.type=e)}get partials(){return this._oscillator.partials}set partials(e){!this._getOscType(this._oscillator,`pulse`)&&!this._getOscType(this._oscillator,`pwm`)&&(this._oscillator.partials=e)}get partialCount(){return this._oscillator.partialCount}set partialCount(e){!this._getOscType(this._oscillator,`pulse`)&&!this._getOscType(this._oscillator,`pwm`)&&(this._oscillator.partialCount=e)}set(e){return Reflect.has(e,`type`)&&e.type&&(this.type=e.type),super.set(e),this}_createNewOscillator(e){if(e!==this._sourceType){this._sourceType=e;let t=Fb[e],n=this.now();if(this._oscillator){let e=this._oscillator;e.stop(n),this.context.setTimeout(()=>e.dispose(),this.blockTime)}this._oscillator=new t({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),this.state===`started`&&this._oscillator.start(n)}}get phase(){return this._oscillator.phase}set phase(e){this._oscillator.phase=e}get sourceType(){return this._sourceType}set sourceType(e){let t=`sine`;this._oscillator.type!==`pwm`&&this._oscillator.type!==`pulse`&&(t=this._oscillator.type),e===`fm`?this.type=`fm`+t:e===`am`?this.type=`am`+t:e===`fat`?this.type=`fat`+t:e===`oscillator`?this.type=t:e===`pulse`?this.type=`pulse`:e===`pwm`&&(this.type=`pwm`)}_getOscType(e,t){return e instanceof Fb[t]}get baseType(){return this._oscillator.baseType}set baseType(e){!this._getOscType(this._oscillator,`pulse`)&&!this._getOscType(this._oscillator,`pwm`)&&e!==`pulse`&&e!==`pwm`&&(this._oscillator.baseType=e)}get width(){if(this._getOscType(this._oscillator,`pulse`))return this._oscillator.width}get count(){if(this._getOscType(this._oscillator,`fat`))return this._oscillator.count}set count(e){this._getOscType(this._oscillator,`fat`)&&vv(e)&&(this._oscillator.count=e)}get spread(){if(this._getOscType(this._oscillator,`fat`))return this._oscillator.spread}set spread(e){this._getOscType(this._oscillator,`fat`)&&vv(e)&&(this._oscillator.spread=e)}get modulationType(){if(this._getOscType(this._oscillator,`fm`)||this._getOscType(this._oscillator,`am`))return this._oscillator.modulationType}set modulationType(e){(this._getOscType(this._oscillator,`fm`)||this._getOscType(this._oscillator,`am`))&&Sv(e)&&(this._oscillator.modulationType=e)}get modulationIndex(){if(this._getOscType(this._oscillator,`fm`))return this._oscillator.modulationIndex}get harmonicity(){if(this._getOscType(this._oscillator,`fm`)||this._getOscType(this._oscillator,`am`))return this._oscillator.harmonicity}get modulationFrequency(){if(this._getOscType(this._oscillator,`pwm`))return this._oscillator.modulationFrequency}asArray(){return zv(this,arguments,void 0,function*(e=1024){return Tb(this,e)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}},Lb=class e extends Jy{constructor(){super(q(e.getDefaults(),arguments,[`value`])),this.override=!1,this.name=`Add`,this._sum=new Z({context:this.context}),this.input=this._sum,this.output=this._sum,this.addend=this._param,Uy(this._constantSource,this._sum)}static getDefaults(){return Object.assign(Jy.getDefaults(),{value:0})}dispose(){return super.dispose(),this._sum.dispose(),this}},Rb=class e extends fb{constructor(){let t=q(e.getDefaults(),arguments,[`min`,`max`]);super(t),this.name=`Scale`,this._mult=this.input=new kb({context:this.context,value:t.max-t.min}),this._add=this.output=new Lb({context:this.context,value:t.min}),this._min=t.min,this._max=t.max,this.input.connect(this.output)}static getDefaults(){return Object.assign(fb.getDefaults(),{max:1,min:0})}get min(){return this._min}set min(e){this._min=e,this._setRange()}get max(){return this._max}set max(e){this._max=e,this._setRange()}_setRange(){this._add.value=this._min,this._mult.value=this._max-this._min}dispose(){return super.dispose(),this._add.dispose(),this._mult.dispose(),this}},zb=class e extends fb{constructor(){super(q(e.getDefaults(),arguments)),this.name=`Zero`,this._gain=new Z({context:this.context}),this.output=this._gain,this.input=void 0,Wy(this.context.getConstant(0),this._gain)}dispose(){return super.dispose(),Gy(this.context.getConstant(0),this._gain),this}},Bb=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`frequency`,`min`,`max`]);super(t),this.name=`LFO`,this._stoppedValue=0,this._units=`number`,this.convert=!0,this._fromType=Y.prototype._fromType,this._toType=Y.prototype._toType,this._is=Y.prototype._is,this._clampValue=Y.prototype._clampValue,this._oscillator=new Db(t),this.frequency=this._oscillator.frequency,this._amplitudeGain=new Z({context:this.context,gain:t.amplitude,units:`normalRange`}),this.amplitude=this._amplitudeGain.gain,this._stoppedSignal=new Jy({context:this.context,units:`audioRange`,value:0}),this._zeros=new zb({context:this.context}),this._a2g=new Ob({context:this.context}),this._scaler=this.output=new Rb({context:this.context,max:t.max,min:t.min}),this.units=t.units,this.min=t.min,this.max=t.max,this._oscillator.chain(this._amplitudeGain,this._a2g,this._scaler),this._zeros.connect(this._a2g),this._stoppedSignal.connect(this._a2g),J(this,[`amplitude`,`frequency`]),this.phase=t.phase}static getDefaults(){return Object.assign(Db.getDefaults(),{amplitude:1,frequency:`4n`,max:1,min:0,type:`sine`,units:`number`})}start(e){return e=this.toSeconds(e),this._stoppedSignal.setValueAtTime(0,e),this._oscillator.start(e),this}stop(e){return e=this.toSeconds(e),this._stoppedSignal.setValueAtTime(this._stoppedValue,e),this._oscillator.stop(e),this}sync(){return this._oscillator.sync(),this._oscillator.syncFrequency(),this}unsync(){return this._oscillator.unsync(),this._oscillator.unsyncFrequency(),this}_setStoppedValue(){this._stoppedValue=this._oscillator.getInitialValue(),this._stoppedSignal.value=this._stoppedValue}get min(){return this._toType(this._scaler.min)}set min(e){e=this._fromType(e),this._scaler.min=e}get max(){return this._toType(this._scaler.max)}set max(e){e=this._fromType(e),this._scaler.max=e}get type(){return this._oscillator.type}set type(e){this._oscillator.type=e,this._setStoppedValue()}get partials(){return this._oscillator.partials}set partials(e){this._oscillator.partials=e,this._setStoppedValue()}get phase(){return this._oscillator.phase}set phase(e){this._oscillator.phase=e,this._setStoppedValue()}get units(){return this._units}set units(e){let t=this.min,n=this.max;this._units=e,this.min=t,this.max=n}get state(){return this._oscillator.state}connect(e,t,n){return(e instanceof Y||e instanceof Jy)&&(this.convert=e.convert,this.units=e.units),Yy(this,e,t,n),this}dispose(){return super.dispose(),this._oscillator.dispose(),this._stoppedSignal.dispose(),this._zeros.dispose(),this._scaler.dispose(),this._a2g.dispose(),this._amplitudeGain.dispose(),this.amplitude.dispose(),this}};function Vb(e,t=1/0){let n=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return n.get(this)},set:function(r){wv(r,e,t),n.set(this,r)}})}}function Hb(e,t=1/0){let n=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return n.get(this)},set:function(r){wv(this.toSeconds(r),e,t),n.set(this,r)}})}}var Ub=class e extends vb{constructor(){let t=q(e.getDefaults(),arguments,[`url`,`onload`]);super(t),this.name=`Player`,this._activeSources=new Set,this._buffer=new vy({onload:this._onload.bind(this,t.onload),onerror:t.onerror,reverse:t.reverse,url:t.url}),this.autostart=t.autostart,this._loop=t.loop,this._loopStart=t.loopStart,this._loopEnd=t.loopEnd,this._playbackRate=t.playbackRate,this.fadeIn=t.fadeIn,this.fadeOut=t.fadeOut}static getDefaults(){return Object.assign(vb.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:_y,onerror:_y,playbackRate:1,reverse:!1})}load(e){return zv(this,void 0,void 0,function*(){return yield this._buffer.load(e),this._onload(),this})}_onload(e=_y){e(),this.autostart&&this.start()}_onSourceEnd(e){this.onstop(this),this._activeSources.delete(e),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())===`started`&&(this._state.cancel(this.now()),this._state.setStateAtTime(`stopped`,this.now()))}start(e,t,n){return super.start(e,t,n),this}_start(e,t,n){t=this._loop?Xv(t,this._loopStart):Xv(t,0);let r=this.toSeconds(t),i=n;n=Xv(n,Math.max(this._buffer.duration-r,0));let a=this.toSeconds(n);a/=this._playbackRate,e=this.toSeconds(e);let o=new yb({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);!this._loop&&!this._synced&&(this._state.cancel(e+a),this._state.setStateAtTime(`stopped`,e+a,{implicitEnd:!0})),this._activeSources.add(o),this._loop&&gv(i)?o.start(e,r):o.start(e,r,a-this.toSeconds(this.fadeOut))}_stop(e){let t=this.toSeconds(e);this._activeSources.forEach(e=>e.stop(t))}restart(e,t,n){return super.restart(e,t,n),this}_restart(e,t,n){var r;(r=[...this._activeSources].pop())==null||r.stop(e),this._start(e,t,n)}seek(e,t){let n=this.toSeconds(t);if(this._state.getValueAtTime(n)===`started`){let t=this.toSeconds(e);this._stop(n),this._start(n,t)}return this}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}get loopStart(){return this._loopStart}set loopStart(e){this._loopStart=e,this.buffer.loaded&&wv(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEach(t=>{t.loopStart=e})}get loopEnd(){return this._loopEnd}set loopEnd(e){this._loopEnd=e,this.buffer.loaded&&wv(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEach(t=>{t.loopEnd=e})}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._loop}set loop(e){if(this._loop!==e&&(this._loop=e,this._activeSources.forEach(t=>{t.loop=e}),e)){let e=this._state.getNextState(`stopped`,this.now());e&&this._state.cancel(e.time)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e;let t=this.now(),n=this._state.getNextState(`stopped`,t);n&&n.implicitEnd&&(this._state.cancel(n.time),this._activeSources.forEach(e=>e.cancelStop())),this._activeSources.forEach(n=>{n.playbackRate.setValueAtTime(e,t)})}get reverse(){return this._buffer.reverse}set reverse(e){this._buffer.reverse=e}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(e=>e.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}};Rv([Hb(0)],Ub.prototype,`fadeIn`,void 0),Rv([Hb(0)],Ub.prototype,`fadeOut`,void 0);var Wb=class extends fb{constructor(){super(...arguments),this.name=`GainToAudio`,this._norm=new pb({context:this.context,mapping:e=>Math.abs(e)*2-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}},Gb=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`attack`,`decay`,`sustain`,`release`]);super(t),this.name=`Envelope`,this._sig=new Jy({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=t.attack,this.decay=t.decay,this.sustain=t.sustain,this.release=t.release,this.attackCurve=t.attackCurve,this.releaseCurve=t.releaseCurve,this.decayCurve=t.decayCurve}static getDefaults(){return Object.assign(X.getDefaults(),{attack:.01,attackCurve:`linear`,decay:.1,decayCurve:`exponential`,release:1,releaseCurve:`exponential`,sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(e,t){if(Sv(e))return e;{let n;for(n in Kb)if(Kb[n][t]===e)return n;return e}}_setCurve(e,t,n){if(Sv(n)&&Reflect.has(Kb,n)){let r=Kb[n];yv(r)?e!==`_decayCurve`&&(this[e]=r[t]):this[e]=r}else if(xv(n)&&e!==`_decayCurve`)this[e]=n;else throw Error(`Envelope: invalid curve: `+n)}get attackCurve(){return this._getCurve(this._attackCurve,`In`)}set attackCurve(e){this._setCurve(`_attackCurve`,`In`,e)}get releaseCurve(){return this._getCurve(this._releaseCurve,`Out`)}set releaseCurve(e){this._setCurve(`_releaseCurve`,`Out`,e)}get decayCurve(){return this._getCurve(this._decayCurve,`Out`)}set decayCurve(e){this._setCurve(`_decayCurve`,`Out`,e)}triggerAttack(e,t=1){this.log(`triggerAttack`,e,t),e=this.toSeconds(e);let n=this.toSeconds(this.attack),r=this.toSeconds(this.decay),i=this.getValueAtTime(e);if(i>0){let e=1/n;n=(1-i)/e}if(n<this.sampleTime)this._sig.cancelScheduledValues(e),this._sig.setValueAtTime(t,e);else if(this._attackCurve===`linear`)this._sig.linearRampTo(t,n,e);else if(this._attackCurve===`exponential`)this._sig.targetRampTo(t,n,e);else{this._sig.cancelAndHoldAtTime(e);let r=this._attackCurve;for(let e=1;e<r.length;e++)if(r[e-1]<=i&&i<=r[e]){r=this._attackCurve.slice(e),r[0]=i;break}this._sig.setValueCurveAtTime(r,e,n,t)}if(r&&this.sustain<1){let i=t*this.sustain,a=e+n;this.log(`decay`,a),this._decayCurve===`linear`?this._sig.linearRampToValueAtTime(i,r+a):this._sig.exponentialApproachValueAtTime(i,a,r)}return this}triggerRelease(e){this.log(`triggerRelease`,e),e=this.toSeconds(e);let t=this.getValueAtTime(e);if(t>0){let n=this.toSeconds(this.release);n<this.sampleTime?this._sig.setValueAtTime(0,e):this._releaseCurve===`linear`?this._sig.linearRampTo(0,n,e):this._releaseCurve===`exponential`?this._sig.targetRampTo(0,n,e):(K(xv(this._releaseCurve),`releaseCurve must be either 'linear', 'exponential' or an array`),this._sig.cancelAndHoldAtTime(e),this._sig.setValueCurveAtTime(this._releaseCurve,e,n,t))}return this}getValueAtTime(e){return this._sig.getValueAtTime(e)}triggerAttackRelease(e,t,n=1){return t=this.toSeconds(t),this.triggerAttack(t,n),this.triggerRelease(t+this.toSeconds(e)),this}cancel(e){return this._sig.cancelScheduledValues(this.toSeconds(e)),this}connect(e,t=0,n=0){return Yy(this,e,t,n),this}asArray(){return zv(this,arguments,void 0,function*(e=1024){let t=e/this.context.sampleRate,n=new yy(1,t,this.context.sampleRate),r=this.toSeconds(this.attack)+this.toSeconds(this.decay),i=r+this.toSeconds(this.release),a=i*.1,o=i+a,s=new this.constructor(Object.assign(this.get(),{attack:t*this.toSeconds(this.attack)/o,decay:t*this.toSeconds(this.decay)/o,release:t*this.toSeconds(this.release)/o,context:n}));return s._sig.toDestination(),s.triggerAttackRelease(t*(r+a)/o,0),(yield n.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}};Rv([Hb(0)],Gb.prototype,`attack`,void 0),Rv([Hb(0)],Gb.prototype,`decay`,void 0),Rv([Vb(0,1)],Gb.prototype,`sustain`,void 0),Rv([Hb(0)],Gb.prototype,`release`,void 0);var Kb=(()=>{let e,t,n=[];for(e=0;e<128;e++)n[e]=Math.sin(e/127*(Math.PI/2));let r=[];for(e=0;e<127;e++){t=e/127;let n=Math.sin(Math.PI*2*t*6.4-Math.PI/2)+1;r[e]=n/10+t*.83}r[127]=1;let i=[];for(e=0;e<128;e++)i[e]=Math.ceil(e/127*5)/5;let a=[];for(e=0;e<128;e++)t=e/127,a[e]=.5*(1-Math.cos(Math.PI*t));let o=[];for(e=0;e<128;e++){t=e/127;let n=t**3*4+.2,r=Math.cos(n*Math.PI*2*t);o[e]=Math.abs(r*(1-t))}function s(e){let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=1-e[n];return t}function c(e){return e.slice(0).reverse()}return{bounce:{In:s(o),Out:o},cosine:{In:n,Out:c(n)},exponential:`exponential`,linear:`linear`,ripple:{In:r,Out:s(r)},sine:{In:a,Out:s(a)},step:{In:i,Out:s(i)}}})(),qb=class e extends X{constructor(){let t=q(e.getDefaults(),arguments);super(t),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease,this._syncedRelease=e=>this._original_triggerRelease(e),this._volume=this.output=new tb({context:this.context,volume:t.volume}),this.volume=this._volume.volume,J(this,`volume`)}static getDefaults(){return Object.assign(X.getDefaults(),{volume:0})}sync(){return this._syncState()&&(this._syncMethod(`triggerAttack`,1),this._syncMethod(`triggerRelease`,0),this.context.transport.on(`stop`,this._syncedRelease),this.context.transport.on(`pause`,this._syncedRelease),this.context.transport.on(`loopEnd`,this._syncedRelease)),this}_syncState(){let e=!1;return this._synced||(this._synced=!0,e=!0),e}_syncMethod(e,t){let n=this[`_original_`+e]=this[e];this[e]=(...e)=>{let r=e[t],i=this.context.transport.schedule(r=>{e[t]=r,n.apply(this,e)},r);this._scheduledEvents.push(i)}}unsync(){return this._scheduledEvents.forEach(e=>this.context.transport.clear(e)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease,this.context.transport.off(`stop`,this._syncedRelease),this.context.transport.off(`pause`,this._syncedRelease),this.context.transport.off(`loopEnd`,this._syncedRelease)),this}triggerAttackRelease(e,t,n,r){let i=this.toSeconds(n),a=this.toSeconds(t);return this.triggerAttack(e,i,r),this.triggerRelease(i+a),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}},Jb=class e extends qb{constructor(){let t=q(e.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(qb.getDefaults(),{detune:0,onsilence:_y,portamento:0})}triggerAttack(e,t,n=1){this.log(`triggerAttack`,e,t,n);let r=this.toSeconds(t);return this._triggerEnvelopeAttack(r,n),this.setNote(e,r),this}triggerRelease(e){this.log(`triggerRelease`,e);let t=this.toSeconds(e);return this._triggerEnvelopeRelease(t),this}setNote(e,t){let n=this.toSeconds(t),r=e instanceof Iy?e.toFrequency():e;if(this.portamento>0&&this.getLevelAtTime(n)>.05){let e=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(r,e,n)}else this.frequency.setValueAtTime(r,n);return this}};Rv([Hb(0)],Jb.prototype,`portamento`,void 0);var Yb=class e extends Gb{constructor(){super(q(e.getDefaults(),arguments,[`attack`,`decay`,`sustain`,`release`])),this.name=`AmplitudeEnvelope`,this._gainNode=new Z({context:this.context,gain:0}),this.output=this._gainNode,this.input=this._gainNode,this._sig.connect(this._gainNode.gain),this.output=this._gainNode,this.input=this._gainNode}dispose(){return super.dispose(),this._gainNode.dispose(),this}},Xb=class e extends Jb{constructor(){let t=q(e.getDefaults(),arguments);super(t),this.name=`Synth`,this.oscillator=new Ib(Object.assign({context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)},t.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new Yb(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),J(this,[`oscillator`,`frequency`,`detune`,`envelope`])}static getDefaults(){return Object.assign(Jb.getDefaults(),{envelope:Object.assign(Zv(Gb.getDefaults(),Object.keys(X.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(Zv(Ib.getDefaults(),[...Object.keys(vb.getDefaults()),`frequency`,`detune`]),{type:`triangle`})})}_triggerEnvelopeAttack(e,t){if(this.envelope.triggerAttack(e,t),this.oscillator.start(e),this.envelope.sustain===0){let t=this.toSeconds(this.envelope.attack),n=this.toSeconds(this.envelope.decay);this.oscillator.stop(e+t+n)}}_triggerEnvelopeRelease(e){this.envelope.triggerRelease(e),this.oscillator.stop(e+this.toSeconds(this.envelope.release))}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}},Zb=class e extends Jb{constructor(){let t=q(e.getDefaults(),arguments);super(t),this.name=`ModulationSynth`,this._carrier=new Xb({context:this.context,oscillator:t.oscillator,envelope:t.envelope,onsilence:()=>this.onsilence(this),volume:-10}),this._modulator=new Xb({context:this.context,oscillator:t.modulation,envelope:t.modulationEnvelope,volume:-10}),this.oscillator=this._carrier.oscillator,this.envelope=this._carrier.envelope,this.modulation=this._modulator.oscillator,this.modulationEnvelope=this._modulator.envelope,this.frequency=new Jy({context:this.context,units:`frequency`}),this.detune=new Jy({context:this.context,value:t.detune,units:`cents`}),this.harmonicity=new kb({context:this.context,value:t.harmonicity,minValue:0}),this._modulationNode=new Z({context:this.context,gain:0}),J(this,[`frequency`,`harmonicity`,`oscillator`,`envelope`,`modulation`,`modulationEnvelope`,`detune`])}static getDefaults(){return Object.assign(Jb.getDefaults(),{harmonicity:3,oscillator:Object.assign(Zv(Ib.getDefaults(),[...Object.keys(vb.getDefaults()),`frequency`,`detune`]),{type:`sine`}),envelope:Object.assign(Zv(Gb.getDefaults(),Object.keys(X.getDefaults())),{attack:.01,decay:.01,sustain:1,release:.5}),modulation:Object.assign(Zv(Ib.getDefaults(),[...Object.keys(vb.getDefaults()),`frequency`,`detune`]),{type:`square`}),modulationEnvelope:Object.assign(Zv(Gb.getDefaults(),Object.keys(X.getDefaults())),{attack:.5,decay:0,sustain:1,release:.5})})}_triggerEnvelopeAttack(e,t){this._carrier._triggerEnvelopeAttack(e,t),this._modulator._triggerEnvelopeAttack(e,t)}_triggerEnvelopeRelease(e){return this._carrier._triggerEnvelopeRelease(e),this._modulator._triggerEnvelopeRelease(e),this}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this._carrier.dispose(),this._modulator.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._modulationNode.dispose(),this}},Qb=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`frequency`,`type`]);super(t),this.name=`BiquadFilter`,this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new Y({context:this.context,units:`number`,value:t.Q,param:this._filter.Q}),this.frequency=new Y({context:this.context,units:`frequency`,value:t.frequency,param:this._filter.frequency}),this.detune=new Y({context:this.context,units:`cents`,value:t.detune,param:this._filter.detune}),this.gain=new Y({context:this.context,units:`decibels`,convert:!1,value:t.gain,param:this._filter.gain}),this.type=t.type}static getDefaults(){return Object.assign(X.getDefaults(),{Q:1,type:`lowpass`,frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(e){K([`lowpass`,`highpass`,`bandpass`,`lowshelf`,`highshelf`,`notch`,`allpass`,`peaking`].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._filter.type=e}getFrequencyResponse(e=128){let t=new Float32Array(e);for(let n=0;n<e;n++){let r=(n/e)**2*19980+20;t[n]=r}let n=new Float32Array(e),r=new Float32Array(e),i=this.context.createBiquadFilter();return i.type=this.type,i.Q.value=this.Q.value,i.frequency.value=this.frequency.value,i.gain.value=this.gain.value,i.getFrequencyResponse(t,n,r),n}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}},$b=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`frequency`,`type`,`rolloff`]);super(t),this.name=`Filter`,this.input=new Z({context:this.context}),this.output=new Z({context:this.context}),this._filters=[],this._filters=[],this.Q=new Jy({context:this.context,units:`positive`,value:t.Q}),this.frequency=new Jy({context:this.context,units:`frequency`,value:t.frequency}),this.detune=new Jy({context:this.context,units:`cents`,value:t.detune}),this.gain=new Jy({context:this.context,units:`decibels`,convert:!1,value:t.gain}),this._type=t.type,this.rolloff=t.rolloff,J(this,[`detune`,`frequency`,`gain`,`Q`])}static getDefaults(){return Object.assign(X.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:`lowpass`})}get type(){return this._type}set type(e){K([`lowpass`,`highpass`,`bandpass`,`lowshelf`,`highshelf`,`notch`,`allpass`,`peaking`].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._type=e,this._filters.forEach(t=>t.type=e)}get rolloff(){return this._rolloff}set rolloff(e){let t=vv(e)?e:parseInt(e,10),n=[-12,-24,-48,-96],r=n.indexOf(t);K(r!==-1,`rolloff can only be ${n.join(`, `)}`),r+=1,this._rolloff=t,this.input.disconnect(),this._filters.forEach(e=>e.disconnect()),this._filters=Array(r);for(let e=0;e<r;e++){let t=new Qb({context:this.context});t.type=this._type,this.frequency.connect(t.frequency),this.detune.connect(t.detune),this.Q.connect(t.Q),this.gain.connect(t.gain),this._filters[e]=t}this._internalChannels=this._filters,Uy(this.input,...this._internalChannels,this.output)}getFrequencyResponse(e=128){let t=new Qb({context:this.context,frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),n=new Float32Array(e).map(()=>1);return this._filters.forEach(()=>{t.getFrequencyResponse(e).forEach((e,t)=>n[t]*=e)}),t.dispose(),n}dispose(){return super.dispose(),this._filters.forEach(e=>{e.dispose()}),gy(this,[`detune`,`frequency`,`gain`,`Q`]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}},ex=class e extends Gb{constructor(){let t=q(e.getDefaults(),arguments,[`attack`,`decay`,`sustain`,`release`]);super(t),this.name=`FrequencyEnvelope`,this._octaves=t.octaves,this._baseFrequency=this.toFrequency(t.baseFrequency),this._exponent=this.input=new mb({context:this.context,value:t.exponent}),this._scale=this.output=new Rb({context:this.context,min:this._baseFrequency,max:this._baseFrequency*2**this._octaves}),this._sig.chain(this._exponent,this._scale)}static getDefaults(){return Object.assign(Gb.getDefaults(),{baseFrequency:200,exponent:1,octaves:4})}get baseFrequency(){return this._baseFrequency}set baseFrequency(e){let t=this.toFrequency(e);wv(t,0),this._baseFrequency=t,this._scale.min=this._baseFrequency,this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(e){this._octaves=e,this._scale.max=this._baseFrequency*2**e}get exponent(){return this._exponent.value}set exponent(e){this._exponent.value=e}dispose(){return super.dispose(),this._exponent.dispose(),this._scale.dispose(),this}},tx=class e extends Jb{constructor(){let t=q(e.getDefaults(),arguments);super(t),this.name=`MonoSynth`,this.oscillator=new Ib(Object.assign(t.oscillator,{context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)})),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.filter=new $b(Object.assign(t.filter,{context:this.context})),this.filterEnvelope=new ex(Object.assign(t.filterEnvelope,{context:this.context})),this.envelope=new Yb(Object.assign(t.envelope,{context:this.context})),this.oscillator.chain(this.filter,this.envelope,this.output),this.filterEnvelope.connect(this.filter.frequency),J(this,[`oscillator`,`frequency`,`detune`,`filter`,`filterEnvelope`,`envelope`])}static getDefaults(){return Object.assign(Jb.getDefaults(),{envelope:Object.assign(Zv(Gb.getDefaults(),Object.keys(X.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.9}),filter:Object.assign(Zv($b.getDefaults(),Object.keys(X.getDefaults())),{Q:1,rolloff:-12,type:`lowpass`}),filterEnvelope:Object.assign(Zv(ex.getDefaults(),Object.keys(X.getDefaults())),{attack:.6,baseFrequency:200,decay:.2,exponent:2,octaves:3,release:2,sustain:.5}),oscillator:Object.assign(Zv(Ib.getDefaults(),Object.keys(vb.getDefaults())),{type:`sawtooth`})})}_triggerEnvelopeAttack(e,t=1){if(this.envelope.triggerAttack(e,t),this.filterEnvelope.triggerAttack(e),this.oscillator.start(e),this.envelope.sustain===0){let t=this.toSeconds(this.envelope.attack),n=this.toSeconds(this.envelope.decay);this.oscillator.stop(e+t+n)}}_triggerEnvelopeRelease(e){this.envelope.triggerRelease(e),this.filterEnvelope.triggerRelease(e),this.oscillator.stop(e+this.toSeconds(this.envelope.release))}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this.filterEnvelope.dispose(),this.filter.dispose(),this}},nx=class e extends Zb{constructor(){let t=q(e.getDefaults(),arguments);super(t),this.name=`FMSynth`,this.modulationIndex=new kb({context:this.context,value:t.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output)}static getDefaults(){return Object.assign(Zb.getDefaults(),{modulationIndex:10})}dispose(){return super.dispose(),this.modulationIndex.dispose(),this}},rx=class e extends Xb{constructor(){let t=q(e.getDefaults(),arguments);super(t),this.name=`MembraneSynth`,this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,J(this,[`oscillator`,`envelope`])}static getDefaults(){return qv(Jb.getDefaults(),Xb.getDefaults(),{envelope:{attack:.001,attackCurve:`exponential`,decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:`sine`},pitchDecay:.05})}setNote(e,t){let n=this.toSeconds(t),r=this.toFrequency(e instanceof Iy?e.toFrequency():e),i=r*this.octaves;return this.oscillator.frequency.setValueAtTime(i,n),this.oscillator.frequency.exponentialRampToValueAtTime(r,n+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}};Rv([Vb(0)],rx.prototype,`octaves`,void 0),Rv([Hb(0)],rx.prototype,`pitchDecay`,void 0);var ix=new Set;function ax(e){ix.add(e)}function ox(e,t){let n=`registerProcessor("${e}", ${t})`;ix.add(n)}ax(`
|
|
83
|
+
/**
|
|
84
|
+
* The base AudioWorkletProcessor for use in Tone.js. Works with the {@link ToneAudioWorklet}.
|
|
85
|
+
*/
|
|
86
|
+
class ToneAudioWorkletProcessor extends AudioWorkletProcessor {
|
|
87
|
+
|
|
88
|
+
constructor(options) {
|
|
89
|
+
|
|
90
|
+
super(options);
|
|
91
|
+
/**
|
|
92
|
+
* If the processor was disposed or not. Keep alive until it's disposed.
|
|
93
|
+
*/
|
|
94
|
+
this.disposed = false;
|
|
95
|
+
/**
|
|
96
|
+
* The number of samples in the processing block
|
|
97
|
+
*/
|
|
98
|
+
this.blockSize = 128;
|
|
99
|
+
/**
|
|
100
|
+
* the sample rate
|
|
101
|
+
*/
|
|
102
|
+
this.sampleRate = sampleRate;
|
|
103
|
+
|
|
104
|
+
this.port.onmessage = (event) => {
|
|
105
|
+
// when it receives a dispose
|
|
106
|
+
if (event.data === "dispose") {
|
|
107
|
+
this.disposed = true;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
`),ax(`
|
|
113
|
+
/**
|
|
114
|
+
* Abstract class for a single input/output processor.
|
|
115
|
+
* has a 'generate' function which processes one sample at a time
|
|
116
|
+
*/
|
|
117
|
+
class SingleIOProcessor extends ToneAudioWorkletProcessor {
|
|
118
|
+
|
|
119
|
+
constructor(options) {
|
|
120
|
+
super(Object.assign(options, {
|
|
121
|
+
numberOfInputs: 1,
|
|
122
|
+
numberOfOutputs: 1
|
|
123
|
+
}));
|
|
124
|
+
/**
|
|
125
|
+
* Holds the name of the parameter and a single value of that
|
|
126
|
+
* parameter at the current sample
|
|
127
|
+
* @type { [name: string]: number }
|
|
128
|
+
*/
|
|
129
|
+
this.params = {}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Generate an output sample from the input sample and parameters
|
|
134
|
+
* @abstract
|
|
135
|
+
* @param input number
|
|
136
|
+
* @param channel number
|
|
137
|
+
* @param parameters { [name: string]: number }
|
|
138
|
+
* @returns number
|
|
139
|
+
*/
|
|
140
|
+
generate(){}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Update the private params object with the
|
|
144
|
+
* values of the parameters at the given index
|
|
145
|
+
* @param parameters { [name: string]: Float32Array },
|
|
146
|
+
* @param index number
|
|
147
|
+
*/
|
|
148
|
+
updateParams(parameters, index) {
|
|
149
|
+
for (const paramName in parameters) {
|
|
150
|
+
const param = parameters[paramName];
|
|
151
|
+
if (param.length > 1) {
|
|
152
|
+
this.params[paramName] = parameters[paramName][index];
|
|
153
|
+
} else {
|
|
154
|
+
this.params[paramName] = parameters[paramName][0];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Process a single frame of the audio
|
|
161
|
+
* @param inputs Float32Array[][]
|
|
162
|
+
* @param outputs Float32Array[][]
|
|
163
|
+
*/
|
|
164
|
+
process(inputs, outputs, parameters) {
|
|
165
|
+
const input = inputs[0];
|
|
166
|
+
const output = outputs[0];
|
|
167
|
+
// get the parameter values
|
|
168
|
+
const channelCount = Math.max(input && input.length || 0, output.length);
|
|
169
|
+
for (let sample = 0; sample < this.blockSize; sample++) {
|
|
170
|
+
this.updateParams(parameters, sample);
|
|
171
|
+
for (let channel = 0; channel < channelCount; channel++) {
|
|
172
|
+
const inputSample = input && input.length ? input[channel][sample] : 0;
|
|
173
|
+
output[channel][sample] = this.generate(inputSample, channel, this.params);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return !this.disposed;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
`),ax(`
|
|
180
|
+
/**
|
|
181
|
+
* A multichannel buffer for use within an AudioWorkletProcessor as a delay line
|
|
182
|
+
*/
|
|
183
|
+
class DelayLine {
|
|
184
|
+
|
|
185
|
+
constructor(size, channels) {
|
|
186
|
+
this.buffer = [];
|
|
187
|
+
this.writeHead = []
|
|
188
|
+
this.size = size;
|
|
189
|
+
|
|
190
|
+
// create the empty channels
|
|
191
|
+
for (let i = 0; i < channels; i++) {
|
|
192
|
+
this.buffer[i] = new Float32Array(this.size);
|
|
193
|
+
this.writeHead[i] = 0;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Push a value onto the end
|
|
199
|
+
* @param channel number
|
|
200
|
+
* @param value number
|
|
201
|
+
*/
|
|
202
|
+
push(channel, value) {
|
|
203
|
+
this.writeHead[channel] += 1;
|
|
204
|
+
if (this.writeHead[channel] > this.size) {
|
|
205
|
+
this.writeHead[channel] = 0;
|
|
206
|
+
}
|
|
207
|
+
this.buffer[channel][this.writeHead[channel]] = value;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Get the recorded value of the channel given the delay
|
|
212
|
+
* @param channel number
|
|
213
|
+
* @param delay number delay samples
|
|
214
|
+
*/
|
|
215
|
+
get(channel, delay) {
|
|
216
|
+
let readHead = this.writeHead[channel] - Math.floor(delay);
|
|
217
|
+
if (readHead < 0) {
|
|
218
|
+
readHead += this.size;
|
|
219
|
+
}
|
|
220
|
+
return this.buffer[channel][readHead];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
`),ox(`feedback-comb-filter`,`
|
|
224
|
+
class FeedbackCombFilterWorklet extends SingleIOProcessor {
|
|
225
|
+
|
|
226
|
+
constructor(options) {
|
|
227
|
+
super(options);
|
|
228
|
+
this.delayLine = new DelayLine(this.sampleRate, options.channelCount || 2);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
static get parameterDescriptors() {
|
|
232
|
+
return [{
|
|
233
|
+
name: "delayTime",
|
|
234
|
+
defaultValue: 0.1,
|
|
235
|
+
minValue: 0,
|
|
236
|
+
maxValue: 1,
|
|
237
|
+
automationRate: "k-rate"
|
|
238
|
+
}, {
|
|
239
|
+
name: "feedback",
|
|
240
|
+
defaultValue: 0.5,
|
|
241
|
+
minValue: 0,
|
|
242
|
+
maxValue: 0.9999,
|
|
243
|
+
automationRate: "k-rate"
|
|
244
|
+
}];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
generate(input, channel, parameters) {
|
|
248
|
+
const delayedSample = this.delayLine.get(channel, parameters.delayTime * this.sampleRate);
|
|
249
|
+
this.delayLine.push(channel, input + delayedSample * parameters.feedback);
|
|
250
|
+
return delayedSample;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
`);var sx=class e extends qb{constructor(){let t=q(e.getDefaults(),arguments,[`voice`,`options`]);super(t),this.name=`PolySynth`,this._availableVoices=[],this._activeVoices=[],this._voices=[],this._gcTimeout=-1,this._averageActiveVoices=0,this._syncedRelease=e=>this.releaseAll(e),K(!vv(t.voice),`DEPRECATED: The polyphony count is no longer the first argument.`);let n=t.voice.getDefaults();this.options=Object.assign(n,t.options),this.voice=t.voice,this.maxPolyphony=t.maxPolyphony,this._dummyVoice=this._getNextAvailableVoice();let r=this._voices.indexOf(this._dummyVoice);this._voices.splice(r,1),this._gcTimeout=this.context.setInterval(this._collectGarbage.bind(this),1)}static getDefaults(){return Object.assign(qb.getDefaults(),{maxPolyphony:32,options:{},voice:Xb})}get activeVoices(){return this._activeVoices.length}_makeVoiceAvailable(e){this._availableVoices.push(e);let t=this._activeVoices.findIndex(t=>t.voice===e);this._activeVoices.splice(t,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.length<this.maxPolyphony){let e=new this.voice(Object.assign(this.options,{context:this.context,onsilence:this._makeVoiceAvailable.bind(this)}));return K(e instanceof Jb,`Voice must extend Monophonic class`),e.connect(this.output),this._voices.push(e),e}Mv(`Max polyphony exceeded. Note dropped.`)}_collectGarbage(){if(this._averageActiveVoices=Math.max(this._averageActiveVoices*.95,this.activeVoices),this._availableVoices.length&&this._voices.length>Math.ceil(this._averageActiveVoices+1)){let e=this._availableVoices.shift(),t=this._voices.indexOf(e);this._voices.splice(t,1),this.context.isOffline||e.dispose()}}_triggerAttack(e,t,n){e.forEach(e=>{let r=new ob(this.context,e).toMidi(),i=this._getNextAvailableVoice();i&&(i.triggerAttack(e,t,n),this._activeVoices.push({midi:r,voice:i,released:!1}),this.log(`triggerAttack`,e,t))})}_triggerRelease(e,t){e.forEach(e=>{let n=new ob(this.context,e).toMidi(),r=this._activeVoices.find(({midi:e,released:t})=>e===n&&!t);r&&(r.voice.triggerRelease(t),r.released=!0,this.log(`triggerRelease`,e,t))})}_scheduleEvent(e,t,n,r){K(!this.disposed,`Synth was already disposed`),n<=this.now()?e===`attack`?this._triggerAttack(t,n,r):this._triggerRelease(t,n):this.context.setTimeout(()=>{this.disposed||this._scheduleEvent(e,t,n,r)},n-this.now())}triggerAttack(e,t,n){Array.isArray(e)||(e=[e]);let r=this.toSeconds(t);return this._scheduleEvent(`attack`,e,r,n),this}triggerRelease(e,t){Array.isArray(e)||(e=[e]);let n=this.toSeconds(t);return this._scheduleEvent(`release`,e,n),this}triggerAttackRelease(e,t,n,r){let i=this.toSeconds(n);if(this.triggerAttack(e,i,r),xv(t)){K(xv(e),`If the duration is an array, the notes must also be an array`),e=e;for(let n=0;n<e.length;n++){let r=t[Math.min(n,t.length-1)],a=this.toSeconds(r);K(a>0,`The duration must be greater than 0`),this.triggerRelease(e[n],i+a)}}else{let n=this.toSeconds(t);K(n>0,`The duration must be greater than 0`),this.triggerRelease(e,i+n)}return this}sync(){return this._syncState()&&(this._syncMethod(`triggerAttack`,1),this._syncMethod(`triggerRelease`,1),this.context.transport.on(`stop`,this._syncedRelease),this.context.transport.on(`pause`,this._syncedRelease),this.context.transport.on(`loopEnd`,this._syncedRelease)),this}set(e){let t=Zv(e,[`onsilence`,`context`]);return this.options=qv(this.options,t),this._voices.forEach(e=>e.set(t)),this._dummyVoice.set(t),this}get(){return this._dummyVoice.get()}releaseAll(e){let t=this.toSeconds(e);return this._activeVoices.forEach(({voice:e})=>{e.triggerRelease(t)}),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach(e=>e.dispose()),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}},cx=class e extends qb{constructor(){let t=q(e.getDefaults(),arguments,[`urls`,`onload`,`baseUrl`],`urls`);super(t),this.name=`Sampler`,this._activeSources=new Map;let n={};Object.keys(t.urls).forEach(e=>{let r=parseInt(e,10);if(K(Cv(e)||vv(r)&&isFinite(r),`url key is neither a note or midi pitch: ${e}`),Cv(e)){let r=new Iy(this.context,e).toMidi();n[r]=t.urls[e]}else vv(r)&&isFinite(r)&&(n[r]=t.urls[r])}),this._buffers=new ab({urls:n,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.attack=t.attack,this.release=t.release,this.curve=t.curve,this._buffers.loaded&&Promise.resolve().then(t.onload)}static getDefaults(){return Object.assign(qb.getDefaults(),{attack:0,baseUrl:``,curve:`exponential`,onload:_y,onerror:_y,release:.1,urls:{}})}_findClosest(e){let t=0;for(;t<96;){if(this._buffers.has(e+t))return-t;if(this._buffers.has(e-t))return t;t++}throw Error(`No available buffers for note: ${e}`)}triggerAttack(e,t,n=1){return this.log(`triggerAttack`,e,t,n),Array.isArray(e)||(e=[e]),e.forEach(e=>{let r=My(new Iy(this.context,e).toFrequency()),i=Math.round(r),a=r-i,o=this._findClosest(i),s=i-o,c=this._buffers.get(s),l=Dy(o+a),u=new yb({url:c,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:l}).connect(this.output);u.start(t,0,c.duration/l,n),xv(this._activeSources.get(i))||this._activeSources.set(i,[]),this._activeSources.get(i).push(u),u.onended=()=>{if(this._activeSources&&this._activeSources.has(i)){let e=this._activeSources.get(i),t=e.indexOf(u);t!==-1&&e.splice(t,1)}}}),this}triggerRelease(e,t){return this.log(`triggerRelease`,e,t),Array.isArray(e)||(e=[e]),e.forEach(e=>{let n=new Iy(this.context,e).toMidi();if(this._activeSources.has(n)&&this._activeSources.get(n).length){let e=this._activeSources.get(n);t=this.toSeconds(t),e.forEach(e=>{e.stop(t)}),this._activeSources.set(n,[])}}),this}releaseAll(e){let t=this.toSeconds(e);return this._activeSources.forEach(e=>{for(;e.length;)e.shift().stop(t)}),this}sync(){return this._syncState()&&(this._syncMethod(`triggerAttack`,1),this._syncMethod(`triggerRelease`,1)),this}triggerAttackRelease(e,t,n,r=1){let i=this.toSeconds(n);return this.triggerAttack(e,i,r),xv(t)?(K(xv(e),`notes must be an array when duration is array`),e.forEach((e,n)=>{let r=t[Math.min(n,t.length-1)];this.triggerRelease(e,i+this.toSeconds(r))})):this.triggerRelease(e,i+this.toSeconds(t)),this}add(e,t,n){if(K(Cv(e)||isFinite(e),`note must be a pitch or midi: ${e}`),Cv(e)){let r=new Iy(this.context,e).toMidi();this._buffers.add(r,t,n)}else this._buffers.add(e,t,n);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(e=>{e.forEach(e=>e.dispose())}),this._activeSources.clear(),this}};Rv([Hb(0)],cx.prototype,`attack`,void 0),Rv([Hb(0)],cx.prototype,`release`,void 0);var lx=class e extends Vy{constructor(){let t=q(e.getDefaults(),arguments,[`callback`,`value`]);super(t),this.name=`ToneEvent`,this._state=new Hy(`stopped`),this._startOffset=0,this._loop=t.loop,this.callback=t.callback,this.value=t.value,this._loopStart=this.toTicks(t.loopStart),this._loopEnd=this.toTicks(t.loopEnd),this._playbackRate=t.playbackRate,this._probability=t.probability,this._humanize=t.humanize,this.mute=t.mute,this._playbackRate=t.playbackRate,this._state.increasing=!0,this._rescheduleEvents()}static getDefaults(){return Object.assign(Vy.getDefaults(),{callback:_y,humanize:!1,loop:!1,loopEnd:`1m`,loopStart:0,mute:!1,playbackRate:1,probability:1,value:null})}_rescheduleEvents(e=-1){this._state.forEachFrom(e,e=>{let t;if(e.state===`started`){e.id!==-1&&this.context.transport.clear(e.id);let n=e.time+Math.round(this.startOffset/this._playbackRate);if(this._loop===!0||vv(this._loop)&&this._loop>1){t=1/0,vv(this._loop)&&(t=this._loop*this._getLoopDuration());let r=this._state.getAfter(n);r!==null&&(t=Math.min(t,r.time-n)),t!==1/0&&(t=new sb(this.context,t));let i=new sb(this.context,this._getLoopDuration());e.id=this.context.transport.scheduleRepeat(this._tick.bind(this),i,new sb(this.context,n),t)}else e.id=this.context.transport.schedule(this._tick.bind(this),new sb(this.context,n))}})}get state(){return this._state.getValueAtTime(this.context.transport.ticks)}get startOffset(){return this._startOffset}set startOffset(e){this._startOffset=e}get probability(){return this._probability}set probability(e){this._probability=e}get humanize(){return this._humanize}set humanize(e){this._humanize=e}start(e){let t=this.toTicks(e);return this._state.getValueAtTime(t)===`stopped`&&(this._state.add({id:-1,state:`started`,time:t}),this._rescheduleEvents(t)),this}stop(e){this.cancel(e);let t=this.toTicks(e);if(this._state.getValueAtTime(t)===`started`){this._state.setStateAtTime(`stopped`,t,{id:-1});let e=this._state.getBefore(t),n=t;e!==null&&(n=e.time),this._rescheduleEvents(n)}return this}cancel(e){e=Xv(e,-1/0);let t=this.toTicks(e);return this._state.forEachFrom(t,e=>{this.context.transport.clear(e.id)}),this._state.cancel(t),this}_tick(e){let t=this.context.transport.getTicksAtTime(e);if(!this.mute&&this._state.getValueAtTime(t)===`started`){if(this.probability<1&&Math.random()>this.probability)return;if(this.humanize){let t=.02;bv(this.humanize)||(t=this.toSeconds(this.humanize)),e+=(Math.random()*2-1)*t}this.callback(e,this.value)}}_getLoopDuration(){return(this._loopEnd-this._loopStart)/this._playbackRate}get loop(){return this._loop}set loop(e){this._loop=e,this._rescheduleEvents()}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._rescheduleEvents()}get loopEnd(){return new sb(this.context,this._loopEnd).toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e),this._loop&&this._rescheduleEvents()}get loopStart(){return new sb(this.context,this._loopStart).toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e),this._loop&&this._rescheduleEvents()}get progress(){if(this._loop){let e=this.context.transport.ticks,t=this._state.get(e);if(t!==null&&t.state===`started`){let n=this._getLoopDuration();return(e-t.time)%n/n}return 0}return 0}dispose(){return super.dispose(),this.cancel(),this._state.dispose(),this}},ux=class e extends lx{constructor(){let t=q(e.getDefaults(),arguments,[`callback`,`events`]);super(t),this.name=`Part`,this._state=new Hy(`stopped`),this._events=new Set,this._state.increasing=!0,t.events.forEach(e=>{xv(e)?this.add(e[0],e[1]):this.add(e)})}static getDefaults(){return Object.assign(lx.getDefaults(),{events:[]})}start(e,t){let n=this.toTicks(e);if(this._state.getValueAtTime(n)!==`started`){t=Xv(t,this._loop?this._loopStart:0),t=this._loop?Xv(t,this._loopStart):Xv(t,0);let e=this.toTicks(t);this._state.add({id:-1,offset:e,state:`started`,time:n}),this._forEach(t=>{this._startNote(t,n,e)})}return this}_startNote(e,t,n){t-=n,this._loop?e.startOffset>=this._loopStart&&e.startOffset<this._loopEnd?(e.startOffset<n&&(t+=this._getLoopDuration()),e.start(new sb(this.context,t))):e.startOffset<this._loopStart&&e.startOffset>=n&&(e.loop=!1,e.start(new sb(this.context,t))):e.startOffset>=n&&e.start(new sb(this.context,t))}get startOffset(){return this._startOffset}set startOffset(e){this._startOffset=e,this._forEach(e=>{e.startOffset+=this._startOffset})}stop(e){let t=this.toTicks(e);return this._state.cancel(t),this._state.setStateAtTime(`stopped`,t),this._forEach(t=>{t.stop(e)}),this}at(e,t){let n=new By(this.context,e).toTicks(),r=new sb(this.context,1).toSeconds(),i=this._events.values(),a=i.next();for(;!a.done;){let e=a.value;if(Math.abs(n-e.startOffset)<r)return G(t)&&(e.value=t),e;a=i.next()}return G(t)?(this.add(e,t),this.at(e)):null}add(e,t){e instanceof Object&&Reflect.has(e,`time`)&&(t=e,e=t.time);let n=this.toTicks(e),r;return t instanceof lx?(r=t,r.callback=this._tick.bind(this)):r=new lx({callback:this._tick.bind(this),context:this.context,value:t}),r.startOffset=n,r.set({humanize:this.humanize,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,playbackRate:this.playbackRate,probability:this.probability}),this._events.add(r),this._restartEvent(r),this}_restartEvent(e){this._state.forEach(t=>{t.state===`started`?this._startNote(e,t.time,t.offset):e.stop(new sb(this.context,t.time))})}remove(e,t){return yv(e)&&e.hasOwnProperty(`time`)&&(t=e,e=t.time),e=this.toTicks(e),this._events.forEach(n=>{n.startOffset===e&&(gv(t)||G(t)&&n.value===t)&&(this._events.delete(n),n.dispose())}),this}clear(){return this._forEach(e=>e.dispose()),this._events.clear(),this}cancel(e){return this._forEach(t=>t.cancel(e)),this._state.cancel(this.toTicks(e)),this}_forEach(t){return this._events&&this._events.forEach(n=>{n instanceof e?n._forEach(t):t(n)}),this}_setAll(e,t){this._forEach(n=>{n[e]=t})}_tick(e,t){this.mute||this.callback(e,t)}_testLoopBoundries(e){this._loop&&(e.startOffset<this._loopStart||e.startOffset>=this._loopEnd)?e.cancel(0):e.state===`stopped`&&this._restartEvent(e)}get probability(){return this._probability}set probability(e){this._probability=e,this._setAll(`probability`,e)}get humanize(){return this._humanize}set humanize(e){this._humanize=e,this._setAll(`humanize`,e)}get loop(){return this._loop}set loop(e){this._loop=e,this._forEach(t=>{t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.loop=e,this._testLoopBoundries(t)})}get loopEnd(){return new sb(this.context,this._loopEnd).toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e),this._loop&&this._forEach(t=>{t.loopEnd=e,this._testLoopBoundries(t)})}get loopStart(){return new sb(this.context,this._loopStart).toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e),this._loop&&this._forEach(e=>{e.loopStart=this.loopStart,this._testLoopBoundries(e)})}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._setAll(`playbackRate`,e)}get length(){return this._events.size}dispose(){return super.dispose(),this.clear(),this}},dx=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`fade`]);super(t),this.name=`CrossFade`,this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new Wb({context:this.context}),this.a=new Z({context:this.context,gain:0}),this.b=new Z({context:this.context,gain:0}),this.output=new Z({context:this.context}),this._internalChannels=[this.a,this.b],this.fade=new Jy({context:this.context,units:`normalRange`,value:t.fade}),J(this,`fade`),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode=`explicit`,Wy(this._split,this.a.gain,0),Wy(this._split,this.b.gain,1),this.fade.chain(this._g2a,this._panner.pan),this.a.connect(this.output),this.b.connect(this.output)}static getDefaults(){return Object.assign(X.getDefaults(),{fade:.5})}dispose(){return super.dispose(),this.a.dispose(),this.b.dispose(),this.output.dispose(),this.fade.dispose(),this._g2a.dispose(),this._panner.disconnect(),this._split.disconnect(),this}},fx=class extends X{constructor(e){super(e),this.name=`Effect`,this._dryWet=new dx({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new Z({context:this.context}),this.effectReturn=new Z({context:this.context}),this.input=new Z({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(e.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],J(this,`wet`)}static getDefaults(){return Object.assign(X.getDefaults(),{wet:1})}connectEffect(e){return this._internalChannels.push(e),this.effectSend.chain(e,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}},px=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`pan`]);super(t),this.name=`Panner`,this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new Y({context:this.context,param:this._panner.pan,value:t.pan,minValue:-1,maxValue:1}),this._panner.channelCount=t.channelCount,this._panner.channelCountMode=`explicit`,J(this,`pan`)}static getDefaults(){return Object.assign(X.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}};ox(`bit-crusher`,`
|
|
254
|
+
class BitCrusherWorklet extends SingleIOProcessor {
|
|
255
|
+
|
|
256
|
+
static get parameterDescriptors() {
|
|
257
|
+
return [{
|
|
258
|
+
name: "bits",
|
|
259
|
+
defaultValue: 12,
|
|
260
|
+
minValue: 1,
|
|
261
|
+
maxValue: 16,
|
|
262
|
+
automationRate: 'k-rate'
|
|
263
|
+
}];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
generate(input, _channel, parameters) {
|
|
267
|
+
const step = Math.pow(0.5, parameters.bits - 1);
|
|
268
|
+
const val = step * Math.floor(input / step + 0.5);
|
|
269
|
+
return val;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
`);var mx=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`channels`]);super(t),this.name=`Merge`,this._merger=this.output=this.input=this.context.createChannelMerger(t.channels)}static getDefaults(){return Object.assign(X.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}},hx=class e extends fx{constructor(){let t=q(e.getDefaults(),arguments,[`decay`]);super(t),this.name=`Reverb`,this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();let n=this.toSeconds(t.decay);wv(n,.001),this._decay=n;let r=this.toSeconds(t.preDelay);wv(r,0),this._preDelay=r,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(fx.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(e){e=this.toSeconds(e),wv(e,.001),this._decay=e,this.generate()}get preDelay(){return this._preDelay}set preDelay(e){e=this.toSeconds(e),wv(e,0),this._preDelay=e,this.generate()}generate(){return zv(this,void 0,void 0,function*(){let e=this.ready,t=new yy(2,this._decay+this._preDelay,this.context.sampleRate),n=new bb({context:t}),r=new bb({context:t}),i=new mx({context:t});n.connect(i,0,0),r.connect(i,0,1);let a=new Z({context:t}).toDestination();i.connect(a),n.start(0),r.start(0),a.gain.setValueAtTime(0,0),a.gain.setValueAtTime(1,this._preDelay),a.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);let o=t.render();return this.ready=o.then(_y),yield e,this._convolver.buffer=(yield o).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}},gx=class e extends fx{constructor(){let t=q(e.getDefaults(),arguments,[`frequency`,`depth`]);super(t),this.name=`Vibrato`,this._delayNode=new eb({context:this.context,delayTime:0,maxDelay:t.maxDelay}),this._lfo=new Bb({context:this.context,type:t.type,min:0,max:t.maxDelay,frequency:t.frequency,phase:-90}).start().connect(this._delayNode.delayTime),this.frequency=this._lfo.frequency,this.depth=this._lfo.amplitude,this.depth.value=t.depth,J(this,[`frequency`,`depth`]),this.effectSend.chain(this._delayNode,this.effectReturn)}static getDefaults(){return Object.assign(fx.getDefaults(),{maxDelay:.005,frequency:5,depth:.1,type:`sine`})}get type(){return this._lfo.type}set type(e){this._lfo.type=e}dispose(){return super.dispose(),this._delayNode.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}},_x=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`solo`]);super(t),this.name=`Solo`,this.input=this.output=new Z({context:this.context}),e._allSolos.has(this.context)||e._allSolos.set(this.context,new Set),e._allSolos.get(this.context).add(this),this.solo=t.solo}static getDefaults(){return Object.assign(X.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),e._allSolos.get(this.context).forEach(e=>e._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){e._soloed.has(this.context)||e._soloed.set(this.context,new Set),e._soloed.get(this.context).add(this)}_removeSolo(){e._soloed.has(this.context)&&e._soloed.get(this.context).delete(this)}_isSoloed(){return e._soloed.has(this.context)&&e._soloed.get(this.context).has(this)}_noSolos(){return!e._soloed.has(this.context)||e._soloed.has(this.context)&&e._soloed.get(this.context).size===0}_updateSolo(){this._isSoloed()||this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),e._allSolos.get(this.context).delete(this),this._removeSolo(),this}};_x._allSolos=new Map,_x._soloed=new Map;var vx=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`pan`,`volume`]);super(t),this.name=`PanVol`,this._panner=this.input=new px({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new tb({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,J(this,[`pan`,`volume`])}static getDefaults(){return Object.assign(X.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}},yx=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`volume`,`pan`]);super(t),this.name=`Channel`,this._solo=this.input=new _x({solo:t.solo,context:this.context}),this._panVol=this.output=new vx({context:this.context,pan:t.pan,volume:t.volume,mute:t.mute,channelCount:t.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),J(this,[`pan`,`volume`])}static getDefaults(){return Object.assign(X.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(e){this._solo.solo=e}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(e){this._panVol.mute=e}_getBus(t){return e.buses.has(t)||e.buses.set(t,new Z({context:this.context})),e.buses.get(t)}send(e,t=0){let n=this._getBus(e),r=new Z({context:this.context,units:`decibels`,gain:t});return this.connect(r),r.connect(n),r}receive(e){return this._getBus(e).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}};yx.buses=new Map;var bx=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`threshold`,`ratio`]);super(t),this.name=`Compressor`,this._compressor=this.context.createDynamicsCompressor(),this.input=this._compressor,this.output=this._compressor,this.threshold=new Y({minValue:this._compressor.threshold.minValue,maxValue:this._compressor.threshold.maxValue,context:this.context,convert:!1,param:this._compressor.threshold,units:`decibels`,value:t.threshold}),this.attack=new Y({minValue:this._compressor.attack.minValue,maxValue:this._compressor.attack.maxValue,context:this.context,param:this._compressor.attack,units:`time`,value:t.attack}),this.release=new Y({minValue:this._compressor.release.minValue,maxValue:this._compressor.release.maxValue,context:this.context,param:this._compressor.release,units:`time`,value:t.release}),this.knee=new Y({minValue:this._compressor.knee.minValue,maxValue:this._compressor.knee.maxValue,context:this.context,convert:!1,param:this._compressor.knee,units:`decibels`,value:t.knee}),this.ratio=new Y({minValue:this._compressor.ratio.minValue,maxValue:this._compressor.ratio.maxValue,context:this.context,convert:!1,param:this._compressor.ratio,units:`positive`,value:t.ratio}),J(this,[`knee`,`release`,`attack`,`ratio`,`threshold`])}static getDefaults(){return Object.assign(X.getDefaults(),{attack:.003,knee:30,ratio:12,release:.25,threshold:-24})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.disconnect(),this.attack.dispose(),this.release.dispose(),this.threshold.dispose(),this.ratio.dispose(),this.knee.dispose(),this}},xx=class e extends X{constructor(){let t=q(e.getDefaults(),arguments,[`threshold`]);super(t),this.name=`Limiter`,this._compressor=this.input=this.output=new bx({context:this.context,ratio:20,attack:.003,release:.01,threshold:t.threshold}),this.threshold=this._compressor.threshold,J(this,`threshold`)}static getDefaults(){return Object.assign(X.getDefaults(),{threshold:-12})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.dispose(),this.threshold.dispose(),this}};Sy().transport,Sy().destination,Sy().destination;function Sx(){return Sy().destination}Sy().listener,Sy().draw,Sy();function Cx(e){let t=new Set;for(let n of Object.values(e.instruments))for(let e of n?.layers??[])for(let n of Object.values(e.zones))t.add(n);for(let n of Object.values(e.drums.pieces))for(let e of n??[])for(let n of e.files)t.add(n);for(let n of Object.values(e.ambience))t.add(n.file);return[...t]}async function wx(e,t,n){let r=Cx(e),i=new Map,a=0;return await Promise.all(r.map(async e=>{let o=await t(e);i.set(e,new vy(o)),n?.(++a,r.length)})),{manifest:e,buffers:i}}function Tx(e){let t=e.endsWith(`/`)?e:`${e}/`;return async e=>{let n=await fetch(t+e);if(!n.ok)throw Error(`Couldn't load ${e} (${n.status})`);return Sy().decodeAudioData(await n.arrayBuffer())}}function Ex(e,t){let n=e.buffers.get(t);if(!n)throw Error(`Sample ${t} isn't loaded`);return n}var Dx={piano:0,wurli:-9,"fm-ep":-2,glock:-9,marimba:-2,harp:-3,pad:-11,pluck:-6,bass:-19,drums:0},Ox={piano:[12,0]},kx=e=>.45+.55*e,Ax={kick:0,snare:-3,brush:8,rim:-4,hat:-9,brushhat:2,openhat:-12,ride:-10,tom:-4},jx=.55;function Mx(e){return Math.max(0,Math.min(1,e))**2}var Nx=e=>10**(e/20),Px=e=>1e3*2**(Math.max(0,Math.min(1,e))*4);function Fx(e,t,n,r){let i=new Z(Nx(Dx[e]));return r.connect(i),{output:i,play(e,n,i){r.frequency.setValueAtTime(Px(e.brightness),n),t(e).triggerAttackRelease(zy(e.midi,`midi`).toFrequency(),i,n,e.velocity)},dispose(){for(let e of n)e.dispose();r.dispose(),i.dispose()}}}function Ix(e,t){let n=t.manifest.instruments[e];if(!n)throw Error(`No samples for ${e}`);let r=new $b({type:`lowpass`,frequency:12e3,rolloff:-12}),i=Ox[e]??[],a=[],o=n.layers.map((e,o)=>{let s={};for(let[n,r]of Object.entries(e.zones))s[Number(n)]=Ex(t,r);let c=new Z(Nx(i[o]??0)).connect(r),l=new cx({urls:s,release:n.release}).connect(c);return a.push(l,c),{maxVelocity:e.maxVelocity,sampler:l}});return Fx(e,e=>{let{sampler:t}=id(o,e.velocity);return{triggerAttackRelease:(e,n,r,i)=>t.triggerAttackRelease(e,n,r,kx(i)),dispose(){}}},a,r)}function Lx(e){let t=new $b({type:`lowpass`,frequency:8e3,rolloff:-12}),n;switch(e){case`fm-ep`:n=new sx(nx,{harmonicity:1,modulationIndex:3.5,oscillator:{type:`sine`},modulation:{type:`sine`},envelope:{attack:.002,decay:1.8,sustain:.18,release:.9},modulationEnvelope:{attack:.002,decay:.45,sustain:.08,release:.6}});break;case`pad`:n=new sx(Xb,{oscillator:{type:`fatsawtooth`,count:3,spread:16},envelope:{attack:.9,decay:.6,sustain:.8,release:2.4}}),t.Q.value=.5;break;case`pluck`:n=new sx(Xb,{oscillator:{type:`triangle`},envelope:{attack:.003,decay:.4,sustain:0,release:.35}});break;case`bass`:n=new sx(tx,{oscillator:{type:`triangle`},envelope:{attack:.008,decay:.35,sustain:.65,release:.35},filter:{Q:1,type:`lowpass`,rolloff:-24},filterEnvelope:{attack:.005,decay:.25,sustain:.35,release:.4,baseFrequency:110,octaves:2.6}}),n.maxPolyphony=4;break;default:throw Error(`${e} isn't a synth`)}return n.connect(t),Fx(e,()=>n,[n],t)}function Rx(e){let t=new Z(Nx(Dx.drums)),n=new Map(Ae.map(e=>[e,new Z(Nx(Ax[e])).connect(t)]));return{output:t,play(r,i){let a=r.drum,o=a&&e.manifest.drums.pieces[a];if(!a||!o?.length)return;let s=id(o,r.velocity).files,c=s[Math.floor(r.time*4+.01)%s.length],l=new yb({url:Ex(e,c),context:t.context}).connect(n.get(a));l.onended=()=>l.dispose(),l.start(i,0,void 0,r.velocity**1.2)},dispose(){for(let e of n.values())e.dispose();t.dispose()}}}function zx(e,t){return we[e].kind===`drums`?Rx(t):t.manifest.instruments[e]?Ix(e,t):Lx(e)}var Bx=7;function Vx(e){let t=El(7),n=new Float32Array(Math.floor(e*Bx)),r=0;for(;r<n.length;){r+=Math.floor(-Math.log(1-t())*e/38);let i=t()<.04,a=(i?.6+t()*.4:.05+t()**3*.35)*(t()<.5?-1:1),o=i?24+Math.floor(t()*40):2+Math.floor(t()*6);for(let e=0;e<o&&r+e<n.length;e++)n[r+e]+=a*Math.exp(-e/(o/3))}let i=0,a=0;for(let e=0;e<n.length;e++){let t=n[e];a=.97*(a+t-i),i=t,n[e]=a}return vy.fromArray(n)}function Hx(e=2.2){let t=2048,n=new Float32Array(t),r=Math.tanh(e);for(let i=0;i<t;i++){let t=i/2047*2-1;n[i]=Math.tanh(t*e)/r}return n}var Ux=class{input=new Z(1);ready;drive=new Z(1);saturate=new pb(Hx(),2048);trim=new Z(1);warmth=new $b({type:`lowpass`,frequency:16e3,rolloff:-12,Q:.4});wobble=new gx({frequency:.55,depth:0,maxDelay:.006,type:`sine`});reverb=new hx({decay:3.2,preDelay:.02,wet:1});reverbReturn=new Z(0);bus=new Z(1);highpass=new $b({type:`highpass`,frequency:32,rolloff:-12});comp=new bx({threshold:-20,ratio:3,attack:.015,release:.25,knee:8});makeup=new Z(Nx(6));fader=new Z(1);limiter=new xx(-1);crackle;crackleGain=new Z(0);hiss=new bb(`pink`);hissGain=new Z(0);hissFilter=new $b({type:`bandpass`,frequency:5e3,Q:.4});rain=new Ub({loop:!0,fadeIn:1.5,fadeOut:.5});rainGain=new Z(0);rainFile=null;bank;constructor(e){this.bank=e,this.input.chain(this.drive,this.saturate,this.trim,this.warmth,this.wobble),this.wobble.connect(this.bus),this.wobble.chain(this.reverb,this.reverbReturn,this.bus),this.bus.chain(this.highpass,this.comp,this.makeup,this.fader,this.limiter,Sx()),this.crackle=new Ub({url:Vx(Sy().sampleRate),loop:!0}),this.crackle.chain(this.crackleGain,this.fader),this.hiss.chain(this.hissFilter,this.hissGain,this.fader),this.rain.chain(this.rainGain,this.fader),this.ready=this.reverb.ready}apply(e){let t=e.warmth;this.drive.gain.value=Nx(t*10),this.trim.gain.value=Nx(-t*8),this.warmth.frequency.value=16e3*(2600/16e3)**t,this.wobble.depth.value=e.wobble*.35,this.wobble.frequency.value=.4+e.wobble*.5,this.reverbReturn.gain.value=e.reverb*jx,this.fader.gain.value=Mx(e.master)*1.56,this.crackleGain.gain.value=e.crackle>0?Nx(-12)*e.crackle**1.5:0,this.hissGain.gain.value=e.crackle>0?Nx(-46)*e.crackle:0;let n=this.bank.manifest.ambience[e.rain.kind===`roof`?`rain_roof`:`rain_window`].file;n!==this.rainFile&&(this.rainFile=n,this.rain.buffer=Ex(this.bank,n)),this.rainGain.gain.value=e.rain.enabled?Nx(12)*Mx(e.rain.level):0}startAmbience(e,t=0){this.crackle.state!==`started`&&this.crackle.start(e),this.hiss.state!==`started`&&this.hiss.start(e),this.rain.state!==`started`&&this.rain.loaded&&this.rain.start(e,t)}stopAmbience(e){this.crackle.stop(e),this.hiss.stop(e),this.rain.stop(e)}dispose(){for(let e of[this.input,this.drive,this.saturate,this.trim,this.warmth,this.wobble,this.reverb,this.reverbReturn,this.bus,this.highpass,this.comp,this.makeup,this.fader,this.limiter,this.crackle,this.crackleGain,this.hiss,this.hissGain,this.hissFilter,this.rain,this.rainGain])e.dispose()}},Wx=[`chords`,`bass`,`drums`];function Gx(e,t){if(!e.track.startsWith(`backing:`))return e.track;let n=t.sections.findLast(t=>e.time>=t.start-.5)??t.sections[0];return`${e.track}@${n?.sceneId??``}`}function Kx(e){let t=new Map;for(let n of e.scenes){for(let e of n.layers)t.set(e.id,{volume:e.volume,pan:e.pan});for(let e of Wx)t.set(`backing:${e}@${n.id}`,{volume:n.backing[e].volume,pan:0})}return t}var qx=class{master;ready;bank;tracks=new Map;settings=new Map;part=null;constructor(e){this.bank=e,this.master=new Ux(e),this.ready=this.master.ready}sync(e){this.settings=Kx(e),this.master.apply(e.mix);for(let[e,t]of this.tracks){let n=this.settings.get(e);n?this.applySettings(t,n):this.disposeTrack(e,t)}}applySettings(e,t){let n=Mx(t.volume)*1.56;e.channel.volume.value=n>0?Ey(n):-1/0,e.channel.pan.value=t.pan}voice(e,t){let n=this.tracks.get(e);n||(n={channel:new yx().connect(this.master.input),voices:new Map},this.applySettings(n,this.settings.get(e)??{volume:.8,pan:0}),this.tracks.set(e,n));let r=n.voices.get(t);return r||(r=zx(t,this.bank),r.output.connect(n.channel),n.voices.set(t,r)),r}schedule(e){this.part?.dispose();let t=e.events.map(t=>{let n=Gx(t,e);return this.voice(n,t.instrument),{time:Math.max(0,Ll(t.time,e.bpm)),e:t,key:n,seconds:Math.max(.03,Ll(t.duration,e.bpm))}});this.part=new ux((e,t)=>this.voice(t.key,t.e.instrument).play(t.e,e,t.seconds),t),this.part.start(0)}clear(){this.part?.dispose(),this.part=null}disposeTrack(e,t){for(let e of t.voices.values())e.dispose();t.channel.dispose(),this.tracks.delete(e)}dispose(){this.clear();for(let[e,t]of this.tracks)this.disposeTrack(e,t);this.master.dispose()}},Jx=.05;function Yx(e,t){if(t<=1)return e;let n={...e,beats:e.beats*t,events:[],chords:[],sections:[]};for(let r=0;r<t;r++){let t=r*e.beats;n.events.push(...e.events.map(e=>({...e,time:e.time+t}))),n.chords.push(...e.chords.map(e=>({...e,time:e.time+t}))),n.sections.push(...e.sections.map(e=>({...e,start:e.start+t})))}return n}function Xx(e,t={}){return t.scope===`song`?Du(e):Yx(Eu(e,t.sceneId),t.loops??1)}var Zx=Promise.resolve();function Qx(e,t,n={}){let r=Zx.then(()=>$x(e,t,n));return Zx=r.catch(()=>{}),r}async function $x(e,t,n){let r=Xx(e,n),i=n.sampleRate??44100,a=(await ib(async n=>{let i=new qx(t);i.sync(e),await i.ready,n.transport.bpm.value=r.bpm,i.schedule(r),i.master.startAmbience(0),n.transport.start(Jx)},Jx+Ll(r.beats,r.bpm)+(n.tail??3),2,i)).get();if(!a)throw Error(`Render came back empty`);let o=Array.from({length:a.numberOfChannels},(e,t)=>a.getChannelData(t));return{sampleRate:a.sampleRate,channels:o}}function eS({sampleRate:e,channels:t}){let n=t.length,r=t[0]?.length??0,i=r*n*2,a=new Uint8Array(44+i),o=new DataView(a.buffer),s=(e,t)=>{for(let n=0;n<t.length;n++)o.setUint8(e+n,t.charCodeAt(n))};s(0,`RIFF`),o.setUint32(4,36+i,!0),s(8,`WAVE`),s(12,`fmt `),o.setUint32(16,16,!0),o.setUint16(20,1,!0),o.setUint16(22,n,!0),o.setUint32(24,e,!0),o.setUint32(28,e*n*2,!0),o.setUint16(32,n*2,!0),o.setUint16(34,16,!0),s(36,`data`),o.setUint32(40,i,!0);let c=44;for(let e=0;e<r;e++)for(let r=0;r<n;r++){let n=(Math.random()-Math.random())/32768,i=Math.max(-1,Math.min(1,t[r][e]+n));o.setInt16(c,Math.round(i*32767),!0),c+=2}return a}var tS=new class{rig=null;bank=null;context=null;loading=null;project=null;score=null;scheduledKey=``;exporting=!1;listeners=new Set;status={state:`idle`};playing=!1;mode=`loop`;manifest=null;subscribe(e){return this.listeners.add(e),()=>void this.listeners.delete(e)}emit(){for(let e of this.listeners)e()}setStatus(e){this.status=e,this.emit()}get transport(){return this.context.transport}load(){return this.loading??=(async()=>{try{this.context=Sy();let e=await fetch(`/manifest.json`);if(!e.ok)throw Error(`Couldn't load the sample manifest (${e.status})`);this.manifest=await e.json(),this.setStatus({state:`loading`,loaded:0,total:1}),this.bank=await wx(this.manifest,Tx(`/`),(e,t)=>this.setStatus({state:`loading`,loaded:e,total:t})),this.rig=new qx(this.bank),await this.rig.ready,this.setStatus({state:`ready`}),this.project&&this.update(this.project)}catch(e){this.loading=null,this.setStatus({state:`error`,message:e instanceof Error?e.message:String(e)})}})(),this.loading}update(e){this.project=e;let t=this.rig;if(!t||this.exporting)return;t.sync(e);let n=this.mode===`song`?Du(e):Eu(e),r=`${this.mode}|${n.bpm}|${n.beats}|${JSON.stringify(n.events)}`;if(this.score=n,r===this.scheduledKey)return;this.scheduledKey=r;let i=this.transport;i.bpm.value=n.bpm,i.loop=!0,i.loopStart=0,i.loopEnd=Ll(n.beats,n.bpm),t.schedule(n)}setMode(e){e!==this.mode&&(this.mode=e,this.playing&&(this.transport.position=0),this.project&&this.update(this.project),this.emit())}async play(){await wy(),await this.load(),!this.rig||this.playing||this.exporting||(this.transport.start(`+0.05`,0),this.rig.master.startAmbience(this.context.now(),Math.random()*20),this.playing=!0,this.emit())}stop(){this.rig&&this.playing&&(this.transport.stop(),this.rig.master.stopAmbience(this.context.now()),this.playing=!1,this.emit())}toggle(){return this.playing?this.stop():this.play()}position(){if(!this.playing||!this.score||this.exporting)return null;let e=Math.max(0,this.transport.seconds*this.score.bpm/60)%this.score.beats,t=this.score.sections.findLast(t=>e>=t.start)??this.score.sections[0];return t?{sceneId:t.sceneId,beat:e-t.start}:null}async render(e,t){if(await this.load(),!this.bank)throw Error(`Sounds aren't loaded yet`);this.stop(),this.exporting=!0,this.emit();try{return await Qx(e,this.bank,t)}finally{this.exporting=!1,this.scheduledKey=``,this.project&&this.update(this.project),this.emit()}}get isExporting(){return this.exporting}},nS=Cc().min(0).max(1),rS=z({x:nS.describe(`0 is the start of the scene, 1 the end`),y:nS.describe(`0 is the top (high notes), 1 the bottom`)}),iS={scene:R().optional().describe(`Scene id or name. Defaults to the active scene.`),layer:R().optional().describe(`Layer id or name. Defaults to the first melodic layer.`)},aS={...iS,brush:Hc(De).optional().describe(`pencil: eighth-note melody. brush: long soft notes. chalk: two-note harmonies. spray: scattered sparkles. stamp: one hit per sixteenth.`),size:nS.optional().describe(`Brush thickness. Thicker plays softer and darker. Default 0.3.`),velocity:nS.optional().describe(`How hard to play, like pen pressure. Leave out to use drawing speed.`),duration_ms:Cc().min(20).max(2e4).optional().describe(`How long the stroke takes to draw. Faster strokes play louder. Default 1500.`)},oS=Rc(`type`,[z({type:B(`set_project`),name:R().min(1).max(80).optional(),bpm:Cc().min(50).max(140).optional(),swing:nS.optional(),humanize:nS.optional(),window:Hc(Le).optional().describe(`What you see outside the window`)}),z({type:B(`set_key`),tonic:R().regex(/^[A-Ga-g][#b]?$/).describe(`Like C, F#, or Bb`),mode:Hc(ee)}),z({type:B(`set_mood`),mood:Hc(wl),keep_key:Dc().optional().describe(`Keep the current key instead of the mood key`),scene:iS.scene}),z({type:B(`set_progression`),progression:R().describe(`A preset id, or chords like "ii9 V13 Imaj9 vi9" or "Em9 A13 Dmaj9:2 Bm9:2". ":N" sets beats, default 4.`),scene:iS.scene}),z({type:B(`set_backing`),scene:iS.scene,chords:z({enabled:Dc(),instrument:Hc(Fe),style:Hc(Ne),volume:nS}).partial().optional(),bass:z({enabled:Dc(),style:Hc(Pe),volume:nS}).partial().optional(),drums:z({enabled:Dc(),groove:Hc(Ie),volume:nS}).partial().optional()}),z({type:B(`mix`),master:nS.optional(),warmth:nS.optional(),crackle:nS.optional(),reverb:nS.optional(),wobble:nS.optional(),rain:z({enabled:Dc(),kind:Hc(Re),level:nS}).partial().optional()}),z({type:B(`add_layer`),instrument:Hc(Te),name:R().min(1).max(40).optional(),color:R().optional(),harmony:Hc(Oe).optional(),octave:Cc().int().min(-2).max(2).optional(),kit:Hc(je).optional(),scene:iS.scene}),z({type:B(`update_layer`),layer:R(),scene:iS.scene,name:R().min(1).max(40).optional(),instrument:Hc(Te).optional(),color:R().optional(),volume:nS.optional(),pan:Cc().min(-1).max(1).optional(),muted:Dc().optional(),solo:Dc().optional(),harmony:Hc(Oe).optional(),octave:Cc().int().min(-2).max(2).optional(),kit:Hc(je).optional()}),z({type:B(`remove_layer`),layer:R(),scene:iS.scene}),z({type:B(`draw_path`),...aS,points:Nc(z({x:nS,y:nS,t:Cc().min(0).optional(),p:nS.optional()})).min(1).max(5e3)}),z({type:B(`draw_line`),...aS,from:rS,to:rS}),z({type:B(`draw_curve`),...aS,points:Nc(rS).min(2).max(64).describe(`A smooth curve passes through every point`)}),z({type:B(`draw_shape`),...aS,shape:Hc(Ou),x:nS.describe(`Left edge`),y:nS.describe(`Vertical center`),width:Cc().min(.005).max(1),height:Cc().min(0).max(1),cycles:Cc().min(.5).max(32).optional().describe(`Waves, zigzags, or stair steps across the width`)}),z({type:B(`draw_melody`),...iS,notes:Nc(z({pitch:Ic([R(),Cc().int().min(0).max(127)]).describe(`Like "A4" or a MIDI number. Played exactly, no snapping.`),beat:Cc().min(0).describe(`Start, in beats from the start of the scene (4 per bar)`),beats:Cc().min(.25).max(16).optional().describe(`Length in beats. Default 1.`),velocity:nS.optional()})).min(1).max(256)}),z({type:B(`erase`),...iS,strokes:Nc(R()).optional().describe(`Stroke ids to remove`),region:z({x0:nS,x1:nS,y0:nS.optional(),y1:nS.optional()}).optional().describe(`Remove strokes that pass through this box`),all:Dc().optional().describe(`Clear the whole layer`)}),z({type:B(`add_scene`),name:R().min(1).max(40),bars:Cc().int().min(1).max(16).optional(),copy_from:R().optional().describe(`Scene to copy layers, chords, and backing from`),progression:R().optional(),select:Dc().optional().describe(`Make it the active scene. Default true.`)}),z({type:B(`update_scene`),scene:R(),name:R().min(1).max(40).optional(),bars:Cc().int().min(1).max(16).optional()}),z({type:B(`remove_scene`),scene:R()}),z({type:B(`select_scene`),scene:R()}),z({type:B(`arrange`),items:Nc(z({scene:R(),repeat:Cc().int().min(1).max(16).optional()})).min(1).max(64)}),z({type:B(`describe`),scene:iS.scene})]),sS=[`describe`],cS=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function lS(e){let t=e.duration_ms??1500;switch(e.type){case`draw_path`:return e.points.every(e=>e.t!==void 0)?e.points.map(t=>{let n=t.p??e.velocity;return{x:t.x,y:t.y,t:t.t,...n===void 0?{}:{p:n}}}):Au(e.points,t,e.velocity).map((t,n)=>e.points[n].p===void 0?t:{...t,p:e.points[n].p});case`draw_line`:return Au(ju(e.from,e.to),t,e.velocity);case`draw_curve`:return Au(Mu(e.points),t,e.velocity);case`draw_shape`:return Au(Nu(e.shape,e),t,e.velocity)}}function uS(e,t,n,r){let i=Eu({...e,swing:0,humanize:0,scenes:e.scenes.map(e=>e.id===t?{...e,layers:e.layers.map(e=>({...e,muted:!1,solo:!1}))}:e)},t).events.filter(e=>e.strokeId&&r.has(e.strokeId));if(i.length===0)return{text:`no notes (the stroke may be outside the canvas or too small)`,count:0};let a=oe(e.key);if(we[n.instrument].kind===`drums`){let e=new Map;for(let t of i)e.set(t.drum,(e.get(t.drum)??0)+1);return{text:`${cS(i.length,`hit`)} (${[...e].map(([e,t])=>`${e} ${t}`).join(`, `)})`,count:i.length}}let o=i.slice(0,16).map(e=>`${O(e.midi,a)}@${Math.round(e.time*100)/100}`),s=i.length>16?` and ${i.length-16} more`:``;return{text:`${cS(i.length,`note`)} (pitch@beat): ${o.join(` `)}${s}`,count:i.length}}function dS(e,t){let{scene:n,layer:r}=Il(e,t.layer,t.scene),i={id:Al(`k`),brush:t.brush??`pencil`,size:t.size??.3,points:lS(t)};r.strokes.push(i);let{text:a,count:o}=uS(e,n.id,r,new Set([i.id])),s=t.type===`draw_shape`?`${t.shape} shape`:t.type.replace(`draw_`,``);return{project:e,message:`Drew a ${i.brush} ${s} on "${r.name}" [${i.id}]: ${a}`,data:{strokeId:i.id,notes:o}}}function fS(e,t){let{scene:n,layer:r}=Il(e,t.layer,t.scene);if(we[r.instrument].kind===`drums`)throw Error(`"${r.name}" is a drum layer. Use draw_path with dots, or pick a melodic layer.`);let i=Yl(r),a=n.bars*4,o=oe(e.key),s=new Set;for(let e of t.notes){let t=typeof e.pitch==`number`?e.pitch:E(e.pitch);if(t===null)throw Error(`Can't read pitch "${e.pitch}". Use a note like "A4" or a MIDI number.`);if(t<i[0]||t>i[1])throw Error(`${O(t,o)} is outside "${r.name}" (${O(i[0],o)} to ${O(i[1],o)}). Change the layer octave or pick another note.`);let n=e.beats??1;if(e.beat+n>a+1e-6)throw Error(`A note at beat ${e.beat} lasting ${n} runs past the end of the scene (${a} beats)`);let c=Zl(t,i),l=(e.beat+.01)/a,u=(e.beat+n-.01)/a,d=Au([{x:l,y:c},{x:u,y:c}],200,e.velocity??.6),f={id:Al(`k`),brush:`pencil`,size:.3,points:d,exact:!0};r.strokes.push(f),s.add(f.id)}let{text:c}=uS(e,n.id,r,s);return{project:e,message:`Wrote a melody on "${r.name}": ${c}`,data:{strokeIds:[...s]}}}function pS(e,t){let[n,r]=[Math.min(t.x0,t.x1),Math.max(t.x0,t.x1)],[i,a]=[Math.min(t.y0??0,t.y1??1),Math.max(t.y0??0,t.y1??1)];return e.points.some(e=>e.x>=n&&e.x<=r&&e.y>=i&&e.y<=a)}function mS(e,t){let{layer:n}=Il(e,t.layer,t.scene);if(!t.all&&!t.strokes&&!t.region)throw Error(`Say what to erase: strokes, a region, or all`);let r=n.strokes.length,i=new Set(t.strokes??[]);n.strokes=t.all?[]:n.strokes.filter(e=>!i.has(e.id)&&!(t.region&&pS(e,t.region)));let a=r-n.strokes.length;return{project:e,message:`Erased ${cS(a,`stroke`)} from "${n.name}"`,data:{removed:a}}}function hS(e,t){let n=[];for(let[r,i]of Object.entries(t))i!==void 0&&(e[r]=i,n.push(r));return n}var gS=e=>e.length?e.join(`, `):`nothing`;function _S(e,t){let n=vS(structuredClone(e),t);return sS.includes(t.type)||(n.project.updatedAt=new Date().toISOString()),n}function vS(e,t){switch(t.type){case`set_project`:{let{type:n,...r}=t;return{project:e,message:`Updated ${gS(hS(e,r))}`}}case`set_key`:{e.key={tonic:t.tonic[0].toUpperCase()+t.tonic.slice(1),mode:t.mode};let n=Fl(e);return{project:e,message:`Key is now ${se(e.key)}. Chords: ${j(n.progression,e.key)}`}}case`set_mood`:{let n=Tl(t.mood),r=Fl(e,t.scene);return e.mood=t.mood,e.bpm=n.bpm,e.swing=n.swing,e.window=n.window,e.mix=structuredClone(n.mix),t.keep_key||(e.key={...n.key}),r.progression=Ce(n.progression,e.key),r.backing=structuredClone(n.backing),{project:e,message:`Mood is ${n.label}: ${se(e.key)}, ${n.bpm} BPM, chords ${j(r.progression,e.key)}. Your strokes stay put.`}}case`set_progression`:{let n=Fl(e,t.scene);return n.progression=Ce(t.progression,e.key),{project:e,message:`Scene ${n.name} chords: ${j(n.progression,e.key)}`}}case`set_backing`:{let n=Fl(e,t.scene),r=[...hS(n.backing.chords,t.chords??{}).map(e=>`chords.${e}`),...hS(n.backing.bass,t.bass??{}).map(e=>`bass.${e}`),...hS(n.backing.drums,t.drums??{}).map(e=>`drums.${e}`)];return{project:e,message:`Scene ${n.name} backing: updated ${gS(r)}`}}case`mix`:{let{type:n,rain:r,...i}=t;return{project:e,message:`Mix: updated ${gS([...hS(e.mix,i),...hS(e.mix.rain,r??{}).map(e=>`rain.${e}`)])}`}}case`add_layer`:{let n=Fl(e,t.scene),r=jl({instrument:t.instrument,name:t.name,color:t.color,index:n.layers.length});return hS(r,{harmony:t.harmony,octave:t.octave,kit:t.kit}),n.layers.push(r),{project:e,message:`Added layer "${r.name}" [${r.id}] (${we[r.instrument].label}) to scene ${n.name}`,data:{layerId:r.id}}}case`update_layer`:{let{layer:n}=Il(e,t.layer,t.scene),{type:r,layer:i,scene:a,...o}=t,s=hS(n,o);return{project:e,message:`Layer "${n.name}": updated ${gS(s)}`}}case`remove_layer`:{let{scene:n,layer:r}=Il(e,t.layer,t.scene);return n.layers=n.layers.filter(e=>e.id!==r.id),{project:e,message:`Removed layer "${r.name}" and its ${r.strokes.length} strokes`}}case`draw_path`:case`draw_line`:case`draw_curve`:case`draw_shape`:return dS(e,t);case`draw_melody`:return fS(e,t);case`erase`:return mS(e,t);case`add_scene`:{let n=t.copy_from?Fl(e,t.copy_from):null,r=n?{...structuredClone(n),id:Al(`s`),name:t.name}:Ml(e,t.name,t.bars??Fl(e).bars);if(n)for(let e of r.layers)e.id=Al(`l`);return t.bars&&(r.bars=t.bars),t.progression&&(r.progression=Ce(t.progression,e.key)),e.scenes.push(r),e.arrangement.push({sceneId:r.id,repeat:1}),t.select!==!1&&(e.activeSceneId=r.id),{project:e,message:`Added scene ${r.name} [${r.id}], ${r.bars} bars, and put it at the end of the arrangement`,data:{sceneId:r.id}}}case`update_scene`:{let n=Fl(e,t.scene),r=hS(n,{name:t.name,bars:t.bars});return{project:e,message:`Scene ${n.name}: updated ${gS(r)}`}}case`remove_scene`:{let n=Fl(e,t.scene);if(e.scenes.length===1)throw Error(`Can't remove the only scene`);return e.scenes=e.scenes.filter(e=>e.id!==n.id),e.arrangement=e.arrangement.filter(e=>e.sceneId!==n.id),e.arrangement.length===0&&(e.arrangement=[{sceneId:e.scenes[0].id,repeat:1}]),e.activeSceneId===n.id&&(e.activeSceneId=e.scenes[0].id),{project:e,message:`Removed scene ${n.name}`}}case`select_scene`:{let n=Fl(e,t.scene);return e.activeSceneId=n.id,{project:e,message:`Now editing scene ${n.name}`}}case`arrange`:return e.arrangement=t.items.map(t=>({sceneId:Fl(e,t.scene).id,repeat:t.repeat??1})),{project:e,message:`Arrangement: ${e.arrangement.map(t=>`${Fl(e,t.sceneId).name}${t.repeat>1?`×${t.repeat}`:``}`).join(` → `)}`};case`describe`:return{project:e,message:Iu(e,t.scene)}}}var yS=`127.0.0.1`,bS=5179,xS=Rc(`op`,[z({op:B(`get_project`)}),z({op:B(`execute`),commands:Nc(kc()).min(1).max(500)}),z({op:B(`open_project`),project:kc()}),z({op:B(`play`),mode:Hc([`loop`,`song`]).optional(),scene:R().optional()}),z({op:B(`stop`)}),z({op:B(`status`)})]),SS=z({op:B(`ping`)}),CS=Rc(`kind`,[z({kind:B(`hello`),app:B(`haku`),version:R().optional()}),z({kind:B(`request`),id:R().min(1).max(64),op:Ic([xS,SS])}),z({kind:B(`response`),id:R().min(1).max(64),ok:Dc(),result:kc().optional(),error:R().optional()})]);function wS(e){let t;try{t=JSON.parse(e)}catch{return null}let n=CS.safeParse(t);return n.success?n.data:null}var TS=`haku:agent-link`,ES=1e3,DS=15e3,OS=bS,kS=new class{state=`off`;enabled=localStorage.getItem(TS)!==`off`;handler=null;ws=null;timer=null;delay=ES;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>void this.listeners.delete(e));set(e){if(e!==this.state){this.state=e;for(let e of this.listeners)e()}}start(){this.enabled&&!this.ws&&!this.timer&&this.connect()}setEnabled(e){this.enabled=e,localStorage.setItem(TS,e?`on`:`off`),e?(this.delay=ES,this.start()):(this.timer&&clearTimeout(this.timer),this.timer=null,this.ws?.close(),this.ws=null,this.set(`off`))}hello=()=>this.send({kind:`hello`,app:`haku`});send(e){this.ws?.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(e))}connect(){this.timer=null,this.set(`waiting`);let e=new WebSocket(`ws://${yS}:${OS}/tab`);this.ws=e,e.onopen=()=>{this.delay=ES,this.set(`connected`),this.hello(),window.addEventListener(`focus`,this.hello)},e.onmessage=e=>void this.answer(String(e.data)),e.onclose=()=>{if(window.removeEventListener(`focus`,this.hello),this.ws===e){if(this.ws=null,!this.enabled)return this.set(`off`);this.set(`waiting`),this.timer=setTimeout(()=>this.connect(),this.delay),this.delay=Math.min(DS,this.delay*2)}}}async answer(e){let t=wS(e);if(t?.kind!==`request`||t.op.op===`ping`)return;let n=t.id;try{if(!this.handler)throw Error(`Haku is still opening`);let e=await this.handler(t.op);this.send({kind:`response`,id:n,ok:!0,result:e})}catch(e){this.send({kind:`response`,id:n,ok:!1,error:e instanceof Error?e.message:String(e)})}}},AS=`The browser won't let the Haku tab play sound until someone clicks in it once. Click anywhere in the tab, then try again.`;function jS(e){let t=e.current()??e.project,n=Fl(t);return{projectId:t.id,projectName:t.name,sceneId:n.id,sceneName:n.name,playing:tS.playing,mode:tS.mode,engine:tS.status.state}}async function MS(e,t){switch(e.op){case`get_project`:return t.current();case`execute`:return t.apply(e.commands);case`open_project`:{let n=Pl(e.project);return tS.stop(),t.open(n,`An agent opened "${n.name}".`),jS(t)}case`play`:if(e.scene&&t.apply([{type:`select_scene`,scene:e.scene}]),e.mode&&tS.setMode(e.mode),tS.update(t.current()),navigator.userActivation&&!navigator.userActivation.hasBeenActive)throw Error(AS);if(await Promise.race([tS.play(),new Promise(e=>setTimeout(e,15e3))]),!tS.playing)throw Error(tS.status.state===`error`?tS.status.message:AS);return jS(t);case`stop`:return tS.stop(),jS(t);case`status`:return jS(t)}}function NS(e){let t=(0,y.useRef)(e);return(0,y.useEffect)(()=>{t.current=e}),(0,y.useEffect)(()=>(kS.handler=e=>MS(e,t.current),kS.start(),()=>void(kS.handler=null)),[]),(0,y.useSyncExternalStore)(kS.subscribe,()=>kS.state)}var PS=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim();function FS(e,t,n){if(we[e.instrument].kind===`drums`){let t=Me(e.kit);return[1-(Math.max(0,t.indexOf(n))+1)/t.length,1/t.length]}let r=Yl(e),i=1/(r[1]-r[0]);return[Zl(t,r)-i/2,i]}var IS=[`C`,`C#`,`D`,`D#`,`E`,`F`,`F#`,`G`,`G#`,`A`,`A#`,`B`];function LS(e,t){let{width:n,height:r,scene:i,score:a,activeLayerId:o,beat:s}=t,c=r-30,l=i.bars*4,u=e=>e/l*n,d={text:PS(`--text`),muted:PS(`--text-muted`),faint:PS(`--text-faint`),border:PS(`--border`),strong:PS(`--border-strong`),sunken:PS(`--sunken`),raised:PS(`--raised`),coral:PS(`--coral`)};e.clearRect(0,0,n,r),e.lineWidth=1,e.fillStyle=d.sunken,e.globalAlpha=.55,e.fillRect(0,0,n,30),e.globalAlpha=1,e.strokeStyle=d.border,e.beginPath(),e.moveTo(0,29.5),e.lineTo(n,29.5),e.stroke(),e.font=`600 12px ${PS(`--font-ui`)}`,e.textBaseline=`middle`;for(let t of a.chords){let n=u(t.time),r=u(t.time+t.duration)-n;e.fillStyle=s!==null&&s>=t.time&&s<t.time+t.duration?d.text:d.muted,e.fillText(t.symbol,n+10,15,Math.max(0,r-14))}for(let t=0;t<=l;t++){let n=Math.round(u(t))+.5,i=t%4==0;e.strokeStyle=i?d.strong:d.border,e.globalAlpha=i?.9:.45,e.beginPath(),e.moveTo(n,i?0:30),e.lineTo(n,r),e.stroke()}e.globalAlpha=1;let f=i.layers.find(e=>e.id===o)??null;if(e.font=`500 10.5px ${PS(`--font-ui`)}`,e.fillStyle=d.faint,f&&we[f.instrument].kind===`drums`){let t=Me(f.kit);t.forEach((r,i)=>{let a=30+(1-(i+1)/t.length)*c;e.strokeStyle=d.border,e.globalAlpha=.5,e.beginPath(),e.moveTo(0,Math.round(a)+.5),e.lineTo(n,Math.round(a)+.5),e.stroke(),e.globalAlpha=1,e.fillText(r,8,a+c/t.length/2)})}else if(f){let t=Yl(f);for(let r=Math.ceil(t[0]/12)*12;r<=t[1];r+=12){let i=Math.round(30+Zl(r,t)*c)+.5;e.strokeStyle=d.border,e.globalAlpha=.5,e.setLineDash([2,4]),e.beginPath(),e.moveTo(0,i),e.lineTo(n,i),e.stroke(),e.setLineDash([]),e.globalAlpha=1,e.fillText(`${IS[r%12]}${Math.floor(r/12)-1}`,8,i-30<16?i+9:i-7)}}let p=[...i.layers].sort((e,t)=>Number(e.id===o)-Number(t.id===o)),m=new Map(i.layers.map(e=>[e.id,e]));for(let t of p){let n=t.id===o;for(let r of a.events){if(r.track!==t.id)continue;let[i,a]=FS(m.get(r.track),r.midi,r.drum),o=u(r.time),l=a*c,f=Math.max(5,Math.min(12,l-2)),p=Math.max(f,u(r.time+r.duration)-o-2),h=30+i*c+(l-f)/2,g=s!==null&&s>=r.time&&s<r.time+Math.max(r.duration,.12),_=n?g?1:.8:g?.6:.38;e.globalAlpha=_,e.fillStyle=t.color,e.beginPath(),e.roundRect(o,h,p,f,f/2),e.fill(),f>=7&&p>f&&(e.globalAlpha=_*(g?.5:.3),e.fillStyle=d.text,e.beginPath(),e.roundRect(o+f/2,h+f*.18,p-f,f*.26,f*.13),e.fill())}}e.globalAlpha=1;let h=(t,r,i,a,o)=>{if(!t.length)return;let s=t.map(e=>[e.x*n,30+e.y*c]);if(e.strokeStyle=r,e.fillStyle=r,e.globalAlpha=a,e.lineWidth=1.6+i*5,e.lineCap=`round`,e.lineJoin=`round`,s.length===1)e.beginPath(),e.arc(s[0][0],s[0][1],e.lineWidth/2+2,0,Math.PI*2),e.fill(),e.globalAlpha=1;else{e.beginPath(),e.moveTo(s[0][0],s[0][1]);for(let t=1;t<s.length-1;t++){let[n,r]=s[t],[i,a]=s[t+1];e.quadraticCurveTo(n,r,(n+i)/2,(r+a)/2)}if(e.lineTo(s.at(-1)[0],s.at(-1)[1]),e.stroke(),o){let t=e.lineWidth/2+2.5,n=(n,i)=>{e.beginPath(),e.arc(n,i,t,0,Math.PI*2),e.fillStyle=r,e.fill(),e.lineWidth=1.5,e.strokeStyle=d.sunken,e.stroke()},i=e.lineWidth,a=[[s[0][0],s[0][1]]],o=0;for(let e=1;e<s.length;e++)o+=Math.hypot(s[e][0]-s[e-1][0],s[e][1]-s[e-1][1]),o>=64&&(a.push([s[e][0],s[e][1]]),o=0);o>20&&a.push([s.at(-1)[0],s.at(-1)[1]]);for(let[e,t]of a)n(e,t);e.lineWidth=i}e.globalAlpha=1}};for(let e of p){let t=e.id===o;for(let n of e.strokes)h(n.points,e.color,n.size,t?.9:.22,t)}if(t.draft&&h(t.draft.points,t.draft.color,t.draft.size,1,!1),t.eraseBox){let{x0:r,x1:i,y0:a,y1:o}=t.eraseBox;e.strokeStyle=d.text,e.setLineDash([5,4]),e.lineWidth=1,e.strokeRect(Math.min(r,i)*n+.5,30+Math.min(a,o)*c+.5,Math.abs(i-r)*n,Math.abs(o-a)*c),e.setLineDash([])}if(s!==null){let t=Math.round(u(s))+.5;e.strokeStyle=d.coral,e.lineWidth=2,e.beginPath(),e.moveTo(t,0),e.lineTo(t,r),e.stroke(),e.lineWidth=1}}var RS=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Q=o(((e,t)=>{t.exports=RS()}))(),zS=e=>Math.min(1,Math.max(0,e));function BS({project:e,scene:t,activeLayerId:n,tool:r,size:i,onStroke:a,onErase:o}){let s=(0,y.useRef)(null),c=(0,y.useRef)(null),l=(0,y.useMemo)(()=>Eu(e,t.id),[e,t.id]),u=(0,y.useRef)({draft:null,eraseBox:null,dirty:!0,size:{w:0,h:0}}),d=(0,y.useRef)({scene:t,score:l,activeLayerId:n,size:i});d.current={scene:t,score:l,activeLayerId:n,size:i},u.current.dirty=!0,(0,y.useEffect)(()=>{let e=c.current,t=s.current,n=e.getContext(`2d`),r=0,i=!1,a=()=>{let r=window.devicePixelRatio||1,{width:i,height:a}=t.getBoundingClientRect();e.width=Math.round(i*r),e.height=Math.round(a*r),e.style.width=`${i}px`,e.style.height=`${a}px`,n.setTransform(r,0,0,r,0,0),u.current.size={w:i,h:a},u.current.dirty=!0},o=new ResizeObserver(a);o.observe(t),a();let l=()=>{let e=tS.position(),t=e&&e.sceneId===d.current.scene.id?e.beat:null,a=t!==null;if(u.current.dirty||a||i){let e=d.current,r=e.scene.layers.find(t=>t.id===e.activeLayerId),i=u.current.draft;LS(n,{width:u.current.size.w,height:u.current.size.h,scene:e.scene,score:e.score,activeLayerId:e.activeLayerId,draft:i&&r?{points:i.points,color:r.color,size:e.size}:null,eraseBox:u.current.eraseBox,beat:t}),u.current.dirty=!1}i=a,r=requestAnimationFrame(l)};return r=requestAnimationFrame(l),()=>{cancelAnimationFrame(r),o.disconnect()}},[]);let f=(e,t)=>{let n=c.current.getBoundingClientRect(),r={x:zS((e.clientX-n.left)/n.width),y:zS((e.clientY-n.top-30)/(n.height-30)),t:Math.max(0,e.timeStamp-t)};return e.pointerType===`pen`&&e.pressure>0&&(r.p=zS(e.pressure)),r},p=e=>{if(e.button!==0||!n)return;e.currentTarget.setPointerCapture(e.pointerId);let t=e.timeStamp,i=f(e,t);r===`erase`?u.current.eraseBox={x0:i.x,x1:i.x,y0:i.y,y1:i.y}:u.current.draft={points:[i],started:t},u.current.dirty=!0},m=e=>{let{draft:t,eraseBox:n}=u.current;if(n){let t=f(e,0);n.x1=t.x,n.y1=t.y}else if(t){let n=e.nativeEvent.getCoalescedEvents?.()??[e.nativeEvent];for(let e of n)t.points.push(f(e,t.started))}else return;u.current.dirty=!0},h=(e,t=!1)=>{let{draft:n,eraseBox:r}=u.current;if(u.current.draft=null,u.current.eraseBox=null,u.current.dirty=!0,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),!t&&(n&&a(n.points),r)){let e=.012;o({x0:zS(Math.min(r.x0,r.x1)-e),x1:zS(Math.max(r.x0,r.x1)+e),y0:zS(Math.min(r.y0,r.y1)-e*2),y1:zS(Math.max(r.y0,r.y1)+e*2)})}},g=t.layers.find(e=>e.id===n)?.name??`no layer`;return(0,Q.jsx)(`div`,{ref:s,className:`canvas-wrap`,"data-tool":r,children:(0,Q.jsx)(`canvas`,{ref:c,className:`draw-canvas`,role:`img`,"aria-label":`Scene ${t.name}, ${t.bars} bars. Drawing on ${g}.`,onPointerDown:p,onPointerMove:m,onPointerUp:e=>h(e),onPointerCancel:e=>h(e,!0)})})}var VS=new Set([`select_scene`,`describe`]),HS=new Set([`draw_path`,`draw_line`,`draw_curve`,`draw_shape`,`draw_melody`,`erase`,`add_layer`,`remove_layer`,`add_scene`,`remove_scene`,`set_mood`,`set_key`,`set_progression`]);function US(e){return HS.has(e.type)?null:JSON.stringify(e,(e,t)=>typeof t==`number`?0:t)}var WS=e=>({past:[],present:e,future:[],last:null});function GS(e,t,n,r=Date.now()){if(VS.has(t.type))return{...e,present:n,last:null};let i=US(t);return{past:i!==null&&e.last?.key===i&&r-e.last.at<800?e.past:[...e.past,e.present].slice(-100),present:n,future:[],last:i?{key:i,at:r}:null}}function KS(e,t,n,r=Date.now()){return t.every(e=>VS.has(e.type))?{...e,present:n,last:null}:t.length===1?GS(e,t[0],n,r):{past:[...e.past,e.present].slice(-100),present:n,future:[],last:null}}function qS(e,t){return e.activeSceneId===t.activeSceneId||!e.scenes.some(e=>e.id===t.activeSceneId)?e:{...e,activeSceneId:t.activeSceneId}}function JS(e){let t=e.past.at(-1);return t?{past:e.past.slice(0,-1),present:qS(t,e.present),future:[e.present,...e.future],last:null}:e}function YS(e){let t=e.future[0];return t?{past:[...e.past,e.present],present:qS(t,e.present),future:e.future.slice(1),last:null}:e}var XS=`haku`,ZS=`projects`,QS=`haku:last-project`,$S=null;function eC(){return $S??=new Promise((e,t)=>{let n=indexedDB.open(XS,1);n.onupgradeneeded=()=>n.result.createObjectStore(ZS,{keyPath:`id`}),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),$S}function tC(e,t){return eC().then(n=>new Promise((r,i)=>{let a=t(n.transaction(ZS,e).objectStore(ZS));a.onsuccess=()=>r(a.result),a.onerror=()=>i(a.error)}))}async function nC(e){await tC(`readwrite`,t=>t.put(e)),localStorage.setItem(QS,e.id)}async function rC(e){let t=await tC(`readonly`,t=>t.get(e));return t?Pl(t):null}async function iC(e){await tC(`readwrite`,t=>t.delete(e)),localStorage.getItem(QS)===e&&localStorage.removeItem(QS)}async function aC(){let e=await tC(`readonly`,e=>e.getAll()),t=[];for(let n of e)try{let e=Pl(n);t.push({id:e.id,name:e.name,updatedAt:e.updatedAt,scenes:e.scenes.length,mood:e.mood})}catch{}return t.sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}async function oC(){let e=localStorage.getItem(QS);if(!e)return null;try{return await rC(e)}catch{return null}}var sC=600,cC=(e,t)=>({history:WS(e),message:t,error:null});function lC(){let[e,t]=(0,y.useState)(null),n=(0,y.useRef)(null),[r,i]=(0,y.useState)(`saved`),a=(0,y.useRef)(null),o=(0,y.useCallback)(e=>{n.current=e,t(e)},[]),s=(0,y.useCallback)(e=>{let t=n.current;if(!t)return;let r=e(t);r&&o(r)},[o]);(0,y.useEffect)(()=>{let e=!1;return oC().then(t=>{e||(t?(a.current=t,o(cC(t,`Opened "${t.name}".`))):o(cC(Nl({mood:`rainy-study`}),`New loop in Rainy study. Draw on the canvas, then press play.`)))}),()=>void(e=!0)},[o]);let c=e?.history.present??null;(0,y.useEffect)(()=>{if(!c||c===a.current)return;i(`saving`);let e=setTimeout(()=>{nC(c).then(()=>{a.current=c,i(`saved`)}).catch(()=>i(`error`))},sC);return()=>clearTimeout(e)},[c]);let l=(0,y.useCallback)(e=>s(t=>{try{let n=_S(t.history.present,e);return{history:GS(t.history,e,n.project),message:n.message,error:null}}catch(e){return{...t,error:e instanceof Error?e.message:String(e)}}}),[s]),u=(0,y.useCallback)(e=>{let t=n.current;if(!t)throw Error(`Haku is still opening`);let r=[],i=[],a=[],s=t.history.present;for(let[t,n]of e.entries()){let o=oS.safeParse(n),c=e.length>1?`Command ${t+1}: `:``;if(!o.success){let e=o.error.issues[0];throw Error(`${c}Bad command: ${e.path.join(`.`)||`command`}: ${e.message}`)}try{let e=_S(s,o.data);s=e.project,r.push(o.data),i.push(e.message),a.push(e.data??null)}catch(e){throw Error(`${c}${e instanceof Error?e.message:String(e)}`)}}let c=i.length===1?i[0]:`An agent ran ${i.length} commands. ${i.at(-1)}`;return o({history:KS(t.history,r,s),message:c,error:null}),{messages:i,data:a}},[o]),d=(0,y.useCallback)(()=>s(e=>e.history.past.length?{...e,history:JS(e.history),message:`Undid the last change.`,error:null}:null),[s]),f=(0,y.useCallback)(()=>s(e=>e.history.future.length?{...e,history:YS(e.history),message:`Redid it.`,error:null}:null),[s]),p=(0,y.useCallback)((e,t=`Opened "${e.name}".`)=>o(cC(e,t)),[o]),m=(0,y.useCallback)(e=>o(cC(Nl({mood:e}),`New loop. Draw on the canvas, then press play.`)),[o]),h=(0,y.useCallback)((e,t=!1)=>s(n=>({...n,message:e,error:t?e:null})),[s]),g=(0,y.useCallback)(()=>n.current?.history.present??null,[]);if(!e)return null;let _=e.history.present;return{project:_,scene:Fl(_),message:e.message,error:e.error,canUndo:e.history.past.length>0,canRedo:e.history.future.length>0,saveState:r,run:l,apply:u,current:g,undo:d,redo:f,open:p,newProject:m,notify:h}}var uC=e=>e?.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function dC(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return{name:uC(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var fC=e=>{let t=``,n=!1;for(let r of e)r===`-`||r===`_`||r<=` `?n=t.length>0:(t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1);return t},pC=e=>{let t=fC(e);return t.charAt(0).toUpperCase()+t.slice(1)},mC=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),hC={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`};function gC(e){return e!=null}function _C(e,t={}){let n=t.attributeNames??{},r=e=>n[e]??e,i=e.size??e.width??hC.width,a=e.size??e.height??hC.height,o=e.aliases?.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`)??[],s=[...e.name?[`lucide-${e.name}`]:[],...o],c=t.className?.split(` `).filter(Boolean)??[],l=t.includeDefaultClasses===!1?mC(...c):mC(`lucide`,...s,...c),u=t.absoluteStrokeWidth?Number(t.strokeWidth??hC[`stroke-width`])*Number(e.size??e.width??hC.width)/Number(t.size??t.width??hC.width):t.strokeWidth??hC[`stroke-width`];return[`svg`,{...Object.entries(hC).reduce((e,[t,n])=>(e[r(t)]=n,e),{}),...`color`in t&&t.color&&{[r(`stroke`)]:t.color},...`size`in t&&gC(t.size)&&{[r(`width`)]:t.size,[r(`height`)]:t.size},...`width`in t&&gC(t.width)&&{[r(`width`)]:t.width},...`height`in t&&gC(t.height)&&{[r(`height`)]:t.height},[r(`stroke-width`)]:u,...l&&{[r(`class`)]:l},[r(`viewBox`)]:`0 0 ${i} ${a}`,...t.hasA11yProp===!1?{[r(`aria-hidden`)]:`true`}:{},...`attributes`in t&&t.attributes},e.node.map(e=>{let[n,i,a]=e,o=t.nonScalingStroke?{[r(`vector-effect`)]:`non-scaling-stroke`,...i}:i;return a?[n,o,a]:[n,o]})]}function vC(e,t={}){return _C(e,{...t,attributeNames:{...t.attributeNames,class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`}})}var yC=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},bC=(0,y.createContext)({}),xC=()=>(0,y.useContext)(bC),SC=(0,y.forwardRef)(({color:e,size:t,width:n,height:r,strokeWidth:i,absoluteStrokeWidth:a,nonScalingStroke:o,className:s=``,children:c,iconNode:l=[],icon:u={node:l,aliases:[],size:24},...d},f)=>{let{size:p=24,strokeWidth:m=2,absoluteStrokeWidth:h=!1,nonScalingStroke:g=!1,color:_=`currentColor`,className:v=``}=xC()??{},b=!!c||yC(d),[x,S,C=[]]=vC(u,{color:e??_,width:n??t??p,height:r??t??p,strokeWidth:i??m,absoluteStrokeWidth:a??h,nonScalingStroke:o??g,className:mC(v,s),hasA11yProp:b,attributes:d});return(0,y.createElement)(x,{ref:f,...S},[...C.map(([e,t])=>(0,y.createElement)(e,t)),...Array.isArray(c)?c:[c]])});function CC(e,t=[],n=[]){let r=typeof e==`string`?dC(e,t,n):e,i=(0,y.forwardRef)(({className:e,...t},n)=>(0,y.createElement)(SC,{ref:n,icon:r,className:e,...t}));return r.name&&(i.displayName=pC(r.name)),i}var wC={name:`audio-lines`,size:24,node:[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]};wC.node;var TC=CC(wC),EC={name:`brush`,size:24,node:[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]};EC.node;var DC=CC(EC),OC={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};OC.node;var kC=CC(OC),AC={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};AC.node;var jC=CC(AC),MC={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};MC.node;var NC=CC(MC),PC={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};PC.node;var FC=CC(PC),IC={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};IC.node;var LC=CC(IC),RC={name:`eighth-notes`,size:24,node:[[`path`,{d:`M21 16V3a1 1 0 0 0-1.28-.96l-10 2.917a1 1 0 0 0-.72.96V19`,key:`uy6ho8`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}],[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}]],aliases:[`music`]};RC.node;var zC=CC(RC),BC={name:`eraser`,size:24,node:[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]};BC.node;var VC=CC(BC),HC={name:`file-down`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]};HC.node;var UC=CC(HC),WC={name:`file-up`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]};WC.node;var GC=CC(WC),KC={name:`folder-open`,size:24,node:[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]};KC.node;var qC=CC(KC),JC={name:`headphones`,size:24,node:[[`path`,{d:`M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3`,key:`1xhozi`}]]};JC.node;var YC=CC(JC),XC={name:`highlighter`,size:24,node:[[`path`,{d:`m9 11-6 6v3h9l3-3`,key:`1a3l36`}],[`path`,{d:`m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4`,key:`14a9rk`}]]};XC.node;var ZC=CC(XC),QC={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};QC.node;var $C=CC(QC),ew={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};ew.node;var tw=CC(ew),nw={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};nw.node;var rw=CC(nw),iw={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};iw.node;var aw=CC(iw),ow={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};ow.node;var sw=CC(ow),cw={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};cw.node;var lw=CC(cw),uw={name:`redo-2`,size:24,node:[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]};uw.node;var dw=CC(uw),fw={name:`repeat`,size:24,node:[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]};fw.node;var pw=CC(fw),mw={name:`spray-can`,size:24,node:[[`path`,{d:`M3 3h.01`,key:`159qn6`}],[`path`,{d:`M7 5h.01`,key:`1hq22a`}],[`path`,{d:`M11 7h.01`,key:`1osv80`}],[`path`,{d:`M3 7h.01`,key:`1xzrh3`}],[`path`,{d:`M7 9h.01`,key:`19b3jx`}],[`path`,{d:`M3 11h.01`,key:`1eifu7`}],[`rect`,{width:`4`,height:`4`,x:`15`,y:`5`,key:`mri9e4`}],[`path`,{d:`m19 9 2 2v10c0 .6-.4 1-1 1h-6c-.6 0-1-.4-1-1V11l2-2`,key:`aib6hk`}],[`path`,{d:`m13 14 8-2`,key:`1d7bmk`}],[`path`,{d:`m13 19 8-2`,key:`1y2vml`}]]};mw.node;var hw=CC(mw),gw={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};gw.node;var _w=CC(gw),vw={name:`stamp`,size:24,node:[[`path`,{d:`M14 13V8.5C14 7 15 7 15 5a3 3 0 0 0-6 0c0 2 1 2 1 3.5V13`,key:`i9gjdv`}],[`path`,{d:`M20 15.5a2.5 2.5 0 0 0-2.5-2.5h-11A2.5 2.5 0 0 0 4 15.5V17a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1z`,key:`1vzg3v`}],[`path`,{d:`M5 22h14`,key:`ehvnwv`}]]};vw.node;var yw=CC(vw),bw={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};bw.node;var xw=CC(bw),Sw={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};Sw.node;var Cw=CC(Sw),ww={name:`volume-x`,size:24,node:[[`path`,{d:`M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z`,key:`1p7khw`}],[`path`,{d:`m16.5 14.5 5-5`,key:`cul3yw`}],[`path`,{d:`m16.5 9.5 5 5`,key:`1akey5`}]]};ww.node;var Tw=CC(ww),Ew={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};Ew.node;var Dw=CC(Ew);function Ow({label:e,onClick:t,children:n,pressed:r,disabled:i,variant:a=`ghost`,tipSide:o=`bottom`,className:s=``}){return(0,Q.jsx)(`button`,{type:`button`,className:`icon-btn icon-btn--${a} ${s}`,"aria-label":e,"aria-pressed":r,"data-tip":e,"data-tip-side":o,disabled:i,onClick:t,children:n})}function kw({label:e,value:t,onChange:n,min:r=0,max:i=1,step:a=.01,format:o=e=>`${Math.round(e*100)}`,hideLabel:s}){let c=(0,y.useId)(),l=(t-r)/(i-r)*100;return(0,Q.jsxs)(`div`,{className:`slider ${s?`slider--bare`:``}`,children:[!s&&(0,Q.jsxs)(`label`,{htmlFor:c,className:`slider__label`,children:[(0,Q.jsx)(`span`,{children:e}),(0,Q.jsx)(`output`,{htmlFor:c,children:o(t)})]}),(0,Q.jsx)(`input`,{id:c,type:`range`,min:r,max:i,step:a,value:t,"aria-label":s?e:void 0,"aria-valuetext":o(t),style:{"--pct":`${l}%`},onChange:e=>n(Number(e.target.value))})]})}function Aw({label:e,value:t,options:n,onChange:r,hideLabel:i,className:a=``}){let o=(0,y.useId)();return(0,Q.jsxs)(`div`,{className:`field ${a}`,children:[!i&&(0,Q.jsx)(`label`,{htmlFor:o,className:`field__label`,children:e}),(0,Q.jsx)(`select`,{id:o,className:`select`,value:t,"aria-label":i?e:void 0,onChange:e=>r(e.target.value),children:n.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function jw({label:e,checked:t,onChange:n}){return(0,Q.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":t,className:`switch`,onClick:()=>n(!t),children:[(0,Q.jsx)(`span`,{className:`switch__track`,"aria-hidden":`true`,children:(0,Q.jsx)(`span`,{className:`switch__thumb`})}),(0,Q.jsx)(`span`,{className:`switch__label`,children:e})]})}var Mw=e=>{let t=e.replace(/-/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)};function Nw({open:e,title:t,onClose:n,children:r,wide:i}){let a=(0,y.useRef)(null),o=(0,y.useId)();return(0,y.useEffect)(()=>{let t=a.current;t&&(e&&!t.open&&t.showModal(),!e&&t.open&&t.close())},[e]),(0,Q.jsx)(`dialog`,{ref:a,className:`dialog ${i?`dialog--wide`:``}`,"aria-labelledby":o,onClose:n,onClick:e=>e.target===e.currentTarget&&n(),children:(0,Q.jsxs)(`div`,{className:`dialog__box`,children:[(0,Q.jsxs)(`header`,{className:`dialog__head`,children:[(0,Q.jsx)(`h2`,{id:o,children:t}),(0,Q.jsx)(Ow,{label:`Close`,onClick:n,children:(0,Q.jsx)(Dw,{size:16})})]}),(0,Q.jsx)(`div`,{className:`dialog__body`,children:e&&r})]})})}var Pw=[{name:`Tone.js`,license:`MIT`,url:`https://github.com/Tonejs/Tone.js`},{name:`@tonejs/midi`,license:`MIT`,url:`https://github.com/Tonejs/Midi`},{name:`React`,license:`MIT`,url:`https://react.dev`},{name:`Zod`,license:`MIT`,url:`https://zod.dev`},{name:`Lucide icons`,license:`ISC`,url:`https://lucide.dev`},{name:`Figtree`,license:`OFL-1.1`,url:`https://fontsource.org/fonts/figtree`},{name:`Fraunces`,license:`OFL-1.1`,url:`https://fontsource.org/fonts/fraunces`}];function Fw(e){let t=[...Object.values(e.instruments).map(e=>e.credit),e.drums.credit,...Object.values(e.ambience).map(e=>e.credit)];return[...new Map(t.map(e=>[e.name,e])).values()]}function Iw({open:e,onClose:t,manifest:n}){return(0,Q.jsxs)(Nw,{open:e,title:`Credits`,onClose:t,wide:!0,children:[(0,Q.jsx)(`h3`,{className:`dialog__section`,children:`Sounds`}),n?(0,Q.jsx)(`ul`,{className:`credit-list`,children:Fw(n).map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.name}),(0,Q.jsx)(`span`,{children:e.author}),(0,Q.jsx)(`span`,{className:`credit-list__license`,children:e.license})]},e.name))}):(0,Q.jsx)(`p`,{className:`dialog__note`,children:`Sounds are still loading.`}),(0,Q.jsx)(`h3`,{className:`dialog__section`,children:`Built with`}),(0,Q.jsx)(`ul`,{className:`credit-list`,children:Pw.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.name}),(0,Q.jsx)(`span`,{className:`credit-list__license`,children:e.license})]},e.name))}),(0,Q.jsxs)(`p`,{className:`dialog__note`,children:[`Haku is Apache 2.0. Made with 💖 by`,` `,(0,Q.jsx)(`a`,{href:`https://pinkpixel.dev`,target:`_blank`,rel:`noreferrer`,children:`Pink Pixel`}),`.`]})]})}var Lw=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)||`haku`;function Rw(e,t,n){let r=URL.createObjectURL(new Blob([e],{type:t})),i=document.createElement(`a`);i.href=r,i.download=n,i.click(),setTimeout(()=>URL.revokeObjectURL(r),1e4)}function zw(e,t){return t===`song`?Lw(e.name):`${Lw(e.name)}-${Lw(Fl(e).name)}`}async function Bw(e,t){let n=await tS.render(e,t===`song`?{scope:`song`}:{scope:`scene`,loops:2}),r=`${zw(e,t)}.wav`;return Rw(eS(n).slice().buffer,`audio/wav`,r),r}function Vw(e,t){let n=t===`song`?Du(e):Eu(e),r=`${zw(e,t)}.mid`;return Rw(rd(e,n).slice().buffer,`audio/midi`,r),r}function Hw(e){let t=`${Lw(e.name)}.haku.json`;return Rw(JSON.stringify(e,null,2),`application/json`,t),t}async function Uw(e){let t;try{t=JSON.parse(await e.text())}catch{throw Error(`${e.name} isn't a JSON file`)}return{...Pl(t),id:Al(`p`),updatedAt:new Date().toISOString()}}function Ww({open:e,onClose:t,project:n,notify:r}){let[i,a]=(0,y.useState)(`scene`),[o,s]=(0,y.useState)(!1),c=Fl(n),l=n.arrangement.reduce((e,t)=>e+(n.scenes.find(e=>e.id===t.sceneId)?.bars??0)*t.repeat,0),u=async()=>{s(!0);try{r(`Saved ${await Bw(n,i)}.`),t()}catch(e){r(`WAV export failed: ${e instanceof Error?e.message:String(e)}`,!0)}finally{s(!1)}};return(0,Q.jsxs)(Nw,{open:e,title:`Export`,onClose:()=>!o&&t(),children:[(0,Q.jsxs)(`fieldset`,{className:`choice`,disabled:o,children:[(0,Q.jsx)(`legend`,{className:`field__label`,children:`What to export`}),(0,Q.jsxs)(`label`,{className:`choice__option`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`scope`,checked:i===`scene`,onChange:()=>a(`scene`)}),(0,Q.jsxs)(`span`,{children:[`Scene `,c.name,(0,Q.jsxs)(`small`,{children:[c.bars,` bars, played twice for WAV`]})]})]}),(0,Q.jsxs)(`label`,{className:`choice__option`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`scope`,checked:i===`song`,onChange:()=>a(`song`)}),(0,Q.jsxs)(`span`,{children:[`Whole song`,(0,Q.jsxs)(`small`,{children:[l,` bars in arrangement order`]})]})]})]}),(0,Q.jsxs)(`div`,{className:`dialog__actions`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`btn btn--primary`,disabled:o,onClick:()=>void u(),children:[o?(0,Q.jsx)(tw,{size:15,className:`spin`}):(0,Q.jsx)(TC,{size:15}),` `,o?`Rendering…`:`WAV audio`]}),(0,Q.jsxs)(`button`,{type:`button`,className:`btn`,disabled:o,onClick:()=>{r(`Saved ${Vw(n,i)}.`),t()},children:[(0,Q.jsx)(zC,{size:15}),` MIDI`]})]})]})}function Gw(e){let t=e;return()=>((t=t*16807%2147483647)-1)/2147483646}function Kw({x:e,y:t,r:n,s:r=1,flip:i=!1}){return(0,Q.jsxs)(`g`,{transform:`translate(${e} ${t}) rotate(${n}) scale(${i?-r:r} ${r})`,children:[(0,Q.jsx)(`path`,{className:`art-leaf`,d:`M0 0 C 6 -6 14 -4 15 4 C 14 10 6 13 0 0 Z`}),(0,Q.jsx)(`path`,{className:`art-leaf-shade`,d:`M0 0 C 6 4 10 8 15 4 C 14 10 6 13 0 0 Z`})]})}function qw({length:e,seed:t,horizontal:n=!1,className:r=``}){let{stem:i,leaves:a}=(0,y.useMemo)(()=>{let r=Gw(t),i=[];for(let n=0;n<=e;n+=24)i.push([n,22+Math.sin(n/41+t)*9]);let a=([e,t])=>n?`${e} ${t}`:`${t} ${e}`,o=`M${a(i[0])}`;for(let e=1;e<i.length;e++){let[t,n]=i[e-1],[r,s]=i[e];o+=` Q${a([t+12,n])} ${a([(t+r)/2,(n+s)/2])} T${a([r,s])}`}let s=i.slice(1).map(([t,i],a)=>{let o=a%2==0,s=1-t/e*.35,c=n?(o?62:118)+r()*24-12:(o?28:152)+r()*30-15,[l,u]=n?[t,i]:[i,t];return{x:l,y:u,r:c,s:(1.25+r()*.45)*s,flip:r()>.5}});return{stem:o,leaves:s}},[e,t,n]),[o,s]=n?[e+24,48]:[48,e+24];return(0,Q.jsxs)(`svg`,{className:`vine ${r}`,viewBox:`0 0 ${o} ${s}`,width:o,height:s,"aria-hidden":`true`,children:[(0,Q.jsx)(`path`,{className:`art-vine`,d:i,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`}),a.map((e,t)=>(0,Q.jsx)(Kw,{...e},t))]})}function Jw({className:e=``}){return(0,Q.jsxs)(`svg`,{className:`sprig ${e}`,viewBox:`0 0 36 18`,width:`30`,height:`15`,"aria-hidden":`true`,children:[(0,Q.jsx)(`path`,{className:`art-vine`,d:`M2 13 C 12 13 22 10 34 4`,fill:`none`,strokeWidth:`1.4`,strokeLinecap:`round`}),(0,Q.jsx)(Kw,{x:9,y:13,r:-110,s:.62}),(0,Q.jsx)(Kw,{x:17,y:11,r:-60,s:.7,flip:!0}),(0,Q.jsx)(Kw,{x:24,y:9,r:-100,s:.66}),(0,Q.jsx)(Kw,{x:33,y:4,r:-20,s:.62})]})}function Yw({className:e=``}){return(0,Q.jsxs)(`svg`,{className:`cat ${e}`,viewBox:`0 0 230 200`,"aria-hidden":`true`,children:[(0,Q.jsx)(`path`,{className:`art-fur-stroke`,d:`M186 108 C 214 110 216 140 208 162 C 203 176 208 186 214 192`,fill:`none`,strokeWidth:`13`,strokeLinecap:`round`}),(0,Q.jsx)(`path`,{className:`art-fur-dark-stroke`,d:`M210 152 C 206 166 206 178 212 188`,fill:`none`,strokeWidth:`13`,strokeLinecap:`round`,strokeDasharray:`7 9`}),(0,Q.jsx)(`path`,{className:`art-fur-light-stroke`,d:`M209 181 C 210 186 212 190 214 192`,fill:`none`,strokeWidth:`13`,strokeLinecap:`round`}),(0,Q.jsx)(`path`,{className:`art-fur`,d:`M66 119 C 60 84 96 58 140 60 C 182 62 206 88 200 119 Z`}),(0,Q.jsx)(`path`,{className:`art-fur-dark`,d:`M80 119 C 110 106 168 102 200 112 L 200 119 Z`}),(0,Q.jsx)(`path`,{className:`art-fur-dark-stroke`,d:`M124 63 q 7 12 2 24 M144 62 q 7 12 2 24 M163 67 q 6 11 1 22 M180 76 q 5 10 0 19`,fill:`none`,strokeWidth:`5`,strokeLinecap:`round`}),(0,Q.jsx)(`path`,{className:`art-fur`,d:`M38 76 L 34 44 L 58 62 Z`}),(0,Q.jsx)(`path`,{className:`art-fur`,d:`M74 62 L 96 44 L 98 76 Z`}),(0,Q.jsx)(`path`,{className:`art-ear`,d:`M40 70 L 38 52 L 52 63 Z`}),(0,Q.jsx)(`path`,{className:`art-ear`,d:`M80 63 L 93 52 L 93 70 Z`}),(0,Q.jsx)(`ellipse`,{className:`art-fur`,cx:`66`,cy:`90`,rx:`36`,ry:`28`}),(0,Q.jsx)(`path`,{className:`art-fur-dark-stroke`,d:`M60 66 v 10 M67 64 v 12 M74 66 v 10`,fill:`none`,strokeWidth:`3.4`,strokeLinecap:`round`}),(0,Q.jsx)(`ellipse`,{className:`art-fur-light`,cx:`64`,cy:`102`,rx:`18`,ry:`11`}),(0,Q.jsx)(`path`,{className:`art-ink`,d:`M42 91 q 7 6 14 0 M72 91 q 7 6 14 0`,fill:`none`,strokeWidth:`2.2`,strokeLinecap:`round`}),(0,Q.jsx)(`path`,{className:`art-ear`,d:`M60 97 h 8 l -4 4 Z`}),(0,Q.jsx)(`path`,{className:`art-blush`,d:`M38 100 h 10 M82 100 h 10`,fill:`none`,strokeWidth:`2.4`,strokeLinecap:`round`}),(0,Q.jsx)(`ellipse`,{className:`art-fur-light`,cx:`50`,cy:`116`,rx:`15`,ry:`6`}),(0,Q.jsx)(`ellipse`,{className:`art-fur-light`,cx:`86`,cy:`117`,rx:`13`,ry:`5`})]})}function Xw(){return(0,Q.jsxs)(`svg`,{viewBox:`0 0 80 70`,preserveAspectRatio:`xMidYMid slice`,"aria-hidden":`true`,children:[(0,Q.jsx)(`rect`,{width:`80`,height:`70`,fill:`#5f4763`}),(0,Q.jsx)(`rect`,{y:`16`,width:`80`,height:`14`,fill:`#86566c`}),(0,Q.jsx)(`rect`,{y:`30`,width:`80`,height:`12`,fill:`#c46f6c`}),(0,Q.jsx)(`rect`,{y:`42`,width:`80`,height:`12`,fill:`#e69172`}),(0,Q.jsx)(`circle`,{cx:`50`,cy:`44`,r:`10`,fill:`#f7c48f`}),(0,Q.jsx)(`path`,{d:`M0 50 Q 22 40 44 50 T 80 46 V 70 H 0 Z`,fill:`#6a4558`}),(0,Q.jsx)(`path`,{d:`M0 60 Q 30 52 60 60 T 80 58 V 70 H 0 Z`,fill:`#4a3046`}),(0,Q.jsx)(`path`,{d:`M16 56 v -8 M12 50 q 4 -8 8 0`,stroke:`#3a2638`,strokeWidth:`2`,fill:`none`}),(0,Q.jsx)(`path`,{d:`M8 16 q 6 -3 12 -1 q 6 2 12 0 M50 10 q 5 -3 10 -1`,stroke:`#9b6a80`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`})]})}function Zw(){let e=(e,t,n)=>(0,Q.jsxs)(`g`,{transform:`translate(${e} ${t}) scale(${n})`,children:[[0,72,144,216,288].map(e=>(0,Q.jsx)(`ellipse`,{className:`art-petal`,cx:`0`,cy:`-5`,rx:`3.4`,ry:`5`,transform:`rotate(${e})`},e)),(0,Q.jsx)(`circle`,{className:`art-flower-heart`,r:`2.4`})]});return(0,Q.jsxs)(`svg`,{viewBox:`0 0 44 34`,"aria-hidden":`true`,children:[(0,Q.jsx)(`path`,{className:`art-vine`,d:`M6 30 C 12 22 18 20 24 12 M24 22 C 30 20 34 16 38 10`,fill:`none`,strokeWidth:`1.2`}),(0,Q.jsx)(Kw,{x:12,y:24,r:-150,s:.5}),(0,Q.jsx)(Kw,{x:30,y:19,r:-40,s:.5}),e(14,14,1),e(32,22,.8),e(36,8,.6)]})}function Qw({seed:e}){let t=(0,y.useMemo)(()=>{let t=Gw(e);return Array.from({length:14},(e,n)=>({x:14+n%7*22+t()*4,y:14+Math.floor(n/7)*34+Math.floor(t()*9)*2.5}))},[e]);return(0,Q.jsxs)(`svg`,{className:`sheet__notes`,viewBox:`0 0 170 70`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[[14,48].flatMap(e=>[0,5,10,15,20].map(t=>(0,Q.jsx)(`path`,{className:`art-staff`,d:`M6 ${e+t} H164`,strokeWidth:`0.6`},`${e}-${t}`))),t.map((e,t)=>(0,Q.jsxs)(`g`,{transform:`translate(${e.x} ${e.y})`,children:[(0,Q.jsx)(`ellipse`,{className:`art-ink-fill`,rx:`2.6`,ry:`1.9`,transform:`rotate(-20)`}),(0,Q.jsx)(`path`,{className:`art-ink`,d:`M2.3 -0.5 V -11`,strokeWidth:`0.9`})]},t))]})}var $w=Te.map(e=>({value:e,label:we[e].label})),eT=[`-2`,`-1`,`0`,`1`,`2`];function tT({scene:e,activeLayerId:t,onSelect:n,run:r}){let[i,a]=(0,y.useState)(!1),o=(0,y.useRef)(null),s=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!i)return;o.current?.querySelector(`.add-layer__option`)?.focus();let e=e=>{o.current?.contains(e.target)||a(!1)},t=e=>{e.key===`Escape`&&(a(!1),s.current?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[i]);let c=t=>{r({type:`add_layer`,instrument:t,scene:e.id}),a(!1),s.current?.focus()},l=(t,n)=>r({type:`update_layer`,layer:t,scene:e.id,...n});return(0,Q.jsxs)(`section`,{className:`panel layers`,"aria-labelledby":`layers-title`,children:[(0,Q.jsxs)(`h2`,{id:`layers-title`,className:`panel__title`,children:[`Layers `,(0,Q.jsx)(Jw,{})]}),(0,Q.jsx)(`ul`,{className:`layer-list`,children:e.layers.map(i=>{let a=i.id===t,o=we[i.instrument].kind===`drums`;return(0,Q.jsxs)(`li`,{className:`layer ${a?`layer--active`:``} ${i.muted?`layer--muted`:``}`,children:[(0,Q.jsxs)(`div`,{className:`layer__row`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`layer__select`,"aria-pressed":a,onClick:()=>n(i.id),children:[(0,Q.jsx)(`span`,{className:`layer__swatch`,style:{background:i.color},"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{className:`layer__text`,children:[(0,Q.jsx)(`span`,{className:`layer__name`,children:i.name}),(0,Q.jsxs)(`span`,{className:`layer__meta`,children:[we[i.instrument].label,` · `,i.strokes.length,` `,i.strokes.length===1?`stroke`:`strokes`]})]})]}),(0,Q.jsx)(Ow,{label:i.muted?`Unmute ${i.name}`:`Mute ${i.name}`,pressed:i.muted,onClick:()=>l(i.id,{muted:!i.muted}),children:(0,Q.jsx)(Tw,{size:15})}),(0,Q.jsx)(Ow,{label:i.solo?`Unsolo ${i.name}`:`Solo ${i.name}`,pressed:i.solo,onClick:()=>l(i.id,{solo:!i.solo}),children:(0,Q.jsx)(YC,{size:15})})]}),a&&(0,Q.jsxs)(`div`,{className:`layer__detail`,children:[(0,Q.jsx)(kw,{label:`Volume`,value:i.volume,onChange:e=>l(i.id,{volume:e})}),(0,Q.jsx)(kw,{label:`Pan`,value:i.pan,min:-1,max:1,format:e=>Math.abs(e)<.02?`C`:`${e<0?`L`:`R`}${Math.round(Math.abs(e)*100)}`,onChange:e=>l(i.id,{pan:e})}),(0,Q.jsx)(Aw,{label:`Instrument`,value:i.instrument,options:$w,onChange:e=>l(i.id,{instrument:e})}),o?(0,Q.jsx)(Aw,{label:`Kit`,value:i.kit,options:je.map(e=>({value:e,label:Mw(e)})),onChange:e=>l(i.id,{kit:e})}):(0,Q.jsxs)(`div`,{className:`field-row`,children:[(0,Q.jsx)(Aw,{label:`Harmony`,value:i.harmony,options:Oe.map(e=>({value:e,label:Mw(e)})),onChange:e=>l(i.id,{harmony:e})}),(0,Q.jsx)(Aw,{label:`Octave`,value:String(i.octave),options:eT.map(e=>({value:e,label:Number(e)>0?`+${e}`:e})),onChange:e=>l(i.id,{octave:Number(e)})})]}),(0,Q.jsxs)(`button`,{type:`button`,className:`text-btn text-btn--danger`,onClick:()=>r({type:`remove_layer`,layer:i.id,scene:e.id}),children:[(0,Q.jsx)(xw,{size:14}),` Remove layer`]})]})]},i.id)})}),(0,Q.jsxs)(`div`,{className:`add-layer`,ref:o,children:[(0,Q.jsxs)(`button`,{ref:s,type:`button`,className:`btn btn--primary add-layer__button`,"aria-expanded":i,"aria-controls":`add-layer-menu`,onClick:()=>a(e=>!e),children:[(0,Q.jsx)(lw,{size:16,"aria-hidden":`true`}),` Add layer`]}),i&&(0,Q.jsx)(`div`,{id:`add-layer-menu`,className:`add-layer__menu`,role:`group`,"aria-label":`Pick an instrument for the new layer`,children:Te.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:`add-layer__option`,onClick:()=>c(e),children:we[e].label},e))})]})]})}var nT=e=>{let t=new Date(e);return t.toDateString()===new Date().toDateString()?t.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`}):t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})};function rT({open:e,onClose:t,current:n,onOpen:r,onNew:i,notify:a}){let[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(`rainy-study`),f=(0,y.useRef)(null),p=()=>aC().then(s,()=>s([]));(0,y.useEffect)(()=>{e&&(l(null),p())},[e]);let m=async e=>{if(e===n.id)return t();try{let n=await rC(e);if(!n)throw Error(`That project is gone`);r(n),t()}catch(e){a(e instanceof Error?e.message:String(e),!0)}},h=async e=>{await iC(e),l(null),await p()},g=async e=>{if(e)try{let n=await Uw(e);r(n,`Imported "${n.name}".`),t()}catch(e){a(e instanceof Error?e.message:String(e),!0)}};return(0,Q.jsxs)(Nw,{open:e,title:`Projects`,onClose:t,wide:!0,children:[(0,Q.jsxs)(`div`,{className:`projects__new`,children:[(0,Q.jsx)(Aw,{label:`Mood for a new loop`,value:u,options:wl.map(e=>({value:e,label:Cl[e].label})),onChange:d}),(0,Q.jsxs)(`button`,{type:`button`,className:`btn btn--primary`,onClick:()=>{i(u),t()},children:[(0,Q.jsx)(lw,{size:15}),` New loop`]})]}),(0,Q.jsxs)(`ul`,{className:`project-list`,"aria-label":`Saved projects`,children:[o===null&&(0,Q.jsx)(`li`,{className:`project-list__empty`,children:`Loading…`}),o?.length===0&&(0,Q.jsx)(`li`,{className:`project-list__empty`,children:`Nothing saved yet.`}),o?.map(e=>{let t=e.id===n.id;return(0,Q.jsxs)(`li`,{className:`project-row ${t?`project-row--current`:``}`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`project-row__open`,onClick:()=>void m(e.id),children:[(0,Q.jsx)(`span`,{className:`project-row__name`,children:t?n.name:e.name}),(0,Q.jsxs)(`span`,{className:`project-row__meta`,children:[e.mood?Cl[e.mood]?.label??e.mood:`No mood`,` · `,e.scenes,` `,e.scenes===1?`scene`:`scenes`,` · `,nT(e.updatedAt),t&&` · open now`]})]}),c===e.id?(0,Q.jsxs)(`span`,{className:`project-row__confirm`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`btn btn--danger btn--sm`,onClick:()=>void h(e.id),children:`Delete`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:()=>l(null),children:`Keep`})]}):(0,Q.jsx)(`button`,{type:`button`,className:`icon-btn icon-btn--ghost`,"aria-label":`Delete ${e.name}`,title:t?`Can't delete the open project`:`Delete ${e.name}`,disabled:t,onClick:()=>l(e.id),children:(0,Q.jsx)(xw,{size:15})})]},e.id)})]}),(0,Q.jsxs)(`div`,{className:`dialog__actions`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>f.current?.click(),children:[(0,Q.jsx)(GC,{size:15}),` Import file`]}),(0,Q.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>a(`Saved ${Hw(n)}.`),children:[(0,Q.jsx)(UC,{size:15}),` Save as file`]}),(0,Q.jsx)(`input`,{ref:f,type:`file`,accept:`.json,application/json`,hidden:!0,onChange:e=>{g(e.target.files?.[0]),e.target.value=``}})]})]})}var $={x:14,y:12,w:292,h:166},iT=$.x+$.w,aT=$.y+$.h;function oT({colors:e}){let t=e.map((e,t)=>1+t*.25),n=t.reduce((e,t)=>e+t,0),r=$.y;return(0,Q.jsx)(Q.Fragment,{children:e.map((e,i)=>{let a=t[i]/n*$.h,o=(0,Q.jsx)(`rect`,{x:$.x,y:r,width:$.w,height:a+.5,fill:e},e+i);return r+=a,o})})}function sT(e,t){let n=t,r=()=>((n=n*16807%2147483647)-1)/2147483646;return Array.from({length:e},()=>[r(),r()])}var cT=sT(26,11).map(([e,t])=>[$.x+e*$.w,$.y+t*70]);function lT(){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(oT,{colors:[`#38414d`,`#424c58`,`#4d5864`,`#58636d`]}),(0,Q.jsx)(`path`,{d:`M${$.x} 140 Q 70 118 130 132 T 230 124 T ${iT} 132 V ${aT} H ${$.x} Z`,fill:`#343d48`}),(0,Q.jsx)(`path`,{d:`M${$.x} 152 L 40 152 L 60 136 L 80 152 L 112 152 V 146 H 150 L 172 128 L 194 146 H 238 L 256 134 L 274 146 H ${iT} V ${aT} H ${$.x} Z`,fill:`#272d35`}),(0,Q.jsx)(`rect`,{x:`62`,y:`128`,width:`7`,height:`12`,fill:`#272d35`}),(0,Q.jsx)(`rect`,{x:`258`,y:`124`,width:`6`,height:`12`,fill:`#272d35`}),(0,Q.jsx)(`rect`,{x:`120`,y:`156`,width:`8`,height:`7`,fill:`#e7b77f`,opacity:`0.55`}),(0,Q.jsx)(`rect`,{x:`204`,y:`154`,width:`8`,height:`7`,fill:`#e7b77f`,opacity:`0.4`})]})}function uT(){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(oT,{colors:[`#5f4763`,`#86566c`,`#b56a6e`,`#d9846c`,`#efa679`]}),(0,Q.jsx)(`circle`,{cx:`214`,cy:`150`,r:`28`,fill:`#f7c48f`}),(0,Q.jsx)(`path`,{d:`M${$.x} 138 Q 80 116 150 134 T ${iT} 126 V ${aT} H ${$.x} Z`,fill:`#6a4558`}),(0,Q.jsx)(`path`,{d:`M${$.x} 156 Q 110 140 190 154 T ${iT} 150 V ${aT} H ${$.x} Z`,fill:`#4a3046`}),(0,Q.jsx)(`path`,{d:`M86 58 q4 -4 8 0 q4 -4 8 0 M110 46 q3 -3 6 0 q3 -3 6 0`,stroke:`#4a3046`,strokeWidth:`1.6`,fill:`none`,strokeLinecap:`round`})]})}function dT(){let e=[[14,34,70],[46,26,96],[70,40,58],[108,22,110],[128,36,76],[162,30,92],[190,44,64],[232,24,104],[254,30,80],[282,24,66]],t=sT(60,5);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(oT,{colors:[`#11172a`,`#171f37`,`#1e2744`,`#262f50`]}),cT.map(([e,t],n)=>(0,Q.jsx)(`circle`,{cx:e,cy:t,r:n%5==0?1.1:.7,fill:`#efe6cf`,opacity:.5+n%3*.2},n)),(0,Q.jsx)(`circle`,{cx:`244`,cy:`44`,r:`14`,fill:`#f2e6c9`}),(0,Q.jsx)(`circle`,{cx:`251`,cy:`39`,r:`12.5`,fill:`#11172a`}),e.map(([e,t,n],r)=>(0,Q.jsx)(`rect`,{x:e,y:aT-n,width:t,height:n,fill:r%2?`#0d101b`:`#121626`},r)),t.map(([t,n],r)=>{let[i,a,o]=e[Math.floor(t*e.length)],s=i+4+Math.floor(n*((a-10)/6))*6,c=aT-o+6+Math.floor(t*97%1*((o-12)/8))*8;return r%3==0?null:(0,Q.jsx)(`rect`,{x:s,y:c,width:`3`,height:`4`,fill:`#f2c48d`,opacity:r%4==0?.9:.55},r)})]})}function fT(){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(oT,{colors:[`#86c3dc`,`#9dd0e4`,`#b6dceb`,`#cde8f1`]}),(0,Q.jsx)(`circle`,{cx:`72`,cy:`50`,r:`17`,fill:`#f6d47e`}),(0,Q.jsxs)(`g`,{fill:`#f6f2ea`,children:[(0,Q.jsx)(`circle`,{cx:`190`,cy:`54`,r:`11`}),(0,Q.jsx)(`circle`,{cx:`204`,cy:`48`,r:`14`}),(0,Q.jsx)(`circle`,{cx:`220`,cy:`55`,r:`10`}),(0,Q.jsx)(`rect`,{x:`186`,y:`55`,width:`40`,height:`10`,rx:`5`})]}),(0,Q.jsx)(`path`,{d:`M${$.x} 132 Q 90 108 170 128 T ${iT} 120 V ${aT} H ${$.x} Z`,fill:`#9dbd8e`}),(0,Q.jsx)(`path`,{d:`M${$.x} 152 Q 120 134 210 150 T ${iT} 146 V ${aT} H ${$.x} Z`,fill:`#7b9c71`}),(0,Q.jsxs)(`g`,{fill:`#5f7f5a`,children:[(0,Q.jsx)(`circle`,{cx:`64`,cy:`140`,r:`11`}),(0,Q.jsx)(`circle`,{cx:`78`,cy:`144`,r:`8`}),(0,Q.jsx)(`rect`,{x:`68`,y:`146`,width:`3`,height:`12`,fill:`#6b4a34`})]})]})}function pT(){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(oT,{colors:[`#95a1b1`,`#a7b2c1`,`#b9c3cf`,`#cbd3dc`]}),(0,Q.jsx)(`path`,{d:`M${$.x} 130 Q 100 110 180 128 T ${iT} 122 V ${aT} H ${$.x} Z`,fill:`#dfe5eb`}),(0,Q.jsx)(`path`,{d:`M${$.x} 154 Q 120 138 220 152 T ${iT} 148 V ${aT} H ${$.x} Z`,fill:`#eef1f4`}),[[58,136,1],[80,140,.8],[232,132,1.1],[256,138,.85]].map(([e,t,n],r)=>(0,Q.jsxs)(`g`,{transform:`translate(${e} ${t}) scale(${n})`,children:[(0,Q.jsx)(`path`,{d:`M0 -24 L10 0 H-10 Z`,fill:`#4c605c`}),(0,Q.jsx)(`path`,{d:`M0 -24 L4 -14 H-4 Z`,fill:`#eef1f4`}),(0,Q.jsx)(`rect`,{x:`-1.5`,y:`0`,width:`3`,height:`5`,fill:`#5a4334`})]},r))]})}var mT={rain:{label:`Rain`,art:lT},dusk:{label:`Dusk`,art:uT},"night-city":{label:`Night city`,art:dT},sunny:{label:`Sunny`,art:fT},snow:{label:`Snow`,art:pT}},hT=48472,gT=(e,t)=>e+Math.random()*(t-e),_T=class{area;streaks;flakes;petals;stars;drops;t=0;constructor(e){this.area=e;let t=Math.min(6,Math.max(1,e.w*e.h/hT)),n=(e,n)=>Array.from({length:Math.round(e*t)},n),r=()=>this.glassX(),i=()=>this.glassY();this.streaks=n(70,()=>({x:r(),y:i(),v:gT(220,320),size:gT(7,13),phase:0})),this.flakes=n(60,()=>({x:r(),y:i(),v:gT(9,24),size:gT(.7,2),phase:gT(0,Math.PI*2)})),this.petals=n(7,()=>({x:r(),y:i(),v:gT(10,18),size:gT(2.2,3.4),phase:gT(0,Math.PI*2)})),this.stars=n(10,()=>({x:r(),y:gT(e.y,e.y+e.h*.45),v:gT(.8,2),size:gT(.8,1.4),phase:gT(0,Math.PI*2)})),this.drops=n(16,()=>({x:r(),y:i(),v:gT(1,6),size:gT(1.1,2.6),phase:gT(0,10)}))}glassX(){return gT(this.area.x,this.area.x+this.area.w)}glassY(){return gT(this.area.y,this.area.y+this.area.h)}get bottom(){return this.area.y+this.area.h}frame(e,t,n){let{x:r,y:i,w:a,h:o}=this.area,s=t*n.speed;switch(this.t+=s,e.clearRect(r,i,a,o),e.save(),e.beginPath(),e.rect(r,i,a,o),e.clip(),n.scene){case`rain`:this.drawRain(e,s);break;case`snow`:this.drawSnow(e,s);break;case`sunny`:case`dusk`:this.drawPetals(e,s,n.scene===`dusk`?`#d98f9b`:`#e8897a`);break;case`night-city`:this.drawStars(e)}n.wetGlass&&this.drawDrops(e,s),e.restore()}drawRain(e,t){e.strokeStyle=`rgba(205, 218, 232, 0.32)`,e.lineWidth=.8,e.beginPath();for(let n of this.streaks)n.y+=n.v*t,n.x-=n.v*.12*t,n.y>this.bottom+n.size&&(n.y=this.area.y-n.size,n.x=this.glassX()+20),e.moveTo(n.x,n.y),e.lineTo(n.x+n.size*.12,n.y-n.size);e.stroke()}drawSnow(e,t){e.fillStyle=`rgba(250, 251, 253, 0.85)`;for(let n of this.flakes)n.y+=n.v*t,n.phase+=t*1.3,n.y>this.bottom+3&&(n.y=this.area.y-3,n.x=this.glassX()),e.beginPath(),e.arc(n.x+Math.sin(n.phase)*5,n.y,n.size,0,Math.PI*2),e.fill()}drawPetals(e,t,n){e.fillStyle=n;for(let n of this.petals)n.y+=n.v*t,n.x+=n.v*.6*t,n.phase+=t*1.6,(n.y>this.bottom+5||n.x>this.area.x+this.area.w+5)&&(n.y=gT(this.area.y-20,this.area.y),n.x=gT(this.area.x-40,this.area.x+this.area.w*.7)),e.save(),e.translate(n.x+Math.sin(n.phase)*4,n.y),e.rotate(n.phase),e.beginPath(),e.ellipse(0,0,n.size,n.size*.5,0,0,Math.PI*2),e.fill(),e.restore()}drawStars(e){for(let t of this.stars)e.fillStyle=`rgba(239, 230, 207, ${(.25+.6*(.5+.5*Math.sin(this.t*t.v+t.phase))).toFixed(3)})`,e.beginPath(),e.arc(t.x,t.y,t.size,0,Math.PI*2),e.fill()}drawDrops(e,t){for(let n of this.drops)n.phase-=t,n.phase<0&&(n.y+=n.v*6*t),n.phase<-1.5&&(n.phase=gT(2,9)),n.y>this.bottom+3&&(n.y=this.area.y,n.x=this.glassX()),e.fillStyle=`rgba(226, 234, 242, 0.32)`,e.beginPath(),e.ellipse(n.x,n.y,n.size*.8,n.size,0,0,Math.PI*2),e.fill(),e.fillStyle=`rgba(255, 255, 255, 0.45)`,e.beginPath(),e.arc(n.x-n.size*.25,n.y-n.size*.35,n.size*.28,0,Math.PI*2),e.fill()}},vT=1.4,yT=()=>window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;function bT({project:e,playing:t}){let n=(0,y.useRef)(null),r=(0,y.useRef)({scene:e.window,wetGlass:!1,speed:.45});r.current={scene:e.window,wetGlass:e.mix.rain.enabled,speed:t?1:.45};let i=mT[e.window].art;return(0,y.useEffect)(()=>{let e=n.current,t=e.getContext(`2d`),i=null,a=0,o=performance.now(),s=()=>{let n=window.devicePixelRatio||1,{width:r,height:a}=e.getBoundingClientRect();r&&a&&(e.width=Math.round(r*n),e.height=Math.round(a*n),t.setTransform(n*vT,0,0,n*vT,0,0),i=new _T({x:0,y:0,w:r/vT,h:a/vT}))},c=new ResizeObserver(s);c.observe(e),s();let l=e=>{let n=Math.min(.05,(e-o)/1e3);o=e,i?.frame(t,yT()?0:n,r.current),a=requestAnimationFrame(l)};return a=requestAnimationFrame(l),()=>{cancelAnimationFrame(a),c.disconnect()}},[]),(0,Q.jsx)(`div`,{className:`room-window`,"aria-hidden":`true`,children:(0,Q.jsxs)(`div`,{className:`room-window__glass`,children:[(0,Q.jsx)(`svg`,{className:`room-window__view`,viewBox:`${$.x} ${$.y} ${$.w} ${$.h}`,preserveAspectRatio:`xMidYMax slice`,children:(0,Q.jsx)(i,{})}),(0,Q.jsx)(`canvas`,{ref:n,className:`room-window__weather`}),(0,Q.jsx)(`div`,{className:`room-window__panes`})]})})}var xT=[{left:`19%`,bottom:40,r:-20},{left:`24%`,bottom:18,r:35},{left:`47%`,bottom:52,r:10},{left:`71%`,bottom:30,r:-40},{left:`75%`,bottom:46,r:25},{left:`88%`,bottom:24,r:-10}];function ST({project:e,playing:t}){return(0,Q.jsxs)(`div`,{className:`room`,"aria-hidden":`true`,children:[(0,Q.jsx)(`div`,{className:`room__beam`}),(0,Q.jsx)(`div`,{className:`room__brace room__brace--left`}),(0,Q.jsx)(`div`,{className:`room__brace room__brace--right`}),(0,Q.jsx)(bT,{project:e,playing:t}),(0,Q.jsx)(qw,{className:`room__garland`,length:560,seed:3,horizontal:!0}),(0,Q.jsx)(qw,{className:`room__vine room__vine--left`,length:760,seed:7}),(0,Q.jsx)(qw,{className:`room__vine room__vine--left-2`,length:420,seed:19}),(0,Q.jsx)(qw,{className:`room__vine room__vine--right`,length:680,seed:11}),(0,Q.jsx)(qw,{className:`room__vine room__vine--right-2`,length:360,seed:23}),(0,Q.jsxs)(`div`,{className:`lantern`,children:[(0,Q.jsx)(`span`,{className:`lantern__light lantern__light--wide`}),(0,Q.jsx)(`span`,{className:`lantern__light`}),(0,Q.jsx)(`span`,{className:`lantern__chain`}),(0,Q.jsx)(`span`,{className:`lantern__cap`}),(0,Q.jsx)(`span`,{className:`lantern__body`,children:(0,Q.jsx)(`span`,{className:`lantern__flame`})}),(0,Q.jsx)(`span`,{className:`lantern__base`})]}),(0,Q.jsxs)(`div`,{className:`photo`,children:[(0,Q.jsx)(`span`,{className:`photo__pin`}),(0,Q.jsx)(`span`,{className:`photo__pin photo__pin--right`}),(0,Q.jsx)(Xw,{})]}),(0,Q.jsxs)(`div`,{className:`desk`,children:[(0,Q.jsx)(`span`,{className:`desk__sun desk__sun--a`}),(0,Q.jsx)(`span`,{className:`desk__sun desk__sun--b`}),(0,Q.jsx)(`span`,{className:`desk__sun desk__sun--c`}),xT.map((e,t)=>(0,Q.jsx)(`span`,{className:`petal`,style:{left:e.left,bottom:e.bottom,rotate:`${e.r}deg`}},t))]}),(0,Q.jsxs)(`div`,{className:`books`,children:[(0,Q.jsx)(`span`,{className:`book book--red`}),(0,Q.jsx)(`span`,{className:`book book--green`}),(0,Q.jsx)(`span`,{className:`book book--blue`}),(0,Q.jsx)(`span`,{className:`book book--plum`}),(0,Q.jsx)(`span`,{className:`book book--lean`})]}),(0,Q.jsxs)(`div`,{className:`mug`,children:[(0,Q.jsx)(`span`,{className:`mug__saucer`}),(0,Q.jsx)(`span`,{className:`mug__handle`}),(0,Q.jsx)(`span`,{className:`mug__body`,children:(0,Q.jsx)(Zw,{})})]}),(0,Q.jsxs)(`div`,{className:`sheet`,children:[(0,Q.jsx)(`span`,{className:`sheet__page sheet__page--left`,children:(0,Q.jsx)(Qw,{seed:5})}),(0,Q.jsx)(`span`,{className:`sheet__page sheet__page--right`,children:(0,Q.jsx)(Qw,{seed:13})})]})]})}function CT(e){let t=new Set(e.scenes.map(e=>e.name));for(let e=0;e<26;e++){let n=String.fromCharCode(65+e);if(!t.has(n))return n}return`Scene ${e.scenes.length+1}`}function wT({project:e,scene:t,playingSceneId:n,run:r}){let[i,a]=(0,y.useState)(t.name);(0,y.useEffect)(()=>a(t.name),[t.id,t.name]);let o=e.arrangement,s=e=>r({type:`arrange`,items:e.map(e=>({scene:e.sceneId,repeat:e.repeat}))}),c=(e,t)=>{let n=[...o],[r]=n.splice(e,1);n.splice(e+t,0,r),s(n)};return(0,Q.jsxs)(`div`,{className:`scenes-bar`,children:[(0,Q.jsxs)(`div`,{className:`scenes`,role:`group`,"aria-label":`Scenes`,children:[(0,Q.jsx)(`div`,{className:`scene-tabs`,role:`tablist`,"aria-label":`Scene to edit`,children:e.scenes.map(e=>(0,Q.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===t.id,className:`scene-tab`,onClick:()=>r({type:`select_scene`,scene:e.id}),children:e.name},e.id))}),(0,Q.jsx)(Ow,{label:`New scene`,tipSide:`top`,onClick:()=>r({type:`add_scene`,name:CT(e)}),children:(0,Q.jsx)(lw,{size:15})}),(0,Q.jsx)(Ow,{label:`Duplicate scene ${t.name}`,tipSide:`top`,onClick:()=>r({type:`add_scene`,name:CT(e),copy_from:t.id}),children:(0,Q.jsx)(FC,{size:15})}),(0,Q.jsx)(`input`,{className:`scene-name`,"aria-label":`Scene name`,value:i,maxLength:40,onChange:e=>a(e.target.value),onBlur:()=>{let e=i.trim();e&&e!==t.name?r({type:`update_scene`,scene:t.id,name:e}):a(t.name)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(a(t.name),e.currentTarget.blur())}}),(0,Q.jsx)(Ow,{label:`Remove scene ${t.name}`,tipSide:`top`,disabled:e.scenes.length===1,onClick:()=>r({type:`remove_scene`,scene:t.id}),children:(0,Q.jsx)(xw,{size:15})})]}),(0,Q.jsxs)(`div`,{className:`arrangement`,role:`group`,"aria-label":`Song arrangement`,children:[(0,Q.jsx)(`span`,{className:`arrangement__label`,children:`Song`}),(0,Q.jsx)(`ol`,{className:`arrangement__list`,children:o.map((r,i)=>{let a=e.scenes.find(e=>e.id===r.sceneId);if(!a)return null;let l=n===a.id;return(0,Q.jsxs)(`li`,{className:`chip ${a.id===t.id?`chip--viewed`:``} ${l?`chip--playing`:``}`,children:[(0,Q.jsx)(Ow,{label:`Move ${a.name} earlier`,tipSide:`top`,disabled:i===0,onClick:()=>c(i,-1),className:`chip__btn`,children:(0,Q.jsx)(jC,{size:13})}),(0,Q.jsx)(`span`,{className:`chip__name`,children:a.name}),(0,Q.jsx)(Ow,{label:`Play ${a.name} one time fewer`,tipSide:`top`,disabled:r.repeat<=1,onClick:()=>s(o.map((e,t)=>t===i?{...e,repeat:e.repeat-1}:e)),className:`chip__btn`,children:(0,Q.jsx)(rw,{size:12})}),(0,Q.jsxs)(`span`,{className:`chip__repeat`,"aria-label":`plays ${r.repeat} times`,children:[`×`,r.repeat]}),(0,Q.jsx)(Ow,{label:`Play ${a.name} one more time`,tipSide:`top`,disabled:r.repeat>=16,onClick:()=>s(o.map((e,t)=>t===i?{...e,repeat:e.repeat+1}:e)),className:`chip__btn`,children:(0,Q.jsx)(lw,{size:12})}),(0,Q.jsx)(Ow,{label:`Move ${a.name} later`,tipSide:`top`,disabled:i===o.length-1,onClick:()=>c(i,1),className:`chip__btn`,children:(0,Q.jsx)(NC,{size:13})}),(0,Q.jsx)(Ow,{label:`Take ${a.name} out of the song`,tipSide:`top`,disabled:o.length===1,onClick:()=>s(o.filter((e,t)=>t!==i)),className:`chip__btn`,children:(0,Q.jsx)(Dw,{size:13})})]},`${i}-${r.sceneId}`)})}),(0,Q.jsxs)(`button`,{type:`button`,className:`btn btn--sm`,disabled:o.length>=64,onClick:()=>s([...o,{sceneId:t.id,repeat:1}]),children:[(0,Q.jsx)(lw,{size:13}),` Add `,t.name]})]})]})}var TT=(e,t=Mw)=>e.map(e=>({value:e,label:t(e)}));function ET({project:e,scene:t,run:n}){let r=t.backing,i=e.mix,a=e=>n({type:`set_backing`,scene:t.id,...e}),o=e=>n({type:`mix`,...e});return(0,Q.jsxs)(`aside`,{className:`side`,children:[(0,Q.jsx)(`div`,{className:`side__cat`,children:(0,Q.jsx)(Yw,{})}),(0,Q.jsxs)(`div`,{className:`side__scroll`,children:[(0,Q.jsxs)(`section`,{className:`panel`,"aria-labelledby":`band-title`,children:[(0,Q.jsxs)(`h2`,{id:`band-title`,className:`panel__title`,children:[`Band `,(0,Q.jsx)(Jw,{})]}),(0,Q.jsxs)(`div`,{className:`band-part`,children:[(0,Q.jsx)(jw,{label:`Chords`,checked:r.chords.enabled,onChange:e=>a({chords:{enabled:e}})}),(0,Q.jsxs)(`div`,{className:`field-row`,children:[(0,Q.jsx)(Aw,{label:`Sound`,value:r.chords.instrument,options:TT(Fe,e=>we[e].label),onChange:e=>a({chords:{instrument:e}})}),(0,Q.jsx)(Aw,{label:`Style`,value:r.chords.style,options:TT(Ne),onChange:e=>a({chords:{style:e}})})]}),(0,Q.jsx)(kw,{label:`Volume`,value:r.chords.volume,onChange:e=>a({chords:{volume:e}})})]}),(0,Q.jsxs)(`div`,{className:`band-part`,children:[(0,Q.jsx)(jw,{label:`Bass`,checked:r.bass.enabled,onChange:e=>a({bass:{enabled:e}})}),(0,Q.jsx)(Aw,{label:`Style`,value:r.bass.style,options:TT(Pe),onChange:e=>a({bass:{style:e}})}),(0,Q.jsx)(kw,{label:`Volume`,value:r.bass.volume,onChange:e=>a({bass:{volume:e}})})]}),(0,Q.jsxs)(`div`,{className:`band-part`,children:[(0,Q.jsx)(jw,{label:`Drums`,checked:r.drums.enabled,onChange:e=>a({drums:{enabled:e}})}),(0,Q.jsx)(Aw,{label:`Groove`,value:r.drums.groove,options:TT(Ie),onChange:e=>a({drums:{groove:e}})}),(0,Q.jsx)(kw,{label:`Volume`,value:r.drums.volume,onChange:e=>a({drums:{volume:e}})})]}),(0,Q.jsxs)(`div`,{className:`band-part`,children:[(0,Q.jsx)(kw,{label:`Swing`,value:e.swing,onChange:e=>n({type:`set_project`,swing:e})}),(0,Q.jsx)(kw,{label:`Humanize`,value:e.humanize,onChange:e=>n({type:`set_project`,humanize:e})})]})]}),(0,Q.jsxs)(`section`,{className:`panel`,"aria-labelledby":`mix-title`,children:[(0,Q.jsxs)(`h2`,{id:`mix-title`,className:`panel__title`,children:[`Mix `,(0,Q.jsx)(Jw,{})]}),(0,Q.jsx)(kw,{label:`Master`,value:i.master,onChange:e=>o({master:e})}),(0,Q.jsx)(kw,{label:`Warmth`,value:i.warmth,onChange:e=>o({warmth:e})}),(0,Q.jsx)(kw,{label:`Crackle`,value:i.crackle,onChange:e=>o({crackle:e})}),(0,Q.jsx)(kw,{label:`Reverb`,value:i.reverb,onChange:e=>o({reverb:e})}),(0,Q.jsx)(kw,{label:`Wobble`,value:i.wobble,onChange:e=>o({wobble:e})}),(0,Q.jsxs)(`div`,{className:`band-part`,role:`group`,"aria-labelledby":`ambience-title`,children:[(0,Q.jsx)(`h3`,{id:`ambience-title`,className:`panel__subtitle`,children:`Ambience`}),(0,Q.jsx)(jw,{label:`Rain`,checked:i.rain.enabled,onChange:e=>o({rain:{enabled:e}})}),(0,Q.jsxs)(`div`,{className:`field-row`,children:[(0,Q.jsx)(Aw,{label:`Sound`,value:i.rain.kind,options:TT(Re,e=>e===`roof`?`Roof window`:`Window pane`),onChange:e=>o({rain:{kind:e}})}),(0,Q.jsx)(Aw,{label:`View`,value:e.window,options:Le.map(e=>({value:e,label:mT[e].label})),onChange:e=>n({type:`set_project`,window:e})})]}),(0,Q.jsx)(kw,{label:`Level`,value:i.rain.level,onChange:e=>o({rain:{level:e}})})]})]})]})]})}var DT={pencil:aw,brush:DC,chalk:ZC,spray:hw,stamp:yw};function OT({brush:e,size:t,tool:n,canClear:r,onBrush:i,onSize:a,onTool:o,onClear:s}){return(0,Q.jsxs)(`div`,{className:`toolbar`,role:`toolbar`,"aria-label":`Drawing tools`,children:[(0,Q.jsx)(`div`,{className:`segmented`,role:`group`,"aria-label":`Brush`,children:De.map((t,r)=>{let a=DT[t];return(0,Q.jsx)(Ow,{label:`${Ee[t].label}: ${Ee[t].note} (${r+1})`,pressed:n===`draw`&&e===t,onClick:()=>{i(t),o(`draw`)},children:(0,Q.jsx)(a,{size:16})},t)})}),(0,Q.jsx)(Ow,{label:`Eraser: drag a box over strokes (E)`,pressed:n===`erase`,onClick:()=>o(n===`erase`?`draw`:`erase`),children:(0,Q.jsx)(VC,{size:16})}),(0,Q.jsx)(`div`,{className:`toolbar__size`,children:(0,Q.jsx)(kw,{label:`Size`,value:t,onChange:a,format:e=>e<.34?`Thin`:e<.67?`Medium`:`Thick`})}),(0,Q.jsx)(`span`,{className:`toolbar__spacer`}),(0,Q.jsxs)(`button`,{type:`button`,className:`text-btn`,disabled:!r,onClick:s,children:[(0,Q.jsx)(xw,{size:14}),` Clear layer`]})]})}var kT=`#5c3f2c`,AT=`#7a5640`,jT=`#3f2a1e`,MT=`#8fae8b`,NT=`#6c8c6a`;function PT({x:e,y:t,r:n,flip:r=!1,s:i=1}){return(0,Q.jsxs)(`g`,{transform:`translate(${e} ${t}) rotate(${n}) scale(${r?-i:i} ${i})`,children:[(0,Q.jsx)(`path`,{d:`M0 0 C 6 -6 14 -4 15 4 C 14 10 6 13 0 0 Z`,fill:MT}),(0,Q.jsx)(`path`,{d:`M0 0 C 6 4 10 8 15 4 C 14 10 6 13 0 0 Z`,fill:NT})]})}function FT({scene:e,swaySeconds:t,swaying:n=!1,className:r=``}){let i=(0,y.useId)(),a=mT[e].art,o=t?{"--sway-duration":`${t}s`}:void 0;return(0,Q.jsxs)(`svg`,{viewBox:`0 0 320 206`,className:`window-art ${r}`,role:`img`,"aria-label":`Window view: ${mT[e].label}`,children:[(0,Q.jsx)(`defs`,{children:(0,Q.jsx)(`clipPath`,{id:`${i}-glass`,children:(0,Q.jsx)(`rect`,{x:$.x,y:$.y,width:$.w,height:$.h})})}),(0,Q.jsx)(`rect`,{width:`320`,height:`206`,fill:`#2a1f19`}),(0,Q.jsxs)(`g`,{clipPath:`url(#${i}-glass)`,children:[(0,Q.jsx)(a,{}),(0,Q.jsx)(`path`,{d:`M${$.x+30} ${$.y} h22 l-60 ${$.h} h-22 Z`,fill:`#fff`,opacity:`0.05`}),(0,Q.jsx)(`path`,{d:`M${$.x+200} ${$.y} h10 l-60 ${$.h} h-10 Z`,fill:`#fff`,opacity:`0.04`})]}),(0,Q.jsx)(`path`,{fillRule:`evenodd`,fill:kT,d:`M4 2 H316 V188 H4 Z M${$.x} ${$.y} V${$.y+$.h} H${$.x+$.w} V${$.y} Z`}),(0,Q.jsx)(`rect`,{x:`4`,y:`2`,width:`312`,height:`3`,fill:AT}),(0,Q.jsx)(`rect`,{x:`157`,y:$.y,width:`6`,height:$.h,fill:kT}),(0,Q.jsx)(`rect`,{x:`157`,y:$.y,width:`2`,height:$.h,fill:AT}),(0,Q.jsx)(`rect`,{x:$.x,y:`88`,width:$.w,height:`6`,fill:kT}),(0,Q.jsx)(`rect`,{x:$.x,y:`88`,width:$.w,height:`2`,fill:AT}),(0,Q.jsx)(`rect`,{x:`0`,y:`184`,width:`320`,height:`14`,rx:`2`,fill:AT}),(0,Q.jsx)(`rect`,{x:`0`,y:`188`,width:`320`,height:`10`,fill:kT}),(0,Q.jsx)(`rect`,{x:`6`,y:`198`,width:`308`,height:`6`,fill:jT}),(0,Q.jsxs)(`g`,{className:`window-art__vine`,children:[(0,Q.jsx)(`path`,{d:`M2 4 C 22 20 18 44 30 62 S 40 96 34 118`,stroke:`#5d6f4f`,strokeWidth:`2`,fill:`none`}),(0,Q.jsx)(PT,{x:8,y:10,r:40}),(0,Q.jsx)(PT,{x:20,y:30,r:100,flip:!0}),(0,Q.jsx)(PT,{x:24,y:52,r:50,s:1.1}),(0,Q.jsx)(PT,{x:34,y:74,r:120,flip:!0}),(0,Q.jsx)(PT,{x:36,y:96,r:70,s:.9}),(0,Q.jsx)(PT,{x:33,y:114,r:110,flip:!0,s:.8})]}),(0,Q.jsxs)(`g`,{className:`window-art__plant ${n?`is-swaying`:``}`,style:o,children:[(0,Q.jsx)(`path`,{d:`M262 166 C 258 154 250 146 244 140 M268 166 C 268 150 266 138 262 126 M273 166 C 276 152 284 144 292 140 M266 166 C 262 158 256 156 250 156 M270 166 C 274 158 280 154 288 154`,stroke:`#5d6f4f`,strokeWidth:`1.6`,fill:`none`,strokeLinecap:`round`}),(0,Q.jsx)(PT,{x:244,y:140,r:-150,s:1.15}),(0,Q.jsx)(PT,{x:262,y:126,r:-105,s:1.25,flip:!0}),(0,Q.jsx)(PT,{x:262,y:128,r:-70,s:1.1}),(0,Q.jsx)(PT,{x:292,y:140,r:-30,s:1.15}),(0,Q.jsx)(PT,{x:250,y:156,r:-170,s:1,flip:!0}),(0,Q.jsx)(PT,{x:288,y:154,r:-10,s:1})]}),(0,Q.jsx)(`path`,{d:`M246 166 H290 L285 188 H251 Z`,fill:`#b8674f`}),(0,Q.jsx)(`path`,{d:`M268 166 H290 L285 188 H268 Z`,fill:`#9a5543`}),(0,Q.jsx)(`rect`,{x:`243`,y:`163`,width:`50`,height:`6`,rx:`1.5`,fill:`#c97a60`})]})}function IT({project:e,sceneId:t,run:n}){let[r,i]=(0,y.useState)(!1),a=(0,y.useRef)(null),o=(0,y.useRef)(null),s=e.mood&&e.mood in Cl?e.mood:null;(0,y.useEffect)(()=>{if(!r)return;a.current?.querySelector(`[aria-pressed="true"], .mood-card`)?.focus();let e=e=>{a.current?.contains(e.target)||i(!1)},t=e=>{e.key===`Escape`&&(i(!1),o.current?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[r]);let c=e=>{n({type:`set_mood`,scene:t,mood:e}),i(!1),o.current?.focus()};return(0,Q.jsxs)(`div`,{className:`mood-picker`,ref:a,children:[(0,Q.jsxs)(`button`,{ref:o,type:`button`,className:`mood-button`,"aria-haspopup":`true`,"aria-expanded":r,"aria-label":`Mood: ${s?Cl[s].label:`none`}. Change mood`,onClick:()=>i(e=>!e),children:[(0,Q.jsx)(FT,{scene:s?Cl[s].window:e.window,className:`mood-button__thumb`}),(0,Q.jsx)(`span`,{children:s?Cl[s].label:`Pick a mood`}),(0,Q.jsx)(kC,{size:14,"aria-hidden":`true`})]}),r&&(0,Q.jsx)(`div`,{className:`mood-popover`,role:`group`,"aria-label":`Moods`,onKeyDown:e=>{if(e.key!==`ArrowRight`&&e.key!==`ArrowLeft`)return;let t=[...a.current?.querySelectorAll(`.mood-card`)??[]];t[(t.indexOf(document.activeElement)+(e.key===`ArrowRight`?1:t.length-1))%t.length]?.focus(),e.preventDefault()},children:wl.map(e=>{let t=Cl[e];return(0,Q.jsxs)(`button`,{type:`button`,className:`mood-card`,"aria-pressed":e===s,onClick:()=>c(e),children:[(0,Q.jsx)(FT,{scene:t.window,className:`mood-card__art`}),(0,Q.jsx)(`span`,{className:`mood-card__name`,children:t.label}),(0,Q.jsxs)(`span`,{className:`mood-card__meta`,children:[t.key.tonic,` `,t.key.mode,` · `,t.bpm,` bpm`]})]},e)})})]})}var LT=[`C`,`Db`,`D`,`Eb`,`E`,`F`,`F#`,`G`,`Ab`,`A`,`Bb`,`B`],RT=[1,2,4,8,16],zT={saved:`Saved`,saving:`Saving…`,error:`Couldn't save`},BT=/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl+`;function VT(e){let{project:t,scene:n,run:r}=e,i=(0,y.useMemo)(()=>{let e=JSON.stringify(n.progression);return Se.find(n=>JSON.stringify(Ce(n,t.key))===e)??`custom`},[n.progression,t.key]),a=e.status.state===`loading`;return(0,Q.jsxs)(`header`,{className:`topbar`,children:[(0,Q.jsxs)(`div`,{className:`topbar__brand`,children:[(0,Q.jsx)(`span`,{className:`wordmark`,children:`haku`}),(0,Q.jsx)(`input`,{className:`project-name`,"aria-label":`Project name`,value:t.name,maxLength:80,onChange:e=>e.target.value.trim()&&r({type:`set_project`,name:e.target.value})}),(0,Q.jsx)(`span`,{className:`save-state save-state--${e.saveState}`,role:`status`,children:zT[e.saveState]})]}),(0,Q.jsxs)(`div`,{className:`topbar__transport`,children:[(0,Q.jsx)(Ow,{label:e.playing?`Stop (Space)`:`Play (Space)`,variant:`primary`,onClick:e.onToggle,disabled:a,className:`play-btn`,children:a?(0,Q.jsx)(tw,{size:18,className:`spin`}):e.playing?(0,Q.jsx)(_w,{size:16,fill:`currentColor`}):(0,Q.jsx)(sw,{size:18,fill:`currentColor`})}),(0,Q.jsxs)(`div`,{className:`segmented segmented--text`,role:`group`,"aria-label":`Playback`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Loop`,"aria-pressed":e.mode===`loop`,"data-tip":`Loop the scene you're editing`,onClick:()=>e.onMode(`loop`),children:[(0,Q.jsx)(pw,{size:13}),` Loop`]}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Song`,"aria-pressed":e.mode===`song`,"data-tip":`Play the whole arrangement`,onClick:()=>e.onMode(`song`),children:`Song`})]}),(0,Q.jsxs)(`label`,{className:`bpm`,children:[(0,Q.jsx)(`input`,{type:`number`,min:50,max:140,value:t.bpm,"aria-label":`Tempo in BPM`,onChange:e=>{let t=Number(e.target.value);t>=50&&t<=140&&r({type:`set_project`,bpm:t})}}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`bpm`})]})]}),(0,Q.jsxs)(`div`,{className:`topbar__music`,children:[(0,Q.jsx)(Aw,{label:`Key`,hideLabel:!0,className:`field--key`,value:t.key.tonic,options:(LT.includes(t.key.tonic)?LT:[...LT,t.key.tonic]).map(e=>({value:e,label:e})),onChange:e=>r({type:`set_key`,tonic:e,mode:t.key.mode})}),(0,Q.jsx)(Aw,{label:`Mode`,hideLabel:!0,value:t.key.mode,options:ee.map(e=>({value:e,label:e})),onChange:e=>r({type:`set_key`,tonic:t.key.tonic,mode:e})}),(0,Q.jsx)(Aw,{label:`Chords`,hideLabel:!0,value:i,options:[...i===`custom`?[{value:`custom`,label:`Custom chords`}]:[],...Se.map(e=>({value:e,label:xe[e].label}))],onChange:e=>e!==`custom`&&r({type:`set_progression`,scene:n.id,progression:e})}),(0,Q.jsx)(Aw,{label:`Bars`,hideLabel:!0,value:String(n.bars),options:RT.map(e=>({value:String(e),label:`${e} ${e===1?`bar`:`bars`}`})),onChange:e=>r({type:`update_scene`,scene:n.id,bars:Number(e)})}),(0,Q.jsx)(IT,{project:t,sceneId:n.id,run:r})]}),(0,Q.jsxs)(`div`,{className:`topbar__actions`,children:[(0,Q.jsx)(Ow,{label:`Undo (${BT}Z)`,disabled:!e.canUndo,onClick:e.onUndo,children:(0,Q.jsx)(Cw,{size:16})}),(0,Q.jsx)(Ow,{label:`Redo (${BT}Shift+Z)`,disabled:!e.canRedo,onClick:e.onRedo,children:(0,Q.jsx)(dw,{size:16})}),(0,Q.jsx)(`span`,{className:`topbar__divider`,"aria-hidden":`true`}),(0,Q.jsx)(Ow,{label:`Projects`,onClick:e.onProjects,children:(0,Q.jsx)(qC,{size:16})}),(0,Q.jsx)(Ow,{label:`Export WAV or MIDI`,onClick:e.onExport,children:(0,Q.jsx)(LC,{size:16})}),(0,Q.jsx)(Ow,{label:`Credits`,onClick:e.onCredits,className:`tip-left`,children:(0,Q.jsx)($C,{size:16})})]})]})}function HT(e,t=2e3){if(e.length<=t)return e;let n=e.length/t,r=Array.from({length:t-1},(t,r)=>e[Math.floor(r*n)]);return r.push(e[e.length-1]),r}var UT=e=>e instanceof HTMLElement&&(e.isContentEditable||e.tagName===`TEXTAREA`||e.tagName===`SELECT`||e.tagName===`INPUT`&&![`range`,`radio`,`checkbox`].includes(e.type)),WT=e=>tS.subscribe(e);function GT(e){let[t,n]=(0,y.useState)(null);return(0,y.useEffect)(()=>{if(!e)return n(null);let t=0,r=()=>{n(tS.position()?.sceneId??null),t=requestAnimationFrame(r)};return t=requestAnimationFrame(r),()=>cancelAnimationFrame(t)},[e]),t}function KT(){let e=lC();return e?(0,Q.jsx)(YT,{api:e}):(0,Q.jsx)(`div`,{className:`app-loading`,children:`Opening your last loop…`})}var qT={connected:`Agent connected`,waiting:`Agent link`,off:`Agent link off`},JT={connected:`An agent can read and edit this loop through the Haku MCP server or CLI. Click to disconnect.`,waiting:"Waiting for the Haku MCP server or `haku bridge` on this machine. Click to stop looking.",off:`Let AI agents connect to this tab. Click to turn on.`};function YT({api:e}){let{project:t,scene:n,message:r,error:i,run:a,undo:o,redo:s}=e,[c,l]=(0,y.useState)({}),[u,d]=(0,y.useState)(`pencil`),[f,p]=(0,y.useState)(.3),[m,h]=(0,y.useState)(`draw`),[g,_]=(0,y.useState)(null),v=(0,y.useSyncExternalStore)(WT,()=>tS.status),b=(0,y.useSyncExternalStore)(WT,()=>tS.playing),x=(0,y.useSyncExternalStore)(WT,()=>tS.mode),S=GT(b&&x===`song`),C=NS(e);(0,y.useEffect)(()=>void tS.load(),[]),(0,y.useEffect)(()=>tS.update(t),[t]);let w=c[n.id],T=n.layers.some(e=>e.id===w)?w:n.layers.at(-1)?.id??null,E=(0,y.useCallback)(e=>l(t=>({...t,[n.id]:e})),[n.id]),[D,O]=(0,y.useState)({scene:n.id,count:n.layers.length});if(D.scene!==n.id||D.count!==n.layers.length){let e=D.scene===n.id&&n.layers.length>D.count;O({scene:n.id,count:n.layers.length}),e&&l(e=>({...e,[n.id]:n.layers.at(-1).id}))}let ee=(0,y.useCallback)(()=>void tS.toggle(),[]),te=(0,y.useCallback)(e=>tS.setMode(e),[]);(0,y.useEffect)(()=>{let e=e=>{if(g)return;let t=UT(e.target),n=e.metaKey||e.ctrlKey;n&&!t&&e.key.toLowerCase()===`z`?(e.preventDefault(),e.shiftKey?s():o()):n&&!t&&e.key.toLowerCase()===`y`?(e.preventDefault(),s()):t||n||e.altKey||(e.code===`Space`?(e.preventDefault(),ee()):/^Digit[1-5]$/.test(e.code)?(d(De[Number(e.code.slice(5))-1]),h(`draw`)):(e.key===`e`||e.key===`E`)&&h(e=>e===`erase`?`draw`:`erase`))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ee,o,s,g]);let ne=n.layers.find(e=>e.id===T)??null,re=e=>{T&&a({type:`draw_path`,scene:n.id,layer:T,brush:u,size:f,points:HT(e)})},ie=e=>T&&a({type:`erase`,scene:n.id,layer:T,region:e}),ae=v.state===`loading`?`Loading sounds ${v.loaded}/${v.total}`:v.state===`error`?v.message:i??r;return(0,Q.jsxs)(`div`,{className:`app`,children:[(0,Q.jsx)(ST,{project:t,playing:b}),(0,Q.jsx)(VT,{project:t,scene:n,run:a,playing:b,mode:x,status:v,saveState:e.saveState,canUndo:e.canUndo,canRedo:e.canRedo,onToggle:ee,onMode:te,onUndo:o,onRedo:s,onProjects:()=>_(`projects`),onExport:()=>_(`export`),onCredits:()=>_(`credits`)}),(0,Q.jsx)(tT,{scene:n,activeLayerId:T,onSelect:E,run:a}),(0,Q.jsxs)(`main`,{className:`stage`,children:[(0,Q.jsx)(OT,{brush:u,size:f,tool:m,canClear:!!ne?.strokes.length,onBrush:d,onSize:p,onTool:h,onClear:()=>T&&a({type:`erase`,scene:n.id,layer:T,all:!0})}),(0,Q.jsxs)(`div`,{className:`stage__frame`,children:[(0,Q.jsx)(BS,{project:t,scene:n,activeLayerId:T,tool:m,size:f,onStroke:re,onErase:ie}),(0,Q.jsx)(wT,{project:t,scene:n,playingSceneId:S,run:a})]}),(0,Q.jsx)(qw,{className:`stage__vine`,length:280,seed:29,horizontal:!0})]}),(0,Q.jsx)(ET,{project:t,scene:n,run:a}),(0,Q.jsxs)(`footer`,{className:`statusbar ${i||v.state===`error`?`statusbar--error`:``}`,children:[(0,Q.jsx)(`span`,{className:`statusbar__text`,role:`status`,"aria-live":`polite`,children:ae}),(0,Q.jsxs)(`button`,{type:`button`,className:`statusbar__link statusbar__link--${C}`,"aria-pressed":C!==`off`,title:JT[C],onClick:()=>kS.setEnabled(C===`off`),children:[(0,Q.jsx)(`span`,{className:`statusbar__dot`,"aria-hidden":`true`}),qT[C]]})]}),(0,Q.jsx)(rT,{open:g===`projects`,onClose:()=>_(null),current:t,onOpen:e.open,onNew:e.newProject,notify:e.notify}),(0,Q.jsx)(Ww,{open:g===`export`,onClose:()=>_(null),project:t,notify:e.notify}),(0,Q.jsx)(Iw,{open:g===`credits`,onClose:()=>_(null),manifest:tS.manifest})]})}(0,b.createRoot)(document.getElementById(`root`)).render((0,Q.jsx)(y.StrictMode,{children:(0,Q.jsx)(KT,{})})),`serviceWorker`in navigator&&navigator.serviceWorker.register(`/sw.js`).catch(()=>{});
|